Merge lp:~sil2100/compiz/missing_versions into lp:~compiz/compiz/ubuntu

Proposed by Łukasz Zemczak on 2012-04-10
Status: Merged
Merged at revision: 774
Proposed branch: lp:~sil2100/compiz/missing_versions
Merge into: lp:~compiz/compiz/ubuntu
Diff against target: 9135 lines (+9034/-6)
8 files modified
debian/changelog (+23/-0)
debian/compiz-core.install.armel (+8/-0)
debian/compiz-core.install.armhf (+8/-0)
debian/compiz-plugins.install.armhf (+11/-0)
debian/control (+5/-3)
debian/patches/compiz-package-gles2.patch (+8943/-0)
debian/patches/series.armhf (+1/-0)
debian/rules (+35/-3)
To merge this branch: bzr merge lp:~sil2100/compiz/missing_versions
Reviewer Review Type Date Requested Status
compiz packagers 2012-04-10 Pending
Review via email: mp+101386@code.launchpad.net

Commit Message

Added the missing 1:0.9.7.4-0ubuntu2 and 1:0.9.7.4-0ubuntu3 from the precise PPA.

Description of the Change

Added the missing 1:0.9.7.4-0ubuntu2 and 1:0.9.7.4-0ubuntu3 from the precise PPA, introducing the armel/armhf linaro fixes. Sadly, the introduced patch doesn't seem to build properly for arm - but non-arm builds succeed normally, so everything should be fine.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-04-10 09:02:47 +0000
3+++ debian/changelog 2012-04-10 14:55:03 +0000
4@@ -20,6 +20,29 @@
5
6 -- Didier Roche <didrocks@ubuntu.com> Thu, 05 Apr 2012 12:14:23 +0200
7
8+compiz (1:0.9.7.4-0ubuntu3) precise; urgency=low
9+
10+ * fix typo in copying of the cmake files, so FindOpenGLES2.cmake ends up in
11+ the right place for other packages (i.e. compiz-plugins-main on GLES2
12+ capable arches)
13+ * make copying the GLES2 cmake file architecture specifc instead of ignoring
14+ if it is not found on arches that do not have it.
15+
16+ -- Oliver Grawert <ogra@ubuntu.com> Fri, 06 Apr 2012 13:55:13 +0200
17+
18+compiz (1:0.9.7.4-0ubuntu2) precise; urgency=low
19+
20+ * enable Linaros compiz-package-gles2.patch for armhf(/el) builds, thanks
21+ to Alexandros Frantzis <alexandros.frantzis@linaro.org> for creating it.
22+ * enable quilt in debian/rules
23+ * apply patches based on debian architecture via series.<arch> file
24+ (stolen from eglibc)
25+ * add build deps to libgl1-mesa-dev and libgl-dev for armhf builds
26+ * add armel/armhf specific .install files since only a subset of modules can
27+ be built yet.
28+
29+ -- Oliver Grawert <ogra@ubuntu.com> Thu, 05 Apr 2012 19:09:27 +0200
30+
31 compiz (1:0.9.7.4-0ubuntu1) precise; urgency=low
32
33 * New upstream release
34
35=== added file 'debian/compiz-core.install.armel'
36--- debian/compiz-core.install.armel 1970-01-01 00:00:00 +0000
37+++ debian/compiz-core.install.armel 2012-04-10 14:55:03 +0000
38@@ -0,0 +1,8 @@
39+debian/tmp/usr/bin/compiz*
40+debian/tmp/usr/lib/libcompiz_core.so*
41+debian/compiz-decorator usr/bin/
42+debian/tmp/usr/share/compiz/*.png
43+debian/tmp/usr/share/compiz/core.xml
44+debian/source_compiz.py usr/share/apport/package-hooks
45+debian/tmp/usr/share/locale
46+debian/tmp/usr/share/applications/compiz.desktop
47
48=== added file 'debian/compiz-core.install.armhf'
49--- debian/compiz-core.install.armhf 1970-01-01 00:00:00 +0000
50+++ debian/compiz-core.install.armhf 2012-04-10 14:55:03 +0000
51@@ -0,0 +1,8 @@
52+debian/tmp/usr/bin/compiz*
53+debian/tmp/usr/lib/libcompiz_core.so*
54+debian/compiz-decorator usr/bin/
55+debian/tmp/usr/share/compiz/*.png
56+debian/tmp/usr/share/compiz/core.xml
57+debian/source_compiz.py usr/share/apport/package-hooks
58+debian/tmp/usr/share/locale
59+debian/tmp/usr/share/applications/compiz.desktop
60
61=== added symlink 'debian/compiz-plugins.install.armel'
62=== target is u'compiz-plugins.install.armhf'
63=== added file 'debian/compiz-plugins.install.armhf'
64--- debian/compiz-plugins.install.armhf 1970-01-01 00:00:00 +0000
65+++ debian/compiz-plugins.install.armhf 2012-04-10 14:55:03 +0000
66@@ -0,0 +1,11 @@
67+debian/tmp/usr/*/compiz/*annotate.*
68+debian/tmp/usr/*/compiz/*clone.*
69+debian/tmp/usr/*/compiz/*commands.*
70+debian/tmp/usr/*/compiz/*copytex.*
71+debian/tmp/usr/*/compiz/*dbus.*
72+debian/tmp/usr/*/compiz/*imgsvg.*
73+debian/tmp/usr/*/compiz/*inotify.*
74+debian/tmp/usr/*/compiz/*obs.*
75+debian/tmp/usr/*/compiz/*screenshot.*
76+debian/tmp/usr/*/compiz/*switcher.*
77+debian/tmp/usr/*/compiz/*water.*
78
79=== modified file 'debian/control'
80--- debian/control 2012-03-30 11:26:17 +0000
81+++ debian/control 2012-04-10 14:55:03 +0000
82@@ -8,7 +8,9 @@
83 debhelper (>= 7.0.50~), intltool,
84 libcairo2-dev,
85 libdbus-glib-1-dev, libgconf2-dev,
86- libgl1-mesa-dev (>= 6.5.1) | libgl-dev, libglib2.0-dev, libboost-serialization1.46-dev,
87+ libgl1-mesa-dev (>= 6.5.1) [!armhf !armel]| libgl-dev [!armhf !armel],
88+ libegl1-mesa-dev [armhf armel], libgles2-mesa-dev [armhf armel],
89+ libglib2.0-dev, libboost-serialization1.46-dev,
90 libgtk2.0-dev, libgtk-3-dev, libice-dev (>= 1:1.0.1),
91 libmetacity-dev (>= 1:2.30.3-0ubuntu3), libpango1.0-dev, libpng12-dev | libpng-dev, librsvg2-dev,
92 libsm-dev (>= 1:1.0.1), libtool, libwnck-dev, libx11-dev, libxcomposite-dev (>= 1:0.3-2), libxext-dev,
93@@ -18,7 +20,7 @@
94 libxml2-dev, libxslt1-dev,
95 libstartup-notification0-dev (>= 0.7),
96 quilt (>= 0.40), x11proto-gl-dev (>= 1.4.8), xsltproc,
97- libglu1-mesa-dev,
98+ libglu1-mesa-dev [!armhf !armel],
99 libglib2.0-dev,
100 libglibmm-2.4-dev,
101 kde-workspace-dev, kdelibs5-dev (>= 4:4.2.2),
102@@ -73,7 +75,7 @@
103
104 Package: compiz-dev
105 Architecture: any
106-Depends: compiz-core (= ${binary:Version}), ${misc:Depends}, libgl1-mesa-dev | libgl-dev, libpng-dev, libgtk-3-dev, libxcomposite-dev (>= 1:0.3-2), libxfixes-dev (>=1:4.0.1), libxdamage-dev (>= 1:1.0.3), libxinerama-dev, libxrandr-dev (>=2:1.1.0.2), libxcursor-dev, libice-dev (>= 1:1.0.1), libsm-dev (>= 1:1.0.1), libstartup-notification0-dev (>= 0.7), libxslt1-dev, libxml2-dev, libx11-xcb-dev, libglib2.0-dev, libglibmm-2.4-dev, compiz-plugins (= ${binary:Version}), libdecoration0-dev
107+Depends: compiz-core (= ${binary:Version}), ${misc:Depends}, libgl1-mesa-dev [!armhf !armel]| libgl-dev [!armhf !armel], libegl1-mesa-dev [armhf armel], libgles2-mesa-dev [armhf armel], libpng-dev, libgtk-3-dev, libxcomposite-dev (>= 1:0.3-2), libxfixes-dev (>=1:4.0.1), libxdamage-dev (>= 1:1.0.3), libxinerama-dev, libxrandr-dev (>=2:1.1.0.2), libxcursor-dev, libice-dev (>= 1:1.0.1), libsm-dev (>= 1:1.0.1), libstartup-notification0-dev (>= 0.7), libxslt1-dev, libxml2-dev, libx11-xcb-dev, libglib2.0-dev, libglibmm-2.4-dev, compiz-plugins (= ${binary:Version}), libdecoration0-dev
108 Description: OpenGL window and compositing manager - development files
109 Compiz brings to life a variety of visual effects that make the Linux desktop
110 easier to use, more powerful and intuitive, and more accessible for users
111
112=== added file 'debian/patches/compiz-package-gles2.patch'
113--- debian/patches/compiz-package-gles2.patch 1970-01-01 00:00:00 +0000
114+++ debian/patches/compiz-package-gles2.patch 2012-04-10 14:55:03 +0000
115@@ -0,0 +1,8943 @@
116+--- compiz-0.9.7.6.orig/CMakeLists.txt
117++++ compiz-0.9.7.6/CMakeLists.txt
118+@@ -119,6 +119,12 @@ install (
119+ DESTINATION ${COMPIZ_DESTDIR}${libdir}/pkgconfig
120+ )
121+
122++# temporarily disable plugins that aren't ported yed
123++set (COMPIZ_DISABLE_PLUGIN_BLUR ON)
124++set (COMPIZ_DISABLE_PLUGIN_CUBE ON)
125++set (COMPIZ_DISABLE_PLUGIN_ROTATE ON)
126++set (COMPIZ_DISABLE_PLUGIN_WOBBLY ON)
127++
128+ # Build Google Test and make its headers known
129+ find_package (GTest)
130+
131+@@ -183,6 +189,12 @@ _print_configure_results ()
132+
133+ _check_compiz_cmake_macro (${CMAKE_MODULE_PATH_ORIG})
134+
135++# temporarily disable plugins that aren't ported yed
136++SET(COMPIZ_DISABLE_PLUGIN_BLUR "ON")
137++SET(COMPIZ_DISABLE_PLUGIN_CUBE "ON")
138++SET(COMPIZ_DISABLE_PLUGIN_ROTATE "ON")
139++SET(COMPIZ_DISABLE_PLUGIN_WATER "ON")
140++SET(COMPIZ_DISABLE_PLUGIN_WOBBLY "ON")
141+ # Enable coverage reporting for compiz
142+ enable_coverage_report()
143+
144+--- compiz-0.9.7.6.orig/plugins/wobbly/CMakeLists.txt
145++++ compiz-0.9.7.6/plugins/wobbly/CMakeLists.txt
146+@@ -2,4 +2,4 @@ find_package (Compiz REQUIRED)
147+
148+ include (CompizPlugin)
149+
150+-compiz_plugin(wobbly PLUGINDEPS composite opengl)
151++#compiz_plugin(wobbly PLUGINDEPS composite opengl)
152+--- compiz-0.9.7.6.orig/plugins/rotate/CMakeLists.txt
153++++ compiz-0.9.7.6/plugins/rotate/CMakeLists.txt
154+@@ -2,4 +2,4 @@ find_package (Compiz REQUIRED)
155+
156+ include (CompizPlugin)
157+
158+-compiz_plugin(rotate PLUGINDEPS composite opengl cube)
159+\ No newline at end of file
160++#compiz_plugin(rotate PLUGINDEPS composite opengl cube)
161+--- compiz-0.9.7.6.orig/plugins/decor/decor.xml.in
162++++ compiz-0.9.7.6/plugins/decor/decor.xml.in
163+@@ -30,7 +30,7 @@
164+ <option name="active_shadow_opacity" type="float">
165+ <_short>Shadow Opacity</_short>
166+ <_long>Drop shadow opacity</_long>
167+- <default>0.8</default>
168++ <default>0.5</default>
169+ <min>0.01</min>
170+ <max>6.0</max>
171+ <precision>0.01</precision>
172+@@ -65,7 +65,7 @@
173+ <option name="inactive_shadow_radius" type="float">
174+ <_short>Shadow Radius</_short>
175+ <_long>Drop shadow radius</_long>
176+- <default>5.0</default>
177++ <default>8.0</default>
178+ <min>0.1</min>
179+ <max>13.0</max>
180+ <precision>0.1</precision>
181+@@ -73,7 +73,7 @@
182+ <option name="inactive_shadow_opacity" type="float">
183+ <_short>Shadow Opacity</_short>
184+ <_long>Drop shadow opacity</_long>
185+- <default>0.4</default>
186++ <default>0.5</default>
187+ <min>0.01</min>
188+ <max>6.0</max>
189+ <precision>0.01</precision>
190+@@ -100,7 +100,6 @@
191+ <option name="command" type="string">
192+ <_short>Command</_short>
193+ <_long>Decorator command line that is executed if no decorator is already running</_long>
194+- <default>/usr/bin/compiz-decorator</default>
195+ </option>
196+ <option name="mipmap" type="bool">
197+ <_short>Mipmap</_short>
198+--- compiz-0.9.7.6.orig/plugins/decor/src/decor.cpp
199++++ compiz-0.9.7.6/plugins/decor/src/decor.cpp
200+@@ -177,15 +177,13 @@ isAncestorTo (CompWindow *window,
201+ */
202+
203+ bool
204+-DecorWindow::glDraw (const GLMatrix &transform,
205+- GLFragment::Attrib &attrib,
206+- const CompRegion &region,
207+- unsigned int mask)
208++DecorWindow::glDraw (const GLMatrix &transform,
209++ const GLWindowPaintAttrib &attrib,
210++ const CompRegion &region,
211++ unsigned int mask)
212+ {
213+ bool status;
214+
215+- status = gWindow->glDraw (transform, attrib, region, mask);
216+-
217+ /* Don't render dock decorations (shadows) on just any old window */
218+ if (!(window->type () & CompWindowTypeDockMask))
219+ {
220+@@ -205,16 +203,19 @@ DecorWindow::glDraw (const GLMatrix
221+ }
222+ }
223+
224++ status = gWindow->glDraw (transform, attrib, region, mask);
225++
226+ return status;
227+ }
228+
229+ void
230+-DecorWindow::glDecorate (const GLMatrix &transform,
231+- GLFragment::Attrib &attrib,
232+- const CompRegion &region,
233+- unsigned int mask)
234++DecorWindow::glDecorate (const GLMatrix &transform,
235++ const GLWindowPaintAttrib &attrib,
236++ const CompRegion &region,
237++ unsigned int mask)
238+ {
239+ const CompRegion *preg = NULL;
240++ GLboolean isBlendingEnabled;
241+
242+ if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |
243+ PAINT_WINDOW_WITH_OFFSET_MASK)))
244+@@ -241,7 +242,7 @@ DecorWindow::glDecorate (const GLMatrix
245+ GLTexture::MatrixList ml (1);
246+ mask |= PAINT_WINDOW_BLEND_MASK;
247+
248+- gWindow->geometry ().reset ();
249++ gWindow->vertexBuffer ()->begin ();
250+
251+ for (int i = 0; i < wd->nQuad; i++)
252+ {
253+@@ -258,9 +259,14 @@ DecorWindow::glDecorate (const GLMatrix
254+ }
255+ }
256+
257+- if (gWindow->geometry ().vCount)
258+- gWindow->glDrawTexture (wd->decor->texture->textures[0],
259+- attrib, mask);
260++ gWindow->vertexBuffer ()->end ();
261++
262++ glGetBooleanv (GL_BLEND, &isBlendingEnabled);
263++ glEnable (GL_BLEND);
264++ gWindow->glDrawTexture (wd->decor->texture->textures[0], transform,
265++ attrib, mask);
266++ if (!isBlendingEnabled)
267++ glDisable (GL_BLEND);
268+ }
269+ else if (wd && !reg.isEmpty () &&
270+ wd->decor->type == WINDOW_DECORATION_TYPE_WINDOW)
271+@@ -272,14 +278,18 @@ DecorWindow::glDecorate (const GLMatrix
272+ if (gWindow->textures ().empty ())
273+ return;
274+
275++ glGetBooleanv (GL_BLEND, &isBlendingEnabled);
276++ glEnable (GL_BLEND);
277++
278+ if (gWindow->textures ().size () == 1)
279+ {
280+ ml[0] = gWindow->matrices ()[0];
281+- gWindow->geometry ().reset ();
282++ gWindow->vertexBuffer ()->begin ();
283+ gWindow->glAddGeometry (ml, window->frameRegion (), reg);
284++ gWindow->vertexBuffer ()->end ();
285+
286+- if (gWindow->geometry ().vCount)
287+- gWindow->glDrawTexture (gWindow->textures ()[0], attrib, mask);
288++ gWindow->glDrawTexture (gWindow->textures ()[0], transform,
289++ attrib, mask);
290+ }
291+ else
292+ {
293+@@ -288,14 +298,17 @@ DecorWindow::glDecorate (const GLMatrix
294+ for (unsigned int i = 0; i < gWindow->textures ().size (); i++)
295+ {
296+ ml[0] = gWindow->matrices ()[i];
297+- gWindow->geometry ().reset ();
298++ gWindow->vertexBuffer ()->begin ();
299+ gWindow->glAddGeometry (ml, regions[i], reg);
300++ gWindow->vertexBuffer ()->end ();
301+
302+- if (gWindow->geometry ().vCount)
303+- gWindow->glDrawTexture (gWindow->textures ()[i], attrib,
304+- mask);
305++ gWindow->glDrawTexture (gWindow->textures ()[i], transform,
306++ attrib, mask);
307+ }
308+ }
309++
310++ if (!isBlendingEnabled)
311++ glDisable (GL_BLEND);
312+ }
313+ }
314+
315+--- compiz-0.9.7.6.orig/plugins/decor/src/decor.h
316++++ compiz-0.9.7.6/plugins/decor/src/decor.h
317+@@ -252,10 +252,10 @@ class DecorWindow :
318+
319+ void computeShadowRegion ();
320+
321+- bool glDraw (const GLMatrix &, GLFragment::Attrib &,
322++ bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
323+ const CompRegion &, unsigned int);
324+- void glDecorate (const GLMatrix &, GLFragment::Attrib &,
325+- const CompRegion &, unsigned int);
326++ void glDecorate (const GLMatrix &, const GLWindowPaintAttrib &,
327++ const CompRegion &, unsigned int);
328+
329+ void windowNotify (CompWindowNotify n);
330+
331+--- compiz-0.9.7.6.orig/plugins/cube/CMakeLists.txt
332++++ compiz-0.9.7.6/plugins/cube/CMakeLists.txt
333+@@ -2,4 +2,4 @@ find_package (Compiz REQUIRED)
334+
335+ include (CompizPlugin)
336+
337+-compiz_plugin(cube PLUGINDEPS composite opengl)
338+\ No newline at end of file
339++#compiz_plugin(cube PLUGINDEPS composite opengl)
340+--- compiz-0.9.7.6.orig/plugins/cube/src/cube.cpp
341++++ compiz-0.9.7.6/plugins/cube/src/cube.cpp
342+@@ -1123,7 +1123,6 @@ CubeScreen::cubePaintTop (const GLScreen
343+ if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))
344+ {
345+ priv->gScreen->setTexEnvMode (GL_MODULATE);
346+- glEnable (GL_BLEND);
347+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
348+ }
349+
350+@@ -1149,7 +1148,6 @@ CubeScreen::cubePaintTop (const GLScreen
351+ glEnableClientState (GL_TEXTURE_COORD_ARRAY);
352+
353+ priv->gScreen->setTexEnvMode (GL_REPLACE);
354+- glDisable (GL_BLEND);
355+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
356+ }
357+
358+@@ -1190,7 +1188,6 @@ CubeScreen::cubePaintBottom (const GLScr
359+ if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))
360+ {
361+ priv->gScreen->setTexEnvMode (GL_MODULATE);
362+- glEnable (GL_BLEND);
363+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
364+ }
365+
366+@@ -1206,7 +1203,6 @@ CubeScreen::cubePaintBottom (const GLScr
367+ glEnableClientState (GL_TEXTURE_COORD_ARRAY);
368+
369+ priv->gScreen->setTexEnvMode (GL_REPLACE);
370+- glDisable (GL_BLEND);
371+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
372+ }
373+
374+--- compiz-0.9.7.6.orig/plugins/fade/fade.xml.in
375++++ compiz-0.9.7.6/plugins/fade/fade.xml.in
376+@@ -9,7 +9,6 @@
377+ </requirement>
378+ <relation type="after">
379+ <plugin>decor</plugin>
380+- <plugin>staticswitcher</plugin>
381+ </relation>
382+ <relation type="before">
383+ <plugin>cube</plugin>
384+@@ -50,7 +49,7 @@
385+ <option name="window_match" type="match">
386+ <_short>Fade windows</_short>
387+ <_long>Windows that should be fading</_long>
388+- <default>any &amp; !(title=notify-osd)</default>
389++ <default>any</default>
390+ </option>
391+ <option name="visual_bell" type="bell">
392+ <_short>Visual Bell</_short>
393+--- compiz-0.9.7.6.orig/plugins/screenshot/src/screenshot.cpp
394++++ compiz-0.9.7.6/plugins/screenshot/src/screenshot.cpp
395+@@ -249,6 +249,10 @@ ShotScreen::glPaintOutput (const GLScree
396+ CompOutput *output,
397+ unsigned int mask)
398+ {
399++ GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
400++ GLMatrix transform (matrix);
401++ GLfloat vertexData[12];
402++ GLushort colorData[4];
403+ bool status;
404+
405+ status = gScreen->glPaintOutput (attrib, matrix, region, output, mask);
406+@@ -264,31 +268,54 @@ ShotScreen::glPaintOutput (const GLScree
407+
408+ if (mGrabIndex)
409+ {
410+- glPushMatrix ();
411++ vertexData[0] = x1;
412++ vertexData[1] = y1;
413++ vertexData[2] = 0.0f;
414++ vertexData[3] = x1;
415++ vertexData[4] = y2;
416++ vertexData[5] = 0.0f;
417++ vertexData[6] = x2;
418++ vertexData[7] = y1;
419++ vertexData[8] = 0.0f;
420++ vertexData[9] = x2;
421++ vertexData[10] = y2;
422++ vertexData[11] = 0.0f;
423++
424++ colorData[0] = 0x2fff;
425++ colorData[1] = 0x2fff;
426++ colorData[2] = 0x4fff;
427++ colorData[3] = 0x4fff;
428++
429++
430++ transform.translate (-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
431++ transform.scale (1.0f / output->width (),
432++ -1.0f / output->height (),
433++ 1.0f);
434++ transform.translate (-output->region ()->extents.x1,
435++ -output->region ()->extents.y2,
436++ 0.0f);
437++
438++ streamingBuffer->begin (GL_TRIANGLE_STRIP);
439++
440++ streamingBuffer->addColors (1, colorData);
441++ streamingBuffer->addVertices (4, vertexData);
442++
443++ streamingBuffer->end ();
444++ streamingBuffer->render (transform);
445++
446++ streamingBuffer->begin (GL_LINE_LOOP);
447++
448++ vertexData[6] = x2;
449++ vertexData[7] = y2;
450++ vertexData[9] = x2;
451++ vertexData[10] = y1;
452++ colorData [3] = 0x9fff;
453+
454+- glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
455+- glScalef (1.0f / output->width (),
456+- -1.0f / output->height (),
457+- 1.0f);
458+- glTranslatef (-output->region ()->extents.x1,
459+- -output->region ()->extents.y2,
460+- 0.0f);
461+-
462+- glDisableClientState (GL_TEXTURE_COORD_ARRAY);
463+- glEnable (GL_BLEND);
464+- glColor4us (0x2fff, 0x2fff, 0x4fff, 0x4fff);
465+- glRecti (x1, y2, x2, y1);
466+- glColor4us (0x2fff, 0x2fff, 0x4fff, 0x9fff);
467+- glBegin (GL_LINE_LOOP);
468+- glVertex2i (x1, y1);
469+- glVertex2i (x2, y1);
470+- glVertex2i (x2, y2);
471+- glVertex2i (x1, y2);
472+- glEnd ();
473+- glColor4usv (defaultColor);
474+- glDisable (GL_BLEND);
475+- glEnableClientState (GL_TEXTURE_COORD_ARRAY);
476+- glPopMatrix ();
477++ streamingBuffer->addColors (1, colorData);
478++ streamingBuffer->addVertices (4, vertexData);
479++
480++ streamingBuffer->end ();
481++ streamingBuffer->render (transform);
482+ }
483+ }
484+
485+--- compiz-0.9.7.6.orig/plugins/gnomecompat/gnomecompat.xml.in
486++++ compiz-0.9.7.6/plugins/gnomecompat/gnomecompat.xml.in
487+@@ -52,7 +52,6 @@
488+ <option name="run_command_terminal_key" type="key">
489+ <_short>Open a terminal</_short>
490+ <_long>Open a terminal</_long>
491+- <default>&lt;Control&gt;&lt;Alt&gt;T</default>
492+ </option>
493+ </group>
494+ </options>
495+--- compiz-0.9.7.6.orig/plugins/place/place.xml.in
496++++ compiz-0.9.7.6/plugins/place/place.xml.in
497+@@ -19,8 +19,8 @@
498+ <option name="mode" type="int">
499+ <_short>Placement Mode</_short>
500+ <_long>Algorithm to use for window placement</_long>
501+- <default>2</default>
502+- <min>0</min>
503++ <default>0</default>
504++ <min>2</min>
505+ <max>5</max>
506+ <desc>
507+ <value>0</value>
508+--- compiz-0.9.7.6.orig/plugins/scale/scale.xml.in
509++++ compiz-0.9.7.6/plugins/scale/scale.xml.in
510+@@ -18,14 +18,14 @@
511+ <option name="spacing" type="int">
512+ <_short>Spacing</_short>
513+ <_long>Space between windows</_long>
514+- <default>68</default>
515++ <default>10</default>
516+ <min>0</min>
517+ <max>250</max>
518+ </option>
519+ <option name="speed" type="float">
520+ <_short>Speed</_short>
521+ <_long>Scale speed</_long>
522+- <default>2.4</default>
523++ <default>1.5</default>
524+ <min>0.1</min>
525+ <max>50</max>
526+ <precision>0.1</precision>
527+@@ -33,7 +33,7 @@
528+ <option name="timestep" type="float">
529+ <_short>Timestep</_short>
530+ <_long>Scale timestep</_long>
531+- <default>0.1</default>
532++ <default>1.2</default>
533+ <min>0.1</min>
534+ <max>50</max>
535+ <precision>0.1</precision>
536+@@ -46,7 +46,7 @@
537+ <option name="opacity" type="int">
538+ <_short>Opacity</_short>
539+ <_long>Amount of opacity in percent</_long>
540+- <default>100</default>
541++ <default>75</default>
542+ <min>0</min>
543+ <max>100</max>
544+ </option>
545+@@ -55,7 +55,7 @@
546+ <_long>Overlay an icon on windows once they are scaled</_long>
547+ <min>0</min>
548+ <max>2</max>
549+- <default>0</default>
550++ <default>1</default>
551+ <desc>
552+ <value>0</value>
553+ <_name>None</_name>
554+@@ -112,7 +112,7 @@
555+ <option name="key_bindings_toggle" type="bool">
556+ <_short>Key Bindings Toggle Scale Mode</_short>
557+ <_long>Key bindings toggle scale mode instead of enabling it when pressed and disabling it when released.</_long>
558+- <default>true</default>
559++ <default>false</default>
560+ </option>
561+ <option name="button_bindings_toggle" type="bool">
562+ <_short>Button Bindings Toggle Scale Mode</_short>
563+@@ -122,6 +122,9 @@
564+ <option name="initiate_edge" type="edge">
565+ <_short>Initiate Window Picker</_short>
566+ <_long>Layout and start transforming windows</_long>
567++ <default>
568++ <edge name="TopRight"/>
569++ </default>
570+ <allowed edgednd="true"/>
571+ </option>
572+ <option name="initiate_key" type="key">
573+@@ -145,7 +148,6 @@
574+ <option name="initiate_all_key" type="key">
575+ <_short>Initiate Window Picker For All Windows</_short>
576+ <_long>Layout and start transforming all windows</_long>
577+- <default>&lt;Super&gt;w</default>
578+ </option>
579+ <option name="initiate_group_edge" type="edge">
580+ <_short>Initiate Window Picker For Window Group</_short>
581+@@ -176,7 +178,7 @@
582+ <option name="show_desktop" type="bool">
583+ <_short>Click Desktop to Show Desktop</_short>
584+ <_long>Enter Show Desktop mode when Desktop is clicked during Scale</_long>
585+- <default>false</default>
586++ <default>true</default>
587+ </option>
588+ </group>
589+ </options>
590+--- compiz-0.9.7.6.orig/plugins/scale/src/scale.cpp
591++++ compiz-0.9.7.6/plugins/scale/src/scale.cpp
592+@@ -226,26 +226,19 @@ ScaleWindow::scalePaintDecoration (const
593+ GLTexture::MatrixList ml (1);
594+
595+ ml[0] = icon->matrix ();
596+- priv->gWindow->geometry ().reset ();
597++ priv->gWindow->vertexBuffer ()->begin ();
598+
599+ if (width && height)
600+ priv->gWindow->glAddGeometry (ml, iconReg, iconReg);
601+
602+- if (priv->gWindow->geometry ().vCount)
603+- {
604+- GLFragment::Attrib fragment (sAttrib);
605+- GLMatrix wTransform (transform);
606++ priv->gWindow->vertexBuffer ()->end ();
607+
608+- wTransform.scale (scale, scale, 1.0f);
609+- wTransform.translate (x / scale, y / scale, 0.0f);
610+-
611+- glPushMatrix ();
612+- glLoadMatrixf (wTransform.getMatrix ());
613++ GLMatrix wTransform (transform);
614+
615+- priv->gWindow->glDrawTexture (icon, fragment, mask);
616++ wTransform.scale (scale, scale, 1.0f);
617++ wTransform.translate (x / scale, y / scale, 0.0f);
618+
619+- glPopMatrix ();
620+- }
621++ priv->gWindow->glDrawTexture (icon, wTransform, sAttrib, mask);
622+ }
623+ }
624+ }
625+@@ -392,13 +385,13 @@ PrivateScaleWindow::glPaint (const GLWin
626+
627+ if (scaled)
628+ {
629+- GLFragment::Attrib fragment (gWindow->lastPaintAttrib ());
630++ GLWindowPaintAttrib lastAttrib (gWindow->lastPaintAttrib ());
631+ GLMatrix wTransform (transform);
632+
633+ if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
634+ return false;
635+
636+- if (window->alpha () || fragment.getOpacity () != OPAQUE)
637++ if (window->alpha () || lastAttrib.opacity != OPAQUE)
638+ mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
639+
640+ wTransform.translate (window->x (), window->y (), 0.0f);
641+@@ -406,14 +399,9 @@ PrivateScaleWindow::glPaint (const GLWin
642+ wTransform.translate (tx / scale - window->x (),
643+ ty / scale - window->y (), 0.0f);
644+
645+- glPushMatrix ();
646+- glLoadMatrixf (wTransform.getMatrix ());
647+-
648+- gWindow->glDraw (wTransform, fragment, region,
649++ gWindow->glDraw (wTransform, lastAttrib, region,
650+ mask | PAINT_WINDOW_TRANSFORMED_MASK);
651+
652+- glPopMatrix ();
653+-
654+ sWindow->scalePaintDecoration (sAttrib, transform, region, mask);
655+ }
656+ }
657+--- compiz-0.9.7.6.orig/plugins/clone/src/clone.cpp
658++++ compiz-0.9.7.6/plugins/clone/src/clone.cpp
659+@@ -295,9 +295,6 @@ CloneScreen::glPaintOutput (const GLScre
660+ 0.0f);
661+ sTransform.scale (zoomX, zoomY, 1.0f);
662+
663+- glPushMatrix ();
664+- glLoadMatrixf (sTransform.getMatrix ());
665+-
666+ filter = gScreen->textureFilter ();
667+
668+ if (offset == 0.0f)
669+@@ -325,8 +322,6 @@ CloneScreen::glPaintOutput (const GLScre
670+ }
671+
672+ gScreen->setTextureFilter (filter);
673+-
674+- glPopMatrix ();
675+ }
676+
677+ return status;
678+--- compiz-0.9.7.6.orig/plugins/opengl/compiz-opengl.pc.in
679++++ compiz-0.9.7.6/plugins/opengl/compiz-opengl.pc.in
680+@@ -8,5 +8,5 @@ Description: Opengl compositing plugin f
681+ Version: @VERSION@
682+
683+ Requires: compiz compiz-composite
684+-Libs: -lGL -L${libdir} -lopengl
685+-Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz
686+\ No newline at end of file
687++Libs: @PKGCONFIG_LIBS@ -L${libdir} -lopengl
688++Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz
689+--- compiz-0.9.7.6.orig/plugins/opengl/opengl.xml.in
690++++ compiz-0.9.7.6/plugins/opengl/opengl.xml.in
691+@@ -36,7 +36,7 @@
692+ <option name="sync_to_vblank" type="bool">
693+ <_short>Sync To VBlank</_short>
694+ <_long>Only perform screen updates during vertical blanking period</_long>
695+- <default>true</default>
696++ <default>false</default>
697+ </option>
698+ <option name="texture_compression" type="bool">
699+ <_short>Texture Compression</_short>
700+--- compiz-0.9.7.6.orig/plugins/opengl/CMakeLists.txt
701++++ compiz-0.9.7.6/plugins/opengl/CMakeLists.txt
702+@@ -2,7 +2,12 @@ find_package (Compiz REQUIRED)
703+
704+ include (CompizPlugin)
705+
706+-find_package (OpenGL)
707+-if (OPENGL_FOUND)
708+- compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
709+-endif ()
710+\ No newline at end of file
711++if (USE_GLES)
712++ compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD "-DUSE_GLES -std=c++0x" LIBRARIES ${OPENGLES2_LIBRARIES} INCDIRS ${OPENGLES2_INCLUDE_DIR})
713++else (USE_GLES)
714++ find_package (OpenGL)
715++ if (OPENGL_FOUND)
716++ compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD -std=c++0x LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
717++ endif (OPENGL_FOUND)
718++endif (USE_GLES)
719++
720+--- compiz-0.9.7.6.orig/plugins/opengl/src/screen.cpp
721++++ compiz-0.9.7.6/plugins/opengl/src/screen.cpp
722+@@ -1,4 +1,5 @@
723+ /*
724++ * Copyright © 2011 Linaro Ltd.
725+ * Copyright © 2008 Dennis Kasprzyk
726+ * Copyright © 2007 Novell, Inc.
727+ *
728+@@ -23,6 +24,7 @@
729+ *
730+ * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
731+ * David Reveman <davidr@novell.com>
732++ * Travis Watkins <travis.watkins@linaro.org>
733+ */
734+
735+ #ifndef _GNU_SOURCE
736+@@ -36,6 +38,18 @@
737+ #include <math.h>
738+
739+ namespace GL {
740++ #ifdef USE_GLES
741++ EGLCreateImageKHRProc createImage;
742++ EGLDestroyImageKHRProc destroyImage;
743++
744++ GLEGLImageTargetTexture2DOESProc eglImageTargetTexture;
745++
746++ EGLPostSubBufferNVProc postSubBuffer = NULL;
747++ #else
748++
749++ typedef int (*GLXSwapIntervalProc) (int interval);
750++
751++ GLXSwapIntervalProc swapInterval = NULL;
752+ GLXBindTexImageProc bindTexImage = NULL;
753+ GLXReleaseTexImageProc releaseTexImage = NULL;
754+ GLXQueryDrawableProc queryDrawable = NULL;
755+@@ -47,18 +61,17 @@ namespace GL {
756+ GLXGetFBConfigAttribProc getFBConfigAttrib = NULL;
757+ GLXCreatePixmapProc createPixmap = NULL;
758+ GLXDestroyPixmapProc destroyPixmap = NULL;
759+-
760+- GLActiveTextureProc activeTexture = NULL;
761+- GLClientActiveTextureProc clientActiveTexture = NULL;
762+- GLMultiTexCoord2fProc multiTexCoord2f = NULL;
763+-
764+ GLGenProgramsProc genPrograms = NULL;
765+ GLDeleteProgramsProc deletePrograms = NULL;
766+ GLBindProgramProc bindProgram = NULL;
767+ GLProgramStringProc programString = NULL;
768+ GLProgramParameter4fProc programEnvParameter4f = NULL;
769+ GLProgramParameter4fProc programLocalParameter4f = NULL;
770+- GLGetProgramivProc getProgramiv = NULL;
771++ #endif
772++
773++ GLActiveTextureProc activeTexture = NULL;
774++ GLClientActiveTextureProc clientActiveTexture = NULL;
775++ GLMultiTexCoord2fProc multiTexCoord2f = NULL;
776+
777+ GLGenFramebuffersProc genFramebuffers = NULL;
778+ GLDeleteFramebuffersProc deleteFramebuffers = NULL;
779+@@ -67,16 +80,54 @@ namespace GL {
780+ GLFramebufferTexture2DProc framebufferTexture2D = NULL;
781+ GLGenerateMipmapProc generateMipmap = NULL;
782+
783++ GLBindBufferProc bindBuffer = NULL;
784++ GLDeleteBuffersProc deleteBuffers = NULL;
785++ GLGenBuffersProc genBuffers = NULL;
786++ GLBufferDataProc bufferData = NULL;
787++ GLBufferSubDataProc bufferSubData = NULL;
788++
789++ GLGetShaderivProc getShaderiv = NULL;
790++ GLGetShaderInfoLogProc getShaderInfoLog = NULL;
791++ GLGetProgramivProc getProgramiv = NULL;
792++ GLGetProgramInfoLogProc getProgramInfoLog = NULL;
793++ GLCreateShaderProc createShader = NULL;
794++ GLShaderSourceProc shaderSource = NULL;
795++ GLCompileShaderProc compileShader = NULL;
796++ GLCreateProgramProc createProgram = NULL;
797++ GLAttachShaderProc attachShader = NULL;
798++ GLLinkProgramProc linkProgram = NULL;
799++ GLValidateProgramProc validateProgram = NULL;
800++ GLDeleteShaderProc deleteShader = NULL;
801++ GLDeleteProgramProc deleteProgram = NULL;
802++ GLUseProgramProc useProgram = NULL;
803++ GLGetUniformLocationProc getUniformLocation = NULL;
804++ GLUniform1fProc uniform1f = NULL;
805++ GLUniform1iProc uniform1i = NULL;
806++ GLUniform2fProc uniform2f = NULL;
807++ GLUniform2iProc uniform2i = NULL;
808++ GLUniform3fProc uniform3f = NULL;
809++ GLUniform3iProc uniform3i = NULL;
810++ GLUniform4fProc uniform4f = NULL;
811++ GLUniform4iProc uniform4i = NULL;
812++ GLUniformMatrix4fvProc uniformMatrix4fv = NULL;
813++ GLGetAttribLocationProc getAttribLocation = NULL;
814++
815++ GLEnableVertexAttribArrayProc enableVertexAttribArray = NULL;
816++ GLDisableVertexAttribArrayProc disableVertexAttribArray = NULL;
817++ GLVertexAttribPointerProc vertexAttribPointer = NULL;
818++
819+ bool textureFromPixmap = true;
820+ bool textureRectangle = false;
821+ bool textureNonPowerOfTwo = false;
822++ bool textureNonPowerOfTwoMipmap = false;
823+ bool textureEnvCombine = false;
824+ bool textureEnvCrossbar = false;
825+ bool textureBorderClamp = false;
826+ bool textureCompression = false;
827+ GLint maxTextureSize = 0;
828+ bool fbo = false;
829+- bool fragmentProgram = false;
830++ bool vbo = false;
831++ bool shaders = false;
832+ GLint maxTextureUnits = 1;
833+
834+ bool canDoSaturated = false;
835+@@ -88,24 +139,234 @@ namespace GL {
836+
837+ CompOutput *targetOutput = NULL;
838+
839+-class DetectionWorkaround
840++/**
841++ * Callback object to create GLPrograms automatically when using GLVertexBuffer.
842++ */
843++class GLScreenAutoProgram : public GLVertexBuffer::AutoProgram
844+ {
845+- public:
846++public:
847++ GLScreenAutoProgram (GLScreen *gScreen) : gScreen(gScreen) {}
848+
849+- DetectionWorkaround ()
850+- {
851+- program_invocation_short_name[0] = 'C';
852+- }
853+- ~DetectionWorkaround ()
854+- {
855+- program_invocation_short_name[0] = 'c';
856+- }
857++ GLProgram *getProgram (GLShaderParameters &params)
858++ {
859++ const GLShaderData *shaderData = gScreen->getShaderData (params);
860++ std::list<const GLShaderData *> tempShaders;
861++ tempShaders.push_back (shaderData);
862++ return gScreen->getProgram (tempShaders);
863++ }
864++
865++ GLScreen *gScreen;
866+ };
867+
868+ bool
869+ GLScreen::glInitContext (XVisualInfo *visinfo)
870+ {
871+- DetectionWorkaround workaround;
872++ #ifdef USE_GLES
873++ Display *xdpy;
874++ Window overlay;
875++ EGLDisplay dpy;
876++ EGLConfig config;
877++ EGLint major, minor;
878++ const char *eglExtensions, *glExtensions;
879++ XWindowAttributes attr;
880++ EGLint count, visualid;
881++ EGLConfig configs[1024];
882++ CompOption::Vector o (0);
883++
884++ const EGLint config_attribs[] = {
885++ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
886++ EGL_RED_SIZE, 1,
887++ EGL_GREEN_SIZE, 1,
888++ EGL_BLUE_SIZE, 1,
889++ EGL_ALPHA_SIZE, 0,
890++ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
891++ EGL_CONFIG_CAVEAT, EGL_NONE,
892++ EGL_NONE,
893++ };
894++
895++ const EGLint context_attribs[] = {
896++ EGL_CONTEXT_CLIENT_VERSION, 2,
897++ EGL_NONE
898++ };
899++
900++ xdpy = screen->dpy ();
901++ dpy = eglGetDisplay ((EGLNativeDisplayType)xdpy);
902++ if (!eglInitialize (dpy, &major, &minor))
903++ {
904++ screen->handleCompizEvent ("opengl", "fatal_fallback", o);
905++ return false;
906++ }
907++
908++ eglBindAPI (EGL_OPENGL_ES_API);
909++
910++ if (!eglChooseConfig (dpy, config_attribs, configs, 1024, &count))
911++ {
912++ screen->handleCompizEvent ("opengl", "fatal_fallback", o);
913++ return false;
914++ }
915++
916++ if (!XGetWindowAttributes (xdpy, screen->root (), &attr))
917++ {
918++ screen->handleCompizEvent ("opengl", "fatal_fallback", o);
919++ return false;
920++ }
921++
922++ visualid = XVisualIDFromVisual (attr.visual);
923++ config = configs[0];
924++ for (int i = 0; i < count; i++) {
925++ EGLint val;
926++ eglGetConfigAttrib (dpy, configs[i], EGL_NATIVE_VISUAL_ID, &val);
927++ if (visualid == val) {
928++ config = configs[i];
929++ break;
930++ }
931++ }
932++
933++ overlay = CompositeScreen::get (screen)->overlay ();
934++ priv->surface = eglCreateWindowSurface (dpy, config, overlay, 0);
935++ if (priv->surface == EGL_NO_SURFACE)
936++ {
937++ compLogMessage ("opengl", CompLogLevelFatal,
938++ "eglCreateWindowSurface failed");
939++ screen->handleCompizEvent ("opengl", "fatal_fallback", o);
940++ return false;
941++ }
942++
943++ // Currently we rely unconditionally on preserving the buffer contents.
944++ eglSurfaceAttrib (dpy, priv->surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
945++
946++ priv->ctx = eglCreateContext (dpy, config, EGL_NO_CONTEXT, context_attribs);
947++ if (priv->ctx == EGL_NO_CONTEXT)
948++ {
949++ compLogMessage ("opengl", CompLogLevelFatal, "eglCreateContext failed");
950++ screen->handleCompizEvent ("opengl", "fatal_fallback", o);
951++ return false;
952++ }
953++
954++ if (!eglMakeCurrent (dpy, priv->surface, priv->surface, priv->ctx))
955++ {
956++ compLogMessage ("opengl", CompLogLevelFatal,
957++ "eglMakeCurrent failed");
958++ screen->handleCompizEvent ("opengl", "fatal_fallback", o);
959++ return false;
960++ }
961++
962++ eglExtensions = (const char *) eglQueryString (dpy, EGL_EXTENSIONS);
963++ glExtensions = (const char *) glGetString (GL_EXTENSIONS);
964++
965++ if (!glExtensions || !eglExtensions)
966++ {
967++ compLogMessage ("opengl", CompLogLevelFatal,
968++ "No valid GL extensions string found.");
969++ screen->handleCompizEvent ("opengl", "fatal_fallback", o);
970++ return false;
971++ }
972++
973++ GL::textureFromPixmap = true;
974++ GL::textureNonPowerOfTwo = true;
975++ GL::fbo = true;
976++ GL::vbo = true;
977++ GL::shaders = true;
978++ GL::maxTextureUnits = 4;
979++ glGetIntegerv (GL_MAX_TEXTURE_SIZE, &GL::maxTextureSize);
980++
981++ GL::createImage = (GL::EGLCreateImageKHRProc)
982++ eglGetProcAddress ("eglCreateImageKHR");
983++ GL::destroyImage = (GL::EGLDestroyImageKHRProc)
984++ eglGetProcAddress ("eglDestroyImageKHR");
985++ GL::eglImageTargetTexture = (GL::GLEGLImageTargetTexture2DOESProc)
986++ eglGetProcAddress ("glEGLImageTargetTexture2DOES");
987++
988++ if (!strstr (eglExtensions, "EGL_KHR_image_pixmap") ||
989++ !strstr (glExtensions, "GL_OES_EGL_image") ||
990++ !GL::createImage || !GL::destroyImage || !GL::eglImageTargetTexture)
991++ {
992++ compLogMessage ("opengl", CompLogLevelFatal,
993++ "GL_OES_EGL_image is missing");
994++ screen->handleCompizEvent ("opengl", "fatal_fallback", o);
995++ return false;
996++ }
997++
998++// work around efika supporting GL_BGRA directly instead of via this extension
999++#ifndef GL_BGRA
1000++ if (!strstr (glExtensions, "GL_EXT_texture_format_BGRA8888"))
1001++ {
1002++ compLogMessage ("opengl", CompLogLevelFatal,
1003++ "GL_EXT_texture_format_BGRA8888 is missing");
1004++ screen->handleCompizEvent ("opengl", "fatal_fallback", o);
1005++ return false;
1006++ }
1007++#endif
1008++
1009++ if (strstr (glExtensions, "GL_OES_texture_npot"))
1010++ GL::textureNonPowerOfTwoMipmap = true;
1011++
1012++ if (strstr (eglExtensions, "EGL_NV_post_sub_buffer"))
1013++ GL::postSubBuffer = (GL::EGLPostSubBufferNVProc)
1014++ eglGetProcAddress ("eglPostSubBufferNV");
1015++
1016++ GL::activeTexture = glActiveTexture;
1017++ GL::genFramebuffers = glGenFramebuffers;
1018++ GL::deleteFramebuffers = glDeleteFramebuffers;
1019++ GL::bindFramebuffer = glBindFramebuffer;
1020++ GL::checkFramebufferStatus = glCheckFramebufferStatus;
1021++ GL::framebufferTexture2D = glFramebufferTexture2D;
1022++ GL::generateMipmap = glGenerateMipmap;
1023++
1024++ GL::bindBuffer = glBindBuffer;
1025++ GL::deleteBuffers = glDeleteBuffers;
1026++ GL::genBuffers = glGenBuffers;
1027++ GL::bufferData = glBufferData;
1028++ GL::bufferSubData = glBufferSubData;
1029++
1030++ GL::getShaderiv = glGetShaderiv;
1031++ GL::getShaderInfoLog = glGetShaderInfoLog;
1032++ GL::getProgramiv = glGetProgramiv;
1033++ GL::getProgramInfoLog = glGetProgramInfoLog;
1034++ GL::createShader = glCreateShader;
1035++ GL::shaderSource = glShaderSource;
1036++ GL::compileShader = glCompileShader;
1037++ GL::createProgram = glCreateProgram;
1038++ GL::attachShader = glAttachShader;
1039++ GL::linkProgram = glLinkProgram;
1040++ GL::validateProgram = glValidateProgram;
1041++ GL::deleteShader = glDeleteShader;
1042++ GL::deleteProgram = glDeleteProgram;
1043++ GL::useProgram = glUseProgram;
1044++ GL::getUniformLocation = glGetUniformLocation;
1045++ GL::uniform1f = glUniform1f;
1046++ GL::uniform1i = glUniform1i;
1047++ GL::uniform2f = glUniform2f;
1048++ GL::uniform2i = glUniform2i;
1049++ GL::uniform3f = glUniform3f;
1050++ GL::uniform3i = glUniform3i;
1051++ GL::uniform4f = glUniform4f;
1052++ GL::uniform4i = glUniform4i;
1053++ GL::uniformMatrix4fv = glUniformMatrix4fv;
1054++ GL::getAttribLocation = glGetAttribLocation;
1055++
1056++ GL::enableVertexAttribArray = glEnableVertexAttribArray;
1057++ GL::disableVertexAttribArray = glDisableVertexAttribArray;
1058++ GL::vertexAttribPointer = glVertexAttribPointer;
1059++
1060++ glClearColor (0.0, 0.0, 0.0, 1.0);
1061++ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1062++ glEnable (GL_BLEND);
1063++ glEnable (GL_CULL_FACE);
1064++
1065++ priv->updateView ();
1066++
1067++ priv->lighting = false;
1068++
1069++ priv->filter[NOTHING_TRANS_FILTER] = GLTexture::Fast;
1070++ priv->filter[SCREEN_TRANS_FILTER] = GLTexture::Good;
1071++ priv->filter[WINDOW_TRANS_FILTER] = GLTexture::Good;
1072++
1073++ if (GL::textureFromPixmap)
1074++ registerBindPixmap (EglTexture::bindPixmapToTexture);
1075++
1076++ #else
1077++
1078+ Display *dpy = screen->dpy ();
1079+ const char *glExtensions;
1080+ GLfloat globalAmbient[] = { 0.1f, 0.1f, 0.1f, 0.1f };
1081+@@ -165,6 +426,7 @@ GLScreen::glInitContext (XVisualInfo *vi
1082+
1083+ if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
1084+ GL::textureNonPowerOfTwo = true;
1085++ GL::textureNonPowerOfTwoMipmap = GL::textureNonPowerOfTwo;
1086+
1087+ glGetIntegerv (GL_MAX_TEXTURE_SIZE, &GL::maxTextureSize);
1088+
1089+@@ -221,33 +483,6 @@ GLScreen::glInitContext (XVisualInfo *vi
1090+ glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &GL::maxTextureUnits);
1091+ }
1092+
1093+- if (strstr (glExtensions, "GL_ARB_fragment_program"))
1094+- {
1095+- GL::genPrograms = (GL::GLGenProgramsProc)
1096+- getProcAddress ("glGenProgramsARB");
1097+- GL::deletePrograms = (GL::GLDeleteProgramsProc)
1098+- getProcAddress ("glDeleteProgramsARB");
1099+- GL::bindProgram = (GL::GLBindProgramProc)
1100+- getProcAddress ("glBindProgramARB");
1101+- GL::programString = (GL::GLProgramStringProc)
1102+- getProcAddress ("glProgramStringARB");
1103+- GL::programEnvParameter4f = (GL::GLProgramParameter4fProc)
1104+- getProcAddress ("glProgramEnvParameter4fARB");
1105+- GL::programLocalParameter4f = (GL::GLProgramParameter4fProc)
1106+- getProcAddress ("glProgramLocalParameter4fARB");
1107+- GL::getProgramiv = (GL::GLGetProgramivProc)
1108+- getProcAddress ("glGetProgramivARB");
1109+-
1110+- if (GL::genPrograms &&
1111+- GL::deletePrograms &&
1112+- GL::bindProgram &&
1113+- GL::programString &&
1114+- GL::programEnvParameter4f &&
1115+- GL::programLocalParameter4f &&
1116+- GL::getProgramiv)
1117+- GL::fragmentProgram = true;
1118+- }
1119+-
1120+ if (strstr (glExtensions, "GL_EXT_framebuffer_object"))
1121+ {
1122+ GL::genFramebuffers = (GL::GLGenFramebuffersProc)
1123+@@ -272,6 +507,63 @@ GLScreen::glInitContext (XVisualInfo *vi
1124+ GL::fbo = true;
1125+ }
1126+
1127++ if (strstr (glExtensions, "GL_ARB_vertex_buffer_object"))
1128++ {
1129++ GL::bindBuffer = (GL::GLBindBufferProc)
1130++ getProcAddress ("glBindBufferARB");
1131++ GL::deleteBuffers = (GL::GLDeleteBuffersProc)
1132++ getProcAddress ("glDeleteBuffersARB");
1133++ GL::genBuffers = (GL::GLGenBuffersProc)
1134++ getProcAddress ("glGenBuffersARB");
1135++ GL::bufferData = (GL::GLBufferDataProc)
1136++ getProcAddress ("glBufferDataARB");
1137++ GL::bufferSubData = (GL::GLBufferSubDataProc)
1138++ getProcAddress ("glBufferSubDataARB");
1139++
1140++ if (GL::bindBuffer &&
1141++ GL::deleteBuffers &&
1142++ GL::genBuffers &&
1143++ GL::bufferData &&
1144++ GL::bufferSubData)
1145++ GL::vbo = true;
1146++ }
1147++
1148++ if (strstr (glExtensions, "GL_ARB_fragment_shader") &&
1149++ strstr (glExtensions, "GL_ARB_vertex_shader"))
1150++ {
1151++ GL::getShaderiv = (GL::GLGetShaderivProc) getProcAddress ("glGetShaderiv");
1152++ GL::getShaderInfoLog = (GL::GLGetShaderInfoLogProc) getProcAddress ("glGetShaderInfoLog");
1153++ GL::getProgramiv = (GL::GLGetProgramivProc) getProcAddress ("glGetProgramiv");
1154++ GL::getProgramInfoLog = (GL::GLGetProgramInfoLogProc) getProcAddress ("glGetProgramInfoLog");
1155++ GL::createShader = (GL::GLCreateShaderProc) getProcAddress ("glCreateShader");
1156++ GL::shaderSource = (GL::GLShaderSourceProc) getProcAddress ("glShaderSource");
1157++ GL::compileShader = (GL::GLCompileShaderProc) getProcAddress ("glCompileShader");
1158++ GL::createProgram = (GL::GLCreateProgramProc) getProcAddress ("glCreateProgram");
1159++ GL::attachShader = (GL::GLAttachShaderProc) getProcAddress ("glAttachShader");
1160++ GL::linkProgram = (GL::GLLinkProgramProc) getProcAddress ("glLinkProgram");
1161++ GL::validateProgram = (GL::GLValidateProgramProc) getProcAddress ("glValidateProgram");
1162++ GL::deleteShader = (GL::GLDeleteShaderProc) getProcAddress ("glDeleteShader");
1163++ GL::deleteProgram = (GL::GLDeleteProgramProc) getProcAddress ("glDeleteProgram");
1164++ GL::useProgram = (GL::GLUseProgramProc) getProcAddress ("glUseProgram");
1165++ GL::getUniformLocation = (GL::GLGetUniformLocationProc) getProcAddress ("glGetUniformLocation");
1166++ GL::uniform1f = (GL::GLUniform1fProc) getProcAddress ("glUniform1f");
1167++ GL::uniform1i = (GL::GLUniform1iProc) getProcAddress ("glUniform1i");
1168++ GL::uniform2f = (GL::GLUniform2fProc) getProcAddress ("glUniform2f");
1169++ GL::uniform2i = (GL::GLUniform2iProc) getProcAddress ("glUniform2i");
1170++ GL::uniform3f = (GL::GLUniform3fProc) getProcAddress ("glUniform3f");
1171++ GL::uniform3i = (GL::GLUniform3iProc) getProcAddress ("glUniform3i");
1172++ GL::uniform4f = (GL::GLUniform4fProc) getProcAddress ("glUniform4f");
1173++ GL::uniform4i = (GL::GLUniform4iProc) getProcAddress ("glUniform4i");
1174++ GL::uniformMatrix4fv = (GL::GLUniformMatrix4fvProc) getProcAddress ("glUniformMatrix4fv");
1175++ GL::getAttribLocation = (GL::GLGetAttribLocationProc) getProcAddress ("glGetAttribLocation");
1176++
1177++ GL::enableVertexAttribArray = (GL::GLEnableVertexAttribArrayProc) getProcAddress ("glEnableVertexAttribArray");
1178++ GL::disableVertexAttribArray = (GL::GLDisableVertexAttribArrayProc) getProcAddress ("glDisableVertexAttribArray");
1179++ GL::vertexAttribPointer = (GL::GLVertexAttribPointerProc) getProcAddress ("glVertexAttribPointer");
1180++
1181++ GL::shaders = true;
1182++ }
1183++
1184+ if (strstr (glExtensions, "GL_ARB_texture_compression"))
1185+ GL::textureCompression = true;
1186+
1187+@@ -313,6 +605,12 @@ GLScreen::glInitContext (XVisualInfo *vi
1188+
1189+ if (GL::textureFromPixmap)
1190+ registerBindPixmap (TfpTexture::bindPixmapToTexture);
1191++#endif
1192++
1193++ priv->scratchFbo = new GLFramebufferObject;
1194++ priv->scratchFbo->allocate (*screen, NULL, GL_BGRA);
1195++
1196++ GLVertexBuffer::streamingBuffer ()->setAutoProgram (priv->autoProgram);
1197+
1198+ return true;
1199+ }
1200+@@ -322,14 +620,14 @@ GLScreen::GLScreen (CompScreen *s) :
1201+ PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI> (s),
1202+ priv (new PrivateGLScreen (this))
1203+ {
1204++ XVisualInfo *visinfo = NULL;
1205++#ifndef USE_GLES
1206+ Display *dpy = s->dpy ();
1207+ XVisualInfo templ;
1208+- XVisualInfo *visinfo;
1209+ GLXFBConfig *fbConfigs;
1210+ int defaultDepth, nvisinfo, nElements, value, i;
1211+ const char *glxExtensions;
1212+ XWindowAttributes attr;
1213+- DetectionWorkaround workaround;
1214+ CompOption::Vector o (0);
1215+
1216+ if (!XGetWindowAttributes (dpy, s->root (), &attr))
1217+@@ -574,6 +872,7 @@ GLScreen::GLScreen (CompScreen *s) :
1218+ setFailed ();
1219+ }
1220+
1221++#endif
1222+ if (!glInitContext (visinfo))
1223+ setFailed ();
1224+ }
1225+@@ -582,7 +881,22 @@ GLScreen::~GLScreen ()
1226+ {
1227+ if (priv->hasCompositing)
1228+ CompositeScreen::get (screen)->unregisterPaintHandler ();
1229++
1230++ #ifdef USE_GLES
1231++ Display *xdpy = screen->dpy ();
1232++ EGLDisplay dpy = eglGetDisplay (xdpy);
1233++
1234++ eglMakeCurrent (dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
1235++ eglDestroyContext (dpy, priv->ctx);
1236++ eglDestroySurface (dpy, priv->surface);
1237++ eglTerminate (dpy);
1238++ eglReleaseThread ();
1239++ #else
1240++
1241+ glXDestroyContext (screen->dpy (), priv->ctx);
1242++ #endif
1243++
1244++ delete priv->scratchFbo;
1245+ delete priv;
1246+ }
1247+
1248+@@ -593,14 +907,21 @@ PrivateGLScreen::PrivateGLScreen (GLScre
1249+ backgroundTextures (),
1250+ backgroundLoaded (false),
1251+ rasterPos (0, 0),
1252+- fragmentStorage (),
1253++ projection (NULL),
1254+ clearBuffers (true),
1255+ lighting (false),
1256++ #ifndef USE_GLES
1257+ getProcAddress (0),
1258++ #endif
1259++ scratchFbo (NULL),
1260+ outputRegion (),
1261+ pendingCommands (false),
1262++ lastMask (0),
1263+ bindPixmap (),
1264+ hasCompositing (false),
1265++ programCache (new GLProgramCache (30)),
1266++ shaderCache (),
1267++ autoProgram (new GLScreenAutoProgram(gs)),
1268+ rootPixmapCopy (None),
1269+ rootPixmapSize ()
1270+ {
1271+@@ -609,6 +930,8 @@ PrivateGLScreen::PrivateGLScreen (GLScre
1272+
1273+ PrivateGLScreen::~PrivateGLScreen ()
1274+ {
1275++ delete programCache;
1276++ delete autoProgram;
1277+ if (rootPixmapCopy)
1278+ XFreePixmap (screen->dpy (), rootPixmapCopy);
1279+
1280+@@ -670,8 +993,13 @@ PrivateGLScreen::handleEvent (XEvent *ev
1281+ {
1282+ XDamageNotifyEvent *de = (XDamageNotifyEvent *) event;
1283+
1284++ #ifdef USE_GLES
1285++ std::map<Damage, EglTexture*>::iterator it =
1286++ boundPixmapTex.find (de->damage);
1287++ #else
1288+ std::map<Damage, TfpTexture*>::iterator it =
1289+ boundPixmapTex.find (de->damage);
1290++ #endif
1291+ if (it != boundPixmapTex.end ())
1292+ {
1293+ it->second->damaged = true;
1294+@@ -743,22 +1071,32 @@ perspective (GLfloat *m,
1295+ void
1296+ PrivateGLScreen::updateView ()
1297+ {
1298++ GLfloat projection_array[16];
1299++
1300++ #ifndef USE_GLES
1301+ glMatrixMode (GL_PROJECTION);
1302+ glLoadIdentity ();
1303+ glMatrixMode (GL_MODELVIEW);
1304+ glLoadIdentity ();
1305+ glDepthRange (0, 1);
1306+- glViewport (-1, -1, 2, 2);
1307+ glRasterPos2f (0, 0);
1308++ #endif
1309++ glViewport (-1, -1, 2, 2);
1310+
1311+ rasterPos = CompPoint (0, 0);
1312+
1313+- perspective (projection, 60.0f, 1.0f, 0.1f, 100.0f);
1314++ perspective (projection_array, 60.0f, 1.0f, 0.1f, 100.0f);
1315++
1316++ if (projection != NULL)
1317++ delete projection;
1318++ projection = new GLMatrix (projection_array);
1319+
1320++ #ifndef USE_GLES
1321+ glMatrixMode (GL_PROJECTION);
1322+ glLoadIdentity ();
1323+- glMultMatrixf (projection);
1324++ glMultMatrixf (projection_array);
1325+ glMatrixMode (GL_MODELVIEW);
1326++ #endif
1327+
1328+ CompRegion region (screen->region ());
1329+ /* remove all output regions from visible screen region */
1330+@@ -777,9 +1115,11 @@ PrivateGLScreen::outputChangeNotify ()
1331+ {
1332+ screen->outputChangeNotify ();
1333+
1334++ scratchFbo->allocate (*screen, NULL, GL_BGRA);
1335+ updateView ();
1336+ }
1337+
1338++#ifndef USE_GLES
1339+ GL::FuncPtr
1340+ GLScreen::getProcAddress (const char *name)
1341+ {
1342+@@ -805,6 +1145,7 @@ GLScreen::getProcAddress (const char *na
1343+
1344+ return funcPtr;
1345+ }
1346++#endif
1347+
1348+ void
1349+ PrivateGLScreen::updateScreenBackground ()
1350+@@ -922,32 +1263,23 @@ PrivateGLScreen::updateScreenBackground
1351+
1352+ XFreeGC(dpy, gc);
1353+ }
1354+-
1355+- if (!backgroundTextures.empty ())
1356+- {
1357+- foreach (GLTexture *t, backgroundTextures)
1358+- if (t->target () == GL_TEXTURE_2D)
1359+- {
1360+- glBindTexture (t->target (), t->name ());
1361+- glTexParameteri (t->target (), GL_TEXTURE_WRAP_S, GL_REPEAT);
1362+- glTexParameteri (t->target (), GL_TEXTURE_WRAP_T, GL_REPEAT);
1363+- glBindTexture (t->target (), 0);
1364+- }
1365+- }
1366+ }
1367+
1368+ void
1369+ GLScreen::setTexEnvMode (GLenum mode)
1370+ {
1371++ #ifndef USE_GLES
1372+ if (priv->lighting)
1373+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1374+ else
1375+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);
1376++ #endif
1377+ }
1378+
1379+ void
1380+ GLScreen::setLighting (bool lighting)
1381+ {
1382++ #ifndef USE_GLES
1383+ if (priv->lighting != lighting)
1384+ {
1385+ if (!priv->optionGetLighting ())
1386+@@ -968,6 +1300,7 @@ GLScreen::setLighting (bool lighting)
1387+
1388+ setTexEnvMode (GL_REPLACE);
1389+ }
1390++ #endif
1391+ }
1392+
1393+ bool
1394+@@ -1003,6 +1336,25 @@ void
1395+ GLScreenInterface::glDisableOutputClipping ()
1396+ WRAPABLE_DEF (glDisableOutputClipping)
1397+
1398++GLMatrix *
1399++GLScreenInterface::projectionMatrix ()
1400++ WRAPABLE_DEF (projectionMatrix)
1401++
1402++void
1403++GLScreenInterface::glPaintCompositedOutput (const CompRegion &region,
1404++ GLFramebufferObject *fbo,
1405++ unsigned int mask)
1406++ WRAPABLE_DEF (glPaintCompositedOutput, region, fbo, mask)
1407++
1408++
1409++GLMatrix *
1410++GLScreen::projectionMatrix ()
1411++{
1412++ WRAPABLE_HND_FUNCTN_RETURN (GLMatrix *, projectionMatrix)
1413++
1414++ return priv->projection;
1415++}
1416++
1417+ void
1418+ GLScreen::updateBackground ()
1419+ {
1420+@@ -1033,17 +1385,13 @@ GLScreen::setFilter (int num, GLTexture:
1421+ priv->filter[num] = filter;
1422+ }
1423+
1424+-GLFragment::Storage *
1425+-GLScreen::fragmentStorage ()
1426+-{
1427+- return &priv->fragmentStorage;
1428+-}
1429+-
1430++#ifndef USE_GLES
1431+ GLFBConfig*
1432+ GLScreen::glxPixmapFBConfig (unsigned int depth)
1433+ {
1434+ return &priv->glxPixmapFBConfigs[depth];
1435+ }
1436++#endif
1437+
1438+ void
1439+ GLScreen::clearOutput (CompOutput *output,
1440+@@ -1056,16 +1404,13 @@ GLScreen::clearOutput (CompOutput *out
1441+ pBox->x2 != (int) screen->width () ||
1442+ pBox->y2 != (int) screen->height ())
1443+ {
1444+- glPushAttrib (GL_SCISSOR_BIT);
1445+-
1446+ glEnable (GL_SCISSOR_TEST);
1447+ glScissor (pBox->x1,
1448+ screen->height () - pBox->y2,
1449+ pBox->x2 - pBox->x1,
1450+ pBox->y2 - pBox->y1);
1451+ glClear (mask);
1452+-
1453+- glPopAttrib ();
1454++ glDisable (GL_SCISSOR_TEST);
1455+ }
1456+ else
1457+ {
1458+@@ -1088,12 +1433,33 @@ GLScreen::setDefaultViewport ()
1459+ priv->lastViewport.height);
1460+ }
1461+
1462++#ifdef USE_GLES
1463++EGLContext
1464++GLScreen::getEGLContext ()
1465++{
1466++ return priv->ctx;
1467++}
1468++#endif
1469++
1470++GLProgram *
1471++GLScreen::getProgram (std::list<const GLShaderData*> shaders)
1472++{
1473++ return (*priv->programCache)(shaders);
1474++}
1475++
1476++const GLShaderData *
1477++GLScreen::getShaderData (GLShaderParameters &params)
1478++{
1479++ return &priv->shaderCache.getShaderData(params);
1480++}
1481++
1482+ namespace GL
1483+ {
1484+
1485+ void
1486+ waitForVideoSync ()
1487+ {
1488++#ifndef USE_GLES
1489+ GL::unthrottledFrames++;
1490+ if (GL::waitVideoSync)
1491+ {
1492+@@ -1118,11 +1484,13 @@ waitForVideoSync ()
1493+ if (GL::vsyncCount != oldCount)
1494+ GL::unthrottledFrames = 0;
1495+ }
1496++#endif
1497+ }
1498+
1499+ void
1500+ controlSwapVideoSync (bool sync)
1501+ {
1502++#ifndef USE_GLES
1503+ // Docs: http://www.opengl.org/registry/specs/SGI/swap_control.txt
1504+ if (GL::swapInterval)
1505+ {
1506+@@ -1131,6 +1499,7 @@ controlSwapVideoSync (bool sync)
1507+ }
1508+ else if (sync)
1509+ waitForVideoSync ();
1510++#endif
1511+ }
1512+
1513+ } // namespace GL
1514+@@ -1149,6 +1518,35 @@ PrivateGLScreen::paintOutputs (CompOutpu
1515+ {
1516+ XRectangle r;
1517+
1518++ // Blending is disabled by default. Each operation/plugin
1519++ // should enable it (and reset it) as needed.
1520++ glDisable(GL_BLEND);
1521++
1522++ GLFramebufferObject *oldFbo = NULL;
1523++ bool useFbo = false;
1524++
1525++ oldFbo = scratchFbo->bind ();
1526++ useFbo = scratchFbo->checkStatus () && scratchFbo->tex ();
1527++ if (!useFbo) {
1528++printf ("bailing!");
1529++ GLFramebufferObject::rebind (oldFbo);
1530++ }
1531++
1532++ refreshSubBuffer = ((lastMask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&
1533++ !(mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&
1534++ (mask & COMPOSITE_SCREEN_DAMAGE_REGION_MASK));
1535++
1536++ if (refreshSubBuffer)
1537++ {
1538++ // FIXME: We shouldn't have to substract a 1X1 pixel region here !!
1539++ // This is an ugly workaround for what appears to be a bug in the SGX
1540++ // X11 driver (e.g. on Pandaboard OMAP4 platform).
1541++ // Posting a fullscreen damage region to the SGX seems to reset the
1542++ // framebuffer, causing the screen to blackout.
1543++ cScreen->damageRegion (CompRegion (screen->fullscreenOutput ()) -
1544++ CompRegion (CompRect(0, 0, 1, 1)));
1545++ }
1546++
1547+ if (clearBuffers)
1548+ {
1549+ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
1550+@@ -1175,7 +1573,11 @@ PrivateGLScreen::paintOutputs (CompOutpu
1551+ lastViewport = r;
1552+ }
1553+
1554++#ifdef USE_GLES
1555++ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK || !GL::postSubBuffer)
1556++#else
1557+ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
1558++#endif
1559+ {
1560+ GLMatrix identity;
1561+
1562+@@ -1189,6 +1591,9 @@ PrivateGLScreen::paintOutputs (CompOutpu
1563+ {
1564+ GLMatrix identity;
1565+
1566++ if (refreshSubBuffer)
1567++ tmpRegion = CompRegion (*output);
1568++
1569+ outputRegion = tmpRegion & CompRegion (*output);
1570+
1571+ if (!gScreen->glPaintOutput (defaultScreenPaintAttrib,
1572+@@ -1204,15 +1609,38 @@ PrivateGLScreen::paintOutputs (CompOutpu
1573+ PAINT_SCREEN_FULL_MASK);
1574+
1575+ tmpRegion += *output;
1576+-
1577+ }
1578+ }
1579+ }
1580+
1581+ targetOutput = &screen->outputDevs ()[0];
1582++ glFlush ();
1583+
1584+- if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
1585++ if (useFbo)
1586+ {
1587++ GLFramebufferObject::rebind (oldFbo);
1588++
1589++ // FIXME: does not work if screen dimensions exceed max texture size
1590++ gScreen->glPaintCompositedOutput (tmpRegion, scratchFbo, mask);
1591++ }
1592++
1593++ // FIXME: Actually fix the composite plugin to be more efficient;
1594++ // If GL::swapInterval == NULL && GL::waitVideoSync != NULL then the
1595++ // composite plugin should not be imposing any framerate restriction
1596++ // (ie. blocking the CPU) at all. Because the framerate will be controlled
1597++ // and optimized here:
1598++#ifdef USE_GLES
1599++ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK || !GL::postSubBuffer)
1600++#else
1601++ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
1602++#endif
1603++ {
1604++ #ifdef USE_GLES
1605++ Display *xdpy = screen->dpy ();
1606++ eglSwapBuffers (eglGetDisplay (xdpy), surface);
1607++ eglWaitGL ();
1608++ XFlush (xdpy);
1609++ #else
1610+ /*
1611+ * controlSwapVideoSync is much faster than waitForVideoSync because
1612+ * it won't block the CPU. The waiting is offloaded to the GPU.
1613+@@ -1220,6 +1648,7 @@ PrivateGLScreen::paintOutputs (CompOutpu
1614+ */
1615+ GL::controlSwapVideoSync (optionGetSyncToVblank ());
1616+ glXSwapBuffers (screen->dpy (), cScreen->output ());
1617++ #endif
1618+ }
1619+ else
1620+ {
1621+@@ -1229,6 +1658,31 @@ PrivateGLScreen::paintOutputs (CompOutpu
1622+
1623+ waitForVideoSync ();
1624+
1625++ #ifdef USE_GLES
1626++ Display *xdpy = screen->dpy ();
1627++
1628++ if (GL::postSubBuffer)
1629++ {
1630++ while (nBox--)
1631++ {
1632++ y = screen->height () - pBox->y2;
1633++
1634++ (*GL::postSubBuffer) (eglGetDisplay (xdpy), surface,
1635++ pBox->x1, y,
1636++ pBox->x2 - pBox->x1,
1637++ pBox->y2 - pBox->y1);
1638++ pBox++;
1639++ }
1640++ }
1641++ else
1642++ {
1643++ eglSwapBuffers (eglGetDisplay (xdpy), surface);
1644++ }
1645++
1646++ eglWaitGL ();
1647++ XFlush (xdpy);
1648++
1649++ #else
1650+ if (GL::copySubBuffer)
1651+ {
1652+ while (nBox--)
1653+@@ -1275,14 +1729,21 @@ PrivateGLScreen::paintOutputs (CompOutpu
1654+ glDisable (GL_SCISSOR_TEST);
1655+ glFlush ();
1656+ }
1657++ #endif
1658+ }
1659++
1660++ lastMask = mask;
1661+ }
1662+
1663+ bool
1664+ PrivateGLScreen::hasVSync ()
1665+ {
1666++ #ifdef USE_GLES
1667++ return false;
1668++ #else
1669+ return GL::waitVideoSync && optionGetSyncToVblank () &&
1670+ GL::unthrottledFrames < 5;
1671++ #endif
1672+ }
1673+
1674+ bool
1675+@@ -1327,6 +1788,12 @@ GLScreen::unregisterBindPixmap (GLTextur
1676+ }
1677+ }
1678+
1679++GLFramebufferObject *
1680++GLScreen::fbo ()
1681++{
1682++ return priv->scratchFbo;
1683++}
1684++
1685+ GLTexture *
1686+ GLScreen::defaultIcon ()
1687+ {
1688+@@ -1359,13 +1826,10 @@ GLScreen::defaultIcon ()
1689+ void
1690+ GLScreen::resetRasterPos ()
1691+ {
1692++ #ifndef USE_GLES
1693+ glRasterPos2f (0, 0);
1694++ #endif
1695+ priv->rasterPos.setX (0);
1696+ priv->rasterPos.setY (0);
1697+ }
1698+
1699+-const float *
1700+-GLScreen::projectionMatrix ()
1701+-{
1702+- return priv->projection;
1703+-}
1704+--- /dev/null
1705++++ compiz-0.9.7.6/plugins/opengl/src/program.cpp
1706+@@ -0,0 +1,262 @@
1707++/*
1708++ * Copyright © 2011 Linaro Ltd.
1709++ *
1710++ * Permission to use, copy, modify, distribute, and sell this software
1711++ * and its documentation for any purpose is hereby granted without
1712++ * fee, provided that the above copyright notice appear in all copies
1713++ * and that both that copyright notice and this permission notice
1714++ * appear in supporting documentation, and that the name of
1715++ * Linaro Ltd. not be used in advertising or publicity pertaining to
1716++ * distribution of the software without specific, written prior permission.
1717++ * Linaro Ltd. makes no representations about the suitability of this
1718++ * software for any purpose. It is provided "as is" without express or
1719++ * implied warranty.
1720++ *
1721++ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1722++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1723++ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1724++ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1725++ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1726++ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1727++ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1728++ *
1729++ * Authors: Travis Watkins <travis.watkins@linaro.org>
1730++ */
1731++
1732++#include <iostream>
1733++#include <fstream>
1734++#include <opengl/opengl.h>
1735++
1736++class PrivateProgram
1737++{
1738++ public:
1739++ GLuint program;
1740++ bool valid;
1741++};
1742++
1743++
1744++void printShaderInfoLog (GLuint shader)
1745++{
1746++ GLint length = 0;
1747++ GLint chars = 0;
1748++ GLchar *infoLog;
1749++
1750++ (*GL::getShaderiv) (shader, GL_INFO_LOG_LENGTH, &length);
1751++
1752++ if (length > 0)
1753++ {
1754++ infoLog = new GLchar[length];
1755++ (*GL::getShaderInfoLog) (shader, length, &chars, infoLog);
1756++ std::cout << infoLog << std::endl;
1757++ delete[] infoLog;
1758++ }
1759++}
1760++
1761++void printProgramInfoLog(GLuint program)
1762++{
1763++ GLint length = 0;
1764++ GLint chars = 0;
1765++ GLchar *infoLog;
1766++
1767++ (*GL::getProgramiv) (program, GL_INFO_LOG_LENGTH, &length);
1768++
1769++ if (length > 0)
1770++ {
1771++ infoLog = new GLchar[length];
1772++ (*GL::getProgramInfoLog) (program, length, &chars, infoLog);
1773++ std::cout << infoLog << std::endl;
1774++ delete[] infoLog;
1775++ }
1776++}
1777++
1778++static bool compileShader (GLuint *shader, GLenum type, CompString &source)
1779++{
1780++ const GLchar *data;
1781++ GLint status;
1782++
1783++ data = (GLchar *)source.c_str ();
1784++
1785++ *shader = (*GL::createShader) (type);
1786++ (*GL::shaderSource) (*shader, 1, &data, NULL);
1787++ (*GL::compileShader) (*shader);
1788++
1789++ (*GL::getShaderiv) (*shader, GL_COMPILE_STATUS, &status);
1790++ return (status == GL_TRUE);
1791++}
1792++
1793++GLProgram::GLProgram (CompString &vertexShader, CompString &fragmentShader) :
1794++ priv (new PrivateProgram ())
1795++{
1796++ GLuint vertex, fragment;
1797++ GLint status;
1798++
1799++ priv->valid = false;
1800++ priv->program = (*GL::createProgram) ();
1801++
1802++ if (!compileShader (&vertex, GL_VERTEX_SHADER, vertexShader))
1803++ {
1804++ printShaderInfoLog (vertex);
1805++ std::cout << vertexShader << std::endl << std::endl;
1806++ return;
1807++ }
1808++
1809++ if (!compileShader (&fragment, GL_FRAGMENT_SHADER, fragmentShader))
1810++ {
1811++ printShaderInfoLog (fragment);
1812++ std::cout << fragmentShader << std::endl << std::endl;
1813++ return;
1814++ }
1815++
1816++ (*GL::attachShader) (priv->program, vertex);
1817++ (*GL::attachShader) (priv->program, fragment);
1818++
1819++ (*GL::linkProgram) (priv->program);
1820++ (*GL::validateProgram) (priv->program);
1821++
1822++ (*GL::getProgramiv) (priv->program, GL_LINK_STATUS, &status);
1823++ if (status == GL_FALSE)
1824++ {
1825++ printProgramInfoLog (priv->program);
1826++ return;
1827++ }
1828++
1829++ (*GL::deleteShader) (vertex);
1830++ (*GL::deleteShader) (fragment);
1831++
1832++ priv->valid = true;
1833++}
1834++
1835++GLProgram::~GLProgram ()
1836++{
1837++ (*GL::deleteProgram) (priv->program);
1838++ delete priv;
1839++}
1840++
1841++bool GLProgram::valid ()
1842++{
1843++ return priv->valid;
1844++}
1845++
1846++void GLProgram::bind ()
1847++{
1848++ (*GL::useProgram) (priv->program);
1849++}
1850++
1851++void GLProgram::unbind ()
1852++{
1853++ (*GL::useProgram) (0);
1854++}
1855++
1856++bool GLProgram::setUniform (const char *name, GLfloat value)
1857++{
1858++ GLint location = (*GL::getUniformLocation) (priv->program, name);
1859++ if (location == -1)
1860++ return false;
1861++
1862++ (*GL::uniform1f) (location, value);
1863++ return true;
1864++}
1865++
1866++bool GLProgram::setUniform (const char *name, GLint value)
1867++{
1868++ GLint location = (*GL::getUniformLocation) (priv->program, name);
1869++ if (location == -1)
1870++ return false;
1871++
1872++ (*GL::uniform1i) (location, value);
1873++ return true;
1874++}
1875++
1876++bool GLProgram::setUniform (const char *name, const GLMatrix &value)
1877++{
1878++ GLint location = (*GL::getUniformLocation) (priv->program, name);
1879++ if (location == -1)
1880++ return false;
1881++
1882++ (*GL::uniformMatrix4fv) (location, 1, GL_FALSE, value.getMatrix ());
1883++ return true;
1884++}
1885++
1886++bool GLProgram::setUniform2f (const char *name,
1887++ GLfloat x,
1888++ GLfloat y)
1889++{
1890++ GLint location = (*GL::getUniformLocation) (priv->program, name);
1891++ if (location == -1)
1892++ return false;
1893++
1894++ (*GL::uniform2f) (location, x, y);
1895++ return true;
1896++}
1897++
1898++bool GLProgram::setUniform3f (const char *name,
1899++ GLfloat x,
1900++ GLfloat y,
1901++ GLfloat z)
1902++{
1903++ GLint location = (*GL::getUniformLocation) (priv->program, name);
1904++ if (location == -1)
1905++ return false;
1906++
1907++ (*GL::uniform3f) (location, x, y, z);
1908++ return true;
1909++}
1910++
1911++bool GLProgram::setUniform4f (const char *name,
1912++ GLfloat x,
1913++ GLfloat y,
1914++ GLfloat z,
1915++ GLfloat w)
1916++{
1917++ GLint location = (*GL::getUniformLocation) (priv->program, name);
1918++ if (location == -1)
1919++ return false;
1920++
1921++ (*GL::uniform4f) (location, x, y, z, w);
1922++ return true;
1923++}
1924++
1925++bool GLProgram::setUniform2i (const char *name,
1926++ GLint x,
1927++ GLint y)
1928++{
1929++ GLint location = (*GL::getUniformLocation) (priv->program, name);
1930++ if (location == -1)
1931++ return false;
1932++
1933++ (*GL::uniform2i) (location, x, y);
1934++ return true;
1935++}
1936++
1937++bool GLProgram::setUniform3i (const char *name,
1938++ GLint x,
1939++ GLint y,
1940++ GLint z)
1941++{
1942++ GLint location = (*GL::getUniformLocation) (priv->program, name);
1943++ if (location == -1)
1944++ return false;
1945++
1946++ (*GL::uniform3i) (location, x, y, z);
1947++ return true;
1948++}
1949++
1950++bool GLProgram::setUniform4i (const char *name,
1951++ GLint x,
1952++ GLint y,
1953++ GLint z,
1954++ GLint w)
1955++{
1956++ GLint location = (*GL::getUniformLocation) (priv->program, name);
1957++ if (location == -1)
1958++ return false;
1959++
1960++ (*GL::uniform4i) (location, x, y, z, w);
1961++ return true;
1962++}
1963++
1964++GLuint GLProgram::attributeLocation (const char *name)
1965++{
1966++ return (*GL::getAttribLocation) (priv->program, name);
1967++}
1968++
1969+--- /dev/null
1970++++ compiz-0.9.7.6/plugins/opengl/src/framebufferobject.cpp
1971+@@ -0,0 +1,191 @@
1972++/*
1973++ * Copyright (c) 2011 Collabora, Ltd.
1974++ *
1975++ * Permission to use, copy, modify, distribute, and sell this software
1976++ * and its documentation for any purpose is hereby granted without
1977++ * fee, provided that the above copyright notice appear in all copies
1978++ * and that both that copyright notice and this permission notice
1979++ * appear in supporting documentation, and that the name of
1980++ * Collabora Ltd. not be used in advertising or publicity pertaining to
1981++ * distribution of the software without specific, written prior permission.
1982++ * Collabora Ltd. makes no representations about the suitability of this
1983++ * software for any purpose. It is provided "as is" without express or
1984++ * implied warranty.
1985++ *
1986++ * COLLABORA LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1987++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1988++ * NO EVENT SHALL COLLABORA LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1989++ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1990++ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1991++ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1992++ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1993++ *
1994++ * Authors: Pekka Paalanen <ppaalanen@gmail.com>
1995++ */
1996++
1997++#include <map>
1998++#include <opengl/framebufferobject.h>
1999++#include <opengl/texture.h>
2000++
2001++struct PrivateGLFramebufferObject
2002++{
2003++ PrivateGLFramebufferObject () :
2004++ fboId (0),
2005++ glTex (NULL)
2006++ {
2007++ }
2008++
2009++ void pushFBO ();
2010++ void popFBO ();
2011++
2012++ GLuint fboId;
2013++ GLuint tmpId;
2014++ GLTexture *glTex;
2015++
2016++ static std::map<GLuint, GLFramebufferObject *> idMap;
2017++};
2018++
2019++std::map<GLuint, GLFramebufferObject *> PrivateGLFramebufferObject::idMap;
2020++
2021++void
2022++PrivateGLFramebufferObject::pushFBO ()
2023++{
2024++ GLint id = 0;
2025++ glGetIntegerv (GL_FRAMEBUFFER_BINDING, &id);
2026++ tmpId = id;
2027++ if (tmpId == fboId)
2028++ return;
2029++
2030++ (*GL::bindFramebuffer) (GL_FRAMEBUFFER, fboId);
2031++}
2032++
2033++void
2034++PrivateGLFramebufferObject::popFBO ()
2035++{
2036++ if (tmpId != fboId)
2037++ (*GL::bindFramebuffer) (GL_FRAMEBUFFER, tmpId);
2038++}
2039++
2040++GLFramebufferObject::GLFramebufferObject () :
2041++ priv (new PrivateGLFramebufferObject)
2042++{
2043++ (*GL::genFramebuffers) (1, &priv->fboId);
2044++ if (priv->fboId != 0)
2045++ PrivateGLFramebufferObject::idMap[priv->fboId] = this;
2046++}
2047++
2048++GLFramebufferObject::~GLFramebufferObject ()
2049++{
2050++ if (priv->glTex)
2051++ GLTexture::decRef (priv->glTex);
2052++
2053++ PrivateGLFramebufferObject::idMap.erase (priv->fboId);
2054++ (*GL::deleteFramebuffers) (1, &priv->fboId);
2055++
2056++ delete priv;
2057++}
2058++
2059++bool
2060++GLFramebufferObject::allocate (const CompSize &size, const char *image,
2061++ GLenum format, GLenum type)
2062++{
2063++ if (!priv->glTex ||
2064++ size.width () != priv->glTex->width () ||
2065++ size.height () != priv->glTex->height ())
2066++ {
2067++ if (priv->glTex)
2068++ GLTexture::decRef (priv->glTex);
2069++ priv->glTex = NULL;
2070++
2071++ GLTexture::List list = GLTexture::imageDataToTexture (image, size,
2072++ format, type);
2073++ if (list.size () != 1 || list[0] == NULL)
2074++ return false;
2075++
2076++ priv->glTex = list[0];
2077++ GLTexture::incRef (priv->glTex);
2078++ }
2079++
2080++ priv->pushFBO ();
2081++ (*GL::framebufferTexture2D) (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2082++ priv->glTex->target (),
2083++ priv->glTex->name (), 0);
2084++ priv->popFBO ();
2085++ return true;
2086++}
2087++
2088++GLFramebufferObject *
2089++GLFramebufferObject::bind ()
2090++{
2091++ GLFramebufferObject *old = NULL;
2092++ GLint id = 0;
2093++
2094++ glGetIntegerv (GL_FRAMEBUFFER_BINDING, &id);
2095++ if (id != 0)
2096++ {
2097++ std::map<GLuint, GLFramebufferObject *>::iterator it;
2098++ it = PrivateGLFramebufferObject::idMap.find (id);
2099++
2100++ if (it != PrivateGLFramebufferObject::idMap.end ())
2101++ old = it->second;
2102++ else
2103++ compLogMessage ("opengl", CompLogLevelError,
2104++ "An FBO without GLFramebufferObject cannot be restored");
2105++ }
2106++
2107++ (*GL::bindFramebuffer) (GL_FRAMEBUFFER, priv->fboId);
2108++
2109++ return old;
2110++}
2111++
2112++// static
2113++void
2114++GLFramebufferObject::rebind (GLFramebufferObject *fbo)
2115++{
2116++ GLuint id = fbo ? fbo->priv->fboId : 0;
2117++ (*GL::bindFramebuffer) (GL_FRAMEBUFFER, id);
2118++}
2119++
2120++static const char *
2121++getFboErrorString (GLint status)
2122++{
2123++ switch (status)
2124++ {
2125++ case GL_FRAMEBUFFER_COMPLETE:
2126++ return "GL_FRAMEBUFFER_COMPLETE";
2127++ case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
2128++ return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
2129++ case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
2130++ return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
2131++#ifdef USE_GLES
2132++ case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
2133++ return "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
2134++#endif
2135++ case GL_FRAMEBUFFER_UNSUPPORTED:
2136++ return "GL_FRAMEBUFFER_UNSUPPORTED";
2137++ default:
2138++ return "unexpected status";
2139++ }
2140++}
2141++
2142++bool
2143++GLFramebufferObject::checkStatus ()
2144++{
2145++ priv->pushFBO ();
2146++ GLint status = (*GL::checkFramebufferStatus) (GL_FRAMEBUFFER);
2147++ priv->popFBO ();
2148++
2149++ if (status == GL_FRAMEBUFFER_COMPLETE)
2150++ return true;
2151++
2152++ compLogMessage ("opengl", CompLogLevelError,
2153++ "FBO is incomplete: %s (0x%04x)",
2154++ getFboErrorString (status), status);
2155++ return false;
2156++}
2157++
2158++GLTexture *
2159++GLFramebufferObject::tex ()
2160++{
2161++ return priv->glTex;
2162++}
2163+--- /dev/null
2164++++ compiz-0.9.7.6/plugins/opengl/src/privatevertexbuffer.h
2165+@@ -0,0 +1,138 @@
2166++/*
2167++ * Copyright © 2011 Linaro Ltd.
2168++ *
2169++ * Permission to use, copy, modify, distribute, and sell this software
2170++ * and its documentation for any purpose is hereby granted without
2171++ * fee, provided that the above copyright notice appear in all copies
2172++ * and that both that copyright notice and this permission notice
2173++ * appear in supporting documentation, and that the name of
2174++ * Linaro Ltd. not be used in advertising or publicity pertaining to
2175++ * distribution of the software without specific, written prior permission.
2176++ * Linaro Ltd. makes no representations about the suitability of this
2177++ * software for any purpose. It is provided "as is" without express or
2178++ * implied warranty.
2179++ *
2180++ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2181++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2182++ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2183++ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2184++ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2185++ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2186++ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2187++ *
2188++ * Authors: Travis Watkins <travis.watkins@linaro.org>
2189++ * Frederic Plourde <frederic.plourde@collabora.co.uk>
2190++ */
2191++
2192++#ifndef _VERTEXBUFFER_PRIVATE_H
2193++#define _VERTEXBUFFER_PRIVATE_H
2194++
2195++#ifdef USE_GLES
2196++#include <GLES2/gl2.h>
2197++#else
2198++#include <GL/gl.h>
2199++#endif
2200++
2201++#include <opengl/program.h>
2202++#include <typeinfo>
2203++
2204++class GLVertexBuffer;
2205++
2206++class AbstractUniform
2207++{
2208++ public:
2209++ void virtual set(GLProgram* program) = 0;
2210++};
2211++
2212++template < typename T, int C >
2213++class Uniform: public AbstractUniform
2214++{
2215++ public:
2216++ Uniform(const char *_name, ... );
2217++ void set(GLProgram* program);
2218++
2219++ public:
2220++ T a[C];
2221++ std::string name;
2222++};
2223++
2224++template < typename T, int C >
2225++Uniform< T, C >::Uniform(const char *_name, ... )
2226++{
2227++ va_list arg_list;
2228++ va_start( arg_list, _name );
2229++ name = _name;
2230++ for( int i = 0; i < C; i++ )
2231++ a[i] = va_arg( arg_list, T );
2232++ va_end( arg_list );
2233++}
2234++
2235++template < typename T, int C >
2236++void Uniform< T, C >::set(GLProgram* prog)
2237++{
2238++ const char* n = name.c_str();
2239++
2240++ // This will only get called from privateVertexBuffer::render
2241++ // so we know we've got a valid, bound program here
2242++ if (typeid(a[0]) == typeid(double))
2243++ {
2244++ switch (C)
2245++ {
2246++ case 1: prog->setUniform (n, (GLfloat) a[0]); break;
2247++ case 2: prog->setUniform2f (n, a[0], a[1]); break;
2248++ case 3: prog->setUniform3f (n, a[0], a[1], a[2]); break;
2249++ case 4: prog->setUniform4f (n, a[0], a[1], a[2], a[3]); break;
2250++ }
2251++ } else if (typeid(a[0]) == typeid(int))
2252++ {
2253++ switch (C)
2254++ {
2255++ case 1: prog->setUniform (n, (GLint) a[0]); break;
2256++ case 2: prog->setUniform2i (n, a[0], a[1]); break;
2257++ case 3: prog->setUniform3i (n, a[0], a[1], a[2]); break;
2258++ case 4: prog->setUniform4i (n, a[0], a[1], a[2], a[3]); break;
2259++ }
2260++ } else
2261++ {
2262++ compLogMessage ("opengl", CompLogLevelError, "Unknown uniform type!");
2263++ }
2264++}
2265++
2266++class GLVertexBuffer;
2267++
2268++class PrivateVertexBuffer
2269++{
2270++ public:
2271++ PrivateVertexBuffer ();
2272++ ~PrivateVertexBuffer ();
2273++
2274++ int render (const GLMatrix *projection,
2275++ const GLMatrix *modelview,
2276++ const GLWindowPaintAttrib *attrib);
2277++ int legacyRender (const GLMatrix &projection,
2278++ const GLMatrix &modelview,
2279++ const GLWindowPaintAttrib &attrib);
2280++
2281++ public:
2282++ static GLVertexBuffer *streamingBuffer;
2283++
2284++ std::vector<GLfloat> vertexData;
2285++ std::vector<GLfloat> normalData;
2286++ std::vector<GLfloat> colorData;
2287++ std::vector<std::vector<GLfloat> > textureData;
2288++
2289++ GLProgram *program;
2290++ GLenum primitiveType;
2291++ GLenum usage;
2292++
2293++ GLuint vertexBuffer;
2294++ GLuint normalBuffer;
2295++ GLuint colorBuffer;
2296++ GLuint textureBuffers[4];
2297++ std::vector<AbstractUniform*> uniforms;
2298++
2299++ GLVertexBuffer::AutoProgram *autoProgram;
2300++};
2301++
2302++#endif //_VERTEXBUFFER_PRIVATE_H
2303++
2304+--- compiz-0.9.7.6.orig/plugins/opengl/src/window.cpp
2305++++ compiz-0.9.7.6/plugins/opengl/src/window.cpp
2306+@@ -46,6 +46,28 @@ GLWindow::~GLWindow ()
2307+ delete priv;
2308+ }
2309+
2310++
2311++/**
2312++ * Callback object to create GLPrograms automatically when using GLVertexBuffer.
2313++ */
2314++class GLWindowAutoProgram : public GLVertexBuffer::AutoProgram
2315++{
2316++public:
2317++ GLWindowAutoProgram (PrivateGLWindow *pWindow) : pWindow(pWindow) {}
2318++
2319++ GLProgram *getProgram (GLShaderParameters &params)
2320++ {
2321++ GLScreen *gScreen = pWindow->gScreen;
2322++
2323++ const GLShaderData *shaderData = gScreen->getShaderData (params);
2324++ pWindow->shaders.push_back (shaderData);
2325++ return gScreen->getProgram (pWindow->shaders);
2326++ }
2327++
2328++ PrivateGLWindow *pWindow;
2329++
2330++};
2331++
2332+ PrivateGLWindow::PrivateGLWindow (CompWindow *w,
2333+ GLWindow *gw) :
2334+ window (w),
2335+@@ -57,7 +79,8 @@ PrivateGLWindow::PrivateGLWindow (CompWi
2336+ updateReg (true),
2337+ clip (),
2338+ bindFailed (false),
2339+- geometry (),
2340++ vertexBuffer (new GLVertexBuffer ()),
2341++ autoProgram(new GLWindowAutoProgram(this)),
2342+ icons ()
2343+ {
2344+ paint.xScale = 1.0f;
2345+@@ -67,10 +90,13 @@ PrivateGLWindow::PrivateGLWindow (CompWi
2346+
2347+ WindowInterface::setHandler (w);
2348+ CompositeWindowInterface::setHandler (cWindow);
2349++ vertexBuffer->setAutoProgram(autoProgram);
2350+ }
2351+
2352+ PrivateGLWindow::~PrivateGLWindow ()
2353+ {
2354++ delete vertexBuffer;
2355++ delete autoProgram;
2356+ }
2357+
2358+ void
2359+@@ -105,6 +131,21 @@ GLWindow::bind ()
2360+ compLogMessage ("opengl", CompLogLevelInfo,
2361+ "Couldn't bind redirected window 0x%x to "
2362+ "texture\n", (int) priv->window->id ());
2363++
2364++ if (priv->cWindow->size ().width () > GL::maxTextureSize ||
2365++ priv->cWindow->size ().height () > GL::maxTextureSize)
2366++ {
2367++ compLogMessage ("opengl", CompLogLevelWarn,
2368++ "Bug in window 0x%x (identifying as %s)", (int) priv->window->id (), priv->window->resName ().size () ? priv->window->resName ().c_str () : "(none available)");
2369++ compLogMessage ("opengl", CompLogLevelWarn,
2370++ "This window tried to create an absurdly large window %i x %i\n", priv->cWindow->size ().width (), priv->cWindow->size ().height ());
2371++ compLogMessage ("opengl", CompLogLevelWarn,
2372++ "Unforunately, that's not supported on your hardware, because you have a maximum texture size of %i", GL::maxTextureSize);
2373++ compLogMessage ("opengl", CompLogLevelWarn, "you should probably file a bug against that application");
2374++ compLogMessage ("opengl", CompLogLevelWarn, "for now, we're going to hide tht window so that it doesn't break your desktop\n");
2375++
2376++ XReparentWindow (screen->dpy (), priv->window->id (), GLScreen::get (screen)->priv->saveWindow, 0, 0);
2377++ }
2378+ }
2379+
2380+ priv->setWindowMatrix ();
2381+@@ -132,11 +173,11 @@ GLWindowInterface::glPaint (const GLWind
2382+ WRAPABLE_DEF (glPaint, attrib, transform, region, mask)
2383+
2384+ bool
2385+-GLWindowInterface::glDraw (const GLMatrix &transform,
2386+- GLFragment::Attrib &fragment,
2387+- const CompRegion &region,
2388+- unsigned int mask)
2389+- WRAPABLE_DEF (glDraw, transform, fragment, region, mask)
2390++GLWindowInterface::glDraw (const GLMatrix &transform,
2391++ const GLWindowPaintAttrib &attrib,
2392++ const CompRegion &region,
2393++ unsigned int mask)
2394++ WRAPABLE_DEF (glDraw, transform, attrib, region, mask)
2395+
2396+ void
2397+ GLWindowInterface::glAddGeometry (const GLTexture::MatrixList &matrix,
2398+@@ -148,14 +189,11 @@ GLWindowInterface::glAddGeometry (const
2399+ maxGridWidth, maxGridHeight)
2400+
2401+ void
2402+-GLWindowInterface::glDrawTexture (GLTexture *texture,
2403+- GLFragment::Attrib &fragment,
2404+- unsigned int mask)
2405+- WRAPABLE_DEF (glDrawTexture, texture, fragment, mask)
2406+-
2407+-void
2408+-GLWindowInterface::glDrawGeometry ()
2409+- WRAPABLE_DEF (glDrawGeometry)
2410++GLWindowInterface::glDrawTexture (GLTexture *texture,
2411++ const GLMatrix &transform,
2412++ const GLWindowPaintAttrib &attrib,
2413++ unsigned int mask)
2414++ WRAPABLE_DEF (glDrawTexture, texture, transform, attrib, mask)
2415+
2416+ const CompRegion &
2417+ GLWindow::clip () const
2418+@@ -223,76 +261,10 @@ GLWindow::updatePaintAttribs ()
2419+ priv->paint.saturation = cw->saturation ();
2420+ }
2421+
2422+-GLWindow::Geometry &
2423+-GLWindow::geometry ()
2424+-{
2425+- return priv->geometry;
2426+-}
2427+-
2428+-GLWindow::Geometry::Geometry () :
2429+- vertices (NULL),
2430+- vertexSize (0),
2431+- vertexStride (0),
2432+- indices (NULL),
2433+- indexSize (0),
2434+- vCount (0),
2435+- texUnits (0),
2436+- texCoordSize (0),
2437+- indexCount (0)
2438+-{
2439+-}
2440+-
2441+-GLWindow::Geometry::~Geometry ()
2442+-{
2443+- if (vertices)
2444+- free (vertices);
2445+-
2446+- if (indices)
2447+- free (indices);
2448+-}
2449+-
2450+-void
2451+-GLWindow::Geometry::reset ()
2452+-{
2453+- vCount = indexCount = 0;
2454+-}
2455+-
2456+-bool
2457+-GLWindow::Geometry::moreVertices (int newSize)
2458+-{
2459+- if (newSize > vertexSize)
2460+- {
2461+- GLfloat *nVertices;
2462+-
2463+- nVertices = (GLfloat *)
2464+- realloc (vertices, sizeof (GLfloat) * newSize);
2465+- if (!nVertices)
2466+- return false;
2467+-
2468+- vertices = nVertices;
2469+- vertexSize = newSize;
2470+- }
2471+-
2472+- return true;
2473+-}
2474+-
2475+-bool
2476+-GLWindow::Geometry::moreIndices (int newSize)
2477++GLVertexBuffer *
2478++GLWindow::vertexBuffer ()
2479+ {
2480+- if (newSize > indexSize)
2481+- {
2482+- GLushort *nIndices;
2483+-
2484+- nIndices = (GLushort *)
2485+- realloc (indices, sizeof (GLushort) * newSize);
2486+- if (!nIndices)
2487+- return false;
2488+-
2489+- indices = nIndices;
2490+- indexSize = newSize;
2491+- }
2492+-
2493+- return true;
2494++ return priv->vertexBuffer;
2495+ }
2496+
2497+ const GLTexture::List &
2498+@@ -335,6 +307,19 @@ GLWindow::getIcon (int width, int height
2499+ }
2500+
2501+ void
2502++GLWindow::addShaders (std::string name,
2503++ std::string vertex_shader,
2504++ std::string fragment_shader)
2505++{
2506++ GLShaderData *data = new GLShaderData;
2507++ data->name = name;
2508++ data->vertexShader = vertex_shader;
2509++ data->fragmentShader = fragment_shader;
2510++
2511++ priv->shaders.push_back(data);
2512++}
2513++
2514++void
2515+ PrivateGLWindow::updateFrameRegion (CompRegion &region)
2516+ {
2517+ window->updateFrameRegion (region);
2518+--- compiz-0.9.7.6.orig/plugins/opengl/src/privatetexture.h
2519++++ compiz-0.9.7.6/plugins/opengl/src/privatetexture.h
2520+@@ -1,6 +1,7 @@
2521+ /*
2522+ * Copyright © 2008 Dennis Kasprzyk
2523+ * Copyright © 2007 Novell, Inc.
2524++ * Copyright © 2011 Linaro Ltd.
2525+ *
2526+ * Permission to use, copy, modify, distribute, and sell this software
2527+ * and its documentation for any purpose is hereby granted without
2528+@@ -23,13 +24,21 @@
2529+ *
2530+ * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
2531+ * David Reveman <davidr@novell.com>
2532++ * Travis Watkins <travis.watkins@linaro.org>
2533+ */
2534+
2535+ #ifndef _PRIVATETEXTURE_H
2536+ #define _PRIVATETEXTURE_H
2537+
2538++#ifdef USE_GLES
2539++#define SUPPORT_X11
2540++#include <GLES2/gl2.h>
2541++#include <EGL/egl.h>
2542++#include <EGL/eglext.h>
2543++#else
2544+ #include <GL/gl.h>
2545+ #include <GL/glx.h>
2546++#endif
2547+ #include <opengl/texture.h>
2548+ #include <X11/extensions/Xdamage.h>
2549+
2550+@@ -62,6 +71,28 @@ class PrivateTexture {
2551+ int refCount;
2552+ };
2553+
2554++#ifdef USE_GLES
2555++class EglTexture : public GLTexture {
2556++ public:
2557++ EglTexture ();
2558++ ~EglTexture ();
2559++
2560++ void enable (Filter filter);
2561++
2562++ static List bindPixmapToTexture (Pixmap pixmap,
2563++ int width,
2564++ int height,
2565++ int depth);
2566++
2567++ public:
2568++ bool damaged;
2569++ Damage damage;
2570++ bool updateMipMap;
2571++};
2572++
2573++extern std::map<Damage, EglTexture*> boundPixmapTex;
2574++#else
2575++
2576+ class TfpTexture : public GLTexture {
2577+ public:
2578+ TfpTexture ();
2579+@@ -82,5 +113,6 @@ class TfpTexture : public GLTexture {
2580+ };
2581+
2582+ extern std::map<Damage, TfpTexture*> boundPixmapTex;
2583++#endif
2584+
2585+ #endif
2586+--- /dev/null
2587++++ compiz-0.9.7.6/plugins/opengl/src/programcache.cpp
2588+@@ -0,0 +1,175 @@
2589++/*
2590++ * Copyright © 2011 Linaro Ltd.
2591++ *
2592++ * Permission to use, copy, modify, distribute, and sell this software
2593++ * and its documentation for any purpose is hereby granted without
2594++ * fee, provided that the above copyright notice appear in all copies
2595++ * and that both that copyright notice and this permission notice
2596++ * appear in supporting documentation, and that the name of
2597++ * Linaro Ltd. not be used in advertising or publicity pertaining to
2598++ * distribution of the software without specific, written prior permission.
2599++ * Linaro Ltd. makes no representations about the suitability of this
2600++ * software for any purpose. It is provided "as is" without express or
2601++ * implied warranty.
2602++ *
2603++ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2604++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2605++ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2606++ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2607++ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2608++ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2609++ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2610++ *
2611++ * Authors: Travis Watkins <travis.watkins@linaro.org>
2612++ */
2613++
2614++#include <opengl/programcache.h>
2615++#include "privates.h"
2616++
2617++typedef std::list<std::string> access_history_t;
2618++typedef std::pair<GLProgram*, access_history_t::iterator> value;
2619++
2620++static GLProgram *
2621++compileProgram (std::string name, std::list<const GLShaderData*> shaders)
2622++{
2623++ std::list<const GLShaderData*>::const_iterator it;
2624++ std::string vertex_shader;
2625++ std::string fragment_shader;
2626++ std::string vertex_functions = "";
2627++ std::string vertex_function_calls = "";
2628++ std::string fragment_functions = "";
2629++ std::string fragment_function_calls = "";
2630++ int vpos, vcallpos, fpos, fcallpos;
2631++
2632++ for (it = shaders.begin (); it != shaders.end (); it++)
2633++ {
2634++ //find the special shaders to put the rest in
2635++ if ((*it)->vertexShader.find ("@VERTEX_FUNCTIONS@") != std::string::npos)
2636++ {
2637++ vertex_shader = (*it)->vertexShader;
2638++ }
2639++ else
2640++ {
2641++ if ((*it)->vertexShader.length ())
2642++ {
2643++ vertex_functions += (*it)->vertexShader;
2644++ vertex_function_calls += (*it)->name + "_vertex();\n";
2645++ }
2646++ }
2647++
2648++ if ((*it)->fragmentShader.find ("@FRAGMENT_FUNCTIONS@") != std::string::npos)
2649++ {
2650++ fragment_shader = (*it)->fragmentShader;
2651++ }
2652++ else
2653++ {
2654++ if ((*it)->fragmentShader.length ())
2655++ {
2656++ fragment_functions += (*it)->fragmentShader;
2657++ fragment_function_calls += (*it)->name + "_fragment();\n";
2658++ }
2659++ }
2660++ }
2661++
2662++ // put shader functions and function calls into the main shader
2663++ vpos = vertex_shader.find ("@VERTEX_FUNCTIONS@");
2664++ vertex_shader.replace (vpos, 18, vertex_functions);
2665++
2666++ vcallpos = vertex_shader.find ("@VERTEX_FUNCTION_CALLS@");
2667++ vertex_shader.replace (vcallpos, 23, vertex_function_calls);
2668++
2669++ fpos = fragment_shader.find ("@FRAGMENT_FUNCTIONS@");
2670++ fragment_shader.replace (fpos, 20, fragment_functions);
2671++
2672++ fcallpos = fragment_shader.find ("@FRAGMENT_FUNCTION_CALLS@");
2673++ fragment_shader.replace (fcallpos, 25, fragment_function_calls);
2674++
2675++ return new GLProgram (vertex_shader, fragment_shader);
2676++}
2677++
2678++class PrivateProgramCache
2679++{
2680++ public:
2681++ PrivateProgramCache (size_t);
2682++
2683++ const size_t capacity;
2684++ access_history_t access_history;
2685++ std::map<std::string, value> cache;
2686++
2687++ void insert (std::string, GLProgram *);
2688++ void evict ();
2689++};
2690++
2691++GLProgramCache::GLProgramCache (size_t capacity) :
2692++ priv (new PrivateProgramCache (capacity))
2693++{
2694++ assert (priv->capacity != 0);
2695++}
2696++
2697++GLProgramCache::~GLProgramCache ()
2698++{
2699++ delete priv;
2700++}
2701++
2702++GLProgram* GLProgramCache::operator () (std::list<const GLShaderData*> shaders)
2703++{
2704++ std::list<const GLShaderData*>::const_iterator name_it;
2705++ std::string name;
2706++
2707++ for (name_it = shaders.begin(); name_it != shaders.end(); name_it++)
2708++ {
2709++ if (name.length () == 0)
2710++ name += (*name_it)->name;
2711++ else
2712++ name += ":" + (*name_it)->name;
2713++ }
2714++
2715++ std::map<std::string, value>::iterator it = priv->cache.find (name);
2716++
2717++ if (it == priv->cache.end ())
2718++ {
2719++ GLProgram *program = compileProgram (name, shaders);
2720++ priv->insert (name, program);
2721++ return program;
2722++ }
2723++ else
2724++ {
2725++ priv->access_history.splice (priv->access_history.end (),
2726++ priv->access_history,
2727++ (*it).second.second);
2728++ (*it).second.second = priv->access_history.rbegin ().base ();
2729++
2730++ return (*it).second.first;
2731++ }
2732++}
2733++
2734++PrivateProgramCache::PrivateProgramCache (size_t c) :
2735++ capacity (c)
2736++{
2737++}
2738++
2739++void PrivateProgramCache::insert (std::string name, GLProgram *program)
2740++{
2741++ assert (cache.find (name) == cache.end ());
2742++
2743++ if (cache.size () == capacity)
2744++ evict ();
2745++
2746++ // update most recently used GLProgram
2747++ access_history_t::iterator it = access_history.insert (access_history.end (), name);
2748++
2749++ cache.insert (std::make_pair (name, std::make_pair (program, it)));
2750++}
2751++
2752++void PrivateProgramCache::evict ()
2753++{
2754++ assert (!access_history.empty ());
2755++
2756++ // find least recently used GLProgram
2757++ std::map<std::string, value>::iterator it = cache.find (access_history.front ());
2758++ assert (it != cache.end ());
2759++
2760++ cache.erase (it);
2761++ access_history.pop_front ();
2762++}
2763++
2764+--- compiz-0.9.7.6.orig/plugins/opengl/src/privates.h
2765++++ compiz-0.9.7.6/plugins/opengl/src/privates.h
2766+@@ -32,8 +32,12 @@
2767+ #include <opengl/opengl.h>
2768+ #include <core/atoms.h>
2769+
2770+-#include "privatefragment.h"
2771++#ifdef USE_GLES
2772++#include <opengl/framebufferobject.h>
2773++#endif
2774++
2775+ #include "privatetexture.h"
2776++#include "privatevertexbuffer.h"
2777+ #include "opengl_options.h"
2778+
2779+ extern CompOutput *targetOutput;
2780+@@ -75,8 +79,9 @@ class PrivateGLScreen :
2781+ void controlSwapVideoSync ();
2782+ void waitForVideoSync ();
2783+
2784+- void paintBackground (const CompRegion &region,
2785+- bool transformed);
2786++ void paintBackground (const GLMatrix &transform,
2787++ const CompRegion &region,
2788++ bool transformed);
2789+
2790+ void paintOutputRegion (const GLMatrix &transform,
2791+ const CompRegion &region,
2792+@@ -94,7 +99,9 @@ class PrivateGLScreen :
2793+
2794+ GLenum textureFilter;
2795+
2796++ #ifndef USE_GLES
2797+ GLFBConfig glxPixmapFBConfigs[MAX_DEPTH + 1];
2798++ #endif
2799+
2800+ GLTexture::List backgroundTextures;
2801+ bool backgroundLoaded;
2802+@@ -103,28 +110,41 @@ class PrivateGLScreen :
2803+
2804+ CompPoint rasterPos;
2805+
2806+- GLFragment::Storage fragmentStorage;
2807+-
2808+- GLfloat projection[16];
2809++ GLMatrix *projection;
2810+
2811+ bool clearBuffers;
2812+ bool lighting;
2813+
2814+- GL::GLXGetProcAddressProc getProcAddress;
2815+-
2816++ #ifdef USE_GLES
2817++ EGLContext ctx;
2818++ EGLSurface surface;
2819++ #else
2820+ GLXContext ctx;
2821+
2822++ GL::GLXGetProcAddressProc getProcAddress;
2823++ #endif
2824++
2825++ GLFramebufferObject *scratchFbo;
2826+ CompRegion outputRegion;
2827+
2828+ bool pendingCommands;
2829+
2830+ XRectangle lastViewport;
2831++ bool refreshSubBuffer;
2832++ unsigned int lastMask;
2833+
2834+ std::vector<GLTexture::BindPixmapProc> bindPixmap;
2835+ bool hasCompositing;
2836+
2837+ GLIcon defaultIcon;
2838+
2839++ Window saveWindow; // hack for broken applications, see:
2840++ // https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/807487
2841++
2842++ GLProgramCache *programCache;
2843++ GLShaderCache shaderCache;
2844++ GLVertexBuffer::AutoProgram *autoProgram;
2845++
2846+ Pixmap rootPixmapCopy;
2847+ CompSize rootPixmapSize;
2848+ };
2849+@@ -169,10 +189,15 @@ class PrivateGLWindow :
2850+
2851+ unsigned int lastMask;
2852+
2853+- GLWindow::Geometry geometry;
2854++ GLVertexBuffer *vertexBuffer;
2855++
2856++ // map of shaders, plugin name is key, pair of vertex and fragment
2857++ // shader source code is value
2858++ std::list<const GLShaderData*> shaders;
2859++ GLVertexBuffer::AutoProgram *autoProgram;
2860+
2861+ std::list<GLIcon> icons;
2862+ };
2863+
2864+-
2865+ #endif
2866++
2867+--- compiz-0.9.7.6.orig/plugins/opengl/src/matrix.cpp
2868++++ compiz-0.9.7.6/plugins/opengl/src/matrix.cpp
2869+@@ -163,6 +163,60 @@ operator* (const GLMatrix& lhs,
2870+ #undef B
2871+ #undef P
2872+
2873++/*
2874++** Invert 4x4 matrix.
2875++** Contributed by David Moore (See Mesa bug #6748)
2876++*/
2877++bool GLMatrix::invert ()
2878++{
2879++ float inv[16], det;
2880++ int i;
2881++
2882++ inv[0] = m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15]
2883++ + m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10];
2884++ inv[4] = -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15]
2885++ - m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10];
2886++ inv[8] = m[4]*m[9]*m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15]
2887++ + m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9];
2888++ inv[12] = -m[4]*m[9]*m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14]
2889++ - m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9];
2890++ inv[1] = -m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15]
2891++ - m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10];
2892++ inv[5] = m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15]
2893++ + m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10];
2894++ inv[9] = -m[0]*m[9]*m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15]
2895++ - m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9];
2896++ inv[13] = m[0]*m[9]*m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14]
2897++ + m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9];
2898++ inv[2] = m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15]
2899++ + m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6];
2900++ inv[6] = -m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15]
2901++ - m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6];
2902++ inv[10] = m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15]
2903++ + m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5];
2904++ inv[14] = -m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14]
2905++ - m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5];
2906++ inv[3] = -m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11]
2907++ - m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6];
2908++ inv[7] = m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11]
2909++ + m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6];
2910++ inv[11] = -m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11]
2911++ - m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5];
2912++ inv[15] = m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10]
2913++ + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5];
2914++
2915++ det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12];
2916++ if (det == 0)
2917++ return false;
2918++
2919++ det = 1.0f / det;
2920++
2921++ for (i = 0; i < 16; i++)
2922++ m[i] = inv[i] * det;
2923++
2924++ return true;
2925++}
2926++
2927+ /**
2928+ * Generate a 4x4 transformation matrix from glRotate parameters, and
2929+ * post-multiply the input matrix by it.
2930+--- compiz-0.9.7.6.orig/plugins/opengl/src/texture.cpp
2931++++ compiz-0.9.7.6/plugins/opengl/src/texture.cpp
2932+@@ -35,7 +35,11 @@
2933+ #include <privatetexture.h>
2934+ #include "privates.h"
2935+
2936++#ifdef USE_GLES
2937++std::map<Damage, EglTexture*> boundPixmapTex;
2938++#else
2939+ std::map<Damage, TfpTexture*> boundPixmapTex;
2940++#endif
2941+
2942+ static GLTexture::Matrix _identity_matrix = {
2943+ 1.0f, 0.0f,
2944+@@ -150,7 +154,7 @@ GLTexture::matrix () const
2945+ bool
2946+ GLTexture::mipmap () const
2947+ {
2948+- return priv->mipmap & priv->mipmapSupport;
2949++ return priv->mipmap && priv->mipmapSupport;
2950+ }
2951+
2952+ GLenum
2953+@@ -163,7 +167,9 @@ void
2954+ GLTexture::enable (GLTexture::Filter filter)
2955+ {
2956+ GLScreen *gs = GLScreen::get (screen);
2957++#ifndef USE_GLES
2958+ glEnable (priv->target);
2959++#endif
2960+ glBindTexture (priv->target, priv->name);
2961+
2962+ if (filter == Fast)
2963+@@ -184,7 +190,7 @@ GLTexture::enable (GLTexture::Filter fil
2964+ {
2965+ if (gs->textureFilter () == GL_LINEAR_MIPMAP_LINEAR)
2966+ {
2967+- if (GL::textureNonPowerOfTwo && GL::fbo && priv->mipmap)
2968++ if (mipmap ())
2969+ {
2970+ glTexParameteri (priv->target,
2971+ GL_TEXTURE_MIN_FILTER,
2972+@@ -226,7 +232,7 @@ GLTexture::enable (GLTexture::Filter fil
2973+ {
2974+ if (priv->initial)
2975+ {
2976+- (*GL::generateMipmap) (priv->target);
2977++ GL::generateMipmap (priv->target);
2978+ priv->initial = false;
2979+ }
2980+ }
2981+@@ -236,7 +242,9 @@ void
2982+ GLTexture::disable ()
2983+ {
2984+ glBindTexture (priv->target, 0);
2985++#ifndef USE_GLES
2986+ glDisable (priv->target);
2987++#endif
2988+ }
2989+
2990+ void
2991+@@ -295,20 +303,26 @@ PrivateTexture::loadImageData (const cha
2992+ rv[0] = t;
2993+
2994+ GLTexture::Matrix matrix = _identity_matrix;
2995+- CompOption *opt;
2996+ GLint internalFormat;
2997+ GLenum target;
2998+ bool mipmap;
2999++ bool pot = POWER_OF_TWO (width) && POWER_OF_TWO (height);
3000+
3001++ #ifdef USE_GLES
3002++ target = GL_TEXTURE_2D;
3003++ matrix.xx = 1.0f / width;
3004++ matrix.yy = 1.0f / height;
3005++ matrix.y0 = 0.0f;
3006++ mipmap = GL::textureNonPowerOfTwoMipmap || pot;
3007++ #else
3008+
3009+- if (GL::textureNonPowerOfTwo ||
3010+- (POWER_OF_TWO (width) && POWER_OF_TWO (height)))
3011++ if (GL::textureNonPowerOfTwo || pot)
3012+ {
3013+ target = GL_TEXTURE_2D;
3014+ matrix.xx = 1.0f / width;
3015+ matrix.yy = 1.0f / height;
3016+ matrix.y0 = 0.0f;
3017+- mipmap = true;
3018++ mipmap = GL::fbo && (GL::textureNonPowerOfTwoMipmap || pot);
3019+ }
3020+ else
3021+ {
3022+@@ -318,17 +332,26 @@ PrivateTexture::loadImageData (const cha
3023+ matrix.y0 = 0.0f;
3024+ mipmap = false;
3025+ }
3026++ #endif
3027+
3028+ t->setData (target, matrix, mipmap);
3029+ t->setGeometry (0, 0, width, height);
3030+
3031+ glBindTexture (target, t->name ());
3032+
3033++ #ifdef USE_GLES
3034++// internalFormat = GL_BGRA;
3035++ internalFormat = GL_BGRA;
3036++ #else
3037++ internalFormat = GL_RGBA;
3038++ #endif
3039++
3040++ #ifndef USE_GLES
3041++ CompOption *opt;
3042+ opt = GLScreen::get (screen)->getOption ("texture_compression");
3043+ if (opt->value ().b () && GL::textureCompression)
3044+ internalFormat = GL_COMPRESSED_RGBA_ARB;
3045+- else
3046+- internalFormat = GL_RGBA;
3047++ #endif
3048+
3049+ glTexImage2D (target, 0, internalFormat, width, height, 0,
3050+ format, type, image);
3051+@@ -413,6 +436,106 @@ GLTexture::bindPixmapToTexture (Pixmap p
3052+ return GLTexture::List ();
3053+ }
3054+
3055++#ifdef USE_GLES
3056++EglTexture::EglTexture () :
3057++ damaged (true),
3058++ damage (None),
3059++ updateMipMap (true)
3060++{
3061++}
3062++
3063++EglTexture::~EglTexture ()
3064++{
3065++ GLuint temp = name ();
3066++ glBindTexture (target (), name ());
3067++
3068++ glDeleteTextures (1, &temp);
3069++
3070++ glBindTexture (target (), 0);
3071++
3072++ boundPixmapTex.erase (damage);
3073++ XDamageDestroy (screen->dpy (), damage);
3074++}
3075++
3076++GLTexture::List
3077++EglTexture::bindPixmapToTexture (Pixmap pixmap,
3078++ int width,
3079++ int height,
3080++ int depth)
3081++{
3082++ if ((int) width > GL::maxTextureSize || (int) height > GL::maxTextureSize ||
3083++ !GL::textureFromPixmap)
3084++ return GLTexture::List ();
3085++
3086++ GLTexture::List rv (1);
3087++ EglTexture *tex = NULL;
3088++ EGLImageKHR eglImage = NULL;
3089++ GLTexture::Matrix matrix = _identity_matrix;
3090++
3091++ const EGLint img_attribs[] = {
3092++ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
3093++ EGL_NONE
3094++ };
3095++
3096++ eglImage = GL::createImage (eglGetDisplay (screen->dpy ()),
3097++ EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
3098++ (EGLClientBuffer)pixmap, img_attribs);
3099++
3100++ if (eglImage == EGL_NO_IMAGE_KHR)
3101++ {
3102++ compLogMessage ("core", CompLogLevelWarn,
3103++ "eglCreateImageKHR failed");
3104++
3105++ return GLTexture::List ();
3106++ }
3107++
3108++ matrix.xx = 1.0f / width;
3109++ matrix.yy = 1.0f / height;
3110++ matrix.y0 = 0.0f;
3111++
3112++ tex = new EglTexture ();
3113++ tex->setData (GL_TEXTURE_2D, matrix,
3114++ GL::textureNonPowerOfTwoMipmap ||
3115++ (POWER_OF_TWO (width) && POWER_OF_TWO (height)));
3116++ tex->setGeometry (0, 0, width, height);
3117++
3118++ rv[0] = tex;
3119++
3120++ glBindTexture (GL_TEXTURE_2D, tex->name ());
3121++
3122++ GL::eglImageTargetTexture (GL_TEXTURE_2D, (GLeglImageOES)eglImage);
3123++ GL::destroyImage (eglGetDisplay (screen->dpy ()), eglImage);
3124++
3125++ tex->setFilter (GL_NEAREST);
3126++ tex->setWrap (GL_CLAMP_TO_EDGE);
3127++
3128++ glBindTexture (GL_TEXTURE_2D, 0);
3129++
3130++ tex->damage = XDamageCreate (screen->dpy (), pixmap,
3131++ XDamageReportRawRectangles);
3132++ boundPixmapTex[tex->damage] = tex;
3133++
3134++ return rv;
3135++}
3136++
3137++void
3138++EglTexture::enable (GLTexture::Filter filter)
3139++{
3140++ glBindTexture (target (), name ());
3141++ GLTexture::enable (filter);
3142++
3143++ if (damaged)
3144++ updateMipMap = true;
3145++
3146++ if (this->filter () == GL_LINEAR_MIPMAP_LINEAR && updateMipMap)
3147++ {
3148++ GL::generateMipmap (target ());
3149++ updateMipMap = false;
3150++ }
3151++ damaged = false;
3152++}
3153++#else
3154++
3155+ TfpTexture::TfpTexture () :
3156+ pixmap (0),
3157+ damaged (true),
3158+@@ -611,3 +734,5 @@ TfpTexture::enable (GLTexture::Filter fi
3159+ }
3160+ damaged = false;
3161+ }
3162++#endif
3163++
3164+--- /dev/null
3165++++ compiz-0.9.7.6/plugins/opengl/src/vertexbuffer.cpp
3166+@@ -0,0 +1,550 @@
3167++/*
3168++ * Copyright © 2011 Linaro Ltd.
3169++ *
3170++ * Permission to use, copy, modify, distribute, and sell this software
3171++ * and its documentation for any purpose is hereby granted without
3172++ * fee, provided that the above copyright notice appear in all copies
3173++ * and that both that copyright notice and this permission notice
3174++ * appear in supporting documentation, and that the name of
3175++ * Linaro Ltd. not be used in advertising or publicity pertaining to
3176++ * distribution of the software without specific, written prior permission.
3177++ * Linaro Ltd. makes no representations about the suitability of this
3178++ * software for any purpose. It is provided "as is" without express or
3179++ * implied warranty.
3180++ *
3181++ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
3182++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
3183++ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
3184++ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
3185++ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
3186++ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
3187++ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3188++ *
3189++ * Authors: Travis Watkins <travis.watkins@linaro.org>
3190++ * Frederic Plourde <frederic.plourde@collabora.co.uk>
3191++ * Alexandros Frantzis <alexandros.frantzis@linaro.org>
3192++ */
3193++
3194++#include <vector>
3195++#include <iostream>
3196++
3197++#ifdef USE_GLES
3198++#include <GLES2/gl2.h>
3199++#else
3200++#include <GL/gl.h>
3201++#include <GL/glext.h>
3202++#endif
3203++
3204++#include <opengl/vertexbuffer.h>
3205++
3206++#include "privates.h"
3207++
3208++GLVertexBuffer *PrivateVertexBuffer::streamingBuffer = NULL;
3209++
3210++GLVertexBuffer::GLVertexBuffer () :
3211++ priv (new PrivateVertexBuffer ())
3212++{
3213++ priv->usage = GL_STATIC_DRAW;
3214++}
3215++
3216++GLVertexBuffer::GLVertexBuffer (GLenum usage) :
3217++ priv (new PrivateVertexBuffer ())
3218++{
3219++ priv->usage = usage;
3220++}
3221++
3222++GLVertexBuffer::~GLVertexBuffer ()
3223++{
3224++ delete priv;
3225++}
3226++
3227++GLVertexBuffer *GLVertexBuffer::streamingBuffer ()
3228++{
3229++ if (PrivateVertexBuffer::streamingBuffer == NULL)
3230++ PrivateVertexBuffer::streamingBuffer = new GLVertexBuffer
3231++ (GL_STREAM_DRAW);
3232++ return PrivateVertexBuffer::streamingBuffer;
3233++}
3234++
3235++void GLVertexBuffer::begin (GLenum primitiveType)
3236++{
3237++ priv->primitiveType = primitiveType;
3238++
3239++ priv->vertexData.clear ();
3240++ priv->normalData.clear ();
3241++ priv->colorData.clear ();
3242++ priv->textureData.clear ();
3243++ priv->uniforms.clear ();
3244++}
3245++
3246++void GLVertexBuffer::begin ()
3247++{
3248++ begin (GL_TRIANGLES);
3249++}
3250++
3251++int GLVertexBuffer::end ()
3252++{
3253++ if (!GL::vbo)
3254++ return 0;
3255++
3256++ if (!priv->vertexData.size ())
3257++ return -1;
3258++
3259++ GL::bindBuffer (GL_ARRAY_BUFFER, priv->vertexBuffer);
3260++ GL::bufferData (GL_ARRAY_BUFFER,
3261++ sizeof(GLfloat) * priv->vertexData.size (),
3262++ &priv->vertexData[0], priv->usage);
3263++
3264++ if (priv->normalData.size ())
3265++ {
3266++ GL::bindBuffer (GL_ARRAY_BUFFER, priv->normalBuffer);
3267++ GL::bufferData (GL_ARRAY_BUFFER,
3268++ sizeof(GLfloat) * priv->normalData.size (),
3269++ &priv->normalData[0], priv->usage);
3270++ }
3271++
3272++ if (priv->colorData.size ())
3273++ {
3274++ GL::bindBuffer (GL_ARRAY_BUFFER, priv->colorBuffer);
3275++ GL::bufferData (GL_ARRAY_BUFFER,
3276++ sizeof(GLfloat) * priv->colorData.size (),
3277++ &priv->colorData[0], priv->usage);
3278++ }
3279++
3280++ if (priv->textureData.size ())
3281++ {
3282++ for (unsigned int i = 0; i < priv->textureData.size (); i++)
3283++ {
3284++ GL::bindBuffer (GL_ARRAY_BUFFER, priv->textureBuffers[i]);
3285++ GL::bufferData (GL_ARRAY_BUFFER,
3286++ sizeof(GLfloat) * priv->textureData[i].size (),
3287++ &priv->textureData[i][0], priv->usage);
3288++ }
3289++ }
3290++
3291++ GL::bindBuffer (GL_ARRAY_BUFFER, 0);
3292++
3293++ return 0;
3294++}
3295++
3296++void GLVertexBuffer::addVertices (GLuint nVertices, GLfloat *vertices)
3297++{
3298++ priv->vertexData.reserve (priv->vertexData.size () + (nVertices * 3));
3299++
3300++ for (GLuint i = 0; i < nVertices * 3; i++)
3301++ {
3302++ priv->vertexData.push_back (vertices[i]);
3303++ }
3304++}
3305++
3306++void GLVertexBuffer::addNormals (GLuint nNormals, GLfloat *normals)
3307++{
3308++ priv->normalData.reserve (priv->normalData.size () + (nNormals * 3));
3309++
3310++ for (GLuint i = 0; i < nNormals * 3; i++)
3311++ {
3312++ priv->normalData.push_back (normals[i]);
3313++ }
3314++}
3315++
3316++void GLVertexBuffer::addColors (GLuint nColors, GLushort *colors)
3317++{
3318++ priv->colorData.reserve (priv->colorData.size () + (nColors * 4));
3319++
3320++ for (GLuint i = 0; i < nColors * 4; i++)
3321++ {
3322++ priv->colorData.push_back (colors[i] / 65535.0f);
3323++ }
3324++}
3325++
3326++void GLVertexBuffer::addTexCoords (GLuint texture,
3327++ GLuint nTexcoords,
3328++ GLfloat *texcoords)
3329++{
3330++ //four textures max (zero indexed)
3331++ if (texture > 3)
3332++ return;
3333++
3334++ while (texture >= priv->textureData.size ())
3335++ {
3336++ std::vector<GLfloat> temp;
3337++ priv->textureData.push_back (temp);
3338++ }
3339++
3340++ priv->textureData[texture].reserve (priv->textureData[texture].size () +
3341++ (nTexcoords * 2));
3342++
3343++ for (GLuint i = 0; i < nTexcoords * 2; i++)
3344++ {
3345++ priv->textureData[texture].push_back (texcoords[i]);
3346++ }
3347++}
3348++
3349++void GLVertexBuffer::addUniform (const char *name, GLfloat value)
3350++{
3351++ // we're casting to double here to make our template va_arg happy
3352++ Uniform<double, 1>* uniform = new Uniform<double, 1>(name, (double)value);
3353++ priv->uniforms.push_back (uniform);
3354++}
3355++
3356++void GLVertexBuffer::addUniform (const char *name, GLint value)
3357++{
3358++ Uniform<GLint, 1>* uniform = new Uniform<GLint, 1>(name, value);
3359++ priv->uniforms.push_back (uniform);
3360++}
3361++
3362++bool GLVertexBuffer::addUniform (const char *name, const GLMatrix &value)
3363++{
3364++ //#warning Add 'addUniform' support to GLMatrix type !
3365++ return true;
3366++}
3367++
3368++void GLVertexBuffer::addUniform2f (const char *name,
3369++ GLfloat x,
3370++ GLfloat y)
3371++{
3372++ // we're casting to double here to make our template va_arg happy
3373++ Uniform<double, 2>* uniform = new Uniform<double, 2>(name,
3374++ (double)x,
3375++ (double)y);
3376++ priv->uniforms.push_back (uniform);
3377++}
3378++
3379++void GLVertexBuffer::addUniform3f (const char *name,
3380++ GLfloat x,
3381++ GLfloat y,
3382++ GLfloat z)
3383++{
3384++ // we're casting to double here to make our template va_arg happy
3385++ Uniform<double, 3>* uniform = new Uniform<double, 3>(name,
3386++ (double)x,
3387++ (double)y,
3388++ (double)z);
3389++ priv->uniforms.push_back (uniform);
3390++}
3391++
3392++void GLVertexBuffer::addUniform4f (const char *name,
3393++ GLfloat x,
3394++ GLfloat y,
3395++ GLfloat z,
3396++ GLfloat w)
3397++{
3398++ // we're casting to double here to make our template va_arg happy
3399++ Uniform<double, 4>* uniform = new Uniform<double, 4>(name,
3400++ (double)x,
3401++ (double)y,
3402++ (double)z,
3403++ (double)w);
3404++ priv->uniforms.push_back (uniform);
3405++}
3406++
3407++void GLVertexBuffer::addUniform2i (const char *name,
3408++ GLint x,
3409++ GLint y)
3410++{
3411++ Uniform<GLint, 2>* uniform = new Uniform<GLint, 2>(name, x, y);
3412++ priv->uniforms.push_back (uniform);
3413++}
3414++
3415++void GLVertexBuffer::addUniform3i (const char *name,
3416++ GLint x,
3417++ GLint y,
3418++ GLint z)
3419++{
3420++ Uniform<GLint, 3>* uniform = new Uniform<GLint, 3>(name, x, y, z);
3421++ priv->uniforms.push_back (uniform);
3422++}
3423++
3424++void GLVertexBuffer::addUniform4i (const char *name,
3425++ GLint x,
3426++ GLint y,
3427++ GLint z,
3428++ GLint w)
3429++{
3430++ Uniform<GLint, 4>* uniform = new Uniform<GLint, 4>(name, x, y, z, w);
3431++ priv->uniforms.push_back (uniform);
3432++}
3433++
3434++void GLVertexBuffer::setProgram (GLProgram *program)
3435++{
3436++ priv->program = program;
3437++}
3438++
3439++void GLVertexBuffer::setAutoProgram (AutoProgram *autoProgram)
3440++{
3441++ priv->autoProgram = autoProgram;
3442++}
3443++
3444++int GLVertexBuffer::render ()
3445++{
3446++ if (GL::vbo && GL::shaders)
3447++ return priv->render (NULL, NULL, NULL);
3448++ else
3449++ return -1;
3450++}
3451++
3452++int GLVertexBuffer::render (const GLMatrix &modelview)
3453++{
3454++ const GLWindowPaintAttrib attrib = { OPAQUE, BRIGHT, COLOR, 0, 0, 0, 0 };
3455++
3456++ return render (modelview, attrib);
3457++}
3458++
3459++int GLVertexBuffer::render (const GLMatrix &modelview,
3460++ const GLWindowPaintAttrib &attrib)
3461++{
3462++ GLScreen *gScreen = GLScreen::get (screen);
3463++ GLMatrix *projection = gScreen->projectionMatrix ();
3464++
3465++ return render (*projection, modelview, attrib);
3466++}
3467++
3468++int GLVertexBuffer::render (const GLMatrix &projection,
3469++ const GLMatrix &modelview,
3470++ const GLWindowPaintAttrib &attrib)
3471++{
3472++ if (!priv->vertexData.size ())
3473++ return -1;
3474++
3475++ if (GL::vbo && GL::shaders)
3476++ return priv->render (&projection, &modelview, &attrib);
3477++ else
3478++ return priv->legacyRender (projection, modelview, attrib);
3479++}
3480++
3481++PrivateVertexBuffer::PrivateVertexBuffer () :
3482++ program (NULL)
3483++{
3484++ if (!GL::vbo)
3485++ return;
3486++
3487++ GL::genBuffers (1, &vertexBuffer);
3488++ GL::genBuffers (1, &normalBuffer);
3489++ GL::genBuffers (1, &colorBuffer);
3490++ GL::genBuffers (4, &textureBuffers[0]);
3491++}
3492++
3493++PrivateVertexBuffer::~PrivateVertexBuffer ()
3494++{
3495++ if (!GL::vbo)
3496++ return;
3497++
3498++ GL::deleteBuffers (1, &vertexBuffer);
3499++ GL::deleteBuffers (1, &normalBuffer);
3500++ GL::deleteBuffers (1, &colorBuffer);
3501++ GL::deleteBuffers (4, &textureBuffers[0]);
3502++}
3503++
3504++int PrivateVertexBuffer::render (const GLMatrix *projection,
3505++ const GLMatrix *modelview,
3506++ const GLWindowPaintAttrib *attrib)
3507++{
3508++ GLfloat attribs[3] = {1, 1, 1};
3509++ GLint positionIndex = -1;
3510++ GLint normalIndex = -1;
3511++ GLint colorIndex = -1;
3512++ GLint texCoordIndex[4] = {-1, -1, -1, -1};
3513++ GLProgram *tmpProgram = program;
3514++
3515++ // If we don't have an explicitly set program, try to get one
3516++ // using the AutoProgram callback object.
3517++ if (tmpProgram == NULL && autoProgram) {
3518++ // Convert attrib to shader parameters
3519++ GLShaderParameters params;
3520++
3521++ params.opacity = attrib->opacity != OPAQUE;
3522++ params.brightness = attrib->brightness != BRIGHT;
3523++ params.saturation = attrib->saturation != COLOR;
3524++ params.color = colorData.size () == 4 ? GLShaderVariableUniform :
3525++ colorData.size () > 4 ? GLShaderVariableVarying :
3526++ GLShaderVariableNone;
3527++ params.normal = normalData.size () <= 4 ? GLShaderVariableUniform :
3528++ GLShaderVariableVarying;
3529++ params.numTextures = textureData.size ();
3530++
3531++ // Get a program matching the parameters
3532++ tmpProgram = autoProgram->getProgram(params);
3533++ }
3534++
3535++ if (tmpProgram == NULL)
3536++ {
3537++ std::cerr << "no program defined!" << std::endl;
3538++ return -1;
3539++ }
3540++
3541++ tmpProgram->bind ();
3542++ if (!tmpProgram->valid ())
3543++ {
3544++ return -1;
3545++ }
3546++
3547++ if (projection)
3548++ tmpProgram->setUniform ("projection", *projection);
3549++
3550++ if (modelview)
3551++ tmpProgram->setUniform ("modelview", *modelview);
3552++
3553++ positionIndex = tmpProgram->attributeLocation ("position");
3554++ (*GL::enableVertexAttribArray) (positionIndex);
3555++ (*GL::bindBuffer) (GL_ARRAY_BUFFER, vertexBuffer);
3556++ (*GL::vertexAttribPointer) (positionIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
3557++
3558++ //use default normal
3559++ if (normalData.size () == 0)
3560++ {
3561++ tmpProgram->setUniform3f ("singleNormal", 0.0f, 0.0f, -1.0f);
3562++ }
3563++ // special case a single normal and apply it to the entire operation
3564++ else if (normalData.size () == 3)
3565++ {
3566++ tmpProgram->setUniform3f ("singleNormal",
3567++ normalData[0], normalData[1], normalData[2]);
3568++ }
3569++ else if (normalData.size () > 3)
3570++ {
3571++ normalIndex = tmpProgram->attributeLocation ("normal");
3572++ (*GL::enableVertexAttribArray) (normalIndex);
3573++ (*GL::bindBuffer) (GL_ARRAY_BUFFER, normalBuffer);
3574++ (*GL::vertexAttribPointer) (normalIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
3575++ }
3576++
3577++ // special case a single color and apply it to the entire operation
3578++ if (colorData.size () == 4)
3579++ {
3580++ tmpProgram->setUniform4f ("singleColor", colorData[0],
3581++ colorData[1], colorData[2], colorData[3]);
3582++ }
3583++ else if (colorData.size () > 4)
3584++ {
3585++ colorIndex = tmpProgram->attributeLocation ("color");
3586++ (*GL::enableVertexAttribArray) (colorIndex);
3587++ (*GL::bindBuffer) (GL_ARRAY_BUFFER, colorBuffer);
3588++ (*GL::vertexAttribPointer) (colorIndex, 4, GL_FLOAT, GL_FALSE, 0, 0);
3589++ }
3590++
3591++ for (int i = textureData.size () - 1; i >= 0; i--)
3592++ {
3593++ char name[10];
3594++
3595++ snprintf (name, 10, "texCoord%d", i);
3596++ texCoordIndex[i] = tmpProgram->attributeLocation (name);
3597++
3598++ (*GL::enableVertexAttribArray) (texCoordIndex[i]);
3599++ (*GL::bindBuffer) (GL_ARRAY_BUFFER, textureBuffers[i]);
3600++ (*GL::vertexAttribPointer) (texCoordIndex[i], 2, GL_FLOAT, GL_FALSE, 0, 0);
3601++
3602++ snprintf (name, 9, "texture%d", i);
3603++ tmpProgram->setUniform (name, i);
3604++ }
3605++
3606++ // set per-plugin uniforms
3607++ for (unsigned int i = 0; i < uniforms.size (); i++)
3608++ {
3609++ uniforms[i]->set (program);
3610++ }
3611++
3612++ //convert paint attribs to 0-1 range
3613++ if (attrib)
3614++ {
3615++ attribs[0] = attrib->opacity / 65535.0f;
3616++ attribs[1] = attrib->brightness / 65535.0f;
3617++ attribs[2] = attrib->saturation / 65535.0f;
3618++ tmpProgram->setUniform3f ("paintAttrib", attribs[0], attribs[1], attribs[2]);
3619++ }
3620++
3621++ glDrawArrays (primitiveType, 0, vertexData.size () / 3);
3622++
3623++ for (int i = 0; i < 4; ++i)
3624++ {
3625++ if (texCoordIndex[i] != -1)
3626++ (*GL::disableVertexAttribArray) (texCoordIndex[i]);
3627++ }
3628++
3629++ if (colorIndex != -1)
3630++ (*GL::disableVertexAttribArray) (colorIndex);
3631++
3632++ if (normalIndex != -1)
3633++ (*GL::disableVertexAttribArray) (normalIndex);
3634++
3635++ (*GL::disableVertexAttribArray) (positionIndex);
3636++
3637++ GL::bindBuffer (GL_ARRAY_BUFFER, 0);
3638++ tmpProgram->unbind ();
3639++
3640++ return 0;
3641++}
3642++
3643++int PrivateVertexBuffer::legacyRender (const GLMatrix &projection,
3644++ const GLMatrix &modelview,
3645++ const GLWindowPaintAttrib &attrib)
3646++{
3647++ #ifndef USE_GLES
3648++ glMatrixMode (GL_PROJECTION);
3649++ glPushMatrix ();
3650++ glLoadMatrixf (projection.getMatrix ());
3651++
3652++ glMatrixMode (GL_MODELVIEW);
3653++ glPushMatrix ();
3654++ glLoadMatrixf (modelview.getMatrix ());
3655++
3656++ glEnableClientState (GL_VERTEX_ARRAY);
3657++ glVertexPointer (3, GL_FLOAT, 0, &vertexData[0]);
3658++
3659++ //use default normal
3660++ if (normalData.size () == 0)
3661++ {
3662++ glNormal3f (0.0f, 0.0f, -1.0f);
3663++ }
3664++ // special case a single normal and apply it to the entire operation
3665++ else if (normalData.size () == 3)
3666++ {
3667++ glNormal3fv (&normalData[0]);
3668++ }
3669++ else if (normalData.size () > 3)
3670++ {
3671++ glEnableClientState (GL_NORMAL_ARRAY);
3672++ glNormalPointer (GL_FLOAT, 0, &normalData[0]);
3673++ }
3674++
3675++ // special case a single color and apply it to the entire operation
3676++ if (colorData.size () == 4)
3677++ {
3678++ glColor4fv (&colorData[0]);
3679++ }
3680++ else if (colorData.size () > 4)
3681++ {
3682++ glEnableClientState (GL_COLOR_ARRAY);
3683++ glColorPointer (4, GL_FLOAT, 0, &colorData[0]);
3684++ }
3685++
3686++ for (int i = textureData.size () - 1; i >= 0; i--)
3687++ {
3688++ GL::clientActiveTexture (GL_TEXTURE0_ARB + i);
3689++ glEnableClientState (GL_TEXTURE_COORD_ARRAY);
3690++ glTexCoordPointer (2, GL_FLOAT, 0, &textureData[i][0]);
3691++ }
3692++
3693++ glDrawArrays (primitiveType, 0, vertexData.size () / 3);
3694++
3695++ glDisableClientState (GL_VERTEX_ARRAY);
3696++ glDisableClientState (GL_NORMAL_ARRAY);
3697++ glDisableClientState (GL_COLOR_ARRAY);
3698++
3699++ for (int i = textureData.size (); i > 0; i--)
3700++ {
3701++ GL::clientActiveTexture (GL_TEXTURE0_ARB + i);
3702++ glDisableClientState (GL_TEXTURE_COORD_ARRAY);
3703++ }
3704++
3705++ GL::clientActiveTexture (GL_TEXTURE0_ARB);
3706++
3707++ glMatrixMode (GL_PROJECTION);
3708++ glPopMatrix ();
3709++
3710++ glMatrixMode (GL_MODELVIEW);
3711++ glPopMatrix ();
3712++ #endif
3713++
3714++ return 0;
3715++}
3716++
3717+--- compiz-0.9.7.6.orig/plugins/opengl/src/paint.cpp
3718++++ compiz-0.9.7.6/plugins/opengl/src/paint.cpp
3719+@@ -1,5 +1,6 @@
3720+ /*
3721+ * Copyright © 2005 Novell, Inc.
3722++ * Copyright © 2011 Linaro, Ltd.
3723+ *
3724+ * Permission to use, copy, modify, distribute, and sell this software
3725+ * and its documentation for any purpose is hereby granted without
3726+@@ -20,7 +21,8 @@
3727+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
3728+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3729+ *
3730+- * Author: David Reveman <davidr@novell.com>
3731++ * Authors: David Reveman <davidr@novell.com>
3732++ * Travis Watkins <travis.watkins@linaro.org>
3733+ */
3734+
3735+ #include "privates.h"
3736+@@ -35,6 +37,8 @@
3737+
3738+ #include <opengl/opengl.h>
3739+
3740++#include "privates.h"
3741++
3742+ #define DEG2RAD (M_PI / 180.0f)
3743+
3744+ GLScreenPaintAttrib defaultScreenPaintAttrib = {
3745+@@ -64,14 +68,16 @@ GLScreen::glApplyTransform (const GLScre
3746+ }
3747+
3748+ void
3749+-PrivateGLScreen::paintBackground (const CompRegion &region,
3750+- bool transformed)
3751++PrivateGLScreen::paintBackground (const GLMatrix &transform,
3752++ const CompRegion &region,
3753++ bool transformed)
3754+ {
3755++ GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
3756++ GLfloat vertexData[18];
3757++ GLushort colorData[4];
3758++
3759+ BoxPtr pBox = const_cast <Region> (region.handle ())->rects;
3760+ int n, nBox = const_cast <Region> (region.handle ())->numRects;
3761+- GLfloat *d;
3762+-
3763+- boost::scoped_array <GLfloat> data;
3764+
3765+ if (!nBox)
3766+ return;
3767+@@ -97,86 +103,111 @@ PrivateGLScreen::paintBackground (const
3768+
3769+ if (backgroundTextures.empty ())
3770+ {
3771+- data.reset (new GLfloat [nBox * 8]);
3772+-
3773+- d = data.get ();
3774++ streamingBuffer->begin (GL_TRIANGLES);
3775+ n = nBox;
3776+
3777+ while (n--)
3778+ {
3779+- *d++ = pBox->x1;
3780+- *d++ = pBox->y2;
3781+-
3782+- *d++ = pBox->x2;
3783+- *d++ = pBox->y2;
3784++ vertexData[0] = pBox->x1;
3785++ vertexData[1] = pBox->y1;
3786++ vertexData[2] = 0.0f;
3787++ vertexData[3] = pBox->x1;
3788++ vertexData[4] = pBox->y2;
3789++ vertexData[5] = 0.0f;
3790++ vertexData[6] = pBox->x2;
3791++ vertexData[7] = pBox->y1;
3792++ vertexData[8] = 0.0f;
3793++ vertexData[9] = pBox->x1;
3794++ vertexData[10] = pBox->y2;
3795++ vertexData[11] = 0.0f;
3796++ vertexData[12] = pBox->x2;
3797++ vertexData[13] = pBox->y2;
3798++ vertexData[14] = 0.0f;
3799++
3800++ vertexData[15] = pBox->x2;
3801++ vertexData[16] = pBox->y1;
3802++ vertexData[17] = 0.0f;
3803+
3804+- *d++ = pBox->x2;
3805+- *d++ = pBox->y1;
3806+-
3807+- *d++ = pBox->x1;
3808+- *d++ = pBox->y1;
3809++ streamingBuffer->addVertices (6, vertexData);
3810+
3811+ pBox++;
3812+ }
3813+
3814+- glDisableClientState (GL_TEXTURE_COORD_ARRAY);
3815+-
3816+- glVertexPointer (2, GL_FLOAT, sizeof (GLfloat) * 2, &data[0]);
3817++ colorData[0] = colorData[1] = colorData[2] = 0;
3818++ colorData[3] = std::numeric_limits <unsigned short>::max ();
3819++ streamingBuffer->addColors (1, colorData);
3820+
3821+- glColor4us (0, 0, 0, std::numeric_limits<unsigned short>::max ());
3822+- glDrawArrays (GL_QUADS, 0, nBox * 4);
3823+- glColor4usv (defaultColor);
3824+-
3825+- glEnableClientState (GL_TEXTURE_COORD_ARRAY);
3826++ streamingBuffer->end ();
3827++ streamingBuffer->render (transform);
3828+ }
3829+ else
3830+ {
3831+- data.reset (new GLfloat [nBox * 16]);
3832+-
3833+- d = data.get ();
3834+ n = nBox;
3835+
3836+ for (unsigned int i = 0; i < backgroundTextures.size (); i++)
3837+ {
3838++ GLfloat textureData[12];
3839+ GLTexture *bg = backgroundTextures[i];
3840+ CompRegion r = region & *bg;
3841+
3842+ pBox = const_cast <Region> (r.handle ())->rects;
3843+ nBox = const_cast <Region> (r.handle ())->numRects;
3844+- d = data.get ();
3845+ n = nBox;
3846+
3847++ streamingBuffer->begin (GL_TRIANGLES);
3848++
3849+ while (n--)
3850+ {
3851+- *d++ = COMP_TEX_COORD_X (bg->matrix (), pBox->x1);
3852+- *d++ = COMP_TEX_COORD_Y (bg->matrix (), pBox->y2);
3853+-
3854+- *d++ = pBox->x1;
3855+- *d++ = pBox->y2;
3856+-
3857+- *d++ = COMP_TEX_COORD_X (bg->matrix (), pBox->x2);
3858+- *d++ = COMP_TEX_COORD_Y (bg->matrix (), pBox->y2);
3859+-
3860+- *d++ = pBox->x2;
3861+- *d++ = pBox->y2;
3862+-
3863+- *d++ = COMP_TEX_COORD_X (bg->matrix (), pBox->x2);
3864+- *d++ = COMP_TEX_COORD_Y (bg->matrix (), pBox->y1);
3865++ GLfloat tx1 = COMP_TEX_COORD_X (bg->matrix (), pBox->x1);
3866++ GLfloat tx2 = COMP_TEX_COORD_X (bg->matrix (), pBox->x2);
3867++ GLfloat ty1 = COMP_TEX_COORD_Y (bg->matrix (), pBox->y1);
3868++ GLfloat ty2 = COMP_TEX_COORD_Y (bg->matrix (), pBox->y2);
3869++
3870++ vertexData[0] = pBox->x1;
3871++ vertexData[1] = pBox->y1;
3872++ vertexData[2] = 0.0f;
3873++ vertexData[3] = pBox->x1;
3874++ vertexData[4] = pBox->y2;
3875++ vertexData[5] = 0.0f;
3876++ vertexData[6] = pBox->x2;
3877++ vertexData[7] = pBox->y1;
3878++ vertexData[8] = 0.0f;
3879++ vertexData[9] = pBox->x1;
3880++ vertexData[10] = pBox->y2;
3881++ vertexData[11] = 0.0f;
3882++ vertexData[12] = pBox->x2;
3883++ vertexData[13] = pBox->y2;
3884++ vertexData[14] = 0.0f;
3885++
3886++ vertexData[15] = pBox->x2;
3887++ vertexData[16] = pBox->y1;
3888++ vertexData[17] = 0.0f;
3889++
3890++ textureData[0] = tx1;
3891++ textureData[1] = ty1;
3892++
3893++ textureData[2] = tx1;
3894++ textureData[3] = ty2;
3895++
3896++ textureData[4] = tx2;
3897++ textureData[5] = ty1;
3898++
3899++ textureData[6] = tx1;
3900++ textureData[7] = ty2;
3901+
3902+- *d++ = pBox->x2;
3903+- *d++ = pBox->y1;
3904++ textureData[8] = tx2;
3905++ textureData[9] = ty2;
3906+
3907+- *d++ = COMP_TEX_COORD_X (bg->matrix (), pBox->x1);
3908+- *d++ = COMP_TEX_COORD_Y (bg->matrix (), pBox->y1);
3909++ textureData[10] = tx2;
3910++ textureData[11] = ty1;
3911+
3912+- *d++ = pBox->x1;
3913+- *d++ = pBox->y1;
3914++ streamingBuffer->addVertices (6, vertexData);
3915++ streamingBuffer->addTexCoords (0, 6, textureData);
3916+
3917+ pBox++;
3918+ }
3919+
3920+- glTexCoordPointer (2, GL_FLOAT, sizeof (GLfloat) * 4, &data[0]);
3921+- glVertexPointer (2, GL_FLOAT, sizeof (GLfloat) * 4, &data[2]);
3922++ streamingBuffer->end ();
3923+
3924+ if (bg->name ())
3925+ {
3926+@@ -185,7 +216,7 @@ PrivateGLScreen::paintBackground (const
3927+ else
3928+ bg->enable (GLTexture::Fast);
3929+
3930+- glDrawArrays (GL_QUADS, 0, nBox * 4);
3931++ streamingBuffer->render (transform);
3932+
3933+ bg->disable ();
3934+ }
3935+@@ -329,7 +360,9 @@ PrivateGLScreen::paintOutputRegion (cons
3936+ CompositeWindow::get (fullscreenWindow)->unredirect ();
3937+
3938+ if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
3939+- paintBackground (tmpRegion, (mask & PAINT_SCREEN_TRANSFORMED_MASK));
3940++ paintBackground (transform,
3941++ tmpRegion,
3942++ (mask & PAINT_SCREEN_TRANSFORMED_MASK));
3943+
3944+ /* paint all windows from bottom to top */
3945+ foreach (w, pl)
3946+@@ -377,6 +410,7 @@ GLScreen::glEnableOutputClipping (const
3947+ {
3948+ WRAPABLE_HND_FUNCTN (glEnableOutputClipping, transform, region, output)
3949+
3950++ #ifndef USE_GLES
3951+ GLdouble h = screen->height ();
3952+
3953+ GLdouble p1[2] = { static_cast<GLdouble> (region.handle ()->extents.x1),
3954+@@ -409,6 +443,7 @@ GLScreen::glEnableOutputClipping (const
3955+ glEnable (GL_CLIP_PLANE3);
3956+
3957+ glPopMatrix ();
3958++ #endif
3959+ }
3960+
3961+ void
3962+@@ -416,10 +451,12 @@ GLScreen::glDisableOutputClipping ()
3963+ {
3964+ WRAPABLE_HND_FUNCTN (glDisableOutputClipping)
3965+
3966++ #ifndef USE_GLES
3967+ glDisable (GL_CLIP_PLANE0);
3968+ glDisable (GL_CLIP_PLANE1);
3969+ glDisable (GL_CLIP_PLANE2);
3970+ glDisable (GL_CLIP_PLANE3);
3971++ #endif
3972+ }
3973+
3974+ #define CLIP_PLANE_MASK (PAINT_SCREEN_TRANSFORMED_MASK | \
3975+@@ -449,26 +486,14 @@ GLScreen::glPaintTransformedOutput (cons
3976+ glEnableOutputClipping (sTransform, region, output);
3977+
3978+ sTransform.toScreenSpace (output, -sAttrib.zTranslate);
3979+-
3980+- glPushMatrix ();
3981+- glLoadMatrixf (sTransform.getMatrix ());
3982+-
3983+ priv->paintOutputRegion (sTransform, region, output, mask);
3984+
3985+- glPopMatrix ();
3986+-
3987+ glDisableOutputClipping ();
3988+ }
3989+ else
3990+ {
3991+ sTransform.toScreenSpace (output, -sAttrib.zTranslate);
3992+-
3993+- glPushMatrix ();
3994+- glLoadMatrixf (sTransform.getMatrix ());
3995+-
3996+ priv->paintOutputRegion (sTransform, region, output, mask);
3997+-
3998+- glPopMatrix ();
3999+ }
4000+ }
4001+
4002+@@ -503,13 +528,8 @@ GLScreen::glPaintOutput (const GLScreenP
4003+
4004+ sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
4005+
4006+- glPushMatrix ();
4007+- glLoadMatrixf (sTransform.getMatrix ());
4008+-
4009+ priv->paintOutputRegion (sTransform, region, output, mask);
4010+
4011+- glPopMatrix ();
4012+-
4013+ return true;
4014+ }
4015+ else if (mask & PAINT_SCREEN_FULL_MASK)
4016+@@ -525,182 +545,260 @@ GLScreen::glPaintOutput (const GLScreenP
4017+ }
4018+ }
4019+
4020+-#define ADD_RECT(data, m, n, x1, y1, x2, y2) \
4021+- for (it = 0; it < n; it++) \
4022+- { \
4023+- const GLTexture::Matrix &mat = m[it]; \
4024+- *(data)++ = COMP_TEX_COORD_X (mat, x1); \
4025+- *(data)++ = COMP_TEX_COORD_Y (mat, y1); \
4026+- } \
4027+- *(data)++ = (x1); \
4028+- *(data)++ = (y1); \
4029+- *(data)++ = 0.0; \
4030+- for (it = 0; it < n; it++) \
4031+- { \
4032+- const GLTexture::Matrix &mat = m[it]; \
4033+- *(data)++ = COMP_TEX_COORD_X (mat, x1); \
4034+- *(data)++ = COMP_TEX_COORD_Y (mat, y2); \
4035+- } \
4036+- *(data)++ = (x1); \
4037+- *(data)++ = (y2); \
4038+- *(data)++ = 0.0; \
4039+- for (it = 0; it < n; it++) \
4040+- { \
4041+- const GLTexture::Matrix &mat = m[it]; \
4042+- *(data)++ = COMP_TEX_COORD_X (mat, x2); \
4043+- *(data)++ = COMP_TEX_COORD_Y (mat, y2); \
4044+- } \
4045+- *(data)++ = (x2); \
4046+- *(data)++ = (y2); \
4047+- *(data)++ = 0.0; \
4048+- for (it = 0; it < n; it++) \
4049+- { \
4050+- const GLTexture::Matrix &mat = m[it]; \
4051+- *(data)++ = COMP_TEX_COORD_X (mat, x2); \
4052+- *(data)++ = COMP_TEX_COORD_Y (mat, y1); \
4053+- } \
4054+- *(data)++ = (x2); \
4055+- *(data)++ = (y1); \
4056+- *(data)++ = 0.0
4057+-
4058+-#define ADD_QUAD(data, m, n, x1, y1, x2, y2) \
4059+- for (it = 0; it < n; it++) \
4060+- { \
4061+- const GLTexture::Matrix &mat = m[it]; \
4062+- *(data)++ = COMP_TEX_COORD_XY (mat, x1, y1); \
4063+- *(data)++ = COMP_TEX_COORD_YX (mat, x1, y1); \
4064+- } \
4065+- *(data)++ = (x1); \
4066+- *(data)++ = (y1); \
4067+- *(data)++ = 0.0; \
4068+- for (it = 0; it < n; it++) \
4069+- { \
4070+- const GLTexture::Matrix &mat = m[it]; \
4071+- *(data)++ = COMP_TEX_COORD_XY (mat, x1, y2); \
4072+- *(data)++ = COMP_TEX_COORD_YX (mat, x1, y2); \
4073+- } \
4074+- *(data)++ = (x1); \
4075+- *(data)++ = (y2); \
4076+- *(data)++ = 0.0; \
4077+- for (it = 0; it < n; it++) \
4078+- { \
4079+- const GLTexture::Matrix &mat = m[it]; \
4080+- *(data)++ = COMP_TEX_COORD_XY (mat, x2, y2); \
4081+- *(data)++ = COMP_TEX_COORD_YX (mat, x2, y2); \
4082+- } \
4083+- *(data)++ = (x2); \
4084+- *(data)++ = (y2); \
4085+- *(data)++ = 0.0; \
4086+- for (it = 0; it < n; it++) \
4087+- { \
4088+- const GLTexture::Matrix &mat = m[it]; \
4089+- *(data)++ = COMP_TEX_COORD_XY (mat, x2, y1); \
4090+- *(data)++ = COMP_TEX_COORD_YX (mat, x2, y1); \
4091+- } \
4092+- *(data)++ = (x2); \
4093+- *(data)++ = (y1); \
4094+- *(data)++ = 0.0;
4095+-
4096+ void
4097+-GLWindow::glDrawGeometry ()
4098++GLScreen::glPaintCompositedOutput (const CompRegion &region,
4099++ GLFramebufferObject *fbo,
4100++ unsigned int mask)
4101+ {
4102+- WRAPABLE_HND_FUNCTN (glDrawGeometry)
4103+-
4104+- int texUnit = priv->geometry.texUnits;
4105+- int currentTexUnit = 0;
4106+- int stride = priv->geometry.vertexStride;
4107+- GLfloat *vertices = priv->geometry.vertices + (stride - 3);
4108++ WRAPABLE_HND_FUNCTN (glPaintCompositedOutput, region, fbo, mask)
4109+
4110+- stride *= sizeof (GLfloat);
4111++ GLMatrix sTransform;
4112++ std::vector<GLfloat> vertexData;
4113++ std::vector<GLfloat> textureData;
4114++ const GLTexture::Matrix & texmatrix = fbo->tex ()->matrix ();
4115++ GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
4116++
4117++ streamingBuffer->begin (GL_TRIANGLES);
4118++
4119++ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
4120++ {
4121++ GLfloat tx1 = COMP_TEX_COORD_X (texmatrix, 0.0f);
4122++ GLfloat tx2 = COMP_TEX_COORD_X (texmatrix, screen->width ());
4123++ GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, 0.0f);
4124++ GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, screen->height ());
4125++
4126++ vertexData = {
4127++ 0.0f, 0.0f, 0.0f,
4128++ 0.0f, (float)screen->height (), 0.0f,
4129++ (float)screen->width (), 0.0f, 0.0f,
4130++
4131++ 0.0f, (float)screen->height (), 0.0f,
4132++ (float)screen->width (), (float)screen->height (), 0.0f,
4133++ (float)screen->width (), 0.0f, 0.0f,
4134++ };
4135++
4136++ textureData = {
4137++ tx1, ty1,
4138++ tx1, ty2,
4139++ tx2, ty1,
4140++ tx1, ty2,
4141++ tx2, ty2,
4142++ tx2, ty1,
4143++ };
4144+
4145+- glVertexPointer (3, GL_FLOAT, stride, vertices);
4146+-
4147+- while (texUnit--)
4148++ streamingBuffer->addVertices (6, &vertexData[0]);
4149++ streamingBuffer->addTexCoords (0, 6, &textureData[0]);
4150++ }
4151++ else
4152+ {
4153+- if (texUnit != currentTexUnit)
4154++ BoxPtr pBox = const_cast <Region> (region.handle ())->rects;
4155++ int nBox = const_cast <Region> (region.handle ())->numRects;
4156++
4157++ while (nBox--)
4158+ {
4159+- (*GL::clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
4160+- glEnableClientState (GL_TEXTURE_COORD_ARRAY);
4161+- currentTexUnit = texUnit;
4162++ GLfloat tx1 = COMP_TEX_COORD_X (texmatrix, pBox->x1);
4163++ GLfloat tx2 = COMP_TEX_COORD_X (texmatrix, pBox->x2);
4164++ GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, pBox->y1);
4165++ GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, pBox->y2);
4166++
4167++ vertexData = {
4168++ (float)pBox->x1, (float)pBox->y1, 0.0f,
4169++ (float)pBox->x1, (float)pBox->y2, 0.0f,
4170++ (float)pBox->x2, (float)pBox->y1, 0.0f,
4171++
4172++ (float)pBox->x1, (float)pBox->y2, 0.0f,
4173++ (float)pBox->x2, (float)pBox->y2, 0.0f,
4174++ (float)pBox->x2, (float)pBox->y1, 0.0f,
4175++ };
4176++
4177++ textureData = {
4178++ tx1, ty1,
4179++ tx1, ty2,
4180++ tx2, ty1,
4181++ tx1, ty2,
4182++ tx2, ty2,
4183++ tx2, ty1,
4184++ };
4185++
4186++ streamingBuffer->addVertices (6, &vertexData[0]);
4187++ streamingBuffer->addTexCoords (0, 6, &textureData[0]);
4188++ pBox++;
4189+ }
4190+- vertices -= priv->geometry.texCoordSize;
4191+- glTexCoordPointer (priv->geometry.texCoordSize,
4192+- GL_FLOAT, stride, vertices);
4193+ }
4194+
4195+- glDrawArrays (GL_QUADS, 0, priv->geometry.vCount);
4196+-
4197+- /* disable all texture coordinate arrays except 0 */
4198+- texUnit = priv->geometry.texUnits;
4199+- if (texUnit > 1)
4200+- {
4201+- while (--texUnit)
4202+- {
4203+- (*GL::clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
4204+- glDisableClientState (GL_TEXTURE_COORD_ARRAY);
4205+- }
4206++ streamingBuffer->end ();
4207++ fbo->tex ()-> enable (GLTexture::Fast);
4208++ sTransform.toScreenSpace (&screen->fullscreenOutput (), -DEFAULT_Z_CAMERA);
4209++ streamingBuffer->render (sTransform);
4210++ fbo->tex ()-> disable ();
4211++}
4212+
4213+- (*GL::clientActiveTexture) (GL_TEXTURE0_ARB);
4214++#define ADD_RECT(vertexBuffer, m, n, x1, y1, x2, y2) \
4215++ GLfloat vertexData[18] = { \
4216++ (float)x1, (float)y1, 0.0, \
4217++ (float)x1, (float)y2, 0.0, \
4218++ (float)x2, (float)y1, 0.0, \
4219++ (float)x2, (float)y1, 0.0, \
4220++ (float)x1, (float)y2, 0.0, \
4221++ (float)x2, (float)y2, 0.0 \
4222++ }; \
4223++ vertexBuffer->addVertices (6, vertexData); \
4224++ \
4225++ for (it = 0; it < n; it++) \
4226++ { \
4227++ GLfloat data[2]; \
4228++ const GLTexture::Matrix &mat = m[it]; \
4229++ data[0] = COMP_TEX_COORD_X (mat, x1); \
4230++ data[1] = COMP_TEX_COORD_Y (mat, y1); \
4231++ vertexBuffer->addTexCoords (it, 1, data); \
4232++ } \
4233++ for (it = 0; it < n; it++) \
4234++ { \
4235++ GLfloat data[2]; \
4236++ const GLTexture::Matrix &mat = m[it]; \
4237++ data[0] = COMP_TEX_COORD_X (mat, x1); \
4238++ data[1] = COMP_TEX_COORD_Y (mat, y2); \
4239++ vertexBuffer->addTexCoords (it, 1, data); \
4240++ } \
4241++ for (it = 0; it < n; it++) \
4242++ { \
4243++ GLfloat data[2]; \
4244++ const GLTexture::Matrix &mat = m[it]; \
4245++ data[0] = COMP_TEX_COORD_X (mat, x2); \
4246++ data[1] = COMP_TEX_COORD_Y (mat, y1); \
4247++ vertexBuffer->addTexCoords (it, 1, data); \
4248++ } \
4249++ for (it = 0; it < n; it++) \
4250++ { \
4251++ GLfloat data[2]; \
4252++ const GLTexture::Matrix &mat = m[it]; \
4253++ data[0] = COMP_TEX_COORD_X (mat, x2); \
4254++ data[1] = COMP_TEX_COORD_Y (mat, y1); \
4255++ vertexBuffer->addTexCoords (it, 1, data); \
4256++ } \
4257++ for (it = 0; it < n; it++) \
4258++ { \
4259++ GLfloat data[2]; \
4260++ const GLTexture::Matrix &mat = m[it]; \
4261++ data[0] = COMP_TEX_COORD_X (mat, x1); \
4262++ data[1] = COMP_TEX_COORD_Y (mat, y2); \
4263++ vertexBuffer->addTexCoords (it, 1, data); \
4264++ } \
4265++ for (it = 0; it < n; it++) \
4266++ { \
4267++ GLfloat data[2]; \
4268++ const GLTexture::Matrix &mat = m[it]; \
4269++ data[0] = COMP_TEX_COORD_X (mat, x2); \
4270++ data[1] = COMP_TEX_COORD_Y (mat, y2); \
4271++ vertexBuffer->addTexCoords (it, 1, data); \
4272++ }
4273++
4274++#define ADD_QUAD(vertexBuffer, m, n, x1, y1, x2, y2) \
4275++ GLfloat vertexData[18] = { \
4276++ (float)x1, (float)y1, 0.0, \
4277++ (float)x1, (float)y2, 0.0, \
4278++ (float)x2, (float)y1, 0.0, \
4279++ (float)x2, (float)y1, 0.0, \
4280++ (float)x1, (float)y2, 0.0, \
4281++ (float)x2, (float)y2, 0.0 \
4282++ }; \
4283++ vertexBuffer->addVertices (6, vertexData); \
4284++ \
4285++ for (it = 0; it < n; it++) \
4286++ { \
4287++ GLfloat data[2]; \
4288++ const GLTexture::Matrix &mat = m[it]; \
4289++ data[0] = COMP_TEX_COORD_XY (mat, x1, y1); \
4290++ data[1] = COMP_TEX_COORD_YX (mat, x1, y1); \
4291++ vertexBuffer->addTexCoords (it, 1, data); \
4292++ } \
4293++ for (it = 0; it < n; it++) \
4294++ { \
4295++ GLfloat data[2]; \
4296++ const GLTexture::Matrix &mat = m[it]; \
4297++ data[0] = COMP_TEX_COORD_XY (mat, x1, y2); \
4298++ data[1] = COMP_TEX_COORD_YX (mat, x1, y2); \
4299++ vertexBuffer->addTexCoords (it, 1, data); \
4300++ } \
4301++ for (it = 0; it < n; it++) \
4302++ { \
4303++ GLfloat data[2]; \
4304++ const GLTexture::Matrix &mat = m[it]; \
4305++ data[0] = COMP_TEX_COORD_XY (mat, x2, y1); \
4306++ data[1] = COMP_TEX_COORD_YX (mat, x2, y1); \
4307++ vertexBuffer->addTexCoords (it, 1, data); \
4308++ } \
4309++ for (it = 0; it < n; it++) \
4310++ { \
4311++ GLfloat data[2]; \
4312++ const GLTexture::Matrix &mat = m[it]; \
4313++ data[0] = COMP_TEX_COORD_XY (mat, x2, y1); \
4314++ data[1] = COMP_TEX_COORD_YX (mat, x2, y1); \
4315++ vertexBuffer->addTexCoords (it, 1, data); \
4316++ } \
4317++ for (it = 0; it < n; it++) \
4318++ { \
4319++ GLfloat data[2]; \
4320++ const GLTexture::Matrix &mat = m[it]; \
4321++ data[0] = COMP_TEX_COORD_XY (mat, x1, y2); \
4322++ data[1] = COMP_TEX_COORD_YX (mat, x1, y2); \
4323++ vertexBuffer->addTexCoords (it, 1, data); \
4324++ } \
4325++ for (it = 0; it < n; it++) \
4326++ { \
4327++ GLfloat data[2]; \
4328++ const GLTexture::Matrix &mat = m[it]; \
4329++ data[0] = COMP_TEX_COORD_XY (mat, x2, y2); \
4330++ data[1] = COMP_TEX_COORD_YX (mat, x2, y2); \
4331++ vertexBuffer->addTexCoords (it, 1, data); \
4332+ }
4333+-}
4334++
4335+
4336+ static inline void
4337+-addSingleQuad (GLfloat *&d,
4338+- const GLTexture::MatrixList &matrix,
4339+- unsigned int nMatrix,
4340+- int x1,
4341+- int y1,
4342+- int x2,
4343+- int y2,
4344+- int &n,
4345+- bool rect)
4346++addSingleQuad (GLVertexBuffer *vertexBuffer,
4347++ const GLTexture::MatrixList &matrix,
4348++ unsigned int nMatrix,
4349++ int x1,
4350++ int y1,
4351++ int x2,
4352++ int y2,
4353++ int &n,
4354++ bool rect)
4355+ {
4356+ unsigned int it;
4357+
4358+ if (rect)
4359+ {
4360+- ADD_RECT (d, matrix, nMatrix, x1, y1, x2, y2);
4361++ ADD_RECT (vertexBuffer, matrix, nMatrix, x1, y1, x2, y2);
4362+ }
4363+ else
4364+ {
4365+- ADD_QUAD (d, matrix, nMatrix, x1, y1, x2, y2);
4366++ ADD_QUAD (vertexBuffer, matrix, nMatrix, x1, y1, x2, y2);
4367+ }
4368+ n++;
4369+ }
4370+
4371+ static inline void
4372+-addQuads (GLfloat *&d,
4373+- const GLTexture::MatrixList &matrix,
4374+- unsigned int nMatrix,
4375+- int x1,
4376+- int y1,
4377+- int x2,
4378+- int y2,
4379+- int &n,
4380+- int vSize,
4381+- bool rect,
4382+- GLWindow::Geometry &geometry,
4383+- unsigned int maxGridWidth,
4384+- unsigned int maxGridHeight)
4385++addQuads (GLVertexBuffer *vertexBuffer,
4386++ const GLTexture::MatrixList &matrix,
4387++ unsigned int nMatrix,
4388++ int x1,
4389++ int y1,
4390++ int x2,
4391++ int y2,
4392++ int &n,
4393++ bool rect,
4394++ unsigned int maxGridWidth,
4395++ unsigned int maxGridHeight)
4396+ {
4397+ int nQuadsX = (maxGridWidth == MAXSHORT) ? 1 :
4398+ 1 + (x2 - x1 - 1) / (int) maxGridWidth; // ceil. division
4399+ int nQuadsY = (maxGridHeight == MAXSHORT) ? 1 :
4400+ 1 + (y2 - y1 - 1) / (int) maxGridHeight;
4401+- int newVertexSize = (n + nQuadsX * nQuadsY) * vSize * 4;
4402+-
4403+- // Make sure enough vertices are allocated for nQuadsX * nQuadsY more quads
4404+- if (newVertexSize > geometry.vertexSize)
4405+- {
4406+- if (!geometry.moreVertices (newVertexSize))
4407+- return;
4408+-
4409+- d = geometry.vertices + (n * vSize * 4);
4410+- }
4411+
4412+ if (nQuadsX == 1 && nQuadsY == 1)
4413+ {
4414+- addSingleQuad (d, matrix, nMatrix, x1, y1, x2, y2, n, rect);
4415++ addSingleQuad (vertexBuffer, matrix, nMatrix, x1, y1, x2, y2, n, rect);
4416+ }
4417+ else
4418+ {
4419+@@ -716,7 +814,8 @@ addQuads (GLfloat *&d,
4420+ {
4421+ nx2 = MIN (nx1 + (int) quadWidth, x2);
4422+
4423+- addSingleQuad (d, matrix, nMatrix, nx1, ny1, nx2, ny2, n, rect);
4424++ addSingleQuad (vertexBuffer, matrix, nMatrix,
4425++ nx1, ny1, nx2, ny2, n, rect);
4426+ }
4427+ }
4428+ }
4429+@@ -729,13 +828,11 @@ GLWindow::glAddGeometry (const GLTexture
4430+ unsigned int maxGridWidth,
4431+ unsigned int maxGridHeight)
4432+ {
4433+- WRAPABLE_HND_FUNCTN (glAddGeometry, matrix, region, clip)
4434++ WRAPABLE_HND_FUNCTN (glAddGeometry, matrix, region, clip, maxGridWidth, maxGridHeight)
4435+
4436+ BoxRec full;
4437+ int nMatrix = matrix.size ();
4438+
4439+- priv->geometry.texUnits = nMatrix;
4440+-
4441+ full = clip.handle ()->extents;
4442+ if (region.handle ()->extents.x1 > full.x1)
4443+ full.x1 = region.handle ()->extents.x1;
4444+@@ -753,9 +850,7 @@ GLWindow::glAddGeometry (const GLTexture
4445+ BoxPtr pClip;
4446+ int nClip;
4447+ BoxRec cbox;
4448+- int vSize;
4449+ int n, it, x1, y1, x2, y2;
4450+- GLfloat *d;
4451+ bool rect = true;
4452+
4453+ for (it = 0; it < nMatrix; it++)
4454+@@ -770,18 +865,6 @@ GLWindow::glAddGeometry (const GLTexture
4455+ pBox = const_cast <Region> (region.handle ())->rects;
4456+ nBox = const_cast <Region> (region.handle ())->numRects;
4457+
4458+- vSize = 3 + nMatrix * 2;
4459+-
4460+- n = priv->geometry.vCount / 4;
4461+-
4462+- if ((n + nBox) * vSize * 4 > priv->geometry.vertexSize)
4463+- {
4464+- if (!priv->geometry.moreVertices ((n + nBox) * vSize * 4))
4465+- return;
4466+- }
4467+-
4468+- d = priv->geometry.vertices + (priv->geometry.vCount * vSize);
4469+-
4470+ while (nBox--)
4471+ {
4472+ x1 = pBox->x1;
4473+@@ -806,24 +889,15 @@ GLWindow::glAddGeometry (const GLTexture
4474+
4475+ if (nClip == 1)
4476+ {
4477+- addQuads (d, matrix, nMatrix,
4478++ addQuads (priv->vertexBuffer, matrix, nMatrix,
4479+ x1, y1, x2, y2,
4480+- n, vSize, rect, priv->geometry,
4481++ n, rect,
4482+ maxGridWidth, maxGridHeight);
4483+ }
4484+ else
4485+ {
4486+ pClip = const_cast <Region> (clip.handle ())->rects;
4487+
4488+- if (((n + nClip) * vSize * 4) > priv->geometry.vertexSize)
4489+- {
4490+- if (!priv->geometry.moreVertices ((n + nClip) *
4491+- vSize * 4))
4492+- return;
4493+-
4494+- d = priv->geometry.vertices + (n * vSize * 4);
4495+- }
4496+-
4497+ while (nClip--)
4498+ {
4499+ cbox = *pClip;
4500+@@ -841,120 +915,32 @@ GLWindow::glAddGeometry (const GLTexture
4501+
4502+ if (cbox.x1 < cbox.x2 && cbox.y1 < cbox.y2)
4503+ {
4504+- addQuads (d, matrix, nMatrix,
4505++ addQuads (priv->vertexBuffer, matrix, nMatrix,
4506+ cbox.x1, cbox.y1, cbox.x2, cbox.y2,
4507+- n, vSize, rect, priv->geometry,
4508++ n, rect,
4509+ maxGridWidth, maxGridHeight);
4510+ }
4511+ }
4512+ }
4513+ }
4514+ }
4515+-
4516+- priv->geometry.vCount = n * 4;
4517+- priv->geometry.vertexStride = vSize;
4518+- priv->geometry.texCoordSize = 2;
4519+- }
4520+-}
4521+-
4522+-static bool
4523+-enableFragmentProgramAndDrawGeometry (GLScreen *gs,
4524+- GLWindow *w,
4525+- GLTexture *texture,
4526+- GLFragment::Attrib &attrib,
4527+- GLTexture::Filter filter,
4528+- unsigned int mask)
4529+-{
4530+- GLFragment::Attrib fa (attrib);
4531+- bool blending;
4532+-
4533+- if (GL::canDoSaturated && attrib.getSaturation () != COLOR)
4534+- {
4535+- int param, function;
4536+-
4537+- param = fa.allocParameters (1);
4538+- function =
4539+- GLFragment::getSaturateFragmentFunction (texture, param);
4540+-
4541+- fa.addFunction (function);
4542+-
4543+- (*GL::programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, param,
4544+- RED_SATURATION_WEIGHT,
4545+- GREEN_SATURATION_WEIGHT,
4546+- BLUE_SATURATION_WEIGHT,
4547+- attrib.getSaturation () / 65535.0f);
4548+- }
4549+-
4550+- if (!fa.enable (&blending))
4551+- return false;
4552+-
4553+- texture->enable (filter);
4554+-
4555+- if (mask & PAINT_WINDOW_BLEND_MASK)
4556+- {
4557+- if (blending)
4558+- glEnable (GL_BLEND);
4559+-
4560+- if (attrib.getOpacity () != OPAQUE || attrib.getBrightness () != BRIGHT)
4561+- {
4562+- GLushort color;
4563+-
4564+- color = (attrib.getOpacity () * attrib.getBrightness ()) >> 16;
4565+-
4566+- gs->setTexEnvMode (GL_MODULATE);
4567+- glColor4us (color, color, color, attrib.getOpacity ());
4568+-
4569+- w->glDrawGeometry ();
4570+-
4571+- glColor4usv (defaultColor);
4572+- gs->setTexEnvMode (GL_REPLACE);
4573+- }
4574+- else
4575+- {
4576+- w->glDrawGeometry ();
4577+- }
4578+-
4579+- if (blending)
4580+- glDisable (GL_BLEND);
4581+- }
4582+- else if (attrib.getBrightness () != BRIGHT)
4583+- {
4584+- gs->setTexEnvMode (GL_MODULATE);
4585+- glColor4us (attrib.getBrightness (), attrib.getBrightness (),
4586+- attrib.getBrightness (), BRIGHT);
4587+-
4588+- w->glDrawGeometry ();
4589+-
4590+- glColor4usv (defaultColor);
4591+- gs->setTexEnvMode (GL_REPLACE);
4592+ }
4593+- else
4594+- {
4595+- w->glDrawGeometry ();
4596+- }
4597+-
4598+- texture->disable ();
4599+-
4600+- fa.disable ();
4601+-
4602+- return true;
4603+ }
4604+
4605++#ifndef USE_GLES
4606+ static void
4607+-enableFragmentOperationsAndDrawGeometry (GLScreen *gs,
4608+- GLWindow *w,
4609+- GLTexture *texture,
4610+- GLFragment::Attrib &attrib,
4611+- GLTexture::Filter filter,
4612+- unsigned int mask)
4613++enableLegacyOBSAndRender (GLScreen *gs,
4614++ GLWindow *w,
4615++ GLTexture *texture,
4616++ const GLMatrix &transform,
4617++ const GLWindowPaintAttrib &attrib,
4618++ GLTexture::Filter filter,
4619++ unsigned int mask)
4620+ {
4621+- if (GL::canDoSaturated && attrib.getSaturation () != COLOR)
4622++ if (GL::canDoSaturated && attrib.saturation != COLOR)
4623+ {
4624+ GLfloat constant[4];
4625+
4626+- if (mask & PAINT_WINDOW_BLEND_MASK)
4627+- glEnable (GL_BLEND);
4628+-
4629+ texture->enable (filter);
4630+
4631+ glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
4632+@@ -985,7 +971,7 @@ enableFragmentOperationsAndDrawGeometry
4633+ glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
4634+ glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
4635+
4636+- if (GL::canDoSlightlySaturated && attrib.getSaturation () > 0)
4637++ if (GL::canDoSlightlySaturated && attrib.saturation > 0)
4638+ {
4639+ glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
4640+ glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
4641+@@ -1016,20 +1002,20 @@ enableFragmentOperationsAndDrawGeometry
4642+ glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
4643+ glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
4644+
4645+- constant[3] = attrib.getSaturation () / 65535.0f;
4646++ constant[3] = attrib.saturation / 65535.0f;
4647+
4648+ glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
4649+
4650+- if (attrib.getOpacity () < OPAQUE ||
4651+- attrib.getBrightness () != BRIGHT)
4652++ if (attrib.opacity < OPAQUE ||
4653++ attrib.brightness != BRIGHT)
4654+ {
4655+ GL::activeTexture (GL_TEXTURE3_ARB);
4656+
4657+ texture->enable (filter);
4658+
4659+- constant[3] = attrib.getOpacity () / 65535.0f;
4660++ constant[3] = attrib.opacity / 65535.0f;
4661+ constant[0] = constant[1] = constant[2] = constant[3] *
4662+- attrib.getBrightness () / 65535.0f;
4663++ attrib.brightness / 65535.0f;
4664+
4665+ glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
4666+
4667+@@ -1047,7 +1033,7 @@ enableFragmentOperationsAndDrawGeometry
4668+ glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
4669+ glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
4670+
4671+- w->glDrawGeometry ();
4672++ w->vertexBuffer ()->render (transform, attrib);
4673+
4674+ texture->disable ();
4675+
4676+@@ -1057,7 +1043,7 @@ enableFragmentOperationsAndDrawGeometry
4677+ }
4678+ else
4679+ {
4680+- w->glDrawGeometry ();
4681++ w->vertexBuffer ()->render (transform, attrib);
4682+ }
4683+
4684+ texture->disable ();
4685+@@ -1074,9 +1060,9 @@ enableFragmentOperationsAndDrawGeometry
4686+ glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
4687+ glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
4688+
4689+- constant[3] = attrib.getOpacity () / 65535.0f;
4690++ constant[3] = attrib.opacity / 65535.0f;
4691+ constant[0] = constant[1] = constant[2] = constant[3] *
4692+- attrib.getBrightness ()/ 65535.0f;
4693++ attrib.brightness / 65535.0f;
4694+
4695+ constant[0] = 0.5f + 0.5f * RED_SATURATION_WEIGHT * constant[0];
4696+ constant[1] = 0.5f + 0.5f * GREEN_SATURATION_WEIGHT * constant[1];
4697+@@ -1084,7 +1070,7 @@ enableFragmentOperationsAndDrawGeometry
4698+
4699+ glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
4700+
4701+- w->glDrawGeometry ();
4702++ w->vertexBuffer ()->render (transform, attrib);
4703+ }
4704+
4705+ texture->disable ();
4706+@@ -1097,9 +1083,6 @@ enableFragmentOperationsAndDrawGeometry
4707+
4708+ glColor4usv (defaultColor);
4709+ gs->setTexEnvMode (GL_REPLACE);
4710+-
4711+- if (mask & PAINT_WINDOW_BLEND_MASK)
4712+- glDisable (GL_BLEND);
4713+ }
4714+ else
4715+ {
4716+@@ -1107,57 +1090,64 @@ enableFragmentOperationsAndDrawGeometry
4717+
4718+ if (mask & PAINT_WINDOW_BLEND_MASK)
4719+ {
4720+- glEnable (GL_BLEND);
4721+- if (attrib.getOpacity ()!= OPAQUE ||
4722+- attrib.getBrightness () != BRIGHT)
4723++ if (attrib.opacity != OPAQUE ||
4724++ attrib.brightness != BRIGHT)
4725+ {
4726+ GLushort color;
4727+
4728+- color = (attrib.getOpacity () * attrib.getBrightness ()) >> 16;
4729++ color = (attrib.opacity * attrib.brightness) >> 16;
4730+
4731+ gs->setTexEnvMode (GL_MODULATE);
4732+- glColor4us (color, color, color, attrib.getOpacity ());
4733++ glColor4us (color, color, color, attrib.opacity);
4734+
4735+- w->glDrawGeometry ();
4736++ w->vertexBuffer ()->render (transform, attrib);
4737+
4738+ glColor4usv (defaultColor);
4739+ gs->setTexEnvMode (GL_REPLACE);
4740+ }
4741+ else
4742+ {
4743+- w->glDrawGeometry ();
4744++ w->vertexBuffer ()->render (transform, attrib);
4745+ }
4746+-
4747+- glDisable (GL_BLEND);
4748+ }
4749+- else if (attrib.getBrightness () != BRIGHT)
4750++ else if (attrib.brightness != BRIGHT)
4751+ {
4752+ gs->setTexEnvMode (GL_MODULATE);
4753+- glColor4us (attrib.getBrightness (), attrib.getBrightness (),
4754+- attrib.getBrightness (), BRIGHT);
4755++ glColor4us (attrib.brightness, attrib.brightness,
4756++ attrib.brightness, BRIGHT);
4757+
4758+- w->glDrawGeometry ();
4759++ w->vertexBuffer ()->render (transform, attrib);
4760+
4761+ glColor4usv (defaultColor);
4762+ gs->setTexEnvMode (GL_REPLACE);
4763+ }
4764+ else
4765+ {
4766+- w->glDrawGeometry ();
4767++ w->vertexBuffer ()->render (transform, attrib);
4768+ }
4769+
4770+ texture->disable ();
4771+ }
4772+ }
4773++#endif
4774+
4775+ void
4776+-GLWindow::glDrawTexture (GLTexture *texture,
4777+- GLFragment::Attrib &attrib,
4778+- unsigned int mask)
4779++GLWindow::glDrawTexture (GLTexture *texture,
4780++ const GLMatrix &transform,
4781++ const GLWindowPaintAttrib &attrib,
4782++ unsigned int mask)
4783+ {
4784+- WRAPABLE_HND_FUNCTN (glDrawTexture, texture, attrib, mask)
4785++ WRAPABLE_HND_FUNCTN (glDrawTexture, texture, transform, attrib, mask)
4786+
4787+ GLTexture::Filter filter;
4788++ GLboolean isBlendingEnabled = GL_FALSE;
4789++
4790++ // Enable blending if needed
4791++ if (mask & PAINT_WINDOW_BLEND_MASK) {
4792++ glGetBooleanv (GL_BLEND, &isBlendingEnabled);
4793++ if (!isBlendingEnabled)
4794++ glEnable(GL_BLEND);
4795++ }
4796+
4797+ if (mask & (PAINT_WINDOW_TRANSFORMED_MASK |
4798+ PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK))
4799+@@ -1165,24 +1155,36 @@ GLWindow::glDrawTexture (GLTexture
4800+ else
4801+ filter = priv->gScreen->filter (NOTHING_TRANS_FILTER);
4802+
4803+- if ((!attrib.hasFunctions () && (!priv->gScreen->lighting () ||
4804+- attrib.getSaturation () == COLOR || attrib.getSaturation () == 0)) ||
4805+- !enableFragmentProgramAndDrawGeometry (priv->gScreen, this, texture,
4806+- attrib, filter, mask))
4807+- {
4808+- enableFragmentOperationsAndDrawGeometry (priv->gScreen, this, texture,
4809+- attrib, filter, mask);
4810+- }
4811++ glActiveTexture(GL_TEXTURE0);
4812++ texture->enable (filter);
4813++
4814++ #ifdef USE_GLES
4815++ priv->vertexBuffer->render (transform, attrib);
4816++ #else
4817++
4818++ if (!GL::vbo && !GL::shaders)
4819++ enableLegacyOBSAndRender (priv->gScreen, this, texture, transform,
4820++ attrib, filter, mask);
4821++ else
4822++ priv->vertexBuffer->render (transform, attrib);
4823++ #endif
4824++
4825++ priv->shaders.clear ();
4826++ texture->disable ();
4827++
4828++ // Reset blending to old value
4829++ if ((mask & PAINT_WINDOW_BLEND_MASK) && !isBlendingEnabled)
4830++ glDisable(GL_BLEND);
4831+ }
4832+
4833+ bool
4834+-GLWindow::glDraw (const GLMatrix &transform,
4835+- GLFragment::Attrib &fragment,
4836+- const CompRegion &region,
4837+- unsigned int mask)
4838++GLWindow::glDraw (const GLMatrix &transform,
4839++ const GLWindowPaintAttrib &attrib,
4840++ const CompRegion &region,
4841++ unsigned int mask)
4842+ {
4843+ WRAPABLE_HND_FUNCTN_RETURN (bool, glDraw, transform,
4844+- fragment, region, mask)
4845++ attrib, region, mask)
4846+
4847+ const CompRegion &reg = (mask & PAINT_WINDOW_TRANSFORMED_MASK) ?
4848+ infiniteRegion : region;
4849+@@ -1213,10 +1215,11 @@ GLWindow::glDraw (const GLMatrix &tr
4850+ if (priv->textures.size () == 1)
4851+ {
4852+ ml[0] = priv->matrices[0];
4853+- priv->geometry.reset ();
4854++ priv->vertexBuffer->begin ();
4855+ glAddGeometry (ml, priv->window->region (), reg);
4856+- if (priv->geometry.vCount)
4857+- glDrawTexture (priv->textures[0], fragment, mask);
4858++ priv->vertexBuffer->end ();
4859++
4860++ glDrawTexture (priv->textures[0], transform, attrib, mask);
4861+ }
4862+ else
4863+ {
4864+@@ -1225,10 +1228,11 @@ GLWindow::glDraw (const GLMatrix &tr
4865+ for (unsigned int i = 0; i < priv->textures.size (); i++)
4866+ {
4867+ ml[0] = priv->matrices[i];
4868+- priv->geometry.reset ();
4869++ priv->vertexBuffer->begin ();
4870+ glAddGeometry (ml, priv->regions[i], reg);
4871+- if (priv->geometry.vCount)
4872+- glDrawTexture (priv->textures[i], fragment, mask);
4873++ priv->vertexBuffer->end ();
4874++
4875++ glDrawTexture (priv->textures[i], transform, attrib, mask);
4876+ }
4877+ }
4878+
4879+@@ -1243,7 +1247,6 @@ GLWindow::glPaint (const GLWindowPaintAt
4880+ {
4881+ WRAPABLE_HND_FUNCTN_RETURN (bool, glPaint, attrib, transform, region, mask)
4882+
4883+- GLFragment::Attrib fragment (attrib);
4884+ bool status;
4885+
4886+ priv->lastPaint = attrib;
4887+@@ -1273,18 +1276,7 @@ GLWindow::glPaint (const GLWindowPaintAt
4888+ if (mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK)
4889+ return true;
4890+
4891+- if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
4892+- mask & PAINT_WINDOW_WITH_OFFSET_MASK)
4893+- {
4894+- glPushMatrix ();
4895+- glLoadMatrixf (transform.getMatrix ());
4896+- }
4897+-
4898+- status = glDraw (transform, fragment, region, mask);
4899+-
4900+- if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
4901+- mask & PAINT_WINDOW_WITH_OFFSET_MASK)
4902+- glPopMatrix ();
4903++ status = glDraw (transform, attrib, region, mask);
4904+
4905+ return status;
4906+ }
4907+--- /dev/null
4908++++ compiz-0.9.7.6/plugins/opengl/src/shadercache.cpp
4909+@@ -0,0 +1,246 @@
4910++/*
4911++ * Copyright © 2012 Linaro Ltd.
4912++ *
4913++ * Permission to use, copy, modify, distribute, and sell this software
4914++ * and its documentation for any purpose is hereby granted without
4915++ * fee, provided that the above copyright notice appear in all copies
4916++ * and that both that copyright notice and this permission notice
4917++ * appear in supporting documentation, and that the name of
4918++ * Linaro Ltd. not be used in advertising or publicity pertaining to
4919++ * distribution of the software without specific, written prior permission.
4920++ * Linaro Ltd. makes no representations about the suitability of this
4921++ * software for any purpose. It is provided "as is" without express or
4922++ * implied warranty.
4923++ *
4924++ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
4925++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
4926++ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
4927++ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
4928++ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
4929++ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
4930++ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4931++ *
4932++ * Authors: Alexandros Frantzis <alexandros.frantzis@linaro.org>
4933++ */
4934++#include <map>
4935++#include <sstream>
4936++
4937++#include <opengl/shadercache.h>
4938++
4939++/**
4940++ * Compares two GLShaderParameters objects.
4941++ */
4942++class GLShaderParametersComparer
4943++{
4944++public:
4945++ bool operator()(const GLShaderParameters &left, const GLShaderParameters &right) const
4946++ {
4947++ return left.hash() < right.hash();
4948++ }
4949++
4950++};
4951++
4952++typedef std::map<GLShaderParameters, GLShaderData, GLShaderParametersComparer> ShaderMapType;
4953++
4954++/**
4955++ * Private data for GLPrivate
4956++ */
4957++class PrivateShaderCache
4958++{
4959++public:
4960++ PrivateShaderCache() {}
4961++
4962++ ShaderMapType::const_iterator addShaderData(const GLShaderParameters &params);
4963++
4964++ std::string createVertexShader (const GLShaderParameters &params);
4965++ std::string createFragmentShader (const GLShaderParameters &params);
4966++
4967++ ShaderMapType shaderMap;
4968++};
4969++
4970++/**********************
4971++ * GLShaderParameters *
4972++ **********************/
4973++
4974++int
4975++GLShaderParameters::hash() const
4976++{
4977++ return static_cast<int>(opacity) |
4978++ (static_cast<int>(brightness) << 1) |
4979++ (static_cast<int>(saturation) << 2) |
4980++ (static_cast<int>(color) << 3) |
4981++ (static_cast<int>(normal) << 5) |
4982++ (static_cast<int>(numTextures) << 8);
4983++}
4984++
4985++std::string
4986++GLShaderParameters::id() const
4987++{
4988++ std::stringstream ss;
4989++
4990++ ss << (opacity ? "t" : "f");
4991++ ss << (brightness ? "t" : "f");
4992++ ss << (saturation ? "t" : "f");
4993++ ss << (color == GLShaderVariableNone ? "n" :
4994++ color == GLShaderVariableUniform ? "u" : "v");
4995++
4996++ ss << (normal == GLShaderVariableNone ? "n" :
4997++ normal == GLShaderVariableUniform ? "u" : "v");
4998++ ss << numTextures;
4999++
5000++ return ss.str();
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: