Merge lp:~jaytaoko/nux/nux-linaro-rev518-merge into lp:nux/2.0
- nux-linaro-rev518-merge
- Merge into 2.0
Status: | Merged |
---|---|
Approved by: | Jay Taoko |
Approved revision: | 535 |
Merged at revision: | 535 |
Proposed branch: | lp:~jaytaoko/nux/nux-linaro-rev518-merge |
Merge into: | lp:nux/2.0 |
Diff against target: |
302 lines (+157/-35) 7 files modified
Nux/WindowCompositor.cpp (+102/-26) Nux/WindowCompositor.h (+21/-0) Nux/WindowThread.cpp (+9/-0) NuxGraphics/GraphicsDisplayX11.cpp (+2/-0) configure.ac (+1/-1) tests/manual-tests/linaro-reference-fbo.txt (+8/-0) tools/unity_support_test.c (+14/-8) |
To merge this branch: | bzr merge lp:~jaytaoko/nux/nux-linaro-rev518-merge |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mirco Müller (community) | Approve | ||
Review via email: mp+87566@code.launchpad.net |
Commit message
Description of the change
* Merge linaro branch (lp:~linaro-graphics-wg/nux/nux-gles2-11.12 rev 518) with Nux trunk.
* This branch is adding support for a reference frame buffer in Nux. A Reference frame buffer allows Nux to restore a previously set FBO once it is done with its own rendering.
David Barth (dbarth) wrote : | # |
Alexandros Frantzis (afrantzis) wrote : | # |
The branch fails to build for gles2. Here is a fix:
=== modified file 'NuxGraphics/
--- NuxGraphics/
+++ NuxGraphics/
@@ -64,7 +64,9 @@
, m_X11Screen(0)
, m_ParentWindow(0)
, m_GLCtx(0)
+#ifndef NUX_OPENGLES_20
, glx_window_(0)
+#endif
, m_NumVideoModes(0)
, m_BorderPixel(0)
, _x11_major(0)
=== modified file 'tools/
--- tools/unity_
+++ tools/unity_
@@ -721,21 +721,26 @@
// Open a X11 connection and get the root window.
display = XOpenDisplay (display_name);
+#ifndef NUX_OPENGLES_20
// Before doing anything with GLX, check that it is supported on the system.
Bool glx_supported = False;
int dummy0, dummy1;
if (display)
glx_supported = glXQueryExtensi
-
- if (!display || !glx_supported) {
- if (!display)
- results.error = strdup ("unable to open display");
- else
- results.error = strdup ("GLX is not available on the system");
-
- // exit with 5, to tell "it's not an error we should cache"
- results.result = 5;
- }
+#endif
+
+ if (!display) {
+ results.error = strdup ("unable to open display");
+ // exit with 5, to tell "it's not an error we should cache"
+ results.result = 5;
+ }
+#ifndef NUX_OPENGLES_20
+ else if (!glx_supported) {
+ results.error = strdup ("GLX is not available on the system");
+ // exit with 5, to tell "it's not an error we should cache"
+ results.result = 5;
+ }
+#endif
else
{
screen = DefaultScreen (display);
Jay Taoko (jaytaoko) wrote : | # |
The logic behind the reference framebuffer:
- by default there is no reference frame buffer set and Nux render to the opengl back buffer.
- When a reference frame buffer is set Nux does its rendering into the reference frame buffer texture.
- it is up to the caller to display the texture from the reference frame buffer into the back buffer.
To test this, a sample program would set a reference frame buffer and have Nux render a single color quad all over the window. Then the program would dump the texture in the reference frame buffer to memory and compare a few texels with the color that was used.
Unity Merger (unity-merger) wrote : | # |
Attempt to merge into lp:nux failed due to conflicts:
text conflict in configure.ac
Preview Diff
1 | === modified file 'Nux/WindowCompositor.cpp' |
2 | --- Nux/WindowCompositor.cpp 2012-01-04 00:47:59 +0000 |
3 | +++ Nux/WindowCompositor.cpp 2012-01-06 18:46:23 +0000 |
4 | @@ -41,6 +41,7 @@ |
5 | |
6 | WindowCompositor::WindowCompositor(WindowThread *window_thread) |
7 | : window_thread_(window_thread) |
8 | + , reference_fbo_(0) |
9 | { |
10 | m_FocusAreaWindow = NULL; |
11 | m_MenuWindow = NULL; |
12 | @@ -1465,35 +1466,15 @@ |
13 | { |
14 | m_FrameBufferObject->Deactivate(); |
15 | |
16 | - // Enable this to render the drop shadow under windows: not perfect yet... |
17 | - if (0) |
18 | - { |
19 | - graphics_engine.EmptyClippingRegion(); |
20 | - graphics_engine.SetOpenGLClippingRectangle(0, 0, window_width, window_height); |
21 | - graphics_engine.SetViewport(0, 0, window_width, window_height); |
22 | - graphics_engine.SetOrthographicProjectionMatrix(window_width, window_height); |
23 | - |
24 | - Geometry shadow(window->GetBaseX(), window->GetBaseY(), |
25 | - window->GetBaseWidth(), window->GetBaseHeight()); |
26 | - //if(window->IsVisibleSizeGrip()) |
27 | - { |
28 | - shadow.OffsetPosition(4, 4); |
29 | - GetPainter().PaintShape(graphics_engine, shadow, color::Black, |
30 | - eSHAPE_CORNER_SHADOW); |
31 | - } |
32 | -// else |
33 | -// { |
34 | -// shadow.OffsetPosition(4, 4); |
35 | -// GetPainter().PaintShape(window_thread_->GetGraphicsEngine(), shadow, Color(0xFF000000), eSHAPE_CORNER_ROUND10_SHADOW); |
36 | -// } |
37 | - } |
38 | - |
39 | - CHECKGL( glDepthMask(GL_FALSE)); |
40 | + // Nux is done rendering a BaseWindow into a texture. The previous call to Deactivate |
41 | + // has cancelled any opengl framebuffer object that was set. |
42 | + |
43 | + CHECKGL(glDepthMask(GL_FALSE)); |
44 | { |
45 | graphics_engine.ApplyClippingRectangle(); |
46 | PresentBufferToScreen(rt.color_rt, window->GetBaseX(), window->GetBaseY(), false, false, window->GetOpacity(), window->premultiply()); |
47 | } |
48 | - CHECKGL( glDepthMask(GL_TRUE)); |
49 | + CHECKGL(glDepthMask(GL_TRUE)); |
50 | graphics_engine.GetRenderStates().SetBlend(false); |
51 | } |
52 | |
53 | @@ -1607,7 +1588,20 @@ |
54 | } |
55 | else |
56 | { |
57 | - GetGraphicsDisplay()->GetGpuDevice()->DeactivateFrameBuffer(); |
58 | + if (GetWindowThread()->IsEmbeddedWindow() && reference_fbo_) |
59 | + { |
60 | + // In the context of Unity, we may want Nux to restore a specific fbo and render the |
61 | + // BaseWindow texture into it. That fbo is called a reference framebuffer object. if a |
62 | + // Reference framebuffer object is present, Nux sets it. |
63 | + if (!RestoreReferenceFramebuffer()) |
64 | + { |
65 | + nuxDebugMsg("[WindowCompositor::RenderTopViews] Setting the Reference fbo has failed."); |
66 | + } |
67 | + } |
68 | + else |
69 | + { |
70 | + GetGraphicsDisplay()->GetGpuDevice()->DeactivateFrameBuffer(); |
71 | + } |
72 | } |
73 | |
74 | window_thread_->GetGraphicsEngine().EmptyClippingRegion(); |
75 | @@ -2272,5 +2266,87 @@ |
76 | |
77 | return (*keyboard_grab_stack_.begin()); |
78 | } |
79 | + |
80 | + void WindowCompositor::SetReferenceFramebuffer(unsigned int fbo_object, Geometry fbo_geometry) |
81 | + { |
82 | + reference_fbo_ = fbo_object; |
83 | + reference_fbo_geometry_ = fbo_geometry; |
84 | + } |
85 | + |
86 | + bool WindowCompositor::RestoreReferenceFramebuffer() |
87 | + { |
88 | + // It is assumed that the reference fbo contains valid textures. |
89 | + // Nux does the following: |
90 | + // - Bind the reference fbo (reference_fbo_) |
91 | + // - Call glDrawBuffer with GL_COLOR_ATTACHMENT0 |
92 | + // - Set the opengl viewport size (reference_fbo_geometry_) |
93 | + |
94 | + bool ok = false; |
95 | + |
96 | + CHECKGL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, reference_fbo_)); |
97 | +#ifndef NUX_OPENGLES_20 |
98 | + CHECKGL(glDrawBuffer(GL_COLOR_ATTACHMENT0)); |
99 | +#endif |
100 | + CHECKGL(glViewport(reference_fbo_geometry_.x, |
101 | + reference_fbo_geometry_.y, |
102 | + reference_fbo_geometry_.width, |
103 | + reference_fbo_geometry_.height)); |
104 | + |
105 | + // Nux does some sanity checks to make sure that the FBO is in good condition. |
106 | + GLenum status; |
107 | + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); |
108 | + CHECKGL_MSG(glCheckFramebufferStatusEXT); |
109 | + |
110 | + switch(status) |
111 | + { |
112 | + case GL_FRAMEBUFFER_COMPLETE_EXT: // Everything's OK |
113 | + ok = true; |
114 | + break; |
115 | + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: |
116 | + nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT"); |
117 | + ok = false; |
118 | + break; |
119 | + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: |
120 | + nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT"); |
121 | + ok = false; |
122 | + break; |
123 | + // See issue(87) of http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt |
124 | + // case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: |
125 | + // nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT"); |
126 | + // ok = false; |
127 | + // break; |
128 | + case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: |
129 | + nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT"); |
130 | + ok = false; |
131 | + break; |
132 | +#ifndef NUX_OPENGLES_20 |
133 | + case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: |
134 | + nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT"); |
135 | + ok = false; |
136 | + break; |
137 | + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: |
138 | + nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT"); |
139 | + ok = false; |
140 | + break; |
141 | + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: |
142 | + nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT"); |
143 | + ok = false; |
144 | + break; |
145 | +#endif |
146 | + // case GL_FRAMEBUFFER_STATUS_ERROR_EXT: |
147 | + // nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_STATUS_ERROR_EXT"); |
148 | + // ok = false; |
149 | + // break; |
150 | + case GL_FRAMEBUFFER_UNSUPPORTED_EXT: |
151 | + nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_UNSUPPORTED_EXT"); |
152 | + ok = false; |
153 | + break; |
154 | + default: |
155 | + nuxError("[GLFramebufferObject::IsValid] Unknown ERROR"); |
156 | + ok = false; |
157 | + } |
158 | + |
159 | + return ok; |
160 | + } |
161 | } |
162 | |
163 | |
164 | === modified file 'Nux/WindowCompositor.h' |
165 | --- Nux/WindowCompositor.h 2011-12-29 18:06:53 +0000 |
166 | +++ Nux/WindowCompositor.h 2012-01-06 18:46:23 +0000 |
167 | @@ -175,6 +175,23 @@ |
168 | //==================================== |
169 | |
170 | public: |
171 | + /*! |
172 | + Set and external fbo to draw Nux BaseWindow into. This external fbo will be |
173 | + restored after Nux completes it rendering. The external fbo is used only in embedded mode. \n |
174 | + If the fbo_object parameter 0, then the reference fbo is invalid and will not be used. |
175 | + |
176 | + @param fbo_object The opengl index of the fbo. |
177 | + @param fbo_geometry The geometry of the fbo. |
178 | + */ |
179 | + void SetReferenceFramebuffer(unsigned int fbo_object, Geometry fbo_geometry); |
180 | + |
181 | + /*! |
182 | + Bind the reference opengl framebuffer object. |
183 | + |
184 | + @return True if no error was detected. |
185 | + */ |
186 | + bool RestoreReferenceFramebuffer(); |
187 | + |
188 | ObjectPtr<IOpenGLFrameBufferObject>& GetWindowFrameBufferObject() |
189 | { |
190 | return m_FrameBufferObject; |
191 | @@ -561,6 +578,10 @@ |
192 | int m_TooltipX; |
193 | int m_TooltipY; |
194 | |
195 | + //! The fbo to restore after Nux rendering in embedded mode. |
196 | + unsigned int reference_fbo_; |
197 | + Geometry reference_fbo_geometry_; |
198 | + |
199 | //! Pointer grab stack. |
200 | /*! |
201 | The head of the list is the top of the stack. |
202 | |
203 | === modified file 'Nux/WindowThread.cpp' |
204 | --- Nux/WindowThread.cpp 2012-01-04 00:10:39 +0000 |
205 | +++ Nux/WindowThread.cpp 2012-01-06 18:46:23 +0000 |
206 | @@ -1425,6 +1425,15 @@ |
207 | |
208 | graphics_display_->GetGpuDevice()->DeactivateFrameBuffer(); |
209 | IOpenGLShaderProgram::SetShaderTracking(false); |
210 | + |
211 | + if (IsEmbeddedWindow() && window_compositor_->reference_fbo_) |
212 | + { |
213 | + // Restore the reference framebuffer |
214 | + if (!window_compositor_->RestoreReferenceFramebuffer()) |
215 | + { |
216 | + nuxDebugMsg("[WindowCompositor::RenderTopViews] Setting the Reference fbo has failed."); |
217 | + } |
218 | + } |
219 | } |
220 | |
221 | int WindowThread::InstallEventInspector(EventInspector function, void* data) |
222 | |
223 | === modified file 'NuxGraphics/GraphicsDisplayX11.cpp' |
224 | --- NuxGraphics/GraphicsDisplayX11.cpp 2012-01-04 00:10:39 +0000 |
225 | +++ NuxGraphics/GraphicsDisplayX11.cpp 2012-01-06 18:46:23 +0000 |
226 | @@ -44,7 +44,9 @@ |
227 | , m_X11Screen(0) |
228 | , m_ParentWindow(0) |
229 | , m_GLCtx(0) |
230 | +#ifndef NUX_OPENGLES_20 |
231 | , glx_window_(0) |
232 | +#endif |
233 | , m_NumVideoModes(0) |
234 | , m_BorderPixel(0) |
235 | , _x11_major(0) |
236 | |
237 | === modified file 'configure.ac' |
238 | --- configure.ac 2012-01-06 16:55:41 +0000 |
239 | +++ configure.ac 2012-01-06 18:46:23 +0000 |
240 | @@ -22,7 +22,7 @@ |
241 | # The number format is : year/month/day |
242 | # e.g.: december 5th, 2011 is: 20111205 |
243 | # So far there is no provision for more than one break in a day. |
244 | -m4_define([nux_abi_version], [20111213]) |
245 | +m4_define([nux_abi_version], [20111214]) |
246 | |
247 | m4_define([nux_version], |
248 | [nux_major_version.nux_minor_version.nux_micro_version]) |
249 | |
250 | === added directory 'tests/manual-tests' |
251 | === added file 'tests/manual-tests/linaro-reference-fbo.txt' |
252 | --- tests/manual-tests/linaro-reference-fbo.txt 1970-01-01 00:00:00 +0000 |
253 | +++ tests/manual-tests/linaro-reference-fbo.txt 2012-01-06 18:46:23 +0000 |
254 | @@ -0,0 +1,8 @@ |
255 | + |
256 | +The logic behind the reference framebuffer: |
257 | + - by default there is no reference frame buffer set and Nux render to the opengl back buffer. |
258 | + - When a reference frame buffer is set Nux does its rendering into the reference frame buffer texture. |
259 | + - it is up to the caller to display the texture from the reference frame buffer into the back buffer. |
260 | + |
261 | +To test this, a sample program would set a reference frame buffer and have Nux render a single color quad all over the window. Then the program would dump the texture in the reference frame buffer to memory and compare a few texels with the color that was used. |
262 | + |
263 | |
264 | === modified file 'tools/unity_support_test.c' |
265 | --- tools/unity_support_test.c 2011-11-24 16:45:23 +0000 |
266 | +++ tools/unity_support_test.c 2012-01-06 18:46:23 +0000 |
267 | @@ -721,21 +721,27 @@ |
268 | // Open a X11 connection and get the root window. |
269 | display = XOpenDisplay (display_name); |
270 | |
271 | +#ifndef NUX_OPENGLES_20 |
272 | // Before doing anything with GLX, check that it is supported on the system. |
273 | Bool glx_supported = False; |
274 | int dummy0, dummy1; |
275 | if (display) |
276 | glx_supported = glXQueryExtension(display, &dummy0, &dummy1); |
277 | |
278 | - if (!display || !glx_supported) { |
279 | - if (!display) |
280 | - results.error = strdup ("unable to open display"); |
281 | - else |
282 | - results.error = strdup ("GLX is not available on the system"); |
283 | +#endif |
284 | |
285 | - // exit with 5, to tell "it's not an error we should cache" |
286 | - results.result = 5; |
287 | - } |
288 | + if (!display) { |
289 | + results.error = strdup ("unable to open display"); |
290 | + // exit with 5, to tell "it's not an error we should cache" |
291 | + results.result = 5; |
292 | + } |
293 | +#ifndef NUX_OPENGLES_20 |
294 | + else if (!glx_supported) { |
295 | + results.error = strdup ("GLX is not available on the system"); |
296 | + // exit with 5, to tell "it's not an error we should cache" |
297 | + results.result = 5; |
298 | + } |
299 | +#endif |
300 | else |
301 | { |
302 | screen = DefaultScreen (display); |
Jay, can you document the test requirements for this change, and how much the code is already covered by existing tests?