1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
From: Quy Nguyen Viet <quy.nguyenviet@nxp.com>
Date: Fri, 23 Mar 2018 11:50:34 +0700
Subject: [PATCH] Update for compatibility with fbdev
Modify files native-state-x11.cpp and native-state-x11.h for compatibility
with fbdev (#define EGL_API_FB)
Signed-off-by: Quy Nguyen Viet <quy.nguyenviet@nxp.com>
---
src/native-state-x11.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++----
src/native-state-x11.h | 9 +++++++++
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/src/native-state-x11.cpp b/src/native-state-x11.cpp
index 3c1703b..0182e81 100644
--- a/src/native-state-x11.cpp
+++ b/src/native-state-x11.cpp
@@ -23,10 +23,15 @@
#include "native-state-x11.h"
#include "log.h"
+#ifdef EGL_API_FB
+#include "EGL/egl.h"
+#else
+
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
+#endif
/******************
* Public methods *
******************/
@@ -36,9 +41,13 @@ NativeStateX11::~NativeStateX11()
if (xdpy_)
{
if (xwin_)
+#ifdef EGL_API_FB
+ fbDestroyWindow(xwin_);
+ fbDestroyDisplay(xdpy_);
+#else
XDestroyWindow(xdpy_, xwin_);
-
- XCloseDisplay(xdpy_);
+ XCloseDisplay(xdpy_);
+#endif
}
}
@@ -46,8 +55,11 @@ bool
NativeStateX11::init_display()
{
if (!xdpy_)
+#ifdef EGL_API_FB
+ xdpy_ = fbGetDisplay(NULL);
+#else
xdpy_ = XOpenDisplay(NULL);
-
+#endif
return (xdpy_ != 0);
}
@@ -60,10 +72,16 @@ NativeStateX11::display()
bool
NativeStateX11::create_window(WindowProperties const& properties)
{
+#ifndef EGL_API_FB
static const char *win_name("glmark2 " GLMARK_VERSION);
+#endif
if (!xdpy_) {
+#ifdef EGL_API_FB
+ Log::error("Error: FB Display has not been initialized!\n");
+#else
Log::error("Error: X11 Display has not been initialized!\n");
+#endif
return false;
}
@@ -74,8 +92,13 @@ NativeStateX11::create_window(WindowProperties const& properties)
(properties_.width != properties.width ||
properties_.height != properties.height)))
{
+#ifdef EGL_API_FB
+ fbDestroyWindow(xwin_);
+#else
XDestroyWindow(xdpy_, xwin_);
+#endif
xwin_ = 0;
+
}
else
{
@@ -89,17 +112,28 @@ NativeStateX11::create_window(WindowProperties const& properties)
if (properties_.fullscreen) {
/* Get the screen (root window) size */
+#ifdef EGL_API_FB
+
+#else
XWindowAttributes window_attr;
XGetWindowAttributes(xdpy_, RootWindow(xdpy_, DefaultScreen(xdpy_)),
&window_attr);
properties_.width = window_attr.width;
properties_.height = window_attr.height;
+#endif
}
else {
properties_.width = properties.width;
properties_.height = properties.height;
}
+#ifdef EGL_API_FB
+ xwin_ = fbCreateWindow(xdpy_, 0, 0, properties_.width, properties_.height);
+ if (!xwin_) {
+ Log::error("Error: fbCreateWindow() failed!\n");
+ return false;
+ }
+#else
XVisualInfo vis_tmpl;
XVisualInfo *vis_info = 0;
int num_visuals;
@@ -169,6 +203,7 @@ NativeStateX11::create_window(WindowProperties const& properties)
/* Gracefully handle Window Delete event from window manager */
Atom wmDelete = XInternAtom(xdpy_, "WM_DELETE_WINDOW", True);
XSetWMProtocols(xdpy_, xwin_, &wmDelete, 1);
+#endif
return true;
}
@@ -184,12 +219,17 @@ void
NativeStateX11::visible(bool visible)
{
if (visible)
+#ifdef EGL_API_FB
+ Log::debug("Map window in FB\n");
+#else
XMapWindow(xdpy_, xwin_);
+#endif
}
bool
NativeStateX11::should_quit()
{
+#ifndef EGL_API_FB
XEvent event;
if (!XPending(xdpy_))
@@ -205,6 +245,6 @@ NativeStateX11::should_quit()
/* Window Delete event from window manager */
return true;
}
-
+#endif
return false;
}
diff --git a/src/native-state-x11.h b/src/native-state-x11.h
index cc8b83f..25af79b 100644
--- a/src/native-state-x11.h
+++ b/src/native-state-x11.h
@@ -24,7 +24,11 @@
#define GLMARK2_NATIVE_STATE_X11_H_
#include "native-state.h"
+#ifdef EGL_API_FB
+#include "EGL/egl.h"
+#else
#include <X11/Xlib.h>
+#endif
class NativeStateX11 : public NativeState
{
@@ -41,10 +45,15 @@ public:
void flip() { }
private:
+#ifdef EGL_API_FB
+ NativeDisplayType xdpy_;
+ NativeWindowType xwin_;
+#else
/** The X display associated with this canvas. */
Display* xdpy_;
/** The X window associated with this canvas. */
Window xwin_;
+#endif
WindowProperties properties_;
};
--
1.9.1
|