Merge lp:~unity-team/unity/unity.linaro-desktop-safe-gles2 into lp:unity

Proposed by Jay Taoko
Status: Merged
Approved by: Jay Taoko
Approved revision: no longer in the source branch.
Merged at revision: 1862
Proposed branch: lp:~unity-team/unity/unity.linaro-desktop-safe-gles2
Merge into: lp:unity
Diff against target: 992 lines (+391/-15)
10 files modified
CMakeLists.txt (+4/-0)
plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp (+29/-2)
plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h (+4/-0)
plugins/unitydialog/src/unitydialog.cpp (+92/-4)
plugins/unitydialog/src/unitydialog.h (+23/-1)
plugins/unityshell/src/IconRenderer.cpp (+29/-8)
plugins/unityshell/src/ScreenEffectFramebufferObject.cpp (+4/-0)
plugins/unityshell/src/ScreenEffectFramebufferObject.h (+2/-0)
plugins/unityshell/src/unityshell.cpp (+183/-0)
plugins/unityshell/src/unityshell.h (+21/-0)
To merge this branch: bzr merge lp:~unity-team/unity/unity.linaro-desktop-safe-gles2
Reviewer Review Type Date Requested Status
Jay Taoko (community) Approve
Jason Smith (community) Approve
Review via email: mp+90030@code.launchpad.net

Description of the change

Desktop safe OpenGL ES 2.0 branch from Linaro's Graphics WG
    - This branch protects OpenGL ES 2.0 specific code with a build time option (BUILD_GLES)
    - The branch does not affect the runtime execution of Unity on the desktop if BUILD_GLES is not activated

Authors:
    <email address hidden>
    <email address hidden>

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

Testing on both of my systems reveals no differences. +1 for merge

review: Approve
Revision history for this message
Jay Taoko (jaytaoko) wrote :

Nothing to report after testing for a day. Works fine.
+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2011-12-19 22:18:53 +0000
3+++ CMakeLists.txt 2012-01-26 00:46:25 +0000
4@@ -17,6 +17,9 @@
5 set (CMAKE_CXX_FLAGS_DEBUG "-g3")
6 set (CMAKE_CXX_FLAGS_RELEASE "")
7
8+if (BUILD_GLES)
9+ SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNUX_OPENGLES_20 -DUSE_GLES")
10+endif (BUILD_GLES)
11
12 #
13 # Niceties
14@@ -136,6 +139,7 @@
15 add_subdirectory(guides)
16 add_subdirectory(standalone-clients EXCLUDE_FROM_ALL)
17
18+
19 #
20 # GSettings Schema
21 #
22
23=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp'
24--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp 2011-12-23 07:19:07 +0000
25+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp 2012-01-26 00:46:25 +0000
26@@ -438,13 +438,21 @@
27
28 bool
29 UnityMTGrabHandlesWindow::glDraw(const GLMatrix& transform,
30+#ifdef USE_GLES
31+ const GLWindowPaintAttrib& attrib,
32+#else
33 GLFragment::Attrib& fragment,
34+#endif
35 const CompRegion& region,
36 unsigned int mask)
37 {
38 /* Draw the window on the bottom, we will be drawing the
39 * handles on top */
40+#ifdef USE_GLES
41+ bool status = gWindow->glDraw(transform, attrib, region, mask);
42+#else
43 bool status = gWindow->glDraw(transform, fragment, region, mask);
44+#endif
45
46 if (mHandles && mHandles->visible())
47 {
48@@ -464,10 +472,17 @@
49 GLTexture::MatrixList matl;
50 GLTexture::Matrix mat = tex->matrix();
51 CompRegion paintRegion(region);
52+#ifdef USE_GLES
53+ GLWindowPaintAttrib wAttrib(attrib);
54+#endif
55
56 /* We can reset the window geometry since it will be
57 * re-added later */
58+#ifdef USE_GLES
59+ gWindow->vertexBuffer()->begin();
60+#else
61 gWindow->geometry().reset();
62+#endif
63
64 /* Not sure what this does, but it is necessary
65 * (adjusts for scale?) */
66@@ -483,23 +498,35 @@
67 * dim (so we get a nice render for things like
68 * wobbly etc etc */
69 gWindow->glAddGeometry(matl, reg, paintRegion);
70-
71+#ifdef USE_GLES
72+ gWindow->vertexBuffer()->end();
73+ wAttrib.opacity = mHandles->opacity();
74+#else
75 /* Did it succeed? */
76 if (gWindow->geometry().vertices)
77 {
78 fragment.setOpacity(mHandles->opacity());
79 /* Texture rendering set-up */
80 us->gScreen->setTexEnvMode(GL_MODULATE);
81+#endif
82 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
83 /* Draw the dim texture with all of it's modified
84 * geometry glory */
85- gWindow->glDrawTexture(tex, fragment, mask | PAINT_WINDOW_BLEND_MASK
86+ gWindow->glDrawTexture(tex,
87+#ifdef USE_GLES
88+ transform, wAttrib,
89+#else
90+ fragment,
91+#endif
92+ mask | PAINT_WINDOW_BLEND_MASK
93 | PAINT_WINDOW_TRANSLUCENT_MASK |
94 PAINT_WINDOW_TRANSFORMED_MASK);
95 /* Texture rendering tear-down */
96 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
97+#ifndef USE_GLES
98 us->gScreen->setTexEnvMode(GL_REPLACE);
99 }
100+#endif
101 }
102
103 handle++;
104
105=== modified file 'plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h'
106--- plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h 2011-12-22 12:55:41 +0000
107+++ plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h 2012-01-26 00:46:25 +0000
108@@ -229,7 +229,11 @@
109 void moveNotify(int dx, int dy, bool immediate);
110
111 bool glDraw(const GLMatrix&,
112+#ifdef USE_GLES
113+ const GLWindowPaintAttrib&,
114+#else
115 GLFragment::Attrib&,
116+#endif
117 const CompRegion&,
118 unsigned int);
119
120
121=== modified file 'plugins/unitydialog/src/unitydialog.cpp'
122--- plugins/unitydialog/src/unitydialog.cpp 2012-01-18 18:47:55 +0000
123+++ plugins/unitydialog/src/unitydialog.cpp 2012-01-26 00:46:25 +0000
124@@ -420,7 +420,12 @@
125 /* Collect textures */
126 void
127 UnityDialogWindow::glDrawTexture(GLTexture* texture,
128+#ifdef USE_GLES
129+ const GLMatrix &transform,
130+ const GLWindowPaintAttrib &attrib,
131+#else
132 GLFragment::Attrib& fa,
133+#endif
134 unsigned int mask)
135 {
136 unity::PaintInfoCollector::Active ()->processTexture (texture);
137@@ -448,7 +453,11 @@
138 {
139 /* We can reset the window geometry since it will be
140 * re-added later */
141+#ifdef USE_GLES
142+ GLWindow::get (w)->vertexBuffer()->begin();
143+#else
144 GLWindow::get (w)->geometry().reset();
145+#endif
146
147 for (unsigned int i = 0; i < collectedMatrixLists.size (); i++)
148 {
149@@ -462,6 +471,10 @@
150 * wobbly etc etc */
151 GLWindow::get (w)->glAddGeometry(matl, reg, paintRegion, min, max);
152 }
153+
154+#ifdef USE_GLES
155+ GLWindow::get (w)->vertexBuffer()->end();
156+#endif
157 }
158
159 void
160@@ -497,7 +510,11 @@
161 }
162
163 void
164-unity::TexGeometryCollection::addGeometriesAndDrawTextureForWindow(CompWindow *w, unsigned int mask)
165+unity::TexGeometryCollection::addGeometriesAndDrawTextureForWindow(CompWindow *w,
166+#ifdef USE_GLES
167+ const GLMatrix &transform,
168+#endif
169+ unsigned int mask)
170 {
171 if (mTexture && mGeometries.status ())
172 {
173@@ -509,6 +526,25 @@
174
175 mGeometries.addGeometryForWindow (w, paintRegion);
176
177+#ifdef USE_GLES
178+ UnityDialogScreen *uds = UnityDialogScreen::get (screen);
179+ GLWindowPaintAttrib attrib (gWindow->lastPaintAttrib());
180+ unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
181+ /* Texture rendering set-up */
182+// uds->gScreen->setTexEnvMode(GL_MODULATE);
183+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
184+ /* Draw the dim texture with all of it's modified
185+ * geometry glory */
186+ gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
187+ gWindow->glDrawTexture(mTexture, transform, attrib, mask
188+ | PAINT_WINDOW_BLEND_MASK
189+ | PAINT_WINDOW_TRANSLUCENT_MASK
190+ | PAINT_WINDOW_TRANSFORMED_MASK);
191+ gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
192+ /* Texture rendering tear-down */
193+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
194+ uds->gScreen->setTexEnvMode(GL_REPLACE);
195+#else
196 if (gWindow->geometry().vertices)
197 {
198 UnityDialogScreen *uds = UnityDialogScreen::get (screen);
199@@ -528,6 +564,7 @@
200 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
201 uds->gScreen->setTexEnvMode(GL_REPLACE);
202 }
203+#endif
204 }
205 }
206
207@@ -581,10 +618,18 @@
208 }
209
210 void
211-unity::PaintInfoCollector::drawGeometriesForWindow(CompWindow *w, unsigned int pm)
212+unity::PaintInfoCollector::drawGeometriesForWindow(CompWindow *w,
213+#ifdef USE_GLES
214+ const GLMatrix &transform,
215+#endif
216+ unsigned int pm)
217 {
218 for (unity::TexGeometryCollection &tcg : mCollection)
219+#if USE_GLES
220+ tcg.addGeometriesAndDrawTextureForWindow (w, transform, pm);
221+#else
222 tcg.addGeometriesAndDrawTextureForWindow (w, pm);
223+#endif
224 }
225
226 unity::PaintInfoCollector * unity::PaintInfoCollector::active_collector = NULL;
227@@ -599,7 +644,11 @@
228
229 bool
230 UnityDialogWindow::glDraw(const GLMatrix& transform,
231+#ifdef USE_GLES
232+ const GLWindowPaintAttrib& attrib,
233+#else
234 GLFragment::Attrib& fragment,
235+#endif
236 const CompRegion& region,
237 unsigned int mask)
238 {
239@@ -610,7 +659,13 @@
240
241 /* Draw the window on the bottom, we will be drawing the
242 * dim render on top */
243- bool status = gWindow->glDraw(transform, fragment, region, mask);
244+ bool status = gWindow->glDraw(transform,
245+#ifdef USE_GLES
246+ attrib,
247+#else
248+ fragment,
249+#endif
250+ region, mask);
251
252 UNITY_DIALOG_SCREEN(screen);
253
254@@ -618,10 +673,17 @@
255 {
256 GLTexture::MatrixList matl;
257 GLTexture::Matrix mat = tex->matrix();
258+#ifdef USE_GLES
259+ GLWindowPaintAttrib wAttrib(attrib);
260+#endif
261
262 /* We can reset the window geometry since it will be
263 * re-added later */
264+#ifdef USE_GLES
265+ gWindow->vertexBuffer()->begin();
266+#else
267 gWindow->geometry().reset();
268+#endif
269
270 /* Scale the dim render by the ratio of dim size
271 * to window size */
272@@ -642,7 +704,28 @@
273 * dim (so we get a nice render for things like
274 * wobbly etc etc */
275 gWindow->glAddGeometry(matl, reg, paintRegion);
276+#ifdef USE_GLES
277+ gWindow->vertexBuffer()->end();
278+#endif
279
280+#ifdef USE_GLES
281+ unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
282+ wAttrib.opacity = mShadeProgress;
283+ /* Texture rendering set-up */
284+// uds->gScreen->setTexEnvMode(GL_MODULATE);
285+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
286+ /* Draw the dim texture with all of it's modified
287+ * geometry glory */
288+ gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
289+ gWindow->glDrawTexture(tex, transform, attrib, mask
290+ | PAINT_WINDOW_BLEND_MASK
291+ | PAINT_WINDOW_TRANSLUCENT_MASK
292+ | PAINT_WINDOW_TRANSFORMED_MASK);
293+ gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
294+ /* Texture rendering tear-down */
295+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
296+ uds->gScreen->setTexEnvMode(GL_REPLACE);
297+#else
298 /* Did it succeed? */
299 if (gWindow->geometry().vertices)
300 {
301@@ -662,6 +745,7 @@
302 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
303 uds->gScreen->setTexEnvMode(GL_REPLACE);
304 }
305+#endif
306 }
307
308 for (CompWindow* w : mTransients)
309@@ -674,7 +758,11 @@
310 unity::PaintInfoCollector pc (w);
311
312 pc.collect();
313- pc.drawGeometriesForWindow (window, mask);
314+ pc.drawGeometriesForWindow (window,
315+#ifdef USE_GLES
316+ transform,
317+#endif
318+ mask);
319 }
320 }
321
322
323=== modified file 'plugins/unitydialog/src/unitydialog.h'
324--- plugins/unitydialog/src/unitydialog.h 2012-01-18 18:47:55 +0000
325+++ plugins/unitydialog/src/unitydialog.h 2012-01-26 00:46:25 +0000
326@@ -64,7 +64,13 @@
327 int max);
328 void setTexture (GLTexture *);
329
330+#ifdef USE_GLES
331+ void addGeometriesAndDrawTextureForWindow (CompWindow *w,
332+ const GLMatrix &transform,
333+ unsigned int mask);
334+#else
335 void addGeometriesAndDrawTextureForWindow (CompWindow *, unsigned int pm);
336+#endif
337
338 private:
339 GLTexture* mTexture;
340@@ -78,7 +84,13 @@
341 PaintInfoCollector (CompWindow *w);
342
343 void collect ();
344+#ifdef USE_GLES
345+ void drawGeometriesForWindow (CompWindow *w,
346+ const GLMatrix &transform,
347+ unsigned int pm);
348+#else
349 void drawGeometriesForWindow (CompWindow *w, unsigned int pm);
350+#endif
351
352 void processGeometry (const GLTexture::MatrixList &ml,
353 const CompRegion &r,
354@@ -242,7 +254,12 @@
355 public:
356
357 bool
358- glDraw(const GLMatrix&, GLFragment::Attrib&,
359+ glDraw(const GLMatrix&,
360+#ifdef USE_GLES
361+ const GLWindowPaintAttrib&,
362+#else
363+ GLFragment::Attrib&,
364+#endif
365 const CompRegion&, unsigned int);
366
367 bool
368@@ -258,7 +275,12 @@
369
370 void
371 glDrawTexture(GLTexture* texture,
372+#ifdef USE_GLES
373+ const GLMatrix& transform,
374+ const GLWindowPaintAttrib& attrib,
375+#else
376 GLFragment::Attrib& attrib,
377+#endif
378 unsigned int mask);
379
380
381
382=== modified file 'plugins/unityshell/src/IconRenderer.cpp'
383--- plugins/unityshell/src/IconRenderer.cpp 2012-01-04 01:43:15 +0000
384+++ plugins/unityshell/src/IconRenderer.cpp 2012-01-26 00:46:25 +0000
385@@ -39,6 +39,14 @@
386 namespace ui
387 {
388
389+#ifdef USE_GLES
390+ #define VertexShaderHeader "#version 100\n"
391+ #define FragmentShaderHeader "#version 100\n precision mediump float;\n"
392+#else
393+ #define VertexShaderHeader "#version 120\n"
394+ #define FragmentShaderHeader "#version 110\n"
395+#endif
396+
397 /*
398 Use this shader to pass vertices in screen coordinates in the C++ code and compute use
399 the fragment shader to perform the texture perspective correct division.
400@@ -60,9 +68,9 @@
401 #define LUMIN_BLUE "0.055"
402
403 nux::NString gPerspectiveCorrectShader = TEXT(
404-"[Vertex Shader] \n\
405-#version 120 \n\
406-uniform mat4 ViewProjectionMatrix; \n\
407+"[Vertex Shader] \n"
408+VertexShaderHeader
409+"uniform mat4 ViewProjectionMatrix; \n\
410 \n\
411 attribute vec4 iTexCoord0; \n\
412 attribute vec4 iVertex; \n\
413@@ -75,9 +83,9 @@
414 gl_Position = ViewProjectionMatrix * iVertex; \n\
415 } \n\
416 \n\
417-[Fragment Shader] \n\
418-#version 110 \n\
419- \n\
420+[Fragment Shader] \n"
421+FragmentShaderHeader
422+" \n\
423 varying vec4 varyTexCoord0; \n\
424 \n\
425 uniform sampler2D TextureObject0; \n\
426@@ -649,8 +657,13 @@
427 // Perspective correct
428 v0.x, v0.y, 0.0f, 1.0f, s0 / v0.w, t0 / v0.w, 0.0f, 1.0f / v0.w,
429 v1.x, v1.y, 0.0f, 1.0f, s1 / v1.w, t1 / v1.w, 0.0f, 1.0f / v1.w,
430- v2.x, v2.y, 0.0f, 1.0f, s2 / v2.w, t2 / v2.w, 0.0f, 1.0f / v2.w,
431- v3.x, v3.y, 0.0f, 1.0f, s3 / v3.w, t3 / v3.w, 0.0f, 1.0f / v3.w,
432+#ifdef USE_GLES
433+ v3.x, v3.y, 0.0f, 1.0f, s3 / v3.w, t3 / v3.w, 0.0f, 1.0f / v3.w,
434+ v2.x, v2.y, 0.0f, 1.0f, s2 / v2.w, t2 / v2.w, 0.0f, 1.0f / v2.w,
435+#else
436+ v2.x, v2.y, 0.0f, 1.0f, s2 / v2.w, t2 / v2.w, 0.0f, 1.0f / v2.w,
437+ v3.x, v3.y, 0.0f, 1.0f, s3 / v3.w, t3 / v3.w, 0.0f, 1.0f / v3.w,
438+#endif
439 };
440
441 CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
442@@ -681,6 +694,7 @@
443 local::shader_program_uv_persp_correction->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*) & (_stored_projection_matrix.m));
444 }
445 }
446+#ifndef USE_GLES
447 else
448 {
449 local::asm_shader->Begin();
450@@ -698,6 +712,7 @@
451 CHECKGL(glMatrixMode(GL_PROJECTION));
452 CHECKGL(glLoadMatrixf((float*) GfxContext.GetOpenGLProjectionMatrix().m));
453 }
454+#endif
455
456 CHECKGL(glEnableVertexAttribArrayARB(VertexLocation));
457 CHECKGL(glVertexAttribPointerARB((GLuint)VertexLocation, 4, GL_FLOAT, GL_FALSE, 32, VtxBuffer));
458@@ -716,8 +731,13 @@
459 CHECKGL(glUniform4fARB(DesatFactor, arg.saturation, arg.saturation, arg.saturation, arg.saturation));
460
461 nux::GetWindowThread()->GetGraphicsEngine().SetTexture(GL_TEXTURE0, icon);
462+#ifdef USE_GLES
463+ CHECKGL(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
464+#else
465 CHECKGL(glDrawArrays(GL_QUADS, 0, 4));
466+#endif
467 }
468+#ifndef USE_GLES
469 else
470 {
471 CHECKGL(glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, bg_color.red, bg_color.green, bg_color.blue, bg_color.alpha));
472@@ -726,6 +746,7 @@
473 nux::GetWindowThread()->GetGraphicsEngine().SetTexture(GL_TEXTURE0, icon);
474 CHECKGL(glDrawArrays(GL_QUADS, 0, 4));
475 }
476+#endif
477
478 if (VertexLocation != -1)
479 CHECKGL(glDisableVertexAttribArrayARB(VertexLocation));
480
481=== modified file 'plugins/unityshell/src/ScreenEffectFramebufferObject.cpp'
482--- plugins/unityshell/src/ScreenEffectFramebufferObject.cpp 2012-01-05 02:47:09 +0000
483+++ plugins/unityshell/src/ScreenEffectFramebufferObject.cpp 2012-01-26 00:46:25 +0000
484@@ -17,6 +17,7 @@
485 * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
486 */
487
488+#ifndef USE_GLES
489 #include "ScreenEffectFramebufferObject.h"
490 #include "BackgroundEffectHelper.h"
491 #include <NuxCore/Logger.h>
492@@ -232,3 +233,6 @@
493 if (mFBTexture)
494 glDeleteTextures (1, &mFBTexture);
495 }
496+
497+#endif // USE_GLES
498+
499
500=== modified file 'plugins/unityshell/src/ScreenEffectFramebufferObject.h'
501--- plugins/unityshell/src/ScreenEffectFramebufferObject.h 2011-12-16 09:46:35 +0000
502+++ plugins/unityshell/src/ScreenEffectFramebufferObject.h 2012-01-26 00:46:25 +0000
503@@ -20,6 +20,7 @@
504 #ifndef UNITY_SCREENEFFECT_FRAMEBUFFER_H
505 #define UNITY_SCREENEFFECT_FRAMEBUFFER_H
506
507+#ifndef USE_GLES
508 #include <Nux/Nux.h>
509
510 namespace unity
511@@ -84,4 +85,5 @@
512 };
513 } // namespace unity
514
515+#endif // USE_GLES
516 #endif
517
518=== modified file 'plugins/unityshell/src/unityshell.cpp'
519--- plugins/unityshell/src/unityshell.cpp 2012-01-25 15:59:42 +0000
520+++ plugins/unityshell/src/unityshell.cpp 2012-01-26 00:46:25 +0000
521@@ -114,7 +114,9 @@
522 , damaged(false)
523 , _key_nav_mode_requested(false)
524 , _last_output(nullptr)
525+#ifndef USE_GLES
526 , _active_fbo (0)
527+#endif
528 , dash_is_open_ (false)
529 , grab_index_ (0)
530 , painting_tray_ (false)
531@@ -128,6 +130,7 @@
532 int (*old_handler)(Display*, XErrorEvent*);
533 old_handler = XSetErrorHandler(NULL);
534
535+#ifndef USE_GLES
536 /* Ensure OpenGL version is 1.4+. */
537 version = get_opengl_version_f32((const gchar*) glGetString(GL_VERSION));
538 if (version < 1.4f)
539@@ -183,6 +186,7 @@
540 failed = true;
541 }
542 }
543+#endif
544
545 if (!failed)
546 {
547@@ -199,16 +203,27 @@
548 CompositeScreenInterface::setHandler(cScreen);
549 GLScreenInterface::setHandler(gScreen);
550
551+#ifdef USE_GLES
552+ gScreen->glPaintCompositedOutputSetEnabled (this, true);
553+#endif
554+
555 PluginAdapter::Initialize(screen);
556 WindowManager::SetDefault(PluginAdapter::Default());
557
558 StartupNotifyService::Default()->SetSnDisplay(screen->snDisplay(), screen->screenNum());
559
560 nux::NuxInitialize(0);
561+#ifndef USE_GLES
562 wt = nux::CreateFromForeignWindow(cScreen->output(),
563 glXGetCurrentContext(),
564 &UnityScreen::initUnity,
565 this);
566+#else
567+ wt = nux::CreateFromForeignWindow(cScreen->output(),
568+ eglGetCurrentContext(),
569+ &UnityScreen::initUnity,
570+ this);
571+#endif
572
573 wt->RedrawRequested.connect(sigc::mem_fun(this, &UnityScreen::onRedrawRequested));
574
575@@ -226,6 +241,7 @@
576 _edge_timeout = optionGetLauncherRevealEdgeTimeout ();
577 _in_paint = false;
578
579+#ifndef USE_GLES
580 void *dlhand = dlopen ("libunityshell.so", RTLD_LAZY);
581
582 if (dlhand)
583@@ -242,6 +258,7 @@
584 uScreen->_fbo = ScreenEffectFramebufferObject::Ptr (new ScreenEffectFramebufferObject (glXGetProcAddressP, geometry));
585 uScreen->_fbo->onScreenSizeChanged (geometry);
586 }
587+#endif
588
589 optionSetBackgroundColorNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
590 optionSetLauncherHideModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
591@@ -443,6 +460,7 @@
592
593 void UnityScreen::nuxPrologue()
594 {
595+#ifndef USE_GLES
596 /* Vertex lighting isn't used in Unity, we disable that state as it could have
597 * been leaked by another plugin. That should theoretically be switched off
598 * right after PushAttrib since ENABLE_BIT is meant to restore the LIGHTING
599@@ -459,12 +477,14 @@
600
601 glMatrixMode(GL_MODELVIEW);
602 glPushMatrix();
603+#endif
604
605 glGetError();
606 }
607
608 void UnityScreen::nuxEpilogue()
609 {
610+#ifndef USE_GLES
611 (*GL::bindFramebuffer)(GL_FRAMEBUFFER_EXT, _active_fbo);
612
613 glMatrixMode(GL_PROJECTION);
614@@ -486,6 +506,11 @@
615 glReadBuffer(GL_BACK);
616
617 glPopAttrib();
618+#else
619+ glDepthRangef(0, 1);
620+ //glViewport(-1, -1, 2, 2);
621+ gScreen->resetRasterPos();
622+#endif
623
624 glDisable(GL_SCISSOR_TEST);
625 }
626@@ -500,6 +525,7 @@
627
628 void UnityScreen::paintPanelShadow(const GLMatrix& matrix)
629 {
630+#ifndef USE_GLES
631 if (relayoutSourceId > 0)
632 return;
633
634@@ -559,6 +585,86 @@
635 glDisable(GL_BLEND);
636 }
637 }
638+#else
639+#warning Panel shadow not properly implemented for GLES2
640+ return;
641+
642+ if (relayoutSourceId > 0)
643+ return;
644+
645+ if (PluginAdapter::Default()->IsExpoActive())
646+ return;
647+
648+ nuxPrologue();
649+
650+ CompOutput* output = _last_output;
651+ float vc[4];
652+ float h = 20.0f;
653+ float w = 1.0f;
654+ float panel_h = 24.0f;
655+
656+ float x1 = output->x();
657+ float y1 = output->y() + panel_h;
658+ float x2 = x1 + output->width();
659+ float y2 = y1 + h;
660+
661+ vc[0] = x1;
662+ vc[1] = x2;
663+ vc[2] = y1;
664+ vc[3] = y2;
665+
666+ if (!dash_is_open_ && panel_controller_->opacity() > 0.0f)
667+ {
668+ foreach(GLTexture * tex, _shadow_texture)
669+ {
670+ std::vector<GLfloat> vertexData;
671+ std::vector<GLfloat> textureData;
672+ std::vector<GLushort> colorData;
673+ GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer();
674+ bool wasBlend = glIsEnabled(GL_BLEND);
675+
676+ if (!wasBlend)
677+ glEnable(GL_BLEND);
678+
679+ GL::activeTexture(GL_TEXTURE0);
680+ tex->enable(GLTexture::Fast);
681+
682+ glTexParameteri(tex->target(), GL_TEXTURE_WRAP_S, GL_REPEAT);
683+
684+ colorData = { 0xFFFF, 0xFFFF, 0xFFFF,
685+ (GLushort)(panel_controller_->opacity() * 0xFFFF)
686+ };
687+
688+ vertexData = {
689+ vc[0], vc[2], 0,
690+ vc[0], vc[3], 0,
691+ vc[1], vc[2], 0,
692+ vc[1], vc[3], 0,
693+ };
694+
695+ textureData = {
696+ COMP_TEX_COORD_X(tex->matrix(), 0), COMP_TEX_COORD_Y(tex->matrix(), 0),
697+ COMP_TEX_COORD_X(tex->matrix(), 0), COMP_TEX_COORD_Y(tex->matrix(), h),
698+ COMP_TEX_COORD_X(tex->matrix(), w), COMP_TEX_COORD_Y(tex->matrix(), 0),
699+ COMP_TEX_COORD_X(tex->matrix(), w), COMP_TEX_COORD_Y(tex->matrix(), h),
700+ };
701+
702+ streamingBuffer->begin(GL_TRIANGLE_STRIP);
703+
704+ streamingBuffer->addColors(1, &colorData[0]);
705+ streamingBuffer->addVertices(4, &vertexData[0]);
706+ streamingBuffer->addTexCoords(0, 4, &textureData[0]);
707+
708+ streamingBuffer->end();
709+ streamingBuffer->render(matrix);
710+
711+ tex->disable();
712+ if (!wasBlend)
713+ glDisable(GL_BLEND);
714+ }
715+ }
716+ nuxEpilogue();
717+#endif
718 }
719
720 void
721@@ -573,11 +679,16 @@
722 wy = y + (last_bound.height - height) / 2;
723 }
724
725+#ifdef USE_GLES
726+void UnityScreen::paintDisplay()
727+#else
728 void UnityScreen::paintDisplay(const CompRegion& region, const GLMatrix& transform, unsigned int mask)
729+#endif
730 {
731 CompOutput *output = _last_output;
732 Window tray_xid = panel_controller_->GetTrayXid ();
733
734+#ifndef USE_GLES
735 bool was_bound = _fbo->bound ();
736 _fbo->unbind ();
737
738@@ -596,6 +707,11 @@
739 nux::ObjectPtr<nux::IOpenGLTexture2D> device_texture =
740 nux::GetGraphicsDisplay()->GetGpuDevice()->CreateTexture2DFromID(_fbo->texture(),
741 screen->width (), screen->height(), 1, nux::BITFMT_R8G8B8A8);
742+#else
743+ nux::ObjectPtr<nux::IOpenGLTexture2D> device_texture =
744+ nux::GetGraphicsDisplay()->GetGpuDevice()->CreateTexture2DFromID(gScreen->fbo ()->tex ()->name (),
745+ output->width(), output->height(), 1, nux::BITFMT_R8G8B8A8);
746+#endif
747
748 nux::GetGraphicsDisplay()->GetGpuDevice()->backup_texture0_ = device_texture;
749
750@@ -603,6 +719,13 @@
751 nux::Geometry oGeo = nux::Geometry (output->x (), output->y (), output->width (), output->height ());
752 BackgroundEffectHelper::monitor_rect_ = geo;
753
754+#ifdef USE_GLES
755+ GLint fboID;
756+ // Nux renders to the referenceFramebuffer when it's embedded.
757+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fboID);
758+ wt->GetWindowCompositor().SetReferenceFramebuffer(fboID, geo);
759+#endif
760+
761 nuxPrologue();
762 _in_paint = true;
763 wt->RenderInterfaceFromForeignCmd (&oGeo);
764@@ -617,36 +740,56 @@
765 {
766 GLMatrix oTransform;
767 UnityWindow *uTrayWindow = UnityWindow::get (tray);
768+#ifndef USE_GLES
769 GLFragment::Attrib attrib (uTrayWindow->gWindow->lastPaintAttrib());
770+#else
771+ GLWindowPaintAttrib attrib (uTrayWindow->gWindow->lastPaintAttrib());
772+#endif
773 unsigned int oldGlAddGeometryIndex = uTrayWindow->gWindow->glAddGeometryGetCurrentIndex ();
774 unsigned int oldGlDrawIndex = uTrayWindow->gWindow->glDrawGetCurrentIndex ();
775+#ifndef USE_GLES
776 unsigned int oldGlDrawGeometryIndex = uTrayWindow->gWindow->glDrawGeometryGetCurrentIndex ();
777+#endif
778
779+#ifndef USE_GLES
780 attrib.setOpacity (OPAQUE);
781 attrib.setBrightness (BRIGHT);
782 attrib.setSaturation (COLOR);
783+#else
784+ attrib.opacity = OPAQUE;
785+ attrib.brightness = BRIGHT;
786+ attrib.saturation = COLOR;
787+#endif
788
789 oTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
790
791+#ifndef USE_GLES
792 glPushMatrix ();
793 glLoadMatrixf (oTransform.getMatrix ());
794+#endif
795
796 painting_tray_ = true;
797
798 /* force the use of the core functions */
799 uTrayWindow->gWindow->glDrawSetCurrentIndex (MAXSHORT);
800 uTrayWindow->gWindow->glAddGeometrySetCurrentIndex ( MAXSHORT);
801+#ifndef USE_GLES
802 uTrayWindow->gWindow->glDrawGeometrySetCurrentIndex (MAXSHORT);
803+#endif
804 uTrayWindow->gWindow->glDraw (oTransform, attrib, infiniteRegion,
805 PAINT_WINDOW_TRANSFORMED_MASK |
806 PAINT_WINDOW_BLEND_MASK |
807 PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK);
808+#ifndef USE_GLES
809 uTrayWindow->gWindow->glDrawGeometrySetCurrentIndex (oldGlDrawGeometryIndex);
810+#endif
811 uTrayWindow->gWindow->glAddGeometrySetCurrentIndex (oldGlAddGeometryIndex);
812 uTrayWindow->gWindow->glDrawSetCurrentIndex (oldGlDrawIndex);
813 painting_tray_ = false;
814
815+#ifndef USE_GLES
816 glPopMatrix ();
817+#endif
818 }
819 }
820
821@@ -1009,6 +1152,7 @@
822 allowWindowPaint = true;
823 _last_output = output;
824
825+#ifndef USE_GLES
826 /* bind the framebuffer here
827 * - it will be unbound and flushed
828 * to the backbuffer when some
829@@ -1020,16 +1164,43 @@
830 * its bind reference so make sure that
831 * you always unbind as much as you bind */
832 _fbo->bind (nux::Geometry (output->x (), output->y (), output->width (), output->height ()));
833+#endif
834
835 /* glPaintOutput is part of the opengl plugin, so we need the GLScreen base class. */
836 ret = gScreen->glPaintOutput(attrib, transform, region, output, mask);
837
838+#ifndef USE_GLES
839 if (doShellRepaint)
840 paintDisplay(region, transform, mask);
841+#endif
842
843 return ret;
844 }
845
846+#ifdef USE_GLES
847+void UnityScreen::glPaintCompositedOutput (const CompRegion &region,
848+ GLFramebufferObject *fbo,
849+ unsigned int mask)
850+{
851+ bool useFbo = false;
852+
853+ if (doShellRepaint)
854+ {
855+ oldFbo = fbo->bind ();
856+ useFbo = fbo->checkStatus () && fbo->tex ();
857+ if (!useFbo) {
858+ printf ("bailing from UnityScreen::glPaintCompositedOutput");
859+ GLFramebufferObject::rebind (oldFbo);
860+ return;
861+ }
862+ paintDisplay();
863+ GLFramebufferObject::rebind (oldFbo);
864+ }
865+
866+ gScreen->glPaintCompositedOutput(region, fbo, mask);
867+}
868+#endif
869+
870 /* called whenever a plugin needs to paint the entire scene
871 * transformed */
872
873@@ -1111,7 +1282,9 @@
874 PluginAdapter::Default()->OnScreenGrabbed();
875 else if (event->xfocus.mode == NotifyUngrab)
876 PluginAdapter::Default()->OnScreenUngrabbed();
877+#ifndef USE_GLES
878 cScreen->damageScreen(); // evil hack
879+#endif
880 if (_key_nav_mode_requested)
881 launcher.startKeyNavMode();
882 _key_nav_mode_requested = false;
883@@ -1770,7 +1943,11 @@
884 * and if so paint nux and stop us from painting
885 * other windows or on top of the whole screen */
886 bool UnityWindow::glDraw(const GLMatrix& matrix,
887+#ifndef USE_GLES
888 GLFragment::Attrib& attrib,
889+#else
890+ const GLWindowPaintAttrib& attrib,
891+#endif
892 const CompRegion& region,
893 unsigned int mask)
894 {
895@@ -1786,7 +1963,11 @@
896 {
897 if (xwns[i] == id)
898 {
899+#ifdef USE_GLES
900+ uScreen->paintDisplay();
901+#else
902 uScreen->paintDisplay(region, matrix, mask);
903+#endif
904 break;
905 }
906 }
907@@ -2258,11 +2439,13 @@
908 if (!needsRelayout)
909 return;
910
911+#ifndef USE_GLES
912 if (GL::fbo)
913 {
914 uScreen->_fbo = ScreenEffectFramebufferObject::Ptr (new ScreenEffectFramebufferObject (glXGetProcAddressP, geometry));
915 uScreen->_fbo->onScreenSizeChanged (geometry);
916 }
917+#endif
918
919 UScreen *uscreen = UScreen::GetDefault();
920 int primary_monitor = uscreen->GetPrimaryMonitor();
921
922=== modified file 'plugins/unityshell/src/unityshell.h'
923--- plugins/unityshell/src/unityshell.h 2012-01-20 06:47:42 +0000
924+++ plugins/unityshell/src/unityshell.h 2012-01-26 00:46:25 +0000
925@@ -49,7 +49,9 @@
926 #include "DebugDBusInterface.h"
927 #include "SwitcherController.h"
928 #include "UBusWrapper.h"
929+#ifndef USE_GLES
930 #include "ScreenEffectFramebufferObject.h"
931+#endif
932
933 #include "compizminimizedwindowhandler.h"
934 #include "BGHash.h"
935@@ -130,7 +132,11 @@
936 void nuxEpilogue();
937
938 /* nux draw wrapper */
939+#ifdef USE_GLES
940+ void paintDisplay();
941+#else
942 void paintDisplay(const CompRegion& region, const GLMatrix& transform, unsigned int mask);
943+#endif
944 void paintPanelShadow(const GLMatrix& matrix);
945
946 void preparePaint (int ms);
947@@ -151,6 +157,11 @@
948 const CompRegion&,
949 CompOutput*,
950 unsigned int);
951+#ifdef USE_GLES
952+ void glPaintCompositedOutput (const CompRegion &region,
953+ GLFramebufferObject *fbo,
954+ unsigned int mask);
955+#endif
956
957 /* paint in the special case that the output is transformed */
958 void glPaintTransformedOutput(const GLScreenPaintAttrib&,
959@@ -302,8 +313,12 @@
960
961 unity::BGHash _bghash;
962
963+#ifdef USE_GLES
964+ GLFramebufferObject *oldFbo;
965+#else
966 ScreenEffectFramebufferObject::Ptr _fbo;
967 GLuint _active_fbo;
968+#endif
969
970 bool queryForShader ();
971
972@@ -314,7 +329,9 @@
973 bool painting_tray_;
974 unsigned int tray_paint_mask_;
975
976+#ifndef USE_GLES
977 ScreenEffectFramebufferObject::GLXGetProcAddressProc glXGetProcAddressP;
978+#endif
979
980 friend class UnityWindow;
981 };
982@@ -351,7 +368,11 @@
983
984 /* basic window draw function */
985 bool glDraw(const GLMatrix& matrix,
986+#ifndef USE_GLES
987 GLFragment::Attrib& attrib,
988+#else
989+ const GLWindowPaintAttrib& attrib,
990+#endif
991 const CompRegion& region,
992 unsigned intmask);
993