Nux

Merge lp:~jaytaoko/nux/nux-linaro-rev518-merge into lp:nux/2.0

Proposed by Jay Taoko
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
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+87566@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
David Barth (dbarth) wrote :

Jay, can you document the test requirements for this change, and how much the code is already covered by existing tests?

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

The branch fails to build for gles2. Here is a fix:

=== modified file 'NuxGraphics/GraphicsDisplayX11.cpp'
--- NuxGraphics/GraphicsDisplayX11.cpp 2012-01-03 03:10:54 +0000
+++ NuxGraphics/GraphicsDisplayX11.cpp 2012-01-05 12:58:20 +0000
@@ -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/unity_support_test.c'
--- tools/unity_support_test.c 2011-11-24 16:45:23 +0000
+++ tools/unity_support_test.c 2012-01-05 13:12:19 +0000
@@ -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 = glXQueryExtension(display, &dummy0, &dummy1);
-
- 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);

Revision history for this message
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.

Revision history for this message
Mirco Müller (macslow) wrote :

Approved.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:nux failed due to conflicts:

text conflict in configure.ac

535. By Jay Taoko

* Merged with Trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Nux/WindowCompositor.cpp'
--- Nux/WindowCompositor.cpp 2012-01-04 00:47:59 +0000
+++ Nux/WindowCompositor.cpp 2012-01-06 18:46:23 +0000
@@ -41,6 +41,7 @@
4141
42 WindowCompositor::WindowCompositor(WindowThread *window_thread)42 WindowCompositor::WindowCompositor(WindowThread *window_thread)
43 : window_thread_(window_thread) 43 : window_thread_(window_thread)
44 , reference_fbo_(0)
44 {45 {
45 m_FocusAreaWindow = NULL;46 m_FocusAreaWindow = NULL;
46 m_MenuWindow = NULL;47 m_MenuWindow = NULL;
@@ -1465,35 +1466,15 @@
1465 {1466 {
1466 m_FrameBufferObject->Deactivate();1467 m_FrameBufferObject->Deactivate();
14671468
1468 // Enable this to render the drop shadow under windows: not perfect yet...1469 // Nux is done rendering a BaseWindow into a texture. The previous call to Deactivate
1469 if (0)1470 // has cancelled any opengl framebuffer object that was set.
1470 {1471
1471 graphics_engine.EmptyClippingRegion();1472 CHECKGL(glDepthMask(GL_FALSE));
1472 graphics_engine.SetOpenGLClippingRectangle(0, 0, window_width, window_height);
1473 graphics_engine.SetViewport(0, 0, window_width, window_height);
1474 graphics_engine.SetOrthographicProjectionMatrix(window_width, window_height);
1475
1476 Geometry shadow(window->GetBaseX(), window->GetBaseY(),
1477 window->GetBaseWidth(), window->GetBaseHeight());
1478 //if(window->IsVisibleSizeGrip())
1479 {
1480 shadow.OffsetPosition(4, 4);
1481 GetPainter().PaintShape(graphics_engine, shadow, color::Black,
1482 eSHAPE_CORNER_SHADOW);
1483 }
1484// else
1485// {
1486// shadow.OffsetPosition(4, 4);
1487// GetPainter().PaintShape(window_thread_->GetGraphicsEngine(), shadow, Color(0xFF000000), eSHAPE_CORNER_ROUND10_SHADOW);
1488// }
1489 }
1490
1491 CHECKGL( glDepthMask(GL_FALSE));
1492 {1473 {
1493 graphics_engine.ApplyClippingRectangle();1474 graphics_engine.ApplyClippingRectangle();
1494 PresentBufferToScreen(rt.color_rt, window->GetBaseX(), window->GetBaseY(), false, false, window->GetOpacity(), window->premultiply());1475 PresentBufferToScreen(rt.color_rt, window->GetBaseX(), window->GetBaseY(), false, false, window->GetOpacity(), window->premultiply());
1495 }1476 }
1496 CHECKGL( glDepthMask(GL_TRUE));1477 CHECKGL(glDepthMask(GL_TRUE));
1497 graphics_engine.GetRenderStates().SetBlend(false);1478 graphics_engine.GetRenderStates().SetBlend(false);
1498 }1479 }
14991480
@@ -1607,7 +1588,20 @@
1607 }1588 }
1608 else1589 else
1609 {1590 {
1610 GetGraphicsDisplay()->GetGpuDevice()->DeactivateFrameBuffer();1591 if (GetWindowThread()->IsEmbeddedWindow() && reference_fbo_)
1592 {
1593 // In the context of Unity, we may want Nux to restore a specific fbo and render the
1594 // BaseWindow texture into it. That fbo is called a reference framebuffer object. if a
1595 // Reference framebuffer object is present, Nux sets it.
1596 if (!RestoreReferenceFramebuffer())
1597 {
1598 nuxDebugMsg("[WindowCompositor::RenderTopViews] Setting the Reference fbo has failed.");
1599 }
1600 }
1601 else
1602 {
1603 GetGraphicsDisplay()->GetGpuDevice()->DeactivateFrameBuffer();
1604 }
1611 }1605 }
16121606
1613 window_thread_->GetGraphicsEngine().EmptyClippingRegion();1607 window_thread_->GetGraphicsEngine().EmptyClippingRegion();
@@ -2272,5 +2266,87 @@
22722266
2273 return (*keyboard_grab_stack_.begin());2267 return (*keyboard_grab_stack_.begin());
2274 }2268 }
2269
2270 void WindowCompositor::SetReferenceFramebuffer(unsigned int fbo_object, Geometry fbo_geometry)
2271 {
2272 reference_fbo_ = fbo_object;
2273 reference_fbo_geometry_ = fbo_geometry;
2274 }
2275
2276 bool WindowCompositor::RestoreReferenceFramebuffer()
2277 {
2278 // It is assumed that the reference fbo contains valid textures.
2279 // Nux does the following:
2280 // - Bind the reference fbo (reference_fbo_)
2281 // - Call glDrawBuffer with GL_COLOR_ATTACHMENT0
2282 // - Set the opengl viewport size (reference_fbo_geometry_)
2283
2284 bool ok = false;
2285
2286 CHECKGL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, reference_fbo_));
2287#ifndef NUX_OPENGLES_20
2288 CHECKGL(glDrawBuffer(GL_COLOR_ATTACHMENT0));
2289#endif
2290 CHECKGL(glViewport(reference_fbo_geometry_.x,
2291 reference_fbo_geometry_.y,
2292 reference_fbo_geometry_.width,
2293 reference_fbo_geometry_.height));
2294
2295 // Nux does some sanity checks to make sure that the FBO is in good condition.
2296 GLenum status;
2297 status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
2298 CHECKGL_MSG(glCheckFramebufferStatusEXT);
2299
2300 switch(status)
2301 {
2302 case GL_FRAMEBUFFER_COMPLETE_EXT: // Everything's OK
2303 ok = true;
2304 break;
2305 case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
2306 nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT");
2307 ok = false;
2308 break;
2309 case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
2310 nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT");
2311 ok = false;
2312 break;
2313 // See issue(87) of http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt
2314 // case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
2315 // nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT");
2316 // ok = false;
2317 // break;
2318 case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
2319 nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT");
2320 ok = false;
2321 break;
2322#ifndef NUX_OPENGLES_20
2323 case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
2324 nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT");
2325 ok = false;
2326 break;
2327 case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
2328 nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT");
2329 ok = false;
2330 break;
2331 case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
2332 nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT");
2333 ok = false;
2334 break;
2335#endif
2336 // case GL_FRAMEBUFFER_STATUS_ERROR_EXT:
2337 // nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_STATUS_ERROR_EXT");
2338 // ok = false;
2339 // break;
2340 case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
2341 nuxError("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_UNSUPPORTED_EXT");
2342 ok = false;
2343 break;
2344 default:
2345 nuxError("[GLFramebufferObject::IsValid] Unknown ERROR");
2346 ok = false;
2347 }
2348
2349 return ok;
2350 }
2275}2351}
22762352
22772353
=== modified file 'Nux/WindowCompositor.h'
--- Nux/WindowCompositor.h 2011-12-29 18:06:53 +0000
+++ Nux/WindowCompositor.h 2012-01-06 18:46:23 +0000
@@ -175,6 +175,23 @@
175 //====================================175 //====================================
176 176
177 public:177 public:
178 /*!
179 Set and external fbo to draw Nux BaseWindow into. This external fbo will be
180 restored after Nux completes it rendering. The external fbo is used only in embedded mode. \n
181 If the fbo_object parameter 0, then the reference fbo is invalid and will not be used.
182
183 @param fbo_object The opengl index of the fbo.
184 @param fbo_geometry The geometry of the fbo.
185 */
186 void SetReferenceFramebuffer(unsigned int fbo_object, Geometry fbo_geometry);
187
188 /*!
189 Bind the reference opengl framebuffer object.
190
191 @return True if no error was detected.
192 */
193 bool RestoreReferenceFramebuffer();
194
178 ObjectPtr<IOpenGLFrameBufferObject>& GetWindowFrameBufferObject()195 ObjectPtr<IOpenGLFrameBufferObject>& GetWindowFrameBufferObject()
179 {196 {
180 return m_FrameBufferObject;197 return m_FrameBufferObject;
@@ -561,6 +578,10 @@
561 int m_TooltipX;578 int m_TooltipX;
562 int m_TooltipY;579 int m_TooltipY;
563580
581 //! The fbo to restore after Nux rendering in embedded mode.
582 unsigned int reference_fbo_;
583 Geometry reference_fbo_geometry_;
584
564 //! Pointer grab stack.585 //! Pointer grab stack.
565 /*!586 /*!
566 The head of the list is the top of the stack.587 The head of the list is the top of the stack.
567588
=== modified file 'Nux/WindowThread.cpp'
--- Nux/WindowThread.cpp 2012-01-04 00:10:39 +0000
+++ Nux/WindowThread.cpp 2012-01-06 18:46:23 +0000
@@ -1425,6 +1425,15 @@
14251425
1426 graphics_display_->GetGpuDevice()->DeactivateFrameBuffer();1426 graphics_display_->GetGpuDevice()->DeactivateFrameBuffer();
1427 IOpenGLShaderProgram::SetShaderTracking(false);1427 IOpenGLShaderProgram::SetShaderTracking(false);
1428
1429 if (IsEmbeddedWindow() && window_compositor_->reference_fbo_)
1430 {
1431 // Restore the reference framebuffer
1432 if (!window_compositor_->RestoreReferenceFramebuffer())
1433 {
1434 nuxDebugMsg("[WindowCompositor::RenderTopViews] Setting the Reference fbo has failed.");
1435 }
1436 }
1428 }1437 }
14291438
1430 int WindowThread::InstallEventInspector(EventInspector function, void* data)1439 int WindowThread::InstallEventInspector(EventInspector function, void* data)
14311440
=== modified file 'NuxGraphics/GraphicsDisplayX11.cpp'
--- NuxGraphics/GraphicsDisplayX11.cpp 2012-01-04 00:10:39 +0000
+++ NuxGraphics/GraphicsDisplayX11.cpp 2012-01-06 18:46:23 +0000
@@ -44,7 +44,9 @@
44 , m_X11Screen(0)44 , m_X11Screen(0)
45 , m_ParentWindow(0)45 , m_ParentWindow(0)
46 , m_GLCtx(0)46 , m_GLCtx(0)
47#ifndef NUX_OPENGLES_20
47 , glx_window_(0)48 , glx_window_(0)
49#endif
48 , m_NumVideoModes(0)50 , m_NumVideoModes(0)
49 , m_BorderPixel(0)51 , m_BorderPixel(0)
50 , _x11_major(0)52 , _x11_major(0)
5153
=== modified file 'configure.ac'
--- configure.ac 2012-01-06 16:55:41 +0000
+++ configure.ac 2012-01-06 18:46:23 +0000
@@ -22,7 +22,7 @@
22# The number format is : year/month/day22# The number format is : year/month/day
23# e.g.: december 5th, 2011 is: 2011120523# e.g.: december 5th, 2011 is: 20111205
24# So far there is no provision for more than one break in a day.24# So far there is no provision for more than one break in a day.
25m4_define([nux_abi_version], [20111213])25m4_define([nux_abi_version], [20111214])
2626
27m4_define([nux_version],27m4_define([nux_version],
28 [nux_major_version.nux_minor_version.nux_micro_version])28 [nux_major_version.nux_minor_version.nux_micro_version])
2929
=== added directory 'tests/manual-tests'
=== added file 'tests/manual-tests/linaro-reference-fbo.txt'
--- tests/manual-tests/linaro-reference-fbo.txt 1970-01-01 00:00:00 +0000
+++ tests/manual-tests/linaro-reference-fbo.txt 2012-01-06 18:46:23 +0000
@@ -0,0 +1,8 @@
1
2The logic behind the reference framebuffer:
3 - by default there is no reference frame buffer set and Nux render to the opengl back buffer.
4 - When a reference frame buffer is set Nux does its rendering into the reference frame buffer texture.
5 - it is up to the caller to display the texture from the reference frame buffer into the back buffer.
6
7To 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.
8
09
=== modified file 'tools/unity_support_test.c'
--- tools/unity_support_test.c 2011-11-24 16:45:23 +0000
+++ tools/unity_support_test.c 2012-01-06 18:46:23 +0000
@@ -721,21 +721,27 @@
721 // Open a X11 connection and get the root window.721 // Open a X11 connection and get the root window.
722 display = XOpenDisplay (display_name);722 display = XOpenDisplay (display_name);
723 723
724#ifndef NUX_OPENGLES_20
724 // Before doing anything with GLX, check that it is supported on the system.725 // Before doing anything with GLX, check that it is supported on the system.
725 Bool glx_supported = False;726 Bool glx_supported = False;
726 int dummy0, dummy1;727 int dummy0, dummy1;
727 if (display)728 if (display)
728 glx_supported = glXQueryExtension(display, &dummy0, &dummy1);729 glx_supported = glXQueryExtension(display, &dummy0, &dummy1);
729730
730 if (!display || !glx_supported) {731#endif
731 if (!display)
732 results.error = strdup ("unable to open display");
733 else
734 results.error = strdup ("GLX is not available on the system");
735732
736 // exit with 5, to tell "it's not an error we should cache"733 if (!display) {
737 results.result = 5;734 results.error = strdup ("unable to open display");
738 }735 // exit with 5, to tell "it's not an error we should cache"
736 results.result = 5;
737 }
738#ifndef NUX_OPENGLES_20
739 else if (!glx_supported) {
740 results.error = strdup ("GLX is not available on the system");
741 // exit with 5, to tell "it's not an error we should cache"
742 results.result = 5;
743 }
744#endif
739 else745 else
740 {746 {
741 screen = DefaultScreen (display);747 screen = DefaultScreen (display);

Subscribers

People subscribed via source and target branches

to all changes: