~compiz-team/compiz/compiz.fix_1077866

« back to all changes in this revision

Viewing changes to debian/patches/compiz-package-gles2.patch

first packaging

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/cmake/base.cmake linaro-gles2-debianpatches/cmake/base.cmake
 
2
--- compiz-0.9.7.8/cmake/base.cmake     2012-04-26 08:47:01.000000000 +0200
 
3
+++ linaro-gles2-debianpatches/cmake/base.cmake 2012-04-20 11:41:59.241600000 +0200
 
4
@@ -24,6 +24,7 @@
 
5
     compiz_print_configure_header ("Compiz")
 
6
     compiz_color_message ("\n${_escape}[4mOptional features:${_escape}[0m\n")
 
7
 
 
8
+    compiz_print_result_message ("GLESv2" USE_GLES)
 
9
     compiz_print_result_message ("gtk window decorator" USE_GTK)
 
10
     compiz_print_result_message ("metacity theme support" USE_METACITY)
 
11
     compiz_print_result_message ("gconf schemas" USE_GCONF)
 
12
@@ -46,7 +47,8 @@
 
13
     endif ()
 
14
     add_custom_target (findcompiz_install
 
15
        ${CMAKE_COMMAND} -E make_directory ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules &&
 
16
-       ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindCompiz.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules
 
17
+       ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindCompiz.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules &&
 
18
+       ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindOpenGLES2.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules
 
19
     )
 
20
 endfunction ()
 
21
 
 
22
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/cmake/CMakeLists.txt linaro-gles2-debianpatches/cmake/CMakeLists.txt
 
23
--- compiz-0.9.7.8/cmake/CMakeLists.txt 2012-04-26 08:47:01.000000000 +0200
 
24
+++ linaro-gles2-debianpatches/cmake/CMakeLists.txt     2012-04-20 11:41:59.241600000 +0200
 
25
@@ -15,6 +15,8 @@
 
26
       plugin_extensions/CompizGenInstallData.cmake)
 
27
 list (APPEND _PluginExtensionFiles
 
28
       plugin_extensions/CompizGenInstallImages.cmake)
 
29
+list (APPEND _PluginExtensionFiles
 
30
+      plugin_extensions/CompizOpenGLFixups.cmake)
 
31
 
 
32
 if (USE_GCONF)
 
33
     list (APPEND _files CompizGconf.cmake)
 
34
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/cmake/CompizCommon.cmake linaro-gles2-debianpatches/cmake/CompizCommon.cmake
 
35
--- compiz-0.9.7.8/cmake/CompizCommon.cmake     2012-04-26 08:47:01.000000000 +0200
 
36
+++ linaro-gles2-debianpatches/cmake/CompizCommon.cmake 2012-04-20 11:41:59.241600000 +0200
 
37
@@ -18,6 +18,7 @@
 
38
 
 
39
 set (CMAKE_SKIP_RPATH FALSE)
 
40
 
 
41
+option (BUILD_GLES "Build against GLESv2 instead of GL" OFF)
 
42
 option (COMPIZ_BUILD_WITH_RPATH "Leave as ON unless building packages" ON)
 
43
 option (COMPIZ_RUN_LDCONFIG "Leave OFF unless you need to run ldconfig after install")
 
44
 option (COMPIZ_PACKAGING_ENABLED "Enable to manually set prefix, exec_prefix, libdir, includedir, datadir" OFF)
 
45
@@ -75,6 +76,17 @@
 
46
     set(IS_BZR_REPO 0)
 
47
 endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr)
 
48
 
 
49
+set (USE_GLES ${BUILD_GLES})
 
50
+
 
51
+if (USE_GLES)
 
52
+    find_package(OpenGLES2)
 
53
+
 
54
+    if (NOT OPENGLES2_FOUND)
 
55
+       set (USE_GLES 0)
 
56
+       message (SEND_ERROR "OpenGLESv2 not found")
 
57
+    endif (NOT OPENGLES2_FOUND)
 
58
+endif (USE_GLES)
 
59
+
 
60
 function (compiz_ensure_linkage)
 
61
     find_program (LDCONFIG_EXECUTABLE ldconfig)
 
62
     mark_as_advanced (FORCE LDCONFIG_EXECUTABLE)
 
63
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/cmake/CompizPlugin.cmake linaro-gles2-debianpatches/cmake/CompizPlugin.cmake
 
64
--- compiz-0.9.7.8/cmake/CompizPlugin.cmake     2012-04-26 08:47:01.000000000 +0200
 
65
+++ linaro-gles2-debianpatches/cmake/CompizPlugin.cmake 2012-04-20 11:41:59.241600000 +0200
 
66
@@ -257,6 +257,16 @@
 
67
            NO_DEFAULT_PATH
 
68
        )
 
69
 
 
70
+       set (COMPIZ_CURRENT_PLUGIN ${plugin})
 
71
+       set (COMPIZ_CURRENT_XML_FILE ${_translated_xml})
 
72
+
 
73
+       # find extension files
 
74
+       file (GLOB _extension_files "${COMPIZ_CMAKE_MODULE_PATH}/plugin_extensions/*.cmake")
 
75
+
 
76
+       foreach (_file ${_extension_files})
 
77
+           include (${_file})
 
78
+       endforeach ()
 
79
+
 
80
        # generate pkgconfig file and install it and the plugin header file
 
81
        if (_${plugin}_pkg AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin})
 
82
            if ("${PLUGIN_BUILDTYPE}" STREQUAL "local")
 
83
@@ -269,11 +279,15 @@
 
84
                    set (VERSION 0.0.1-git)
 
85
                endif (NOT VERSION)
 
86
 
 
87
+               #add CFLAGSADD so pkg-config file has correct flags
 
88
+               set (COMPIZ_CFLAGS ${COMPIZ_CFLAGS} ${${_PLUGIN}_CFLAGSADD})
 
89
+
 
90
                compiz_configure_file (
 
91
                    ${_${plugin}_pkg}
 
92
                    ${CMAKE_BINARY_DIR}/generated/compiz-${plugin}.pc
 
93
                    COMPIZ_REQUIRES
 
94
                    COMPIZ_CFLAGS
 
95
+                   PKGCONFIG_LIBS
 
96
                )
 
97
 
 
98
                install (
 
99
@@ -287,16 +301,6 @@
 
100
            endif ()
 
101
        endif ()
 
102
 
 
103
-       set (COMPIZ_CURRENT_PLUGIN ${plugin})
 
104
-       set (COMPIZ_CURRENT_XML_FILE ${_translated_xml})
 
105
-
 
106
-       # find extension files
 
107
-       file (GLOB _extension_files "${COMPIZ_CMAKE_MODULE_PATH}/plugin_extensions/*.cmake")
 
108
-
 
109
-       foreach (_file ${_extension_files})
 
110
-           include (${_file})
 
111
-       endforeach ()
 
112
-
 
113
        # find files for build
 
114
        file (GLOB _h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")
 
115
        file (GLOB _h_ins_files "${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}/*.h")
 
116
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/cmake/FindOpenGLES2.cmake linaro-gles2-debianpatches/cmake/FindOpenGLES2.cmake
 
117
--- compiz-0.9.7.8/cmake/FindOpenGLES2.cmake    1970-01-01 01:00:00.000000000 +0100
 
118
+++ linaro-gles2-debianpatches/cmake/FindOpenGLES2.cmake        2012-04-20 11:41:59.241600000 +0200
 
119
@@ -0,0 +1,51 @@
 
120
+# - Try to find OpenGLES
 
121
+# Once done this will define
 
122
+#  
 
123
+#  OPENGLES2_FOUND        - system has OpenGLES
 
124
+#  OPENGLES2_INCLUDE_DIR  - the GLES include directory
 
125
+#  OPENGLES2_LIBRARY     - the GLES library
 
126
+#  OPENGLES2_LIBRARIES    - Link this to use OpenGLES
 
127
+#   
 
128
+
 
129
+FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
 
130
+  /usr/openwin/share/include
 
131
+  /opt/graphics/OpenGL/include /usr/X11R6/include
 
132
+  /usr/include
 
133
+)
 
134
+
 
135
+FIND_LIBRARY(OPENGLES2_LIBRARY
 
136
+  NAMES GLESv2
 
137
+  PATHS /opt/graphics/OpenGL/lib
 
138
+        /usr/openwin/lib
 
139
+        /usr/shlib /usr/X11R6/lib
 
140
+        /usr/lib
 
141
+)
 
142
+
 
143
+FIND_LIBRARY(OPENGLES2_EGL_LIBRARY
 
144
+    NAMES EGL
 
145
+    PATHS /usr/shlib /usr/X11R6/lib
 
146
+          /usr/lib
 
147
+)
 
148
+
 
149
+# On Unix OpenGL most certainly always requires X11.
 
150
+# Feel free to tighten up these conditions if you don't 
 
151
+# think this is always true.
 
152
+# It's not true on OSX.
 
153
+
 
154
+IF (OPENGLES2_LIBRARY)
 
155
+  IF(NOT X11_FOUND)
 
156
+    INCLUDE(FindX11)
 
157
+  ENDIF(NOT X11_FOUND)
 
158
+  IF (X11_FOUND)
 
159
+    IF (NOT APPLE)
 
160
+      SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES})
 
161
+    ENDIF (NOT APPLE)
 
162
+  ENDIF (X11_FOUND)
 
163
+ENDIF(OPENGLES2_LIBRARY)
 
164
+
 
165
+SET( OPENGLES2_FOUND "NO" )
 
166
+IF(OPENGLES2_LIBRARY AND OPENGLES2_EGL_LIBRARY)
 
167
+    SET( OPENGLES2_LIBRARIES  ${OPENGLES2_LIBRARY} ${OPENGLES2_EGL_LIBRARY} ${OPENGLES2_LIBRARIES})
 
168
+    SET( OPENGLES2_FOUND "YES" )
 
169
+ENDIF(OPENGLES2_LIBRARY AND OPENGLES2_EGL_LIBRARY)
 
170
+
 
171
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/cmake/plugin_extensions/CompizOpenGLFixups.cmake linaro-gles2-debianpatches/cmake/plugin_extensions/CompizOpenGLFixups.cmake
 
172
--- compiz-0.9.7.8/cmake/plugin_extensions/CompizOpenGLFixups.cmake     1970-01-01 01:00:00.000000000 +0100
 
173
+++ linaro-gles2-debianpatches/cmake/plugin_extensions/CompizOpenGLFixups.cmake 2012-04-20 11:41:59.241600000 +0200
 
174
@@ -0,0 +1,22 @@
 
175
+
 
176
+# modify pkg-config libs for opengl based on if we found GLES or not
 
177
+if (${COMPIZ_CURRENT_PLUGIN} STREQUAL "opengl")
 
178
+    if (USE_GLES)
 
179
+       set (PKGCONFIG_LIBS "-lGLESv2 -lEGL")
 
180
+    else (USE_GLES)
 
181
+       set (PKGCONFIG_LIBS "-lGL")
 
182
+    endif (USE_GLES)
 
183
+endif (${COMPIZ_CURRENT_PLUGIN} STREQUAL "opengl")
 
184
+
 
185
+# if plugin is using opengl plugin check for GLES library and set correct define
 
186
+if (NOT "${${_PLUGIN}_PLUGINDEPS}" STREQUAL "")
 
187
+    string (REGEX MATCH "opengl" opengl_found ${${_PLUGIN}_PLUGINDEPS})
 
188
+
 
189
+    if (opengl_found STREQUAL "opengl")
 
190
+       if (USE_GLES)
 
191
+           set (${_PLUGIN}_CFLAGSADD ${${_PLUGIN}_CFLAGSADD} " -DUSE_GLES")
 
192
+           string (REPLACE ";" " " ${_PLUGIN}_CFLAGSADD ${${_PLUGIN}_CFLAGSADD})
 
193
+       endif (USE_GLES)
 
194
+    endif (opengl_found STREQUAL "opengl")
 
195
+endif (NOT "${${_PLUGIN}_PLUGINDEPS}" STREQUAL "")
 
196
+
 
197
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/CMakeLists.txt linaro-gles2-debianpatches/CMakeLists.txt
 
198
--- compiz-0.9.7.8/CMakeLists.txt       2012-04-26 08:47:01.000000000 +0200
 
199
+++ linaro-gles2-debianpatches/CMakeLists.txt   2012-04-20 11:41:59.241600000 +0200
 
200
@@ -119,6 +119,12 @@
 
201
     DESTINATION ${COMPIZ_DESTDIR}${libdir}/pkgconfig
 
202
 )
 
203
 
 
204
+# temporarily disable plugins that aren't ported yed
 
205
+set (COMPIZ_DISABLE_PLUGIN_BLUR ON)
 
206
+set (COMPIZ_DISABLE_PLUGIN_CUBE ON)
 
207
+set (COMPIZ_DISABLE_PLUGIN_ROTATE ON)
 
208
+set (COMPIZ_DISABLE_PLUGIN_WOBBLY ON)
 
209
+
 
210
 # Build Google Test and make its headers known
 
211
 find_package (GTest)
 
212
 
 
213
@@ -183,6 +189,12 @@
 
214
 
 
215
 _check_compiz_cmake_macro (${CMAKE_MODULE_PATH_ORIG})
 
216
 
 
217
+# temporarily disable plugins that aren't ported yed
 
218
+SET(COMPIZ_DISABLE_PLUGIN_BLUR "ON")
 
219
+SET(COMPIZ_DISABLE_PLUGIN_CUBE "ON")
 
220
+SET(COMPIZ_DISABLE_PLUGIN_ROTATE "ON")
 
221
+SET(COMPIZ_DISABLE_PLUGIN_WATER "ON")
 
222
+SET(COMPIZ_DISABLE_PLUGIN_WOBBLY "ON")
 
223
 # Enable coverage reporting for compiz
 
224
 enable_coverage_report()
 
225
 
 
226
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/NEWS linaro-gles2-debianpatches/NEWS
 
227
--- compiz-0.9.7.8/NEWS 2012-04-26 08:47:01.000000000 +0200
 
228
+++ linaro-gles2-debianpatches/NEWS     2012-04-26 12:34:44.027302000 +0200
 
229
@@ -10,7 +10,6 @@
 
230
     976467 - [regression] Compiz 0.9.7.6: Menus often have no shadows at all
 
231
     978900 - Menu shadow clipping flickers while switching menubar
 
232
              items/indicators
 
233
-    979252 - Shadow Clipping / Regressions compiz 0.9.7.7 (built an hour ago)
 
234
     980026 - Compiz should not move windows to workspace 0,0 when restarted
 
235
     981703 - regression / unable to interact with window-titlebar (window
 
236
              decoration) after minimizing/unminimizing gnome-terminal
 
237
@@ -21,6 +20,7 @@
 
238
 
 
239
 Bugs fixed (https://launchpad.net/compiz-core/+milestone/0.9.7.6)
 
240
 
 
241
+    659816 - Drop-down menus look disembodied from their titles 
 
242
     968985 - Memory leak in dlloaderListPlugins
 
243
     969102 - priv->invisible is not updated when the window is mapped
 
244
     919139 - window management, multi-monitor - In multi-monitor
 
245
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/annotate/src/annotate.cpp linaro-gles2-debianpatches/plugins/annotate/src/annotate.cpp
 
246
--- compiz-0.9.7.8/plugins/annotate/src/annotate.cpp    2012-04-26 08:47:01.000000000 +0200
 
247
+++ linaro-gles2-debianpatches/plugins/annotate/src/annotate.cpp        2012-04-20 11:41:59.241600000 +0200
 
248
@@ -629,11 +629,14 @@
 
249
 
 
250
     if (status)
 
251
     {
 
252
+       GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
 
253
+       GLfloat         vertexData[18];
 
254
+       GLfloat         textureData[12];
 
255
        CompRect        rect;
 
256
        GLMatrix        sTransform = transform;
 
257
        int             numRect;
 
258
        int             pos = 0;
 
259
-       float           vectorX, vectorY, offset;
 
260
+       float           offset;
 
261
        int             angle;
 
262
 
 
263
        offset = optionGetStrokeWidth () / 2;
 
264
@@ -641,12 +644,6 @@
 
265
        /* This replaced prepareXCoords (s, output, -DEFAULT_Z_CAMERA) */
 
266
        sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
 
267
 
 
268
-       glPushMatrix ();
 
269
-       glLoadMatrixf (sTransform.getMatrix ());
 
270
-
 
271
-       glDisableClientState (GL_TEXTURE_COORD_ARRAY);
 
272
-       glEnable (GL_BLEND);
 
273
-
 
274
        if (content && !region.isEmpty ())
 
275
        {
 
276
            foreach (GLTexture *tex, texture)
 
277
@@ -656,34 +653,66 @@
 
278
 
 
279
                tex->enable (GLTexture::Fast);
 
280
 
 
281
-               glBegin (GL_QUADS);
 
282
+               streamingBuffer->begin (GL_TRIANGLES);
 
283
 
 
284
                while (numRect--)
 
285
                {
 
286
-                   glTexCoord2f (
 
287
-                       COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x1 ()),
 
288
-                       COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y2 ()));
 
289
-                   glVertex2i (rect.at (pos).x1 (), rect.at (pos).y2 ());
 
290
-
 
291
-                   glTexCoord2f (
 
292
-                       COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x2 ()),
 
293
-                       COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y2 ()));
 
294
-                   glVertex2i (rect.at (pos).x2 (), rect.at (pos).y2 ());
 
295
-
 
296
-                   glTexCoord2f (
 
297
-                       COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x2 ()),
 
298
-                       COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y1 ()));
 
299
-                   glVertex2i (rect.at (pos).x2 (), rect.at (pos).y1 ());
 
300
-
 
301
-                   glTexCoord2f (
 
302
-                       COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x1 ()),
 
303
-                       COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y1 ()));
 
304
-                   glVertex2i (rect.at (pos).x1 (), rect.at (pos).y1 ());
 
305
+                   GLfloat tx1 = COMP_TEX_COORD_X (tex->matrix (),
 
306
+                                                      rect.at (pos).x1 ());
 
307
+                   GLfloat tx2 = COMP_TEX_COORD_X (tex->matrix (),
 
308
+                                                      rect.at (pos).x2 ());
 
309
+                   GLfloat ty1 = COMP_TEX_COORD_Y (tex->matrix (),
 
310
+                                                      rect.at (pos).y1 ());
 
311
+                   GLfloat ty2 = COMP_TEX_COORD_Y (tex->matrix (),
 
312
+                                                      rect.at (pos).y2 ());
 
313
+
 
314
+                   vertexData[0]  = rect.at (pos).x1 ();
 
315
+                   vertexData[1]  = rect.at (pos).y1 ();
 
316
+                   vertexData[2]  = 0.0f;
 
317
+                   vertexData[3]  = rect.at (pos).x1 ();
 
318
+                   vertexData[4]  = rect.at (pos).y2 ();
 
319
+                   vertexData[5]  = 0.0f;
 
320
+                   vertexData[6]  = rect.at (pos).x2 ();
 
321
+                   vertexData[7]  = rect.at (pos).y1 ();
 
322
+                   vertexData[8]  = 0.0f;
 
323
+                   vertexData[9]  = rect.at (pos).x1 ();
 
324
+                   vertexData[10] = rect.at (pos).y2 ();
 
325
+                   vertexData[11] = 0.0f;
 
326
+
 
327
+                   vertexData[12] = rect.at (pos).x2 ();
 
328
+                   vertexData[13] = rect.at (pos).y2 ();
 
329
+                   vertexData[14] = 0.0f;
 
330
+
 
331
+                   vertexData[15] = rect.at (pos).x2 ();
 
332
+                   vertexData[16] = rect.at (pos).y1 ();
 
333
+                   vertexData[17] = 0.0f;
 
334
+
 
335
+                   textureData[0]  = tx1;
 
336
+                   textureData[1]  = ty1;
 
337
+
 
338
+                   textureData[2]  = tx1;
 
339
+                   textureData[3]  = ty2;
 
340
+
 
341
+                   textureData[4]  = tx2;
 
342
+                   textureData[5]  = ty1;
 
343
+
 
344
+                   textureData[6]  = tx1;
 
345
+                   textureData[7]  = ty2;
 
346
+
 
347
+                   textureData[8]  = tx2;
 
348
+                   textureData[9]  = ty2;
 
349
+
 
350
+                   textureData[10] = tx2;
 
351
+                   textureData[11] = ty1;
 
352
 
 
353
+                   streamingBuffer->addVertices (6, vertexData);
 
354
+                   streamingBuffer->addTexCoords (0, 6, textureData);
 
355
                    pos++;
 
356
                }
 
357
 
 
358
-               glEnd ();
 
359
+               streamingBuffer->end ();
 
360
+               streamingBuffer->render (sTransform);
 
361
+
 
362
                tex->disable ();
 
363
            }
 
364
        }
 
365
@@ -691,85 +720,130 @@
 
366
        switch (drawMode)
 
367
        {
 
368
        case LineMode:
 
369
-           glColor4usv (optionGetStrokeColor ());
 
370
            glLineWidth (optionGetStrokeWidth ());
 
371
-           glBegin (GL_LINES);
 
372
-           glVertex2i (initialPointerX, initialPointerY);
 
373
-           glVertex2i (lineVector.x (), lineVector.y ());
 
374
-           glEnd ();
 
375
+
 
376
+           streamingBuffer->begin (GL_LINES);
 
377
+
 
378
+           streamingBuffer->addColors (1, optionGetStrokeColor ());
 
379
+
 
380
+           vertexData[0] = initialPointerX;
 
381
+           vertexData[1] = initialPointerY;
 
382
+           vertexData[2] = 0.0f;
 
383
+           vertexData[3] = lineVector.x ();
 
384
+           vertexData[4] = lineVector.y ();
 
385
+           vertexData[5] = 0.0f;
 
386
+           streamingBuffer->addVertices (2, vertexData);
 
387
+
 
388
+           streamingBuffer->end ();
 
389
+           streamingBuffer->render (sTransform);
 
390
            break;
 
391
 
 
392
        case RectangleMode:
 
393
+           vertexData[0]  = rectangle.x1 ();
 
394
+           vertexData[1]  = rectangle.y1 ();
 
395
+           vertexData[2]  = 0.0f;
 
396
+           vertexData[3]  = rectangle.x1 ();
 
397
+           vertexData[4]  = rectangle.y2 ();
 
398
+           vertexData[5]  = 0.0f;
 
399
+           vertexData[6]  = rectangle.x2 ();
 
400
+           vertexData[7]  = rectangle.y1 ();
 
401
+           vertexData[8]  = 0.0f;
 
402
+           vertexData[9]  = rectangle.x2 ();
 
403
+           vertexData[10] = rectangle.y2 ();
 
404
+           vertexData[11] = 0.0f;
 
405
+
 
406
            /* fill rectangle */
 
407
-           glColor4usv (optionGetFillColor ());
 
408
-           glRecti (rectangle.x1 (), rectangle.y2 (),
 
409
-                    rectangle.x2 (), rectangle.y1 ());
 
410
+           streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
411
+
 
412
+           streamingBuffer->addColors (1, optionGetFillColor ());
 
413
+           streamingBuffer->addVertices (4, vertexData);
 
414
+
 
415
+           streamingBuffer->end ();
 
416
+           streamingBuffer->render (sTransform);
 
417
 
 
418
            /* draw rectangle outline */
 
419
-           glColor4usv (optionGetStrokeColor ());
 
420
-           glRecti (rectangle.x1 () - offset, rectangle.y2 (),
 
421
-                    rectangle.x1 () + offset, rectangle.y1 ());
 
422
+/*         streamingBuffer->begin ();
 
423
+
 
424
+           streamingBuffer->addColors (1, optionGetStrokeColor ());
 
425
+
 
426
+           vertexData[0] = rectangle.x1 () - offset;
 
427
+           vertexData[3] = rectangle.x1 () - offset;
 
428
+           streamingBuffer->addVertices (4, vertexData);
 
429
+
 
430
            glRecti (rectangle.x2 () - offset, rectangle.y2 (),
 
431
                     rectangle.x2 () + offset, rectangle.y1 ());
 
432
            glRecti (rectangle.x1 () - offset, rectangle.y1 () + offset,
 
433
                     rectangle.x2 () + offset, rectangle.y1 () - offset);
 
434
            glRecti (rectangle.x1 () - offset, rectangle.y2 () + offset,
 
435
-                    rectangle.x2 () + offset, rectangle.y2 () - offset);
 
436
+                    rectangle.x2 () + offset, rectangle.y2 () - offset);*/
 
437
            break;
 
438
 
 
439
        case EllipseMode:
 
440
            /* fill ellipse */
 
441
-           glColor4usv (optionGetFillColor ());
 
442
+           streamingBuffer->begin (GL_TRIANGLE_FAN);
 
443
+
 
444
+           streamingBuffer->addColors (1, optionGetFillColor ());
 
445
+
 
446
+           vertexData[0] = ellipse.center.x ();
 
447
+           vertexData[1] = ellipse.center.y ();
 
448
+           vertexData[2] = 0.0f;
 
449
+           streamingBuffer->addVertices (1, vertexData);
 
450
 
 
451
-           glBegin (GL_TRIANGLE_FAN);
 
452
-           glVertex2d (ellipse.center.x (), ellipse.center.y ());
 
453
            for (angle = 0; angle <= 360; angle += 1)
 
454
            {
 
455
-               vectorX = ellipse.center.x () +
 
456
-                        (ellipse.radiusX * sinf (angle * DEG2RAD));
 
457
-               vectorY = ellipse.center.y () +
 
458
-                        (ellipse.radiusY * cosf (angle * DEG2RAD));
 
459
-               glVertex2d (vectorX, vectorY);
 
460
+               vertexData[0] = ellipse.center.x () +
 
461
+                               (ellipse.radiusX * sinf (angle * DEG2RAD));
 
462
+               vertexData[1] = ellipse.center.y () +
 
463
+                               (ellipse.radiusY * cosf (angle * DEG2RAD));
 
464
+               streamingBuffer->addVertices (1, vertexData);
 
465
            }
 
466
-           glVertex2d (ellipse.center.x (), ellipse.center.y () +
 
467
-                       ellipse.radiusY);
 
468
-           glEnd();
 
469
+
 
470
+           vertexData[0] = ellipse.center.x ();
 
471
+           vertexData[1] = ellipse.center.y () + ellipse.radiusY;
 
472
+           streamingBuffer->addVertices (1, vertexData);
 
473
+
 
474
+           streamingBuffer->end ();
 
475
+           streamingBuffer->render (sTransform);
 
476
 
 
477
            /* draw ellipse outline */
 
478
-           glColor4usv (optionGetStrokeColor ());
 
479
            glLineWidth (optionGetStrokeWidth ());
 
480
 
 
481
-           glBegin (GL_TRIANGLE_STRIP);
 
482
-           glVertex2d (ellipse.center.x (), ellipse.center.y () +
 
483
-                       ellipse.radiusY - offset);
 
484
+           streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
485
+
 
486
+           streamingBuffer->addColors (1, optionGetStrokeColor ());
 
487
+
 
488
+
 
489
+           vertexData[0] = ellipse.center.x ();
 
490
+           vertexData[1] = ellipse.center.y () + ellipse.radiusY - offset;
 
491
+           vertexData[2] = 0.0f;
 
492
+           streamingBuffer->addVertices (1, vertexData);
 
493
+
 
494
            for (angle = 360; angle >= 0; angle -= 1)
 
495
            {
 
496
-               vectorX = ellipse.center.x () + ((ellipse.radiusX -
 
497
-                         offset) * sinf (angle * DEG2RAD));
 
498
-               vectorY = ellipse.center.y () + ((ellipse.radiusY -
 
499
-                         offset) * cosf (angle * DEG2RAD));
 
500
-               glVertex2d (vectorX, vectorY);
 
501
-               vectorX = ellipse.center.x () + ((ellipse.radiusX +
 
502
-                         offset) * sinf (angle * DEG2RAD));
 
503
-               vectorY = ellipse.center.y () + ((ellipse.radiusY +
 
504
-                         offset) * cosf (angle * DEG2RAD));
 
505
-               glVertex2d (vectorX, vectorY);
 
506
+               vertexData[0] = ellipse.center.x () + ((ellipse.radiusX -
 
507
+                               offset) * sinf (angle * DEG2RAD));
 
508
+               vertexData[1] = ellipse.center.y () + ((ellipse.radiusY -
 
509
+                               offset) * cosf (angle * DEG2RAD));
 
510
+               vertexData[2] = 0.0f;
 
511
+               vertexData[3] = ellipse.center.x () + ((ellipse.radiusX +
 
512
+                               offset) * sinf (angle * DEG2RAD));
 
513
+               vertexData[4] = ellipse.center.y () + ((ellipse.radiusY +
 
514
+                               offset) * cosf (angle * DEG2RAD));
 
515
+               vertexData[5] = 0.0f;
 
516
+               streamingBuffer->addVertices (2, vertexData);
 
517
            }
 
518
-           glVertex2d (ellipse.center.x (), ellipse.center.y () +
 
519
-                       ellipse.radiusY + offset);
 
520
-           glEnd();
 
521
+
 
522
+           vertexData[0] = ellipse.center.x ();
 
523
+           vertexData[1] = ellipse.center.y () + ellipse.radiusY + offset;
 
524
+           streamingBuffer->addVertices (1, vertexData);
 
525
+
 
526
+           streamingBuffer->end ();
 
527
+           streamingBuffer->render (sTransform);
 
528
            break;
 
529
 
 
530
        default:
 
531
            break;
 
532
        }
 
533
-
 
534
-       /* clean up */
 
535
-       glColor4usv (defaultColor);
 
536
-       glDisable (GL_BLEND);
 
537
-       glEnableClientState (GL_TEXTURE_COORD_ARRAY);
 
538
-
 
539
-       glPopMatrix ();
 
540
     }
 
541
 
 
542
     return status;
 
543
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/blur/CMakeLists.txt linaro-gles2-debianpatches/plugins/blur/CMakeLists.txt
 
544
--- compiz-0.9.7.8/plugins/blur/CMakeLists.txt  2012-04-26 08:47:01.000000000 +0200
 
545
+++ linaro-gles2-debianpatches/plugins/blur/CMakeLists.txt      2012-04-20 11:41:59.241600000 +0200
 
546
@@ -2,15 +2,15 @@
 
547
 
 
548
 include (CompizPlugin)
 
549
 
 
550
-find_package (OpenGL)
 
551
+#find_package (OpenGL)
 
552
 
 
553
-if (OPENGL_GLU_FOUND)
 
554
-    compiz_plugin(blur PLUGINDEPS composite opengl LIBRARIES decoration ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
 
555
+#if (OPENGL_GLU_FOUND)
 
556
+#    compiz_plugin(blur PLUGINDEPS composite opengl LIBRARIES decoration ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
 
557
 
 
558
-    if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)
 
559
-       set_target_properties (
 
560
-           blur PROPERTIES
 
561
-           INSTALL_RPATH "${COMPIZ_LIBDIR}"
 
562
-       )
 
563
-    endif (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)
 
564
-endif ()
 
565
+#    if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)
 
566
+#      set_target_properties (
 
567
+#          blur PROPERTIES
 
568
+#          INSTALL_RPATH "${COMPIZ_LIBDIR}"
 
569
+#      )
 
570
+#    endif (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)
 
571
+#endif ()
 
572
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/clone/src/clone.cpp linaro-gles2-debianpatches/plugins/clone/src/clone.cpp
 
573
--- compiz-0.9.7.8/plugins/clone/src/clone.cpp  2012-04-26 08:47:01.000000000 +0200
 
574
+++ linaro-gles2-debianpatches/plugins/clone/src/clone.cpp      2012-04-20 11:41:59.241600000 +0200
 
575
@@ -295,9 +295,6 @@
 
576
                         0.0f);
 
577
        sTransform.scale (zoomX, zoomY, 1.0f);
 
578
 
 
579
-       glPushMatrix ();
 
580
-       glLoadMatrixf (sTransform.getMatrix ());
 
581
-
 
582
        filter = gScreen->textureFilter ();
 
583
 
 
584
        if (offset == 0.0f)
 
585
@@ -325,8 +322,6 @@
 
586
        }
 
587
 
 
588
        gScreen->setTextureFilter (filter);
 
589
-
 
590
-       glPopMatrix ();
 
591
     }
 
592
 
 
593
     return status;
 
594
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/compiztoolbox/src/compiztoolbox.cpp linaro-gles2-debianpatches/plugins/compiztoolbox/src/compiztoolbox.cpp
 
595
--- compiz-0.9.7.8/plugins/compiztoolbox/src/compiztoolbox.cpp  2012-04-26 08:47:01.000000000 +0200
 
596
+++ linaro-gles2-debianpatches/plugins/compiztoolbox/src/compiztoolbox.cpp      2012-04-20 11:41:59.241600000 +0200
 
597
@@ -465,9 +465,7 @@
 
598
        sAttrib.yTranslate = wy - g.y () +
 
599
                             window->border ().top  * sAttrib.yScale;
 
600
 
 
601
-       GLFragment::Attrib fragment (sAttrib);
 
602
-
 
603
-       if (window->alpha () || fragment.getOpacity () != OPAQUE)
 
604
+       if (window->alpha () || sAttrib.opacity != OPAQUE)
 
605
            mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
 
606
 
 
607
        wTransform.translate (g.x (), g.y (), 0.0f);
 
608
@@ -476,9 +474,6 @@
 
609
                              sAttrib.yTranslate / sAttrib.yScale - g.y (),
 
610
                              0.0f);
 
611
 
 
612
-       glPushMatrix ();
 
613
-       glLoadMatrixf (wTransform.getMatrix ());
 
614
-
 
615
        filter = gScreen->textureFilter ();
 
616
 
 
617
        if (baseScreen->getMipmap ())
 
618
@@ -488,13 +483,11 @@
 
619
           very ugly but necessary until the vertex stage has been made
 
620
           fully pluggable. */
 
621
        gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);
 
622
-       gWindow->glDraw (wTransform, fragment, infiniteRegion, mask);
 
623
+       gWindow->glDraw (wTransform, sAttrib, infiniteRegion, mask);
 
624
        gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);
 
625
 
 
626
        gScreen->setTextureFilter (filter);
 
627
 
 
628
-       glPopMatrix ();
 
629
-
 
630
        if (iconMode != HideIcon)
 
631
        {
 
632
            icon = gWindow->getIcon (MAX_ICON_SIZE, MAX_ICON_SIZE);
 
633
@@ -535,30 +528,23 @@
 
634
        sAttrib.xTranslate = wx - g.x ();
 
635
        sAttrib.yTranslate = wy - g.y ();
 
636
 
 
637
-       gWindow->geometry ().reset ();
 
638
+       gWindow->vertexBuffer ()->begin ();
 
639
 
 
640
        gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);
 
641
        gWindow->glAddGeometry (matrix, iconReg, infiniteRegion);
 
642
        gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);
 
643
 
 
644
-       if (gWindow->geometry ().vCount)
 
645
-       {
 
646
-           GLFragment::Attrib fragment (sAttrib);
 
647
-           GLMatrix           wTransform (transform);
 
648
-
 
649
-           wTransform.translate (g.x (), g.y (), 0.0f);
 
650
-           wTransform.scale (sAttrib.xScale, sAttrib.yScale, 1.0f);
 
651
-           wTransform.translate (sAttrib.xTranslate / sAttrib.xScale - g.x (),
 
652
-                                 sAttrib.yTranslate / sAttrib.yScale - g.y (),
 
653
-                                 0.0f);
 
654
+       gWindow->vertexBuffer ()->end ();
 
655
 
 
656
-           glPushMatrix ();
 
657
-           glLoadMatrixf (wTransform.getMatrix ());
 
658
+       GLMatrix           wTransform (transform);
 
659
 
 
660
-           gWindow->glDrawTexture (icon, fragment, mask);
 
661
+       wTransform.translate (g.x (), g.y (), 0.0f);
 
662
+       wTransform.scale (sAttrib.xScale, sAttrib.yScale, 1.0f);
 
663
+       wTransform.translate (sAttrib.xTranslate / sAttrib.xScale - g.x (),
 
664
+                             sAttrib.yTranslate / sAttrib.yScale - g.y (),
 
665
+                             0.0f);
 
666
 
 
667
-           glPopMatrix ();
 
668
-       }
 
669
+       gWindow->glDrawTexture (icon, wTransform, sAttrib, mask);
 
670
     }
 
671
 }
 
672
 
 
673
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/copytex/src/copytex.cpp linaro-gles2-debianpatches/plugins/copytex/src/copytex.cpp
 
674
--- compiz-0.9.7.8/plugins/copytex/src/copytex.cpp      2012-04-26 08:47:01.000000000 +0200
 
675
+++ linaro-gles2-debianpatches/plugins/copytex/src/copytex.cpp  2012-04-20 11:41:59.241600000 +0200
 
676
@@ -112,6 +112,14 @@
 
677
     GLenum            target;
 
678
     GLTexture::Matrix matrix = _identity_matrix;
 
679
 
 
680
+#ifdef USE_GLES
 
681
+    target = GL_TEXTURE_2D;
 
682
+    matrix.xx = 1.0f / dim.width ();
 
683
+    matrix.yy = 1.0f / dim.height ();
 
684
+    matrix.x0 = -dim.x () * matrix.xx;
 
685
+    matrix.y0 = -dim.y () * matrix.yy;
 
686
+#else
 
687
+
 
688
     if (GL::textureNonPowerOfTwo ||
 
689
        (POWER_OF_TWO (dim.width ()) && POWER_OF_TWO (dim.height ())))
 
690
     {
 
691
@@ -129,6 +137,7 @@
 
692
        matrix.x0 = -dim.x ();
 
693
        matrix.y0 = -dim.y ();
 
694
     }
 
695
+#endif
 
696
 
 
697
     setData (target, matrix, false);
 
698
     setGeometry (dim.x1 (), dim.y1 (), dim.x2 () - dim.x1 (), dim.y2 () - dim.y1 ());
 
699
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/cube/CMakeLists.txt linaro-gles2-debianpatches/plugins/cube/CMakeLists.txt
 
700
--- compiz-0.9.7.8/plugins/cube/CMakeLists.txt  2012-04-26 08:47:01.000000000 +0200
 
701
+++ linaro-gles2-debianpatches/plugins/cube/CMakeLists.txt      2012-04-20 11:41:59.241600000 +0200
 
702
@@ -2,4 +2,4 @@
 
703
 
 
704
 include (CompizPlugin)
 
705
 
 
706
-compiz_plugin(cube PLUGINDEPS composite opengl)
 
707
\ Kein Zeilenumbruch am Dateiende.
 
708
+#compiz_plugin(cube PLUGINDEPS composite opengl)
 
709
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/cube/src/cube.cpp linaro-gles2-debianpatches/plugins/cube/src/cube.cpp
 
710
--- compiz-0.9.7.8/plugins/cube/src/cube.cpp    2012-04-26 08:47:01.000000000 +0200
 
711
+++ linaro-gles2-debianpatches/plugins/cube/src/cube.cpp        2012-04-20 11:41:59.241600000 +0200
 
712
@@ -1123,7 +1123,6 @@
 
713
     if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))
 
714
     {
 
715
        priv->gScreen->setTexEnvMode (GL_MODULATE);
 
716
-       glEnable (GL_BLEND);
 
717
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
718
     }
 
719
 
 
720
@@ -1149,7 +1148,6 @@
 
721
     glEnableClientState (GL_TEXTURE_COORD_ARRAY);
 
722
 
 
723
     priv->gScreen->setTexEnvMode (GL_REPLACE);
 
724
-    glDisable (GL_BLEND);
 
725
     glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
726
 }
 
727
 
 
728
@@ -1190,7 +1188,6 @@
 
729
     if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))
 
730
     {
 
731
        priv->gScreen->setTexEnvMode (GL_MODULATE);
 
732
-       glEnable (GL_BLEND);
 
733
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
734
     }
 
735
 
 
736
@@ -1206,7 +1203,6 @@
 
737
     glEnableClientState (GL_TEXTURE_COORD_ARRAY);
 
738
 
 
739
     priv->gScreen->setTexEnvMode (GL_REPLACE);
 
740
-    glDisable (GL_BLEND);
 
741
     glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
742
 }
 
743
 
 
744
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/decor/src/decor.cpp linaro-gles2-debianpatches/plugins/decor/src/decor.cpp
 
745
--- compiz-0.9.7.8/plugins/decor/src/decor.cpp  2012-04-26 08:47:01.000000000 +0200
 
746
+++ linaro-gles2-debianpatches/plugins/decor/src/decor.cpp      2012-04-26 12:34:44.027302000 +0200
 
747
@@ -177,15 +177,13 @@
 
748
  */
 
749
 
 
750
 bool
 
751
-DecorWindow::glDraw (const GLMatrix     &transform,
 
752
-                    GLFragment::Attrib &attrib,
 
753
-                    const CompRegion   &region,
 
754
-                    unsigned int       mask)
 
755
+DecorWindow::glDraw (const GLMatrix            &transform,
 
756
+                    const GLWindowPaintAttrib &attrib,
 
757
+                    const CompRegion          &region,
 
758
+                    unsigned int              mask)
 
759
 {
 
760
     bool status;
 
761
 
 
762
-    status = gWindow->glDraw (transform, attrib, region, mask);
 
763
-
 
764
     /* Don't render dock decorations (shadows) on just any old window */
 
765
     if (!(window->type () & CompWindowTypeDockMask))
 
766
     {
 
767
@@ -205,15 +203,19 @@
 
768
        }
 
769
     }
 
770
 
 
771
+    status = gWindow->glDraw (transform, attrib, region, mask);
 
772
+
 
773
     return status;
 
774
 }
 
775
 
 
776
 void
 
777
-DecorWindow::glDecorate (const GLMatrix     &transform,
 
778
-                        GLFragment::Attrib &attrib,
 
779
-                        const CompRegion   &region,
 
780
-                        unsigned int       mask)
 
781
+DecorWindow::glDecorate (const GLMatrix            &transform,
 
782
+                        const GLWindowPaintAttrib &attrib,
 
783
+                        const CompRegion          &region,
 
784
+                        unsigned int              mask)
 
785
 {
 
786
+    GLboolean isBlendingEnabled;
 
787
+
 
788
     if (wd &&
 
789
        wd->decor->type == WINDOW_DECORATION_TYPE_PIXMAP)
 
790
     {
 
791
@@ -245,7 +247,7 @@
 
792
 
 
793
        const CompRegion &reg (*preg);
 
794
 
 
795
-       gWindow->geometry ().reset ();
 
796
+       gWindow->vertexBuffer ()->begin ();
 
797
 
 
798
        for (int i = 0; i < wd->nQuad; i++)
 
799
        {
 
800
@@ -262,9 +264,14 @@
 
801
            }
 
802
        }
 
803
 
 
804
-       if (gWindow->geometry ().vCount)
 
805
-           gWindow->glDrawTexture (wd->decor->texture->textures[0],
 
806
-                                   attrib, mask);
 
807
+       gWindow->vertexBuffer ()->end ();
 
808
+
 
809
+       glGetBooleanv (GL_BLEND, &isBlendingEnabled);
 
810
+       glEnable (GL_BLEND);
 
811
+       gWindow->glDrawTexture (wd->decor->texture->textures[0], transform,
 
812
+                               attrib, mask);
 
813
+       if (!isBlendingEnabled)
 
814
+           glDisable (GL_BLEND);
 
815
     }
 
816
     else if (wd && wd->decor->type == WINDOW_DECORATION_TYPE_WINDOW)
 
817
     {
 
818
@@ -275,14 +282,18 @@
 
819
        if (gWindow->textures ().empty ())
 
820
            return;
 
821
 
 
822
+       glGetBooleanv (GL_BLEND, &isBlendingEnabled);
 
823
+       glEnable (GL_BLEND);
 
824
+
 
825
        if (gWindow->textures ().size () == 1)
 
826
        {
 
827
            ml[0] = gWindow->matrices ()[0];
 
828
-           gWindow->geometry ().reset ();
 
829
+           gWindow->vertexBuffer ()->begin ();
 
830
            gWindow->glAddGeometry (ml, window->frameRegion (), region);
 
831
+           gWindow->vertexBuffer ()->end ();
 
832
 
 
833
-           if (gWindow->geometry ().vCount)
 
834
-               gWindow->glDrawTexture (gWindow->textures ()[0], attrib, mask);
 
835
+           gWindow->glDrawTexture (gWindow->textures ()[0], transform,
 
836
+                                   attrib, mask);
 
837
        }
 
838
        else
 
839
        {
 
840
@@ -291,14 +302,17 @@
 
841
            for (unsigned int i = 0; i < gWindow->textures ().size (); i++)
 
842
            {
 
843
                ml[0] = gWindow->matrices ()[i];
 
844
-               gWindow->geometry ().reset ();
 
845
+               gWindow->vertexBuffer ()->begin ();
 
846
                gWindow->glAddGeometry (ml, regions[i], region);
 
847
+               gWindow->vertexBuffer ()->end ();
 
848
 
 
849
-               if (gWindow->geometry ().vCount)
 
850
-                   gWindow->glDrawTexture (gWindow->textures ()[i], attrib,
 
851
-                                           mask);
 
852
+               gWindow->glDrawTexture (gWindow->textures ()[i], transform,
 
853
+                                       attrib, mask);
 
854
            }
 
855
        }
 
856
+
 
857
+       if (!isBlendingEnabled)
 
858
+           glDisable (GL_BLEND);
 
859
     }
 
860
 }
 
861
 
 
862
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/decor/src/decor.h linaro-gles2-debianpatches/plugins/decor/src/decor.h
 
863
--- compiz-0.9.7.8/plugins/decor/src/decor.h    2012-04-26 08:47:01.000000000 +0200
 
864
+++ linaro-gles2-debianpatches/plugins/decor/src/decor.h        2012-04-26 12:34:44.027302000 +0200
 
865
@@ -252,10 +252,10 @@
 
866
 
 
867
        void computeShadowRegion ();
 
868
 
 
869
-       bool glDraw (const GLMatrix &, GLFragment::Attrib &,
 
870
+       bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
 
871
                     const CompRegion &, unsigned int);
 
872
-       void glDecorate (const GLMatrix &, GLFragment::Attrib &,
 
873
-                        const CompRegion &, unsigned int);
 
874
+       void glDecorate (const GLMatrix &, const GLWindowPaintAttrib &,
 
875
+                        const CompRegion &, unsigned int);
 
876
 
 
877
        void windowNotify (CompWindowNotify n);
 
878
 
 
879
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/imgsvg/src/imgsvg.cpp linaro-gles2-debianpatches/plugins/imgsvg/src/imgsvg.cpp
 
880
--- compiz-0.9.7.8/plugins/imgsvg/src/imgsvg.cpp        2012-04-26 08:47:01.000000000 +0200
 
881
+++ linaro-gles2-debianpatches/plugins/imgsvg/src/imgsvg.cpp    2012-04-20 11:41:59.241600000 +0200
 
882
@@ -220,12 +220,12 @@
 
883
 }
 
884
 
 
885
 bool
 
886
-SvgWindow::glDraw (const GLMatrix     &transform,
 
887
-                  GLFragment::Attrib &fragment,
 
888
-                  const CompRegion   &region,
 
889
-                  unsigned int       mask)
 
890
+SvgWindow::glDraw (const GLMatrix            &transform,
 
891
+                  const GLWindowPaintAttrib &attrib,
 
892
+                  const CompRegion          &region,
 
893
+                  unsigned int              mask)
 
894
 {
 
895
-    bool status = gWindow->glDraw (transform, fragment, region, mask);
 
896
+    bool status = gWindow->glDraw (transform, attrib, region, mask);
 
897
 
 
898
     if (!status)
 
899
        return status;
 
900
@@ -251,13 +251,15 @@
 
901
        {
 
902
            matrix[0] = context->texture[0].matrices[i];
 
903
 
 
904
-           gWindow->geometry ().reset ();
 
905
+           gWindow->vertexBuffer ()->begin ();
 
906
            gWindow->glAddGeometry (matrix, context->box, reg);
 
907
+           gWindow->vertexBuffer ()->end ();
 
908
 
 
909
            if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
 
910
                mask |= PAINT_WINDOW_BLEND_MASK;
 
911
 
 
912
-           gWindow->glDrawTexture (context->texture[0].textures[i], fragment, mask);
 
913
+           gWindow->glDrawTexture (context->texture[0].textures[i], transform,
 
914
+                                   attrib, mask);
 
915
 
 
916
            if (rect.width () > 0 && rect.height () > 0)
 
917
            {
 
918
@@ -321,11 +323,12 @@
 
919
                    saveFilter = gScreen->filter (SCREEN_TRANS_FILTER);
 
920
                    gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good);
 
921
 
 
922
-                   gWindow->geometry ().reset ();
 
923
+                   gWindow->vertexBuffer ()->begin ();
 
924
                    gWindow->glAddGeometry (matrix, r, reg);
 
925
+                   gWindow->vertexBuffer ()->end ();
 
926
 
 
927
                    gWindow->glDrawTexture (context->texture[1].textures[j],
 
928
-                                           fragment, mask);
 
929
+                                           transform, attrib, mask);
 
930
 
 
931
                    gScreen->setFilter (SCREEN_TRANS_FILTER, saveFilter);
 
932
                }
 
933
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/imgsvg/src/imgsvg.h linaro-gles2-debianpatches/plugins/imgsvg/src/imgsvg.h
 
934
--- compiz-0.9.7.8/plugins/imgsvg/src/imgsvg.h  2012-04-26 08:47:01.000000000 +0200
 
935
+++ linaro-gles2-debianpatches/plugins/imgsvg/src/imgsvg.h      2012-04-20 11:41:59.241600000 +0200
 
936
@@ -76,7 +76,8 @@
 
937
        SvgWindow (CompWindow *window);
 
938
        ~SvgWindow ();
 
939
 
 
940
-       bool glDraw (const GLMatrix &transform, GLFragment::Attrib &fragment,
 
941
+       bool glDraw (const GLMatrix &transform,
 
942
+                    const GLWindowPaintAttrib &attrib,
 
943
                     const CompRegion &region, unsigned int mask);
 
944
        void moveNotify (int dx, int dy, bool immediate);
 
945
        void resizeNotify (int dx, int dy, int dwidth, int dheight);
 
946
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/obs/src/obs.cpp linaro-gles2-debianpatches/plugins/obs/src/obs.cpp
 
947
--- compiz-0.9.7.8/plugins/obs/src/obs.cpp      2012-04-26 08:47:01.000000000 +0200
 
948
+++ linaro-gles2-debianpatches/plugins/obs/src/obs.cpp  2012-04-20 11:41:59.241600000 +0200
 
949
@@ -151,29 +151,30 @@
 
950
         we wrap into glDrawWindow here */
 
951
 
 
952
 bool
 
953
-ObsWindow::glDraw (const GLMatrix&     transform,
 
954
-                  GLFragment::Attrib& attrib,
 
955
-                  const CompRegion&   region,
 
956
-                  unsigned int        mask)
 
957
+ObsWindow::glDraw (const GLMatrix            &transform,
 
958
+                  const GLWindowPaintAttrib &attrib,
 
959
+                  const CompRegion          &region,
 
960
+                  unsigned int              mask)
 
961
 {
 
962
+    GLWindowPaintAttrib wAttrib (attrib);
 
963
     int factor;
 
964
 
 
965
     factor = customFactor[MODIFIER_OPACITY];
 
966
     if (factor != 100)
 
967
     {
 
968
-       attrib.setOpacity (factor * attrib.getOpacity () / 100);
 
969
+       wAttrib.opacity = factor * wAttrib.opacity / 100;
 
970
        mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
 
971
     }
 
972
 
 
973
     factor = customFactor[MODIFIER_BRIGHTNESS];
 
974
     if (factor != 100)
 
975
-       attrib.setBrightness (factor * attrib.getBrightness () / 100);
 
976
+       wAttrib.brightness = factor * wAttrib.brightness / 100;
 
977
 
 
978
     factor = customFactor[MODIFIER_SATURATION];
 
979
     if (factor != 100)
 
980
-       attrib.setSaturation (factor * attrib.getSaturation () / 100);
 
981
+       wAttrib.saturation = factor * wAttrib.saturation / 100;
 
982
 
 
983
-    return gWindow->glDraw (transform, attrib, region, mask);
 
984
+    return gWindow->glDraw (transform, wAttrib, region, mask);
 
985
 }
 
986
 
 
987
 void
 
988
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/obs/src/obs.h linaro-gles2-debianpatches/plugins/obs/src/obs.h
 
989
--- compiz-0.9.7.8/plugins/obs/src/obs.h        2012-04-26 08:47:01.000000000 +0200
 
990
+++ linaro-gles2-debianpatches/plugins/obs/src/obs.h    2012-04-20 11:41:59.241600000 +0200
 
991
@@ -66,7 +66,7 @@
 
992
 
 
993
        bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
 
994
                      const CompRegion &, unsigned int);
 
995
-       bool glDraw (const GLMatrix &, GLFragment::Attrib &,
 
996
+       bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
 
997
                     const CompRegion &, unsigned int);
 
998
 
 
999
        void changePaintModifier (unsigned int, int);
 
1000
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/CMakeLists.txt linaro-gles2-debianpatches/plugins/opengl/CMakeLists.txt
 
1001
--- compiz-0.9.7.8/plugins/opengl/CMakeLists.txt        2012-04-26 08:47:01.000000000 +0200
 
1002
+++ linaro-gles2-debianpatches/plugins/opengl/CMakeLists.txt    2012-04-20 11:41:59.241600000 +0200
 
1003
@@ -2,7 +2,12 @@
 
1004
 
 
1005
 include (CompizPlugin)
 
1006
 
 
1007
-find_package (OpenGL)
 
1008
-if (OPENGL_FOUND)
 
1009
-    compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
 
1010
-endif ()
 
1011
\ Kein Zeilenumbruch am Dateiende.
 
1012
+if (USE_GLES)
 
1013
+    compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD "-DUSE_GLES -std=c++0x" LIBRARIES ${OPENGLES2_LIBRARIES} INCDIRS ${OPENGLES2_INCLUDE_DIR})
 
1014
+else (USE_GLES)
 
1015
+    find_package (OpenGL)
 
1016
+    if (OPENGL_FOUND)
 
1017
+       compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD -std=c++0x LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
 
1018
+    endif (OPENGL_FOUND)
 
1019
+endif (USE_GLES)
 
1020
+
 
1021
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/compiz-opengl.pc.in linaro-gles2-debianpatches/plugins/opengl/compiz-opengl.pc.in
 
1022
--- compiz-0.9.7.8/plugins/opengl/compiz-opengl.pc.in   2012-04-26 08:47:01.000000000 +0200
 
1023
+++ linaro-gles2-debianpatches/plugins/opengl/compiz-opengl.pc.in       2012-04-20 11:41:59.241600000 +0200
 
1024
@@ -8,5 +8,5 @@
 
1025
 Version: @VERSION@
 
1026
 
 
1027
 Requires: compiz compiz-composite
 
1028
-Libs: -lGL -L${libdir} -lopengl
 
1029
-Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz
 
1030
\ Kein Zeilenumbruch am Dateiende.
 
1031
+Libs: @PKGCONFIG_LIBS@ -L${libdir} -lopengl
 
1032
+Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz
 
1033
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/include/opengl/fragment.h linaro-gles2-debianpatches/plugins/opengl/include/opengl/fragment.h
 
1034
--- compiz-0.9.7.8/plugins/opengl/include/opengl/fragment.h     2012-04-26 08:47:01.000000000 +0200
 
1035
+++ linaro-gles2-debianpatches/plugins/opengl/include/opengl/fragment.h 1970-01-01 01:00:00.000000000 +0100
 
1036
@@ -1,125 +0,0 @@
 
1037
-/*
 
1038
- * Copyright © 2008 Dennis Kasprzyk
 
1039
- * Copyright © 2007 Novell, Inc.
 
1040
- *
 
1041
- * Permission to use, copy, modify, distribute, and sell this software
 
1042
- * and its documentation for any purpose is hereby granted without
 
1043
- * fee, provided that the above copyright notice appear in all copies
 
1044
- * and that both that copyright notice and this permission notice
 
1045
- * appear in supporting documentation, and that the name of
 
1046
- * Dennis Kasprzyk not be used in advertising or publicity pertaining to
 
1047
- * distribution of the software without specific, written prior permission.
 
1048
- * Dennis Kasprzyk makes no representations about the suitability of this
 
1049
- * software for any purpose. It is provided "as is" without express or
 
1050
- * implied warranty.
 
1051
- *
 
1052
- * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
1053
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
1054
- * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
1055
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
1056
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
1057
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
1058
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
1059
- *
 
1060
- * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
 
1061
- *          David Reveman <davidr@novell.com>
 
1062
- */
 
1063
-
 
1064
-#ifndef _GLFRAGMENT_H
 
1065
-#define _GLFRAGMENT_H
 
1066
-
 
1067
-#define MAX_FRAGMENT_FUNCTIONS 16
 
1068
-
 
1069
-#define COMP_FETCH_TARGET_2D   0
 
1070
-#define COMP_FETCH_TARGET_RECT 1
 
1071
-#define COMP_FETCH_TARGET_NUM  2
 
1072
-
 
1073
-struct GLWindowPaintAttrib;
 
1074
-class GLScreen;
 
1075
-class GLTexture;
 
1076
-
 
1077
-/**
 
1078
- * Describes a texture modification fragment program
 
1079
- * for a texture
 
1080
- */
 
1081
-namespace GLFragment {
 
1082
-
 
1083
-    class Storage;
 
1084
-
 
1085
-    typedef unsigned int FunctionId;
 
1086
-
 
1087
-    class PrivateFunctionData;
 
1088
-    class PrivateAttrib;
 
1089
-
 
1090
-    class FunctionData {
 
1091
-       public:
 
1092
-           FunctionData ();
 
1093
-           ~FunctionData ();
 
1094
-
 
1095
-           /**
 
1096
-            * Returns the status of this fragment program
 
1097
-            * (valid or invalid)
 
1098
-            */
 
1099
-           bool status ();
 
1100
-
 
1101
-           void addTempHeaderOp (const char *name);
 
1102
-
 
1103
-           void addParamHeaderOp (const char *name);
 
1104
-
 
1105
-           void addAttribHeaderOp (const char *name);
 
1106
-
 
1107
-
 
1108
-           void addFetchOp (const char *dst, const char *offset, int target);
 
1109
-
 
1110
-           void addColorOp (const char *dst, const char *src);
 
1111
-
 
1112
-           void addDataOp (const char *str, ...);
 
1113
-
 
1114
-           void addBlendOp (const char *str, ...);
 
1115
-
 
1116
-           FunctionId createFragmentFunction (const char *name);
 
1117
-
 
1118
-       private:
 
1119
-           PrivateFunctionData *priv;
 
1120
-    };
 
1121
-
 
1122
-    class Attrib {
 
1123
-       public:
 
1124
-           Attrib (const GLWindowPaintAttrib &paint);
 
1125
-           Attrib (const Attrib&);
 
1126
-           ~Attrib ();
 
1127
-
 
1128
-           Attrib &operator= (const Attrib &rhs);
 
1129
-
 
1130
-           unsigned int allocTextureUnits (unsigned int nTexture);
 
1131
-
 
1132
-           unsigned int allocParameters (unsigned int nParam);
 
1133
-
 
1134
-           void addFunction (FunctionId function);
 
1135
-
 
1136
-           bool enable (bool *blending);
 
1137
-           void disable ();
 
1138
-
 
1139
-           unsigned short getSaturation ();
 
1140
-           unsigned short getBrightness ();
 
1141
-           unsigned short getOpacity ();
 
1142
-
 
1143
-           void setSaturation (unsigned short);
 
1144
-           void setBrightness (unsigned short);
 
1145
-           void setOpacity (unsigned short);
 
1146
-
 
1147
-           bool hasFunctions ();
 
1148
-
 
1149
-       private:
 
1150
-           PrivateAttrib *priv;
 
1151
-    };
 
1152
-
 
1153
-    void destroyFragmentFunction (FunctionId id);
 
1154
-
 
1155
-    FunctionId getSaturateFragmentFunction (GLTexture *texture,
 
1156
-                                           int       param);
 
1157
-};
 
1158
-
 
1159
-
 
1160
-
 
1161
-#endif
 
1162
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/include/opengl/framebufferobject.h linaro-gles2-debianpatches/plugins/opengl/include/opengl/framebufferobject.h
 
1163
--- compiz-0.9.7.8/plugins/opengl/include/opengl/framebufferobject.h    1970-01-01 01:00:00.000000000 +0100
 
1164
+++ linaro-gles2-debianpatches/plugins/opengl/include/opengl/framebufferobject.h        2012-04-20 11:41:59.241600000 +0200
 
1165
@@ -0,0 +1,107 @@
 
1166
+/*
 
1167
+ * Copyright (c) 2011 Collabora, Ltd.
 
1168
+ *
 
1169
+ * Permission to use, copy, modify, distribute, and sell this software
 
1170
+ * and its documentation for any purpose is hereby granted without
 
1171
+ * fee, provided that the above copyright notice appear in all copies
 
1172
+ * and that both that copyright notice and this permission notice
 
1173
+ * appear in supporting documentation, and that the name of
 
1174
+ * Collabora Ltd. not be used in advertising or publicity pertaining to
 
1175
+ * distribution of the software without specific, written prior permission.
 
1176
+ * Collabora Ltd. makes no representations about the suitability of this
 
1177
+ * software for any purpose. It is provided "as is" without express or
 
1178
+ * implied warranty.
 
1179
+ *
 
1180
+ * COLLABORA LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
1181
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
1182
+ * NO EVENT SHALL COLLABORA LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
1183
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
1184
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
1185
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
1186
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
1187
+ *
 
1188
+ * Authors: Pekka Paalanen <ppaalanen@gmail.com>
 
1189
+ */
 
1190
+
 
1191
+#ifndef _COMPIZ_GLFRAMEBUFFEROBJECT_H
 
1192
+#define _COMPIZ_GLFRAMEBUFFEROBJECT_H
 
1193
+
 
1194
+#include <opengl/opengl.h>
 
1195
+
 
1196
+struct PrivateGLFramebufferObject;
 
1197
+
 
1198
+/**
 
1199
+ * Class representing a framebuffer object in GL, supporting only one
 
1200
+ * color attachment as per GLES 2 spec. The color attachment is referred
 
1201
+ * to as the texture (of the FBO).
 
1202
+ *
 
1203
+ * Usage:
 
1204
+ * 1. create a GLFramebufferObject (requires a GL context)
 
1205
+ * 2. call allocate (size), and check status ()
 
1206
+ * 3. old = bind ()
 
1207
+ * 4. do your rendering
 
1208
+ * 5. rebind (old)
 
1209
+ * 6. use the rendered texture via tex ()
 
1210
+ * 7. go to 2 or 3, or delete to quit (requires a GL context)
 
1211
+ *
 
1212
+ * TODO: add depth/stencil attachments
 
1213
+ * FIXME: written for OpenGL ES 2 only, desktop OpenGL might not work.
 
1214
+ */
 
1215
+class GLFramebufferObject
 
1216
+{
 
1217
+    public:
 
1218
+       GLFramebufferObject ();
 
1219
+       ~GLFramebufferObject ();
 
1220
+
 
1221
+       /**
 
1222
+        * Ensure the texture is of the given size, recreating it if needed,
 
1223
+        * and replace the FBO color attachment with it. The texture contents
 
1224
+        * become undefined, unless specified in the 'image' argument.
 
1225
+        * When specifying 'image', it's also possible to pass-in the
 
1226
+        * desired image's 'format' and 'type'.
 
1227
+        *
 
1228
+        * Returns true on success, and false on texture allocation failure.
 
1229
+        */
 
1230
+       bool allocate (const CompSize &size,
 
1231
+                      const char *image = NULL,
 
1232
+                      GLenum format = GL_RGBA,
 
1233
+                      GLenum type = GL_UNSIGNED_BYTE);
 
1234
+
 
1235
+       /**
 
1236
+        * Bind this as the current FBO, previous binding in GL context is
 
1237
+        * undone. GL rendering is now targeted to this FBO.
 
1238
+        * Returns a pointer to the previously bound FBO, or NULL if
 
1239
+        * the previous binding was zero (the window system provided
 
1240
+        * framebuffer).
 
1241
+        *
 
1242
+        * The previous FBO is no longer bound, so you can use its
 
1243
+        * texture. To restore the previous FBO, call rebind (FBO) with
 
1244
+        * the returned pointer as the argument.
 
1245
+        */
 
1246
+       GLFramebufferObject *bind ();
 
1247
+
 
1248
+       /**
 
1249
+        * Bind the given FBO as the current FBO, without looking up the
 
1250
+        * previous binding. The argument can be NULL, in which case the
 
1251
+        * window system provided framebuffer gets bound (FBO is unbound).
 
1252
+        */
 
1253
+       static void rebind (GLFramebufferObject *fbo);
 
1254
+
 
1255
+       /**
 
1256
+        * Check the FBO completeness. Returns true on complete.
 
1257
+        * Otherwise returns false and reports the error to log.
 
1258
+        */
 
1259
+       bool checkStatus ();
 
1260
+
 
1261
+       /**
 
1262
+        * Return a pointer to the texture that is the color attachment.
 
1263
+        * This will return NULL, if allocate () has not been called, or
 
1264
+        * the last allocate () call failed.
 
1265
+        */
 
1266
+       GLTexture *tex ();
 
1267
+
 
1268
+    private:
 
1269
+       PrivateGLFramebufferObject *priv;
 
1270
+};
 
1271
+
 
1272
+#endif // _COMPIZ_GLFRAMEBUFFEROBJECT_H
 
1273
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/include/opengl/matrix.h linaro-gles2-debianpatches/plugins/opengl/include/opengl/matrix.h
 
1274
--- compiz-0.9.7.8/plugins/opengl/include/opengl/matrix.h       2012-04-26 08:47:01.000000000 +0200
 
1275
+++ linaro-gles2-debianpatches/plugins/opengl/include/opengl/matrix.h   2012-04-20 11:41:59.241600000 +0200
 
1276
@@ -44,6 +44,8 @@
 
1277
        void reset ();
 
1278
        void toScreenSpace (const CompOutput *output, float z);
 
1279
 
 
1280
+       bool invert ();
 
1281
+
 
1282
        void rotate (const float angle, const float x,
 
1283
                     const float y, const float z);
 
1284
        void rotate (const float angle, const GLVector& vector);
 
1285
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/include/opengl/opengl.h linaro-gles2-debianpatches/plugins/opengl/include/opengl/opengl.h
 
1286
--- compiz-0.9.7.8/plugins/opengl/include/opengl/opengl.h       2012-04-26 08:47:01.000000000 +0200
 
1287
+++ linaro-gles2-debianpatches/plugins/opengl/include/opengl/opengl.h   2012-04-20 11:41:59.241600000 +0200
 
1288
@@ -28,16 +28,45 @@
 
1289
 #ifndef _COMPIZ_OPENGL_H
 
1290
 #define _COMPIZ_OPENGL_H
 
1291
 
 
1292
+#ifdef USE_GLES
 
1293
+#define SUPPORT_X11
 
1294
+#include <GLES2/gl2.h>
 
1295
+#include <GLES2/gl2ext.h>
 
1296
+#include <EGL/egl.h>
 
1297
+#include <EGL/eglext.h>
 
1298
+#else
 
1299
 #include <GL/gl.h>
 
1300
 #include <GL/glx.h>
 
1301
+#endif
 
1302
+
 
1303
+#include <core/size.h>
 
1304
+#include <core/pluginclasshandler.h>
 
1305
 
 
1306
 #include <opengl/matrix.h>
 
1307
 #include <opengl/texture.h>
 
1308
-#include <opengl/fragment.h>
 
1309
+#include <opengl/framebufferobject.h>
 
1310
+#include <opengl/vertexbuffer.h>
 
1311
+#include <opengl/program.h>
 
1312
+#include <opengl/programcache.h>
 
1313
+#include <opengl/shadercache.h>
 
1314
 
 
1315
 #define COMPIZ_OPENGL_ABI 4
 
1316
 
 
1317
-#include <core/pluginclasshandler.h>
 
1318
+#if !defined(GL_BGRA)
 
1319
+    #if !defined(GL_BGRA_EXT)
 
1320
+       #error GL_BGRA support is required
 
1321
+    #else
 
1322
+       #define GL_BGRA GL_BGRA_EXT
 
1323
+    #endif
 
1324
+#endif
 
1325
+
 
1326
+#if !defined(GL_BGRA)
 
1327
+    #if !defined(GL_BGRA_EXT)
 
1328
+       #error GL_BGRA support is required
 
1329
+    #else
 
1330
+       #define GL_BGRA GL_BGRA_EXT
 
1331
+    #endif
 
1332
+#endif
 
1333
 
 
1334
 /**
 
1335
  * camera distance from screen, 0.5 * tan (FOV)
 
1336
@@ -75,8 +104,26 @@
 
1337
 #endif
 
1338
 
 
1339
 namespace GL {
 
1340
+    #ifdef USE_GLES
 
1341
+    typedef EGLImageKHR (*EGLCreateImageKHRProc)  (EGLDisplay dpy,
 
1342
+                                                   EGLContext ctx,
 
1343
+                                                   EGLenum target,
 
1344
+                                                   EGLClientBuffer buffer,
 
1345
+                                                   const EGLint *attrib_list);
 
1346
+    typedef EGLBoolean  (*EGLDestroyImageKHRProc) (EGLDisplay dpy,
 
1347
+                                                   EGLImageKHR image);
 
1348
+
 
1349
+    typedef void (*GLEGLImageTargetTexture2DOESProc) (GLenum target,
 
1350
+                                                      GLeglImageOES image);
 
1351
+
 
1352
+    typedef EGLBoolean (*EGLPostSubBufferNVProc) (EGLDisplay dpy,
 
1353
+                                                 EGLSurface surface,
 
1354
+                                                 EGLint x, EGLint y,
 
1355
+                                                 EGLint width, EGLint height);
 
1356
 
 
1357
+    #else
 
1358
     typedef void (*FuncPtr) (void);
 
1359
+
 
1360
     typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
 
1361
 
 
1362
     typedef void    (*GLXBindTexImageProc)    (Display  *display,
 
1363
@@ -122,11 +169,6 @@
 
1364
                                              const int   *attribList);
 
1365
     typedef void      (*GLXDestroyPixmapProc) (Display *display,
 
1366
                                               GLXPixmap pixmap);
 
1367
-
 
1368
-    typedef void (*GLActiveTextureProc) (GLenum texture);
 
1369
-    typedef void (*GLClientActiveTextureProc) (GLenum texture);
 
1370
-    typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
 
1371
-
 
1372
     typedef void (*GLGenProgramsProc) (GLsizei n,
 
1373
                                       GLuint  *programs);
 
1374
     typedef void (*GLDeleteProgramsProc) (GLsizei n,
 
1375
@@ -146,11 +188,16 @@
 
1376
     typedef void (*GLGetProgramivProc) (GLenum target,
 
1377
                                        GLenum pname,
 
1378
                                        int    *params);
 
1379
+    #endif
 
1380
+
 
1381
+    typedef void (*GLActiveTextureProc) (GLenum texture);
 
1382
+    typedef void (*GLClientActiveTextureProc) (GLenum texture);
 
1383
+    typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
 
1384
 
 
1385
     typedef void (*GLGenFramebuffersProc) (GLsizei n,
 
1386
                                           GLuint  *framebuffers);
 
1387
     typedef void (*GLDeleteFramebuffersProc) (GLsizei n,
 
1388
-                                             GLuint  *framebuffers);
 
1389
+                                             const GLuint  *framebuffers);
 
1390
     typedef void (*GLBindFramebufferProc) (GLenum target,
 
1391
                                           GLuint framebuffer);
 
1392
     typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target);
 
1393
@@ -161,6 +208,96 @@
 
1394
                                                GLint  level);
 
1395
     typedef void (*GLGenerateMipmapProc) (GLenum target);
 
1396
 
 
1397
+    typedef void (*GLBindBufferProc) (GLenum target,
 
1398
+                                      GLuint buffer);
 
1399
+    typedef void (*GLDeleteBuffersProc) (GLsizei n,
 
1400
+                                         const GLuint *buffers);
 
1401
+    typedef void (*GLGenBuffersProc) (GLsizei n,
 
1402
+                                      GLuint *buffers);
 
1403
+    typedef void (*GLBufferDataProc) (GLenum target,
 
1404
+                                      GLsizeiptr size,
 
1405
+                                      const GLvoid *data,
 
1406
+                                      GLenum usage);
 
1407
+    typedef void (*GLBufferSubDataProc) (GLenum target,
 
1408
+                                         GLintptr offset,
 
1409
+                                         GLsizeiptr size,
 
1410
+                                         const GLvoid *data);
 
1411
+
 
1412
+    typedef void (*GLGetShaderivProc) (GLuint shader,
 
1413
+                                       GLenum pname,
 
1414
+                                       GLint *params);
 
1415
+    typedef void (*GLGetShaderInfoLogProc) (GLuint shader,
 
1416
+                                            GLsizei bufsize,
 
1417
+                                            GLsizei *length,
 
1418
+                                            GLchar *infoLog);
 
1419
+    typedef void (*GLGetProgramivProc) (GLuint program,
 
1420
+                                        GLenum pname,
 
1421
+                                        GLint* params);
 
1422
+    typedef void (*GLGetProgramInfoLogProc) (GLuint program,
 
1423
+                                             GLsizei bufsize,
 
1424
+                                             GLsizei *length,
 
1425
+                                             GLchar *infoLog);
 
1426
+    typedef GLuint (*GLCreateShaderProc) (GLenum type);
 
1427
+    typedef void (*GLShaderSourceProc) (GLuint shader,
 
1428
+                                        GLsizei count,
 
1429
+                                        const GLchar **string,
 
1430
+                                        const GLint* length);
 
1431
+    typedef void (*GLCompileShaderProc) (GLuint shader);
 
1432
+    typedef GLuint (*GLCreateProgramProc) ();
 
1433
+    typedef void (*GLAttachShaderProc) (GLuint program,
 
1434
+                                        GLuint shader);
 
1435
+    typedef void (*GLLinkProgramProc) (GLuint program);
 
1436
+    typedef void (*GLValidateProgramProc) (GLuint program);
 
1437
+    typedef void (*GLDeleteShaderProc) (GLuint shader);
 
1438
+    typedef void (*GLDeleteProgramProc) (GLuint program);
 
1439
+    typedef void (*GLUseProgramProc) (GLuint program);
 
1440
+    typedef int  (*GLGetUniformLocationProc) (GLuint program,
 
1441
+                                              const GLchar* name);
 
1442
+    typedef void (*GLUniform1fProc) (GLint location, GLfloat x);
 
1443
+    typedef void (*GLUniform1iProc) (GLint location, GLint x);
 
1444
+    typedef void (*GLUniform2fProc) (GLint location, GLfloat x, GLfloat y);
 
1445
+    typedef void (*GLUniform3fProc) (GLint location,
 
1446
+                                     GLfloat x,
 
1447
+                                     GLfloat y,
 
1448
+                                     GLfloat z);
 
1449
+    typedef void (*GLUniform4fProc) (GLint location,
 
1450
+                                     GLfloat x,
 
1451
+                                     GLfloat y,
 
1452
+                                     GLfloat z,
 
1453
+                                     GLfloat w);
 
1454
+    typedef void (*GLUniform2iProc) (GLint location, GLint x, GLint y);
 
1455
+    typedef void (*GLUniform3iProc) (GLint location,
 
1456
+                                     GLint x,
 
1457
+                                     GLint y,
 
1458
+                                     GLint z);
 
1459
+    typedef void (*GLUniform4iProc) (GLint location,
 
1460
+                                     GLint x,
 
1461
+                                     GLint y,
 
1462
+                                     GLint z,
 
1463
+                                     GLint w);
 
1464
+    typedef void (*GLUniformMatrix4fvProc) (GLint location,
 
1465
+                                            GLsizei count,
 
1466
+                                            GLboolean transpose,
 
1467
+                                            const GLfloat *value);
 
1468
+    typedef int (*GLGetAttribLocationProc) (GLuint program,
 
1469
+                                            const GLchar *name);
 
1470
+
 
1471
+    typedef void (*GLEnableVertexAttribArrayProc) (GLuint index);
 
1472
+    typedef void (*GLDisableVertexAttribArrayProc) (GLuint index);
 
1473
+    typedef void (*GLVertexAttribPointerProc) (GLuint index,
 
1474
+                                               GLint size,
 
1475
+                                               GLenum type,
 
1476
+                                               GLboolean normalized,
 
1477
+                                               GLsizei stride,
 
1478
+                                               const GLvoid *ptr);
 
1479
+
 
1480
+    #ifdef USE_GLES
 
1481
+    extern EGLCreateImageKHRProc  createImage;
 
1482
+    extern EGLDestroyImageKHRProc destroyImage;
 
1483
+
 
1484
+    extern GLEGLImageTargetTexture2DOESProc eglImageTargetTexture;
 
1485
+
 
1486
+    #else
 
1487
     extern GLXBindTexImageProc      bindTexImage;
 
1488
     extern GLXReleaseTexImageProc   releaseTexImage;
 
1489
     extern GLXQueryDrawableProc     queryDrawable;
 
1490
@@ -172,11 +309,6 @@
 
1491
     extern GLXGetFBConfigAttribProc getFBConfigAttrib;
 
1492
     extern GLXCreatePixmapProc      createPixmap;
 
1493
     extern GLXDestroyPixmapProc     destroyPixmap;
 
1494
-
 
1495
-    extern GLActiveTextureProc       activeTexture;
 
1496
-    extern GLClientActiveTextureProc clientActiveTexture;
 
1497
-    extern GLMultiTexCoord2fProc     multiTexCoord2f;
 
1498
-
 
1499
     extern GLGenProgramsProc        genPrograms;
 
1500
     extern GLDeleteProgramsProc     deletePrograms;
 
1501
     extern GLBindProgramProc        bindProgram;
 
1502
@@ -184,6 +316,11 @@
 
1503
     extern GLProgramParameter4fProc programEnvParameter4f;
 
1504
     extern GLProgramParameter4fProc programLocalParameter4f;
 
1505
     extern GLGetProgramivProc       getProgramiv;
 
1506
+    #endif
 
1507
+
 
1508
+    extern GLActiveTextureProc       activeTexture;
 
1509
+    extern GLClientActiveTextureProc clientActiveTexture;
 
1510
+    extern GLMultiTexCoord2fProc     multiTexCoord2f;
 
1511
 
 
1512
     extern GLGenFramebuffersProc        genFramebuffers;
 
1513
     extern GLDeleteFramebuffersProc     deleteFramebuffers;
 
1514
@@ -192,16 +329,56 @@
 
1515
     extern GLFramebufferTexture2DProc   framebufferTexture2D;
 
1516
     extern GLGenerateMipmapProc         generateMipmap;
 
1517
 
 
1518
+    extern GLBindBufferProc    bindBuffer;
 
1519
+    extern GLDeleteBuffersProc deleteBuffers;
 
1520
+    extern GLGenBuffersProc    genBuffers;
 
1521
+    extern GLBufferDataProc    bufferData;
 
1522
+    extern GLBufferSubDataProc bufferSubData;
 
1523
+
 
1524
+
 
1525
+    extern GLGetShaderivProc        getShaderiv;
 
1526
+    extern GLGetShaderInfoLogProc   getShaderInfoLog;
 
1527
+    extern GLGetProgramivProc       getProgramiv;
 
1528
+    extern GLGetProgramInfoLogProc  getProgramInfoLog;
 
1529
+    extern GLCreateShaderProc       createShader;
 
1530
+    extern GLShaderSourceProc       shaderSource;
 
1531
+    extern GLCompileShaderProc      compileShader;
 
1532
+    extern GLCreateProgramProc      createProgram;
 
1533
+    extern GLAttachShaderProc       attachShader;
 
1534
+    extern GLLinkProgramProc        linkProgram;
 
1535
+    extern GLValidateProgramProc    validateProgram;
 
1536
+    extern GLDeleteShaderProc       deleteShader;
 
1537
+    extern GLDeleteProgramProc      deleteProgram;
 
1538
+    extern GLUseProgramProc         useProgram;
 
1539
+    extern GLGetUniformLocationProc getUniformLocation;
 
1540
+    extern GLUniform1fProc          uniform1f;
 
1541
+    extern GLUniform1iProc          uniform1i;
 
1542
+    extern GLUniform2fProc          uniform2f;
 
1543
+    extern GLUniform2iProc          uniform2i;
 
1544
+    extern GLUniform3fProc          uniform3f;
 
1545
+    extern GLUniform3iProc          uniform3i;
 
1546
+    extern GLUniform4fProc          uniform4f;
 
1547
+    extern GLUniform4iProc          uniform4i;
 
1548
+    extern GLUniformMatrix4fvProc   uniformMatrix4fv;
 
1549
+    extern GLGetAttribLocationProc  getAttribLocation;
 
1550
+
 
1551
+    extern GLEnableVertexAttribArrayProc  enableVertexAttribArray;
 
1552
+    extern GLDisableVertexAttribArrayProc disableVertexAttribArray;
 
1553
+    extern GLVertexAttribPointerProc      vertexAttribPointer;
 
1554
+
 
1555
+
 
1556
     extern bool  textureFromPixmap;
 
1557
     extern bool  textureRectangle;
 
1558
     extern bool  textureNonPowerOfTwo;
 
1559
+    extern bool  textureNonPowerOfTwoMipmap;
 
1560
     extern bool  textureEnvCombine;
 
1561
     extern bool  textureEnvCrossbar;
 
1562
     extern bool  textureBorderClamp;
 
1563
     extern bool  textureCompression;
 
1564
     extern GLint maxTextureSize;
 
1565
     extern bool  fbo;
 
1566
-    extern bool  fragmentProgram;
 
1567
+    extern bool  vbo;
 
1568
+    extern bool  shaders;
 
1569
     extern GLint maxTextureUnits;
 
1570
 
 
1571
     extern bool canDoSaturated;
 
1572
@@ -220,6 +397,7 @@
 
1573
 
 
1574
 #define MAX_DEPTH 32
 
1575
 
 
1576
+#ifndef USE_GLES
 
1577
 struct GLFBConfig {
 
1578
     GLXFBConfig fbConfig;
 
1579
     int         yInverted;
 
1580
@@ -227,6 +405,7 @@
 
1581
     int         textureFormat;
 
1582
     int         textureTargets;
 
1583
 };
 
1584
+#endif
 
1585
 
 
1586
 #define NOTHING_TRANS_FILTER 0
 
1587
 #define SCREEN_TRANS_FILTER  1
 
1588
@@ -236,6 +415,7 @@
 
1589
 extern GLScreenPaintAttrib defaultScreenPaintAttrib;
 
1590
 
 
1591
 class GLScreen;
 
1592
+class GLFramebufferObject;
 
1593
 
 
1594
 class GLScreenInterface :
 
1595
     public WrapableInterface<GLScreen, GLScreenInterface>
 
1596
@@ -302,11 +482,24 @@
 
1597
                                             CompOutput *);
 
1598
        virtual void glDisableOutputClipping ();
 
1599
 
 
1600
+       virtual GLMatrix *projectionMatrix ();
 
1601
+
 
1602
+       /**
 
1603
+        * Hookable function used by plugins to shade the final composited
 
1604
+        * Output.
 
1605
+        *
 
1606
+        * @param tmpRegion Describes the final composited output region
 
1607
+        * @param scratchFbo Describes the final composited FBO that is
 
1608
+        * to be rendered.
 
1609
+        */
 
1610
+       virtual void glPaintCompositedOutput (const CompRegion    &region,
 
1611
+                                             GLFramebufferObject *fbo,
 
1612
+                                             unsigned int         mask);
 
1613
 };
 
1614
 
 
1615
 
 
1616
 class GLScreen :
 
1617
-    public WrapableHandler<GLScreenInterface, 6>,
 
1618
+    public WrapableHandler<GLScreenInterface, 7>,
 
1619
     public PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI>,
 
1620
     public CompOption::Class
 
1621
 {
 
1622
@@ -332,7 +525,9 @@
 
1623
        /**
 
1624
         * Gets the libGL address of a particular openGL functor
 
1625
         */
 
1626
+       #ifndef USE_GLES
 
1627
        GL::FuncPtr getProcAddress (const char *name);
 
1628
+       #endif
 
1629
 
 
1630
        void updateBackground ();
 
1631
 
 
1632
@@ -346,8 +541,6 @@
 
1633
         */
 
1634
        void setFilter (int, GLTexture::Filter);
 
1635
 
 
1636
-       GLFragment::Storage * fragmentStorage ();
 
1637
-
 
1638
        /**
 
1639
         * Sets a new compiz-wid openGL texture environment mode
 
1640
         */
 
1641
@@ -356,7 +549,6 @@
 
1642
        /**
 
1643
         * Turns lighting on and off
 
1644
         */
 
1645
-
 
1646
        void setLighting (bool lighting);
 
1647
 
 
1648
        /**
 
1649
@@ -371,20 +563,35 @@
 
1650
        GLTexture::BindPixmapHandle registerBindPixmap (GLTexture::BindPixmapProc);
 
1651
        void unregisterBindPixmap (GLTexture::BindPixmapHandle);
 
1652
 
 
1653
+       #ifndef USE_GLES
 
1654
        GLFBConfig * glxPixmapFBConfig (unsigned int depth);
 
1655
+       #endif
 
1656
+
 
1657
+       #ifdef USE_GLES
 
1658
+       EGLContext getEGLContext ();
 
1659
+       #endif
 
1660
 
 
1661
        /**
 
1662
-        * Returns a default icon texture
 
1663
+        * Returns a GLProgram from the cache or creates one and caches it
 
1664
         */
 
1665
-       GLTexture *defaultIcon ();
 
1666
+       GLProgram *getProgram (std::list<const GLShaderData*>);
 
1667
 
 
1668
-       void resetRasterPos ();
 
1669
+       /**
 
1670
+        * Returns a GLShaderData from the cache or creates one and caches it
 
1671
+        */
 
1672
+       const GLShaderData *getShaderData (GLShaderParameters &params);
 
1673
 
 
1674
        /**
 
1675
-        * Returns a 4x4 const float array which
 
1676
-        * represents the current projection matrix
 
1677
+        * Returns the FBO compiz is using for the screen
 
1678
         */
 
1679
-       const float * projectionMatrix ();
 
1680
+       GLFramebufferObject *fbo ();
 
1681
+
 
1682
+       /**
 
1683
+        * Returns a default icon texture
 
1684
+        */
 
1685
+       GLTexture *defaultIcon ();
 
1686
+
 
1687
+       void resetRasterPos ();
 
1688
 
 
1689
        bool glInitContext (XVisualInfo *);
 
1690
 
 
1691
@@ -402,7 +609,12 @@
 
1692
                      const GLMatrix &, const CompRegion &, CompOutput *);
 
1693
        WRAPABLE_HND (4, GLScreenInterface, void, glDisableOutputClipping);
 
1694
 
 
1695
+       WRAPABLE_HND (5, GLScreenInterface, GLMatrix *, projectionMatrix);
 
1696
+       WRAPABLE_HND (6, GLScreenInterface, void, glPaintCompositedOutput,
 
1697
+                     const CompRegion &, GLFramebufferObject *, unsigned int);
 
1698
+
 
1699
        friend class GLTexture;
 
1700
+       friend class GLWindow;
 
1701
 
 
1702
     private:
 
1703
        PrivateGLScreen *priv;
 
1704
@@ -453,10 +665,10 @@
 
1705
         * @param region Describes which region will be drawn
 
1706
         * @param mask   Bitmask which describes how this window is drawn
 
1707
         */
 
1708
-       virtual bool glDraw (const GLMatrix     &matrix,
 
1709
-                            GLFragment::Attrib &attrib,
 
1710
-                            const CompRegion   &region,
 
1711
-                            unsigned int       mask);
 
1712
+       virtual bool glDraw (const GLMatrix            &matrix,
 
1713
+                            const GLWindowPaintAttrib &attrib,
 
1714
+                            const CompRegion          &region,
 
1715
+                            unsigned int              mask);
 
1716
 
 
1717
        /**
 
1718
         * Hookable function to add points to a window
 
1719
@@ -479,51 +691,18 @@
 
1720
                                    const CompRegion            &clipRegion,
 
1721
                                    unsigned int                min = MAXSHORT,
 
1722
                                    unsigned int                max = MAXSHORT);
 
1723
-       virtual void glDrawTexture (GLTexture *texture, GLFragment::Attrib &,
 
1724
-                                   unsigned int);
 
1725
-       virtual void glDrawGeometry ();
 
1726
+       virtual void glDrawTexture (GLTexture *texture, const GLMatrix &,
 
1727
+                                   const GLWindowPaintAttrib &, unsigned int);
 
1728
 };
 
1729
 
 
1730
 class GLWindow :
 
1731
-    public WrapableHandler<GLWindowInterface, 5>,
 
1732
+    public WrapableHandler<GLWindowInterface, 4>,
 
1733
     public PluginClassHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI>
 
1734
 {
 
1735
     public:
 
1736
 
 
1737
-       /**
 
1738
-        * Class which describes the texture geometry and transformation points
 
1739
-        * of a window
 
1740
-        */
 
1741
-       class Geometry {
 
1742
-           public:
 
1743
-               Geometry ();
 
1744
-               ~Geometry ();
 
1745
-
 
1746
-               void reset ();
 
1747
-
 
1748
-               /**
 
1749
-                * Set the number of vertices in the texture geometry
 
1750
-                */
 
1751
-               bool moreVertices (int newSize);
 
1752
-
 
1753
-               /**
 
1754
-                * Set the number of indices in the texture geometry
 
1755
-                */
 
1756
-               bool moreIndices (int newSize);
 
1757
-
 
1758
-           public:
 
1759
-               GLfloat  *vertices;
 
1760
-               int      vertexSize;
 
1761
-               int      vertexStride;
 
1762
-               GLushort *indices;
 
1763
-               int      indexSize;
 
1764
-               int      vCount;
 
1765
-               int      texUnits;
 
1766
-               int      texCoordSize;
 
1767
-               int      indexCount;
 
1768
-       };
 
1769
-
 
1770
        static GLWindowPaintAttrib defaultPaintAttrib;
 
1771
+
 
1772
     public:
 
1773
 
 
1774
        GLWindow (CompWindow *w);
 
1775
@@ -566,9 +745,20 @@
 
1776
        void updatePaintAttribs ();
 
1777
 
 
1778
        /**
 
1779
-        * Returns the window texture geometry
 
1780
+        * Returns the window vertex buffer object
 
1781
         */
 
1782
-       Geometry & geometry ();
 
1783
+       GLVertexBuffer * vertexBuffer ();
 
1784
+
 
1785
+       /**
 
1786
+        * Add a vertex and/or fragment shader function to the pipeline.
 
1787
+        *
 
1788
+        * @param name Name of the plugin adding the functions
 
1789
+        * @param vertex_shader Function to add to the vertex shader
 
1790
+        * @param fragment_shader Function to add to the fragment shader
 
1791
+        */
 
1792
+       void addShaders (std::string name,
 
1793
+                        std::string vertex_shader,
 
1794
+                        std::string fragment_shader);
 
1795
 
 
1796
        GLTexture *getIcon (int width, int height);
 
1797
 
 
1798
@@ -576,20 +766,24 @@
 
1799
                      const GLWindowPaintAttrib &, const GLMatrix &,
 
1800
                      const CompRegion &, unsigned int);
 
1801
        WRAPABLE_HND (1, GLWindowInterface, bool, glDraw, const GLMatrix &,
 
1802
-                     GLFragment::Attrib &, const CompRegion &, unsigned int);
 
1803
+                     const GLWindowPaintAttrib &, const CompRegion &,
 
1804
+                     unsigned int);
 
1805
        WRAPABLE_HND (2, GLWindowInterface, void, glAddGeometry,
 
1806
                      const GLTexture::MatrixList &, const CompRegion &,
 
1807
                      const CompRegion &,
 
1808
                      unsigned int = MAXSHORT, unsigned int = MAXSHORT);
 
1809
        WRAPABLE_HND (3, GLWindowInterface, void, glDrawTexture,
 
1810
-                     GLTexture *texture, GLFragment::Attrib &, unsigned int);
 
1811
-       WRAPABLE_HND (4, GLWindowInterface, void, glDrawGeometry);
 
1812
+                     GLTexture *texture, const GLMatrix &,
 
1813
+                     const GLWindowPaintAttrib &, unsigned int);
 
1814
 
 
1815
        friend class GLScreen;
 
1816
        friend class PrivateGLScreen;
 
1817
+       friend class SpewScreen;
 
1818
+       friend class SpewWindow;
 
1819
 
 
1820
     private:
 
1821
        PrivateGLWindow *priv;
 
1822
 };
 
1823
 
 
1824
 #endif
 
1825
+
 
1826
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/include/opengl/programcache.h linaro-gles2-debianpatches/plugins/opengl/include/opengl/programcache.h
 
1827
--- compiz-0.9.7.8/plugins/opengl/include/opengl/programcache.h 1970-01-01 01:00:00.000000000 +0100
 
1828
+++ linaro-gles2-debianpatches/plugins/opengl/include/opengl/programcache.h     2012-04-20 11:41:59.241600000 +0200
 
1829
@@ -0,0 +1,51 @@
 
1830
+/*
 
1831
+ * Copyright © 2011 Linaro Ltd.
 
1832
+ *
 
1833
+ * Permission to use, copy, modify, distribute, and sell this software
 
1834
+ * and its documentation for any purpose is hereby granted without
 
1835
+ * fee, provided that the above copyright notice appear in all copies
 
1836
+ * and that both that copyright notice and this permission notice
 
1837
+ * appear in supporting documentation, and that the name of
 
1838
+ * Linaro Ltd. not be used in advertising or publicity pertaining to
 
1839
+ * distribution of the software without specific, written prior permission.
 
1840
+ * Linaro Ltd. makes no representations about the suitability of this
 
1841
+ * software for any purpose. It is provided "as is" without express or
 
1842
+ * implied warranty.
 
1843
+ *
 
1844
+ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
1845
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
1846
+ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
1847
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
1848
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
1849
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
1850
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
1851
+ *
 
1852
+ * Authors: Travis Watkins <travis.watkins@linaro.org>
 
1853
+ */
 
1854
+
 
1855
+#ifndef _COMPIZ_GLPROGRAMCACHE_H
 
1856
+#define _COMPIZ_GLPROGRAMCACHE_H
 
1857
+
 
1858
+#include <string>
 
1859
+#include <list>
 
1860
+#include <map>
 
1861
+#include <boost/bind.hpp>
 
1862
+#include <opengl/program.h>
 
1863
+
 
1864
+class PrivateProgramCache;
 
1865
+struct GLShaderData;
 
1866
+
 
1867
+class GLProgramCache
 
1868
+{
 
1869
+    private:
 
1870
+       PrivateProgramCache *priv;
 
1871
+
 
1872
+    public:
 
1873
+       GLProgramCache (size_t);
 
1874
+       ~GLProgramCache ();
 
1875
+
 
1876
+       GLProgram* operator () (std::list<const GLShaderData*>);
 
1877
+};
 
1878
+
 
1879
+#endif // _COMPIZ_GLPROGRAMCACHE_H
 
1880
+
 
1881
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/include/opengl/program.h linaro-gles2-debianpatches/plugins/opengl/include/opengl/program.h
 
1882
--- compiz-0.9.7.8/plugins/opengl/include/opengl/program.h      1970-01-01 01:00:00.000000000 +0100
 
1883
+++ linaro-gles2-debianpatches/plugins/opengl/include/opengl/program.h  2012-04-20 11:41:59.241600000 +0200
 
1884
@@ -0,0 +1,75 @@
 
1885
+/*
 
1886
+ * Copyright © 2011 Linaro Ltd.
 
1887
+ *
 
1888
+ * Permission to use, copy, modify, distribute, and sell this software
 
1889
+ * and its documentation for any purpose is hereby granted without
 
1890
+ * fee, provided that the above copyright notice appear in all copies
 
1891
+ * and that both that copyright notice and this permission notice
 
1892
+ * appear in supporting documentation, and that the name of
 
1893
+ * Linaro Ltd. not be used in advertising or publicity pertaining to
 
1894
+ * distribution of the software without specific, written prior permission.
 
1895
+ * Linaro Ltd. makes no representations about the suitability of this
 
1896
+ * software for any purpose. It is provided "as is" without express or
 
1897
+ * implied warranty.
 
1898
+ *
 
1899
+ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
1900
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
1901
+ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
1902
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
1903
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
1904
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
1905
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
1906
+ *
 
1907
+ * Authors: Travis Watkins <travis.watkins@linaro.org>
 
1908
+ */
 
1909
+
 
1910
+#ifndef _COMPIZ_GLPROGRAM_H
 
1911
+#define _COMPIZ_GLPROGRAM_H
 
1912
+
 
1913
+#ifdef USE_GLES
 
1914
+#include <GLES2/gl2.h>
 
1915
+#else
 
1916
+#include <GL/gl.h>
 
1917
+#endif
 
1918
+
 
1919
+#include <core/core.h>
 
1920
+#include <opengl/matrix.h>
 
1921
+
 
1922
+class PrivateProgram;
 
1923
+
 
1924
+class GLProgram
 
1925
+{
 
1926
+    public:
 
1927
+       GLProgram (CompString &vertexShader, CompString &fragmentShader);
 
1928
+       ~GLProgram ();
 
1929
+
 
1930
+       bool valid ();
 
1931
+       void bind ();
 
1932
+       void unbind ();
 
1933
+
 
1934
+       bool setUniform   (const char *name, GLfloat value);
 
1935
+       bool setUniform   (const char *name, GLint value);
 
1936
+       bool setUniform   (const char *name, const GLMatrix &value);
 
1937
+       bool setUniform2f (const char *name, GLfloat x, GLfloat y);
 
1938
+       bool setUniform3f (const char *name, GLfloat x, GLfloat y, GLfloat z);
 
1939
+       bool setUniform4f (const char *name,
 
1940
+                          GLfloat x,
 
1941
+                          GLfloat y,
 
1942
+                          GLfloat z,
 
1943
+                           GLfloat w);
 
1944
+       bool setUniform2i (const char *name, GLint x, GLint y);
 
1945
+       bool setUniform3i (const char *name, GLint x, GLint y, GLint z);
 
1946
+       bool setUniform4i (const char *name,
 
1947
+                          GLint x,
 
1948
+                          GLint y,
 
1949
+                          GLint z,
 
1950
+                           GLint w);
 
1951
+
 
1952
+       GLuint attributeLocation (const char *name);
 
1953
+
 
1954
+    private:
 
1955
+       PrivateProgram *priv;
 
1956
+};
 
1957
+
 
1958
+#endif // _COMPIZ_GLPROGRAM_H
 
1959
+
 
1960
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/include/opengl/shadercache.h linaro-gles2-debianpatches/plugins/opengl/include/opengl/shadercache.h
 
1961
--- compiz-0.9.7.8/plugins/opengl/include/opengl/shadercache.h  1970-01-01 01:00:00.000000000 +0100
 
1962
+++ linaro-gles2-debianpatches/plugins/opengl/include/opengl/shadercache.h      2012-04-20 11:41:59.241600000 +0200
 
1963
@@ -0,0 +1,100 @@
 
1964
+/*
 
1965
+ * Copyright © 2012 Linaro Ltd.
 
1966
+ *
 
1967
+ * Permission to use, copy, modify, distribute, and sell this software
 
1968
+ * and its documentation for any purpose is hereby granted without
 
1969
+ * fee, provided that the above copyright notice appear in all copies
 
1970
+ * and that both that copyright notice and this permission notice
 
1971
+ * appear in supporting documentation, and that the name of
 
1972
+ * Linaro Ltd. not be used in advertising or publicity pertaining to
 
1973
+ * distribution of the software without specific, written prior permission.
 
1974
+ * Linaro Ltd. makes no representations about the suitability of this
 
1975
+ * software for any purpose. It is provided "as is" without express or
 
1976
+ * implied warranty.
 
1977
+ *
 
1978
+ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
1979
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
1980
+ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
1981
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
1982
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
1983
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
1984
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
1985
+ *
 
1986
+ * Authors: Alexandros Frantzis <alexandros.frantzis@linaro.org>
 
1987
+ */
 
1988
+#ifndef GL_SHADER_CACHE_H_
 
1989
+#define GL_SHADER_CACHE_H_
 
1990
+
 
1991
+#include <string>
 
1992
+
 
1993
+/**
 
1994
+ * How to use a variable in a shader.
 
1995
+ */
 
1996
+enum GLShaderVariableType
 
1997
+{
 
1998
+    /** The variable is not used */
 
1999
+    GLShaderVariableNone,
 
2000
+    /** The variable value is held in a uniform */
 
2001
+    GLShaderVariableUniform,
 
2002
+    /** The variable value is held in a varying (from a vertex attribute) */
 
2003
+    GLShaderVariableVarying,
 
2004
+};
 
2005
+
 
2006
+/**
 
2007
+ * Parameters that define a vertex-fragment shader pair.
 
2008
+ */
 
2009
+struct GLShaderParameters
 
2010
+{
 
2011
+    /** Whether this shader supports opacity */
 
2012
+    bool opacity;
 
2013
+    /** Whether this shader supports brightness */
 
2014
+    bool brightness;
 
2015
+    /** Whether this shader supports saturation */
 
2016
+    bool saturation;
 
2017
+    /** Whether this shader supports color and how */
 
2018
+    GLShaderVariableType color;
 
2019
+    /** Whether this shader supports normals and how */
 
2020
+    GLShaderVariableType normal;
 
2021
+    /** The number of textures this shader uses */
 
2022
+    int numTextures;
 
2023
+
 
2024
+    /** Gets a minimalistic string representation of the parameters */
 
2025
+    std::string id() const;
 
2026
+    /** Gets a unique hash value for this set of parameters */
 
2027
+    int hash() const;
 
2028
+};
 
2029
+
 
2030
+/**
 
2031
+ * An object representing a named vertex-fragment shader pair.
 
2032
+ */
 
2033
+struct GLShaderData
 
2034
+{
 
2035
+    std::string name;
 
2036
+    std::string vertexShader;
 
2037
+    std::string fragmentShader;
 
2038
+};
 
2039
+
 
2040
+class PrivateShaderCache;
 
2041
+
 
2042
+/**
 
2043
+ * A cache of vertex-fragment shader pairs (GLShaderData).
 
2044
+ */
 
2045
+class GLShaderCache
 
2046
+{
 
2047
+public:
 
2048
+    GLShaderCache ();
 
2049
+
 
2050
+    /**
 
2051
+     * Gets the GLShaderData associated with the specified parameters.
 
2052
+     *
 
2053
+     * @param params the parameters to get the GLShaderData for.
 
2054
+     *
 
2055
+     * @return the GLShaderData
 
2056
+     */
 
2057
+    const GLShaderData &getShaderData (const GLShaderParameters &params);
 
2058
+
 
2059
+private:
 
2060
+    PrivateShaderCache *priv;
 
2061
+};
 
2062
+
 
2063
+#endif
 
2064
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/include/opengl/texture.h linaro-gles2-debianpatches/plugins/opengl/include/opengl/texture.h
 
2065
--- compiz-0.9.7.8/plugins/opengl/include/opengl/texture.h      2012-04-26 08:47:01.000000000 +0200
 
2066
+++ linaro-gles2-debianpatches/plugins/opengl/include/opengl/texture.h  2012-04-20 11:41:59.241600000 +0200
 
2067
@@ -32,7 +32,12 @@
 
2068
 #include "core/string.h"
 
2069
 
 
2070
 #include <X11/Xlib-xcb.h>
 
2071
+
 
2072
+#ifdef USE_GLES
 
2073
+#include <GLES2/gl2.h>
 
2074
+#else
 
2075
 #include <GL/gl.h>
 
2076
+#endif
 
2077
 
 
2078
 #include <boost/function.hpp>
 
2079
 
 
2080
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/include/opengl/vector.h linaro-gles2-debianpatches/plugins/opengl/include/opengl/vector.h
 
2081
--- compiz-0.9.7.8/plugins/opengl/include/opengl/vector.h       2012-04-26 08:47:01.000000000 +0200
 
2082
+++ linaro-gles2-debianpatches/plugins/opengl/include/opengl/vector.h   2012-04-20 11:41:59.241600000 +0200
 
2083
@@ -40,7 +40,7 @@
 
2084
        } VectorCoordsEnum;
 
2085
 
 
2086
        GLVector ();
 
2087
-       GLVector (float x, float y, float z, float w);
 
2088
+       GLVector (float x, float y, float z, float w = 0.0f);
 
2089
 
 
2090
        /**
 
2091
         * Returns a reference to the x, y, z or w value by using
 
2092
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/include/opengl/vertexbuffer.h linaro-gles2-debianpatches/plugins/opengl/include/opengl/vertexbuffer.h
 
2093
--- compiz-0.9.7.8/plugins/opengl/include/opengl/vertexbuffer.h 1970-01-01 01:00:00.000000000 +0100
 
2094
+++ linaro-gles2-debianpatches/plugins/opengl/include/opengl/vertexbuffer.h     2012-04-20 11:41:59.241600000 +0200
 
2095
@@ -0,0 +1,109 @@
 
2096
+/*
 
2097
+ * Copyright © 2011 Linaro Ltd.
 
2098
+ *
 
2099
+ * Permission to use, copy, modify, distribute, and sell this software
 
2100
+ * and its documentation for any purpose is hereby granted without
 
2101
+ * fee, provided that the above copyright notice appear in all copies
 
2102
+ * and that both that copyright notice and this permission notice
 
2103
+ * appear in supporting documentation, and that the name of
 
2104
+ * Linaro Ltd. not be used in advertising or publicity pertaining to
 
2105
+ * distribution of the software without specific, written prior permission.
 
2106
+ * Linaro Ltd. makes no representations about the suitability of this
 
2107
+ * software for any purpose. It is provided "as is" without express or
 
2108
+ * implied warranty.
 
2109
+ *
 
2110
+ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
2111
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
2112
+ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
2113
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
2114
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
2115
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
2116
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
2117
+ *
 
2118
+ * Authors: Travis Watkins <travis.watkins@linaro.org>
 
2119
+ *          Frederic Plourde <frederic.plourde@collabora.co.uk>
 
2120
+ */
 
2121
+
 
2122
+#ifndef _COMPIZ_GLVERTEXBUFFER_H
 
2123
+#define _COMPIZ_GLVERTEXBUFFER_H
 
2124
+
 
2125
+#ifdef USE_GLES
 
2126
+#include <GLES2/gl2.h>
 
2127
+#else
 
2128
+#include <GL/gl.h>
 
2129
+#endif
 
2130
+
 
2131
+#include <core/core.h>
 
2132
+#include <opengl/program.h>
 
2133
+#include <opengl/shadercache.h>
 
2134
+
 
2135
+class PrivateVertexBuffer;
 
2136
+struct GLWindowPaintAttrib;
 
2137
+
 
2138
+class GLVertexBuffer
 
2139
+{
 
2140
+    public:
 
2141
+       class AutoProgram
 
2142
+       {
 
2143
+       public:
 
2144
+           virtual GLProgram *getProgram(GLShaderParameters &params) = 0;
 
2145
+       };
 
2146
+
 
2147
+       GLVertexBuffer ();
 
2148
+       GLVertexBuffer (GLenum usage);
 
2149
+       ~GLVertexBuffer ();
 
2150
+
 
2151
+       static GLVertexBuffer *streamingBuffer ();
 
2152
+
 
2153
+       void begin (GLenum primitiveType);
 
2154
+       // default primitiveType is GL_TRIANGLES
 
2155
+       void begin ();
 
2156
+       int end ();
 
2157
+
 
2158
+       // vertices and normals are 3 parts, count is number of xyz groups
 
2159
+       void addVertices (GLuint nVertices, GLfloat *vertices);
 
2160
+       void addNormals (GLuint nNormals, GLfloat *normals);
 
2161
+
 
2162
+       // color is always RGBA (4 parts), count is number of rgba groups
 
2163
+       void addColors (GLuint nColors, GLushort *colors);
 
2164
+
 
2165
+       // texture is index, texcoords are 2 parts, count is number of pairs
 
2166
+       void addTexCoords (GLuint texture,
 
2167
+                          GLuint nTexcoords,
 
2168
+                          GLfloat *texcoords);
 
2169
+
 
2170
+       void addUniform (const char *name, GLfloat value);
 
2171
+       void addUniform (const char *name, GLint value);
 
2172
+       bool addUniform (const char *name, const GLMatrix &value);
 
2173
+       void addUniform2f (const char *name, GLfloat x, GLfloat y);
 
2174
+       void addUniform3f (const char *name, GLfloat x, GLfloat y, GLfloat z);
 
2175
+       void addUniform4f (const char *name, GLfloat x, GLfloat y,
 
2176
+                                            GLfloat z, GLfloat w);
 
2177
+       void addUniform2i (const char *name, GLint x, GLint y);
 
2178
+       void addUniform3i (const char *name, GLint x, GLint y, GLint z);
 
2179
+       void addUniform4i (const char *name, GLint x, GLint y,
 
2180
+                                            GLint z, GLint w);
 
2181
+
 
2182
+       void setProgram (GLProgram *program);
 
2183
+
 
2184
+       void setAutoProgram (AutoProgram *autoProgram);
 
2185
+
 
2186
+       // This no-argument render () function is intended for use by plugins
 
2187
+       // that have custom programs.
 
2188
+       int render ();
 
2189
+
 
2190
+       int render (const GLMatrix &modelview);
 
2191
+
 
2192
+       int render (const GLMatrix            &modelview,
 
2193
+                   const GLWindowPaintAttrib &attrib);
 
2194
+
 
2195
+       int render (const GLMatrix            &projection,
 
2196
+                   const GLMatrix            &modelview,
 
2197
+                   const GLWindowPaintAttrib &attrib);
 
2198
+
 
2199
+    private:
 
2200
+       PrivateVertexBuffer *priv;
 
2201
+};
 
2202
+
 
2203
+#endif // _COMPIZ_GLVERTEXBUFFER_H
 
2204
+
 
2205
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/opengl.xml.in linaro-gles2-debianpatches/plugins/opengl/opengl.xml.in
 
2206
--- compiz-0.9.7.8/plugins/opengl/opengl.xml.in 2012-04-26 08:47:01.000000000 +0200
 
2207
+++ linaro-gles2-debianpatches/plugins/opengl/opengl.xml.in     2012-04-20 11:41:59.241600000 +0200
 
2208
@@ -36,7 +36,7 @@
 
2209
            <option name="sync_to_vblank" type="bool">
 
2210
                <_short>Sync To VBlank</_short>
 
2211
                <_long>Only perform screen updates during vertical blanking period</_long>
 
2212
-               <default>true</default>
 
2213
+               <default>false</default>
 
2214
            </option>
 
2215
            <option name="texture_compression" type="bool">
 
2216
                <_short>Texture Compression</_short>
 
2217
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/fragment.cpp linaro-gles2-debianpatches/plugins/opengl/src/fragment.cpp
 
2218
--- compiz-0.9.7.8/plugins/opengl/src/fragment.cpp      2012-04-26 08:47:01.000000000 +0200
 
2219
+++ linaro-gles2-debianpatches/plugins/opengl/src/fragment.cpp  1970-01-01 01:00:00.000000000 +0100
 
2220
@@ -1,1146 +0,0 @@
 
2221
-/*
 
2222
- * Copyright © 2007 Novell, Inc.
 
2223
- *
 
2224
- * Permission to use, copy, modify, distribute, and sell this software
 
2225
- * and its documentation for any purpose is hereby granted without
 
2226
- * fee, provided that the above copyright notice appear in all copies
 
2227
- * and that both that copyright notice and this permission notice
 
2228
- * appear in supporting documentation, and that the name of
 
2229
- * Novell, Inc. not be used in advertising or publicity pertaining to
 
2230
- * distribution of the software without specific, written prior permission.
 
2231
- * Novell, Inc. makes no representations about the suitability of this
 
2232
- * software for any purpose. It is provided "as is" without express or
 
2233
- * implied warranty.
 
2234
- *
 
2235
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
2236
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
2237
- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
2238
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
2239
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
2240
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
2241
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
2242
- *
 
2243
- * Author: David Reveman <davidr@novell.com>
 
2244
- */
 
2245
-
 
2246
-#include "privatefragment.h"
 
2247
-#include "privates.h"
 
2248
-
 
2249
-#include "core/string.h"
 
2250
-
 
2251
-#include <boost/function.hpp>
 
2252
-#include <boost/bind.hpp>
 
2253
-#include <boost/foreach.hpp>
 
2254
-#define foreach BOOST_FOREACH
 
2255
-
 
2256
-#include <opengl/texture.h>
 
2257
-
 
2258
-#include <string.h>
 
2259
-#include <stdlib.h>
 
2260
-#include <stdarg.h>
 
2261
-
 
2262
-#define COMP_FUNCTION_TYPE_ARB 0
 
2263
-#define COMP_FUNCTION_TYPE_NUM 1
 
2264
-
 
2265
-#define COMP_FUNCTION_ARB_MASK (1 << 0)
 
2266
-#define COMP_FUNCTION_MASK     (COMP_FUNCTION_ARB_MASK)
 
2267
-
 
2268
-namespace GLFragment {
 
2269
-
 
2270
-    class Program {
 
2271
-       public:
 
2272
-           Program () :
 
2273
-               signature (0),
 
2274
-               blending (false),
 
2275
-               name (0),
 
2276
-               type (GL_FRAGMENT_PROGRAM_ARB)
 
2277
-           {};
 
2278
-           ~Program ()
 
2279
-           {
 
2280
-               if (name)
 
2281
-                   (*GL::deletePrograms) (1, &name);
 
2282
-           };
 
2283
-
 
2284
-       public:
 
2285
-           std::vector<FunctionId> signature;
 
2286
-
 
2287
-           bool blending;
 
2288
-
 
2289
-           GLuint name;
 
2290
-           GLenum type;
 
2291
-    };
 
2292
-
 
2293
-    typedef enum {
 
2294
-       OpTypeData,
 
2295
-       OpTypeDataStore,
 
2296
-       OpTypeDataOffset,
 
2297
-       OpTypeDataBlend,
 
2298
-       OpTypeHeaderTemp,
 
2299
-       OpTypeHeaderParam,
 
2300
-       OpTypeHeaderAttrib,
 
2301
-       OpTypeColor,
 
2302
-       OpTypeFetch,
 
2303
-       OpTypeLoad
 
2304
-    } OpType;
 
2305
-
 
2306
-    class HeaderOp {
 
2307
-       public:
 
2308
-           HeaderOp () : type (OpTypeHeaderTemp), name ("") {}
 
2309
-       public:
 
2310
-           OpType     type;
 
2311
-           CompString name;
 
2312
-    };
 
2313
-
 
2314
-    class BodyOp {
 
2315
-       public:
 
2316
-           BodyOp () :
 
2317
-               type (OpTypeData),
 
2318
-               data (""),
 
2319
-               dst (""),
 
2320
-               src (""),
 
2321
-               target (0)
 
2322
-           {
 
2323
-               foreach (CompString &str, noOffset)
 
2324
-                   str = "";
 
2325
-               foreach (CompString &str, offset)
 
2326
-                   str = "";
 
2327
-           };
 
2328
-
 
2329
-       public:
 
2330
-           OpType       type;
 
2331
-           CompString   data;
 
2332
-           CompString   dst;
 
2333
-           CompString   src;
 
2334
-           unsigned int target;
 
2335
-           CompString   noOffset[COMP_FETCH_TARGET_NUM];
 
2336
-           CompString   offset[COMP_FETCH_TARGET_NUM];
 
2337
-
 
2338
-    };
 
2339
-
 
2340
-    class PrivateFunctionData {
 
2341
-       public:
 
2342
-           PrivateFunctionData () : header (0), body (0), status (true) {}
 
2343
-           PrivateFunctionData (const PrivateFunctionData&, CompString);
 
2344
-
 
2345
-       public:
 
2346
-           std::vector<HeaderOp> header;
 
2347
-           std::vector<BodyOp>   body;
 
2348
-           bool                  status;
 
2349
-    };
 
2350
-
 
2351
-    class Function {
 
2352
-       public:
 
2353
-           Function ():
 
2354
-               id (0),
 
2355
-               name (""),
 
2356
-               mask (0)
 
2357
-           {};
 
2358
-
 
2359
-       public:
 
2360
-           FunctionId          id;
 
2361
-           CompString          name;
 
2362
-           PrivateFunctionData data[COMP_FUNCTION_TYPE_NUM];
 
2363
-           unsigned int        mask;
 
2364
-    };
 
2365
-
 
2366
-    class PrivateAttrib {
 
2367
-       public:
 
2368
-           PrivateAttrib () :
 
2369
-               opacity (0xffff),
 
2370
-               brightness (0xffff),
 
2371
-               saturation (0xffff),
 
2372
-               nTexture (0),
 
2373
-               nFunction (0),
 
2374
-               nParam (0)
 
2375
-           {}
 
2376
-
 
2377
-           PrivateAttrib (const PrivateAttrib &pa) :
 
2378
-               opacity (pa.opacity),
 
2379
-               brightness (pa.brightness),
 
2380
-               saturation (pa.saturation),
 
2381
-               nTexture (pa.nTexture),
 
2382
-               nFunction (pa.nFunction),
 
2383
-               nParam (pa.nParam)
 
2384
-           {
 
2385
-               for (int i = 0; i < MAX_FRAGMENT_FUNCTIONS; i++)
 
2386
-                   function[i] = pa.function[i];
 
2387
-           }
 
2388
-
 
2389
-       public:
 
2390
-           GLushort   opacity;
 
2391
-           GLushort   brightness;
 
2392
-           GLushort   saturation;
 
2393
-           int        nTexture;
 
2394
-           FunctionId function[MAX_FRAGMENT_FUNCTIONS];
 
2395
-           int        nFunction;
 
2396
-           int        nParam;
 
2397
-    };
 
2398
-
 
2399
-    typedef boost::function<void (BodyOp *, int)> DataOpCallBack;
 
2400
-
 
2401
-    class InitialLoadFunction : public Function {
 
2402
-       public:
 
2403
-           InitialLoadFunction ()
 
2404
-           {
 
2405
-               id   = 0;
 
2406
-               name = "__core_load";
 
2407
-               mask = COMP_FUNCTION_MASK;
 
2408
-
 
2409
-               BodyOp b;
 
2410
-               b.type = OpTypeLoad;
 
2411
-               b.noOffset[0] = "TEX output, fragment.texcoord[0], texture[0], 2D;";
 
2412
-               b.noOffset[1] = "TEX output, fragment.texcoord[0], texture[0], RECT;";
 
2413
-               b.offset[0] = "TEX output, __tmp_texcoord0, texture[0], 2D;";
 
2414
-               b.offset[1] = "TEX output, __tmp_texcoord0, texture[0], RECT;";
 
2415
-               data[0].body.push_back (b);
 
2416
-           };
 
2417
-    };
 
2418
-
 
2419
-    static InitialLoadFunction initialLoadFunction;
 
2420
-
 
2421
-    static Function *
 
2422
-    findFragmentFunction (GLScreen   *s,
 
2423
-                         FunctionId id)
 
2424
-    {
 
2425
-       foreach (Function *f, s->fragmentStorage ()->functions)
 
2426
-           if (f->id == id)
 
2427
-               return f;
 
2428
-       return NULL;
 
2429
-    }
 
2430
-
 
2431
-    static Function *
 
2432
-    findFragmentFunctionWithName (GLScreen   *s,
 
2433
-                                 CompString name)
 
2434
-    {
 
2435
-       foreach (Function *f, s->fragmentStorage ()->functions)
 
2436
-           if (f->name.compare (name) == 0)
 
2437
-               return f;
 
2438
-       return NULL;
 
2439
-    }
 
2440
-
 
2441
-    static Program *
 
2442
-    findFragmentProgram (GLScreen     *s,
 
2443
-                        FunctionId   *signature,
 
2444
-                        unsigned int nSignature)
 
2445
-    {
 
2446
-       unsigned int i;
 
2447
-
 
2448
-       foreach (Program *p, s->fragmentStorage ()->programs)
 
2449
-       {
 
2450
-           if (p->signature.size () != nSignature)
 
2451
-               continue;
 
2452
-
 
2453
-           for (i = 0; i < nSignature; i++)
 
2454
-               if (signature[i] != p->signature[i])
 
2455
-                   break;
 
2456
-
 
2457
-           if (i == nSignature)
 
2458
-               return p;
 
2459
-       }
 
2460
-       return NULL;
 
2461
-    }
 
2462
-
 
2463
-    static unsigned int
 
2464
-    functionMaskToType (int mask)
 
2465
-    {
 
2466
-       static struct {
 
2467
-           unsigned int type;
 
2468
-           unsigned int mask;
 
2469
-       } maskToType[] = {
 
2470
-           { COMP_FUNCTION_TYPE_ARB, COMP_FUNCTION_ARB_MASK }
 
2471
-       };
 
2472
-
 
2473
-       unsigned int i;
 
2474
-
 
2475
-       for (i = 0; i < sizeof (maskToType) / sizeof (maskToType[0]); i++)
 
2476
-           if (mask & maskToType[i].mask)
 
2477
-               return maskToType[i].type;
 
2478
-
 
2479
-       return 0;
 
2480
-    }
 
2481
-
 
2482
-    static void
 
2483
-    forEachDataOpInFunction (std::vector<Function *> list,
 
2484
-                            int                     index,
 
2485
-                            int                     type,
 
2486
-                            int                     loadTarget,
 
2487
-                            CompString              loadOffset,
 
2488
-                            bool                    *color,
 
2489
-                            bool                    *blend,
 
2490
-                            DataOpCallBack          callBack)
 
2491
-    {
 
2492
-       Function *f = list[index];
 
2493
-       BodyOp   dataOp;
 
2494
-       bool     colorDone = false;
 
2495
-       bool     blendDone = false;
 
2496
-
 
2497
-       *color = false;
 
2498
-       *blend = false;
 
2499
-
 
2500
-       foreach (BodyOp &bodyOp, f->data[type].body)
 
2501
-       {
 
2502
-           switch (bodyOp.type) {
 
2503
-               case OpTypeFetch: {
 
2504
-                   CompString offset = loadOffset;
 
2505
-
 
2506
-                   /* add offset */
 
2507
-                   if (bodyOp.data.size ())
 
2508
-                   {
 
2509
-                       if (loadOffset.size ())
 
2510
-                       {
 
2511
-                           dataOp.type = OpTypeDataOffset;
 
2512
-                           dataOp.data =
 
2513
-                               compPrintf ("ADD __tmp_texcoord%d, %s, %s;",
 
2514
-                                           index, loadOffset.c_str (),
 
2515
-                                           bodyOp.data.c_str ());
 
2516
-
 
2517
-                           callBack (&dataOp, index);
 
2518
-
 
2519
-                           offset = compPrintf ("__tmp_texcoord%d", index);
 
2520
-                       }
 
2521
-                       else
 
2522
-                       {
 
2523
-                           offset = bodyOp.data;
 
2524
-                       }
 
2525
-                   }
 
2526
-
 
2527
-                   forEachDataOpInFunction (list, index - 1, type,
 
2528
-                                           bodyOp.target,
 
2529
-                                           offset, &colorDone, &blendDone,
 
2530
-                                           callBack);
 
2531
-
 
2532
-                   if (bodyOp.dst.compare ("output"))
 
2533
-                   {
 
2534
-                       dataOp.type = OpTypeDataStore;
 
2535
-                       dataOp.data =
 
2536
-                           compPrintf ("MOV %s, output;", bodyOp.dst.c_str ());
 
2537
-
 
2538
-                       /* move to destination */
 
2539
-                       callBack (&dataOp, index);
 
2540
-                   }
 
2541
-               } break;
 
2542
-               case OpTypeLoad:
 
2543
-                   if (loadOffset.size ())
 
2544
-                   {
 
2545
-                       dataOp.type = OpTypeDataOffset;
 
2546
-                       dataOp.data =
 
2547
-                           compPrintf ("ADD __tmp_texcoord0, fragment.texcoord[0], %s;",
 
2548
-                                       loadOffset.c_str ());
 
2549
-
 
2550
-                       callBack (&dataOp, index);
 
2551
-
 
2552
-                       dataOp.data = bodyOp.offset[loadTarget];
 
2553
-                   }
 
2554
-                   else
 
2555
-                   {
 
2556
-                       dataOp.data = bodyOp.noOffset[loadTarget];
 
2557
-                   }
 
2558
-
 
2559
-                   dataOp.type = OpTypeData;
 
2560
-
 
2561
-                   callBack (&dataOp, index);
 
2562
-
 
2563
-                   break;
 
2564
-               case OpTypeColor:
 
2565
-                   if (!colorDone)
 
2566
-                   {
 
2567
-                       dataOp.type = OpTypeData;
 
2568
-                       dataOp.data =
 
2569
-                           compPrintf ("MUL %s, fragment.color, %s;",
 
2570
-                                       bodyOp.dst.c_str (),
 
2571
-                                       bodyOp.src.c_str ());
 
2572
-
 
2573
-                       callBack (&dataOp, index);
 
2574
-                   }
 
2575
-                   else if (bodyOp.dst.compare (bodyOp.src))
 
2576
-                   {
 
2577
-                       dataOp.type = OpTypeData;
 
2578
-                       dataOp.data =
 
2579
-                           compPrintf ("MOV %s, %s;",
 
2580
-                                       bodyOp.dst.c_str (),
 
2581
-                                       bodyOp.src.c_str ());
 
2582
-
 
2583
-                       callBack (&dataOp, index);
 
2584
-                   }
 
2585
-                   *color = true;
 
2586
-                   break;
 
2587
-               case OpTypeDataBlend:
 
2588
-                   *blend = true;
 
2589
-                   /* fall-through */
 
2590
-               case OpTypeData:
 
2591
-                   callBack (&bodyOp, index);
 
2592
-                   break;
 
2593
-               case OpTypeDataStore:
 
2594
-               case OpTypeDataOffset:
 
2595
-               case OpTypeHeaderTemp:
 
2596
-               case OpTypeHeaderParam:
 
2597
-               case OpTypeHeaderAttrib:
 
2598
-                   break;
 
2599
-           }
 
2600
-       }
 
2601
-
 
2602
-       if (colorDone)
 
2603
-           *color = true;
 
2604
-
 
2605
-       if (blendDone)
 
2606
-           *blend = true;
 
2607
-    }
 
2608
-
 
2609
-    static int
 
2610
-    forEachHeaderOpWithType (std::vector<HeaderOp> list,
 
2611
-                            int                   index,
 
2612
-                            OpType                type,
 
2613
-                            CompString            prefix,
 
2614
-                            CompString            functionPrefix,
 
2615
-                            int                   count,
 
2616
-                            DataOpCallBack        callBack)
 
2617
-    {
 
2618
-       BodyOp dataOp;
 
2619
-
 
2620
-       dataOp.type = OpTypeData;
 
2621
-
 
2622
-       foreach (HeaderOp &header, list)
 
2623
-       {
 
2624
-           if (header.type == type)
 
2625
-           {
 
2626
-               if (count)
 
2627
-               {
 
2628
-                   dataOp.data = ", ";
 
2629
-               }
 
2630
-               else
 
2631
-               {
 
2632
-                   dataOp.data = prefix;
 
2633
-               }
 
2634
-
 
2635
-               dataOp.data += functionPrefix;
 
2636
-               dataOp.data += "_";
 
2637
-               dataOp.data += header.name;
 
2638
-
 
2639
-               callBack (&dataOp, index);
 
2640
-
 
2641
-               count++;
 
2642
-           }
 
2643
-       }
 
2644
-
 
2645
-       return count;
 
2646
-    }
 
2647
-
 
2648
-    static bool
 
2649
-    forEachDataOp (std::vector<Function *> list,
 
2650
-                  int                     type,
 
2651
-                  DataOpCallBack          callBack)
 
2652
-    {
 
2653
-       BodyOp dataOp;
 
2654
-       bool   colorDone;
 
2655
-       bool   blendDone;
 
2656
-       int    count, nList = list.size ();
 
2657
-
 
2658
-       dataOp.type = OpTypeData;
 
2659
-
 
2660
-       count = 1;
 
2661
-
 
2662
-       dataOp.data = "TEMP output";
 
2663
-
 
2664
-       callBack (&dataOp, nList);
 
2665
-
 
2666
-       foreach (Function *f, list)
 
2667
-           count = forEachHeaderOpWithType (f->data[type].header,
 
2668
-                                            nList, OpTypeHeaderTemp,
 
2669
-                                            "", f->name, count, callBack);
 
2670
-
 
2671
-       dataOp.data = ";";
 
2672
-
 
2673
-       callBack (&dataOp, nList);
 
2674
-
 
2675
-       count = 0;
 
2676
-
 
2677
-       foreach (Function *f, list)
 
2678
-           count = forEachHeaderOpWithType (f->data[type].header,
 
2679
-                                            nList, OpTypeHeaderParam,
 
2680
-                                            "PARAM ", f->name, count,
 
2681
-                                            callBack);
 
2682
-
 
2683
-       if (count)
 
2684
-       {
 
2685
-           dataOp.data = ";";
 
2686
-
 
2687
-           callBack (&dataOp, nList);
 
2688
-       }
 
2689
-
 
2690
-       count = 0;
 
2691
-
 
2692
-       foreach (Function *f, list)
 
2693
-           count = forEachHeaderOpWithType (f->data[type].header,
 
2694
-                                            nList, OpTypeHeaderAttrib,
 
2695
-                                            "ATTRIB ", f->name, count,
 
2696
-                                            callBack);
 
2697
-
 
2698
-       if (count)
 
2699
-       {
 
2700
-           dataOp.data = ";";
 
2701
-
 
2702
-           callBack (&dataOp, nList);
 
2703
-       }
 
2704
-
 
2705
-       forEachDataOpInFunction (list, nList - 1, type, 0, "",
 
2706
-                                &colorDone, &blendDone,
 
2707
-                                callBack);
 
2708
-
 
2709
-       if (colorDone)
 
2710
-           dataOp.data = "MOV result.color, output;END";
 
2711
-       else
 
2712
-           dataOp.data = "MUL result.color, fragment.color, output;END";
 
2713
-
 
2714
-       callBack (&dataOp, nList);
 
2715
-
 
2716
-       return blendDone;
 
2717
-    }
 
2718
-
 
2719
-    static void
 
2720
-    addFetchOffsetVariables (BodyOp     *op,
 
2721
-                            int        index,
 
2722
-                            bool       *indices,
 
2723
-                            CompString *data)
 
2724
-    {
 
2725
-       if (op->type == OpTypeDataOffset)
 
2726
-       {
 
2727
-           if (!indices[index])
 
2728
-           {
 
2729
-               data->append (compPrintf ("TEMP __tmp_texcoord%d;", index));
 
2730
-               indices[index] = true;
 
2731
-           }
 
2732
-       }
 
2733
-    }
 
2734
-
 
2735
-    static void
 
2736
-    addData (BodyOp     *op,
 
2737
-            CompString *data)
 
2738
-    {
 
2739
-       data->append (op->data);
 
2740
-    }
 
2741
-
 
2742
-    static Program *
 
2743
-    buildFragmentProgram (GLScreen      *s,
 
2744
-                         PrivateAttrib *attrib)
 
2745
-    {
 
2746
-       Program                 *program;
 
2747
-       std::vector<Function *> functionList (1);
 
2748
-       int                     mask = COMP_FUNCTION_MASK;
 
2749
-       int                     type;
 
2750
-       GLint                   errorPos;
 
2751
-       GLenum                  errorType;
 
2752
-       CompString fetchData;
 
2753
-       bool       indices[MAX_FRAGMENT_FUNCTIONS];
 
2754
-       int        i;
 
2755
-
 
2756
-       program = new Program ();
 
2757
-       if (!program)
 
2758
-           return NULL;
 
2759
-
 
2760
-       functionList[0] = &initialLoadFunction;
 
2761
-
 
2762
-       for (i = 0; i < attrib->nFunction; i++)
 
2763
-       {
 
2764
-           Function *f = findFragmentFunction (s, attrib->function[i]);
 
2765
-
 
2766
-           if (f)
 
2767
-               functionList.push_back (f);
 
2768
-       }
 
2769
-
 
2770
-       foreach (Function *f, functionList)
 
2771
-           mask &= f->mask;
 
2772
-
 
2773
-       if (!mask)
 
2774
-       {
 
2775
-           compLogMessage ("opengl", CompLogLevelWarn,
 
2776
-                           "fragment functions can't be linked together "
 
2777
-                           "because a common type doesn't exist");
 
2778
-       }
 
2779
-
 
2780
-       if (!mask || functionList.size () == 1)
 
2781
-       {
 
2782
-           delete program;
 
2783
-           return NULL;
 
2784
-       }
 
2785
-
 
2786
-       for (i = 0; i < attrib->nFunction; i++)
 
2787
-           program->signature.push_back (attrib->function[i]);
 
2788
-
 
2789
-       type = functionMaskToType (mask);
 
2790
-
 
2791
-       fetchData = "!!ARBfp1.0";
 
2792
-
 
2793
-       foreach (bool &val, indices)
 
2794
-           val = false;
 
2795
-
 
2796
-       forEachDataOp (functionList, type,
 
2797
-           boost::bind (addFetchOffsetVariables, _1, _2, indices, &fetchData));
 
2798
-
 
2799
-       program->blending = forEachDataOp (functionList, type,
 
2800
-                               boost::bind (addData, _1, &fetchData));
 
2801
-
 
2802
-       program->type = GL_FRAGMENT_PROGRAM_ARB;
 
2803
-
 
2804
-       glGetError ();
 
2805
-
 
2806
-       (*GL::genPrograms) (1, &program->name);
 
2807
-       (*GL::bindProgram) (GL_FRAGMENT_PROGRAM_ARB, program->name);
 
2808
-       (*GL::programString) (GL_FRAGMENT_PROGRAM_ARB,
 
2809
-                             GL_PROGRAM_FORMAT_ASCII_ARB,
 
2810
-                             fetchData.size (), fetchData.c_str ());
 
2811
-
 
2812
-       glGetIntegerv (GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
 
2813
-       errorType = glGetError ();
 
2814
-       if (errorType != GL_NO_ERROR || errorPos != -1)
 
2815
-       {
 
2816
-           compLogMessage ("opengl", CompLogLevelError,
 
2817
-                           "failed to load fragment program");
 
2818
-
 
2819
-           (*GL::deletePrograms) (1, &program->name);
 
2820
-
 
2821
-           program->name = 0;
 
2822
-           program->type = 0;
 
2823
-       }
 
2824
-
 
2825
-       return program;
 
2826
-    }
 
2827
-
 
2828
-    static GLuint
 
2829
-    getFragmentProgram (GLScreen      *s,
 
2830
-                       PrivateAttrib *attrib,
 
2831
-                       GLenum        *type,
 
2832
-                       bool          *blending)
 
2833
-    {
 
2834
-       Program *program;
 
2835
-
 
2836
-       if (!attrib->nFunction)
 
2837
-           return 0;
 
2838
-
 
2839
-       program = findFragmentProgram (s, attrib->function, attrib->nFunction);
 
2840
-       if (!program)
 
2841
-       {
 
2842
-           program = buildFragmentProgram (s, attrib);
 
2843
-           if (program)
 
2844
-           {
 
2845
-               s->fragmentStorage ()->programs.push_back (program);
 
2846
-           }
 
2847
-       }
 
2848
-
 
2849
-       if (program)
 
2850
-       {
 
2851
-           *type     = program->type;
 
2852
-           *blending = program->blending;
 
2853
-
 
2854
-           return program->name;
 
2855
-       }
 
2856
-
 
2857
-       return 0;
 
2858
-    }
 
2859
-
 
2860
-
 
2861
-    /* performs simple variable substitution */
 
2862
-    static CompString
 
2863
-    copyData (std::vector<HeaderOp> header,
 
2864
-             const CompString      prefix,
 
2865
-             CompString            data)
 
2866
-    {
 
2867
-       CompString inPrefix (prefix);
 
2868
-       inPrefix += "_";
 
2869
-
 
2870
-       foreach (HeaderOp &h, header)
 
2871
-       {
 
2872
-           size_t pos = data.find (h.name);
 
2873
-           while (pos != std::string::npos)
 
2874
-           {
 
2875
-               bool prependPrefix = false;
 
2876
-               /* It is possible to match parts of words here, so
 
2877
-                * make sure that we have found the next chunk in the
 
2878
-                * string and not just a header which matches
 
2879
-                * part of another word */
 
2880
-               if (data.size () > pos + h.name.size ())
 
2881
-               {
 
2882
-                   const CompString &token = data.substr (pos + h.name.size (), 1);
 
2883
-                   if (token == "," ||
 
2884
-                       token == "." ||
 
2885
-                       token == ";")
 
2886
-                   {
 
2887
-                       prependPrefix = true;
 
2888
-                   }
 
2889
-                   else
 
2890
-                   {
 
2891
-                       /* We matched part of another word as our
 
2892
-                        * token so search for the next whole
 
2893
-                        * header op */
 
2894
-                       pos = data.find (h.name, pos + 1);
 
2895
-                   }
 
2896
-               }
 
2897
-               else
 
2898
-               {
 
2899
-                   /* If this is the last word in the string, then it must
 
2900
-                    * have matched exactly our header op, so it is ok
 
2901
-                    * to prepend a prefix here and go straight to
 
2902
-                    * std::string::npos */
 
2903
-                   prependPrefix = true;
 
2904
-               }
 
2905
-
 
2906
-               if (prependPrefix)
 
2907
-               {
 
2908
-                   /* prepend the header op prefix to the header op
 
2909
-                    * and seek past this word to the next instance
 
2910
-                    * of the unprepended header op */
 
2911
-                   data.insert (pos, inPrefix);
 
2912
-                   pos += inPrefix.size () + h.name.size ();
 
2913
-                   pos = data.find (h.name, pos);
 
2914
-               }
 
2915
-           }
 
2916
-       }
 
2917
-
 
2918
-       return data;
 
2919
-    }
 
2920
-
 
2921
-    PrivateFunctionData::PrivateFunctionData (const PrivateFunctionData& src,
 
2922
-                                             CompString dstPrefix) :
 
2923
-       header (src.header),
 
2924
-       body (0),
 
2925
-       status (src.status)
 
2926
-    {
 
2927
-
 
2928
-       foreach (BodyOp b, src.body)
 
2929
-       {
 
2930
-           BodyOp dst;
 
2931
-           dst.type = b.type;
 
2932
-
 
2933
-           switch (b.type) {
 
2934
-               case OpTypeFetch:
 
2935
-                   dst.dst = copyData (header, dstPrefix, b.dst);
 
2936
-                   if (b.data.size ())
 
2937
-                       dst.data = copyData (header, dstPrefix, b.data);
 
2938
-                   else
 
2939
-                       dst.data = "";
 
2940
-
 
2941
-                   dst.target = b.target;
 
2942
-                   break;
 
2943
-               case OpTypeLoad:
 
2944
-               case OpTypeHeaderTemp:
 
2945
-               case OpTypeHeaderParam:
 
2946
-               case OpTypeHeaderAttrib:
 
2947
-                   break;
 
2948
-               case OpTypeData:
 
2949
-               case OpTypeDataBlend:
 
2950
-               case OpTypeDataStore:
 
2951
-               case OpTypeDataOffset:
 
2952
-                   dst.data = copyData (header, dstPrefix, b.data);
 
2953
-                   break;
 
2954
-               case OpTypeColor:
 
2955
-                   dst.dst = copyData (header, dstPrefix, b.dst);
 
2956
-                   dst.src = copyData (header, dstPrefix, b.src);
 
2957
-                   break;
 
2958
-               }
 
2959
-           body.push_back (dst);
 
2960
-       }
 
2961
-    }
 
2962
-
 
2963
-    static bool
 
2964
-    addHeaderOpToFunctionData (PrivateFunctionData *data,
 
2965
-                              const char          *name,
 
2966
-                              OpType              type)
 
2967
-    {
 
2968
-       static const char *reserved[] = {
 
2969
-           "output",
 
2970
-           "__tmp_texcoord",
 
2971
-           "fragment",
 
2972
-           "program",
 
2973
-           "result",
 
2974
-           "state",
 
2975
-           "texture"
 
2976
-       };
 
2977
-       HeaderOp   header;
 
2978
-       CompString n (name);
 
2979
-
 
2980
-       foreach (const char *word, reserved)
 
2981
-       {
 
2982
-           if (n.find (word) != std::string::npos)
 
2983
-           {
 
2984
-               compLogMessage ("opengl", CompLogLevelWarn,
 
2985
-                               "%s is a reserved word", word);
 
2986
-               return false;
 
2987
-           }
 
2988
-       }
 
2989
-
 
2990
-
 
2991
-       header.type = type;
 
2992
-       header.name = n;
 
2993
-       data->header.push_back (header);
 
2994
-
 
2995
-       return true;
 
2996
-    }
 
2997
-
 
2998
-    FunctionData::FunctionData () :
 
2999
-       priv (new PrivateFunctionData ())
 
3000
-    {
 
3001
-    }
 
3002
-
 
3003
-    FunctionData::~FunctionData ()
 
3004
-    {
 
3005
-       delete priv;
 
3006
-    }
 
3007
-
 
3008
-    bool
 
3009
-    FunctionData::status ()
 
3010
-    {
 
3011
-       return priv->status;
 
3012
-    }
 
3013
-
 
3014
-    void
 
3015
-    FunctionData::addTempHeaderOp (const char *name)
 
3016
-    {
 
3017
-       priv->status &=
 
3018
-           addHeaderOpToFunctionData (priv, name, OpTypeHeaderTemp);
 
3019
-    }
 
3020
-
 
3021
-    void
 
3022
-    FunctionData::addParamHeaderOp (const char *name)
 
3023
-    {
 
3024
-       priv->status &=
 
3025
-           addHeaderOpToFunctionData (priv, name, OpTypeHeaderParam);
 
3026
-    }
 
3027
-
 
3028
-    void
 
3029
-    FunctionData::addAttribHeaderOp (const char *name)
 
3030
-    {
 
3031
-       priv->status &=
 
3032
-           addHeaderOpToFunctionData (priv, name, OpTypeHeaderAttrib);
 
3033
-    }
 
3034
-
 
3035
-
 
3036
-    void
 
3037
-    FunctionData::addFetchOp (const char *dst, const char *offset, int target)
 
3038
-    {
 
3039
-       BodyOp b;
 
3040
-
 
3041
-       b.type   = OpTypeFetch;
 
3042
-       b.dst    = CompString (dst);
 
3043
-       b.target = target;
 
3044
-
 
3045
-       if (offset)
 
3046
-           b.data = CompString (offset);
 
3047
-       else
 
3048
-           b.data = CompString ("");
 
3049
-
 
3050
-       priv->body.push_back (b);
 
3051
-    }
 
3052
-
 
3053
-    void
 
3054
-    FunctionData::addColorOp (const char *dst, const char *src)
 
3055
-    {
 
3056
-       BodyOp b;
 
3057
-
 
3058
-       b.type = OpTypeColor;
 
3059
-       b.dst  = CompString (dst);
 
3060
-       b.src  = CompString (src);
 
3061
-
 
3062
-       priv->body.push_back (b);
 
3063
-    }
 
3064
-
 
3065
-    void
 
3066
-    FunctionData::addDataOp (const char *str, ...)
 
3067
-    {
 
3068
-       BodyOp  b;
 
3069
-       va_list ap;
 
3070
-
 
3071
-       b.type = OpTypeData;
 
3072
-       va_start (ap, str);
 
3073
-       b.data = compPrintf (str, ap);
 
3074
-       va_end (ap);
 
3075
-
 
3076
-       priv->body.push_back (b);
 
3077
-    }
 
3078
-
 
3079
-    void
 
3080
-    FunctionData::addBlendOp (const char *str, ...)
 
3081
-    {
 
3082
-       BodyOp  b;
 
3083
-       va_list ap;
 
3084
-
 
3085
-       b.type = OpTypeDataBlend;
 
3086
-       va_start (ap, str);
 
3087
-       b.data = compPrintf (str, ap);
 
3088
-       va_end (ap);
 
3089
-
 
3090
-       priv->body.push_back (b);
 
3091
-    }
 
3092
-
 
3093
-    FunctionId
 
3094
-    FunctionData::createFragmentFunction (const char *name)
 
3095
-    {
 
3096
-       GLScreen     *s = GLScreen::get (screen);
 
3097
-       Function     *function = new Function ();
 
3098
-       CompString   validName = name;
 
3099
-       unsigned int i = 0;
 
3100
-
 
3101
-       while (findFragmentFunctionWithName (s, validName))
 
3102
-       {
 
3103
-           validName = compPrintf ("%s%d", name, i++);
 
3104
-       }
 
3105
-
 
3106
-       function->data[COMP_FUNCTION_TYPE_ARB] =
 
3107
-           PrivateFunctionData (*priv, validName);
 
3108
-
 
3109
-       function->name = validName;
 
3110
-       function->mask = COMP_FUNCTION_ARB_MASK;
 
3111
-       function->id   = s->fragmentStorage ()->lastFunctionId++;
 
3112
-
 
3113
-       s->fragmentStorage ()->functions.push_back (function);
 
3114
-
 
3115
-       return function->id;
 
3116
-    }
 
3117
-
 
3118
-    Attrib::Attrib (const GLWindowPaintAttrib &paint) :
 
3119
-       priv (new PrivateAttrib ())
 
3120
-    {
 
3121
-       priv->opacity    = paint.opacity;
 
3122
-       priv->brightness = paint.brightness;
 
3123
-       priv->saturation = paint.saturation;
 
3124
-       priv->nTexture   = 0;
 
3125
-       priv->nFunction  = 0;
 
3126
-       priv->nParam     = 0;
 
3127
-
 
3128
-       foreach (FunctionId &f, priv->function)
 
3129
-           f = 0;
 
3130
-    }
 
3131
-
 
3132
-    Attrib::Attrib (const Attrib &fa) :
 
3133
-       priv (new PrivateAttrib (*fa.priv))
 
3134
-    {
 
3135
-    }
 
3136
-
 
3137
-    Attrib::~Attrib ()
 
3138
-    {
 
3139
-       delete priv;
 
3140
-    }
 
3141
-
 
3142
-    Attrib &
 
3143
-    Attrib::operator= (const Attrib &rhs)
 
3144
-    {
 
3145
-       if (this == &rhs) // Check for self-assignment
 
3146
-           return *this;
 
3147
-
 
3148
-       delete priv;
 
3149
-       priv = new PrivateAttrib (*rhs.priv);
 
3150
-
 
3151
-       return *this;
 
3152
-    }
 
3153
-
 
3154
-    unsigned int
 
3155
-    Attrib::allocTextureUnits (unsigned int nTexture)
 
3156
-    {
 
3157
-       unsigned int first = priv->nTexture;
 
3158
-
 
3159
-       priv->nTexture += nTexture;
 
3160
-
 
3161
-       /* 0 is reserved for source texture */
 
3162
-       return 1 + first;
 
3163
-    }
 
3164
-
 
3165
-    unsigned int
 
3166
-    Attrib::allocParameters (unsigned int nParam)
 
3167
-    {
 
3168
-       unsigned int first = priv->nParam;
 
3169
-
 
3170
-       priv->nParam += nParam;
 
3171
-
 
3172
-       return first;
 
3173
-    }
 
3174
-
 
3175
-    void
 
3176
-    Attrib::addFunction (FunctionId function)
 
3177
-    {
 
3178
-       if (priv->nFunction < MAX_FRAGMENT_FUNCTIONS)
 
3179
-           priv->function[priv->nFunction++] = function;
 
3180
-    }
 
3181
-
 
3182
-    bool
 
3183
-    Attrib::enable (bool *blending)
 
3184
-    {
 
3185
-       GLuint name;
 
3186
-       GLenum type;
 
3187
-       bool   programBlending;
 
3188
-
 
3189
-       if (!GL::fragmentProgram)
 
3190
-           return false;
 
3191
-
 
3192
-       name = getFragmentProgram (GLScreen::get (screen), priv, &type,
 
3193
-                                  &programBlending);
 
3194
-       if (!name)
 
3195
-           return false;
 
3196
-
 
3197
-       *blending = !programBlending;
 
3198
-
 
3199
-       glEnable (GL_FRAGMENT_PROGRAM_ARB);
 
3200
-
 
3201
-       (*GL::bindProgram) (type, name);
 
3202
-
 
3203
-       return true;
 
3204
-    }
 
3205
-
 
3206
-    void
 
3207
-    Attrib::disable ()
 
3208
-    {
 
3209
-       glDisable (GL_FRAGMENT_PROGRAM_ARB);
 
3210
-    }
 
3211
-
 
3212
-    unsigned short
 
3213
-    Attrib::getSaturation ()
 
3214
-    {
 
3215
-       return priv->saturation;
 
3216
-    }
 
3217
-
 
3218
-    unsigned short
 
3219
-    Attrib::getBrightness ()
 
3220
-    {
 
3221
-       return priv->brightness;
 
3222
-    }
 
3223
-
 
3224
-    unsigned short
 
3225
-    Attrib::getOpacity ()
 
3226
-    {
 
3227
-       return priv->opacity;
 
3228
-    }
 
3229
-
 
3230
-    void
 
3231
-    Attrib::setSaturation (unsigned short value)
 
3232
-    {
 
3233
-       priv->saturation = value;
 
3234
-    }
 
3235
-
 
3236
-    void
 
3237
-    Attrib::setBrightness (unsigned short value)
 
3238
-        {
 
3239
-       priv->brightness = value;
 
3240
-    }
 
3241
-
 
3242
-
 
3243
-    void
 
3244
-    Attrib::setOpacity (unsigned short value)
 
3245
-    {
 
3246
-       priv->opacity = value;
 
3247
-    }
 
3248
-
 
3249
-    bool
 
3250
-    Attrib::hasFunctions ()
 
3251
-    {
 
3252
-       return priv->nFunction > 0;
 
3253
-    }
 
3254
-
 
3255
-    void destroyFragmentFunction (FunctionId id)
 
3256
-    {
 
3257
-       GLScreen *s = GLScreen::get (screen);
 
3258
-       Function *function;
 
3259
-       Program  *program;
 
3260
-
 
3261
-       function = findFragmentFunction (s, id);
 
3262
-
 
3263
-       if (!function)
 
3264
-           return;
 
3265
-
 
3266
-       std::vector<Program *>::iterator it;
 
3267
-
 
3268
-       do {
 
3269
-           program = NULL;
 
3270
-
 
3271
-           it = s->fragmentStorage ()->programs.begin ();
 
3272
-
 
3273
-           for (; it != s->fragmentStorage ()->programs.end (); it++)
 
3274
-           {
 
3275
-               foreach (FunctionId i, (*it)->signature)
 
3276
-                   if (i == id)
 
3277
-                   {
 
3278
-                       program = (*it);
 
3279
-                       break;
 
3280
-                   }
 
3281
-
 
3282
-               if (program)
 
3283
-                   break;
 
3284
-           }
 
3285
-
 
3286
-           if (program)
 
3287
-           {
 
3288
-               delete program;
 
3289
-               s->fragmentStorage ()->programs.erase (it);
 
3290
-           }
 
3291
-
 
3292
-       } while (program);
 
3293
-
 
3294
-       std::vector<Function *>::iterator fi =
 
3295
-           std::find (s->fragmentStorage ()->functions.begin (),
 
3296
-                      s->fragmentStorage ()->functions.end (),
 
3297
-                      function);
 
3298
-       if (fi != s->fragmentStorage ()->functions.end ())
 
3299
-           s->fragmentStorage ()->functions.erase (fi);
 
3300
-
 
3301
-       delete (function);
 
3302
-    }
 
3303
-
 
3304
-    FunctionId
 
3305
-    getSaturateFragmentFunction (GLTexture *texture,
 
3306
-                                int         param)
 
3307
-    {
 
3308
-       int      target;
 
3309
-       GLScreen *s = GLScreen::get (screen);
 
3310
-
 
3311
-       if (param >= 64)
 
3312
-           return 0;
 
3313
-
 
3314
-       if (texture->target () == GL_TEXTURE_2D)
 
3315
-           target = COMP_FETCH_TARGET_2D;
 
3316
-       else
 
3317
-           target = COMP_FETCH_TARGET_RECT;
 
3318
-
 
3319
-       if (!s->fragmentStorage ()->saturateFunction [target][param])
 
3320
-       {
 
3321
-           static const char *saturateData =
 
3322
-               "MUL temp, output, { 1.0, 1.0, 1.0, 0.0 };"
 
3323
-               "DP3 temp, temp, program.env[%d];"
 
3324
-               "LRP output.xyz, program.env[%d].w, output, temp;";
 
3325
-           FunctionData  data;
 
3326
-
 
3327
-           data.addTempHeaderOp ("temp");
 
3328
-           data.addFetchOp ("output", NULL, target);
 
3329
-           data.addColorOp ("output", "output");
 
3330
-
 
3331
-           data.addDataOp (saturateData, param, param);
 
3332
-
 
3333
-           if (!data.status ())
 
3334
-               return 0;
 
3335
-
 
3336
-           s->fragmentStorage ()->saturateFunction [target][param] =
 
3337
-               data.createFragmentFunction ("__core_saturate");
 
3338
-
 
3339
-       }
 
3340
-
 
3341
-       return s->fragmentStorage ()->saturateFunction [target][param];
 
3342
-    }
 
3343
-
 
3344
-    Storage::Storage () :
 
3345
-       lastFunctionId (1),
 
3346
-       functions (0),
 
3347
-       programs (0)
 
3348
-    {
 
3349
-       for (int i = 0; i < 64; i++)
 
3350
-       {
 
3351
-           saturateFunction[0][i] = 0;
 
3352
-           saturateFunction[1][i] = 0;
 
3353
-       }
 
3354
-    }
 
3355
-
 
3356
-    Storage::~Storage ()
 
3357
-    {
 
3358
-       foreach (Program *p, programs)
 
3359
-           delete p;
 
3360
-       programs.clear ();
 
3361
-       foreach (Function *f, functions)
 
3362
-           delete f;
 
3363
-       functions.clear ();
 
3364
-    }
 
3365
-
 
3366
-};
 
3367
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/framebufferobject.cpp linaro-gles2-debianpatches/plugins/opengl/src/framebufferobject.cpp
 
3368
--- compiz-0.9.7.8/plugins/opengl/src/framebufferobject.cpp     1970-01-01 01:00:00.000000000 +0100
 
3369
+++ linaro-gles2-debianpatches/plugins/opengl/src/framebufferobject.cpp 2012-04-20 11:41:59.241600000 +0200
 
3370
@@ -0,0 +1,191 @@
 
3371
+/*
 
3372
+ * Copyright (c) 2011 Collabora, Ltd.
 
3373
+ *
 
3374
+ * Permission to use, copy, modify, distribute, and sell this software
 
3375
+ * and its documentation for any purpose is hereby granted without
 
3376
+ * fee, provided that the above copyright notice appear in all copies
 
3377
+ * and that both that copyright notice and this permission notice
 
3378
+ * appear in supporting documentation, and that the name of
 
3379
+ * Collabora Ltd. not be used in advertising or publicity pertaining to
 
3380
+ * distribution of the software without specific, written prior permission.
 
3381
+ * Collabora Ltd. makes no representations about the suitability of this
 
3382
+ * software for any purpose. It is provided "as is" without express or
 
3383
+ * implied warranty.
 
3384
+ *
 
3385
+ * COLLABORA LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
3386
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
3387
+ * NO EVENT SHALL COLLABORA LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
3388
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
3389
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
3390
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
3391
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
3392
+ *
 
3393
+ * Authors: Pekka Paalanen <ppaalanen@gmail.com>
 
3394
+ */
 
3395
+
 
3396
+#include <map>
 
3397
+#include <opengl/framebufferobject.h>
 
3398
+#include <opengl/texture.h>
 
3399
+
 
3400
+struct PrivateGLFramebufferObject
 
3401
+{
 
3402
+    PrivateGLFramebufferObject () :
 
3403
+       fboId (0),
 
3404
+       glTex (NULL)
 
3405
+    {
 
3406
+    }
 
3407
+
 
3408
+    void pushFBO ();
 
3409
+    void popFBO ();
 
3410
+
 
3411
+    GLuint fboId;
 
3412
+    GLuint tmpId;
 
3413
+    GLTexture *glTex;
 
3414
+
 
3415
+    static std::map<GLuint, GLFramebufferObject *> idMap;
 
3416
+};
 
3417
+
 
3418
+std::map<GLuint, GLFramebufferObject *> PrivateGLFramebufferObject::idMap;
 
3419
+
 
3420
+void
 
3421
+PrivateGLFramebufferObject::pushFBO ()
 
3422
+{
 
3423
+    GLint id = 0;
 
3424
+    glGetIntegerv (GL_FRAMEBUFFER_BINDING, &id);
 
3425
+    tmpId = id;
 
3426
+    if (tmpId == fboId)
 
3427
+       return;
 
3428
+
 
3429
+    (*GL::bindFramebuffer) (GL_FRAMEBUFFER, fboId);
 
3430
+}
 
3431
+
 
3432
+void
 
3433
+PrivateGLFramebufferObject::popFBO ()
 
3434
+{
 
3435
+    if (tmpId != fboId)
 
3436
+       (*GL::bindFramebuffer) (GL_FRAMEBUFFER, tmpId);
 
3437
+}
 
3438
+
 
3439
+GLFramebufferObject::GLFramebufferObject () :
 
3440
+    priv (new PrivateGLFramebufferObject)
 
3441
+{
 
3442
+    (*GL::genFramebuffers) (1, &priv->fboId);
 
3443
+    if (priv->fboId != 0)
 
3444
+       PrivateGLFramebufferObject::idMap[priv->fboId] = this;
 
3445
+}
 
3446
+
 
3447
+GLFramebufferObject::~GLFramebufferObject ()
 
3448
+{
 
3449
+    if (priv->glTex)
 
3450
+       GLTexture::decRef (priv->glTex);
 
3451
+
 
3452
+    PrivateGLFramebufferObject::idMap.erase (priv->fboId);
 
3453
+    (*GL::deleteFramebuffers) (1, &priv->fboId);
 
3454
+
 
3455
+    delete priv;
 
3456
+}
 
3457
+
 
3458
+bool
 
3459
+GLFramebufferObject::allocate (const CompSize &size, const char *image,
 
3460
+                              GLenum format, GLenum type)
 
3461
+{
 
3462
+    if (!priv->glTex ||
 
3463
+        size.width () != priv->glTex->width () ||
 
3464
+        size.height () != priv->glTex->height ())
 
3465
+    {
 
3466
+       if (priv->glTex)
 
3467
+           GLTexture::decRef (priv->glTex);
 
3468
+       priv->glTex = NULL;
 
3469
+
 
3470
+       GLTexture::List list = GLTexture::imageDataToTexture (image, size,
 
3471
+                                                             format, type);
 
3472
+       if (list.size () != 1 || list[0] == NULL)
 
3473
+           return false;
 
3474
+
 
3475
+       priv->glTex = list[0];
 
3476
+       GLTexture::incRef (priv->glTex);
 
3477
+    }
 
3478
+
 
3479
+    priv->pushFBO ();
 
3480
+    (*GL::framebufferTexture2D) (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
 
3481
+                                 priv->glTex->target (),
 
3482
+                                 priv->glTex->name (), 0);
 
3483
+    priv->popFBO ();
 
3484
+    return true;
 
3485
+}
 
3486
+
 
3487
+GLFramebufferObject *
 
3488
+GLFramebufferObject::bind ()
 
3489
+{
 
3490
+    GLFramebufferObject *old = NULL;
 
3491
+    GLint id = 0;
 
3492
+
 
3493
+    glGetIntegerv (GL_FRAMEBUFFER_BINDING, &id);
 
3494
+    if (id != 0)
 
3495
+    {
 
3496
+       std::map<GLuint, GLFramebufferObject *>::iterator it;
 
3497
+       it = PrivateGLFramebufferObject::idMap.find (id);
 
3498
+
 
3499
+       if (it != PrivateGLFramebufferObject::idMap.end ())
 
3500
+           old = it->second;
 
3501
+       else
 
3502
+           compLogMessage ("opengl", CompLogLevelError,
 
3503
+               "An FBO without GLFramebufferObject cannot be restored");
 
3504
+    }
 
3505
+
 
3506
+    (*GL::bindFramebuffer) (GL_FRAMEBUFFER, priv->fboId);
 
3507
+
 
3508
+    return old;
 
3509
+}
 
3510
+
 
3511
+// static
 
3512
+void
 
3513
+GLFramebufferObject::rebind (GLFramebufferObject *fbo)
 
3514
+{
 
3515
+    GLuint id = fbo ? fbo->priv->fboId : 0;
 
3516
+    (*GL::bindFramebuffer) (GL_FRAMEBUFFER, id);
 
3517
+}
 
3518
+
 
3519
+static const char *
 
3520
+getFboErrorString (GLint status)
 
3521
+{
 
3522
+    switch (status)
 
3523
+    {
 
3524
+       case        GL_FRAMEBUFFER_COMPLETE:
 
3525
+           return "GL_FRAMEBUFFER_COMPLETE";
 
3526
+       case        GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
 
3527
+           return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
 
3528
+       case        GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
 
3529
+           return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
 
3530
+#ifdef USE_GLES
 
3531
+       case        GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
 
3532
+           return "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
 
3533
+#endif
 
3534
+       case        GL_FRAMEBUFFER_UNSUPPORTED:
 
3535
+           return "GL_FRAMEBUFFER_UNSUPPORTED";
 
3536
+       default:
 
3537
+           return "unexpected status";
 
3538
+    }
 
3539
+}
 
3540
+
 
3541
+bool
 
3542
+GLFramebufferObject::checkStatus ()
 
3543
+{
 
3544
+    priv->pushFBO ();
 
3545
+    GLint status = (*GL::checkFramebufferStatus) (GL_FRAMEBUFFER);
 
3546
+    priv->popFBO ();
 
3547
+
 
3548
+    if (status == GL_FRAMEBUFFER_COMPLETE)
 
3549
+       return true;
 
3550
+
 
3551
+    compLogMessage ("opengl", CompLogLevelError,
 
3552
+                    "FBO is incomplete: %s (0x%04x)",
 
3553
+                    getFboErrorString (status), status);
 
3554
+    return false;
 
3555
+}
 
3556
+
 
3557
+GLTexture *
 
3558
+GLFramebufferObject::tex ()
 
3559
+{
 
3560
+       return priv->glTex;
 
3561
+}
 
3562
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/matrix.cpp linaro-gles2-debianpatches/plugins/opengl/src/matrix.cpp
 
3563
--- compiz-0.9.7.8/plugins/opengl/src/matrix.cpp        2012-04-26 08:47:01.000000000 +0200
 
3564
+++ linaro-gles2-debianpatches/plugins/opengl/src/matrix.cpp    2012-04-20 11:41:59.241600000 +0200
 
3565
@@ -163,6 +163,60 @@
 
3566
 #undef B
 
3567
 #undef P
 
3568
 
 
3569
+/*
 
3570
+** Invert 4x4 matrix.
 
3571
+** Contributed by David Moore (See Mesa bug #6748)
 
3572
+*/
 
3573
+bool GLMatrix::invert ()
 
3574
+{
 
3575
+    float inv[16], det;
 
3576
+    int i;
 
3577
+
 
3578
+    inv[0] =   m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15]
 
3579
+             + m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10];
 
3580
+    inv[4] =  -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15]
 
3581
+             - m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10];
 
3582
+    inv[8] =   m[4]*m[9]*m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15]
 
3583
+             + m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9];
 
3584
+    inv[12] = -m[4]*m[9]*m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14]
 
3585
+             - m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9];
 
3586
+    inv[1] =  -m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15]
 
3587
+             - m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10];
 
3588
+    inv[5] =   m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15]
 
3589
+             + m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10];
 
3590
+    inv[9] =  -m[0]*m[9]*m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15]
 
3591
+             - m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9];
 
3592
+    inv[13] =  m[0]*m[9]*m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14]
 
3593
+             + m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9];
 
3594
+    inv[2] =   m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15]
 
3595
+             + m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6];
 
3596
+    inv[6] =  -m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15]
 
3597
+             - m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6];
 
3598
+    inv[10] =  m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15]
 
3599
+             + m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5];
 
3600
+    inv[14] = -m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14]
 
3601
+             - m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5];
 
3602
+    inv[3] =  -m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11]
 
3603
+             - m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6];
 
3604
+    inv[7] =   m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11]
 
3605
+             + m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6];
 
3606
+    inv[11] = -m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11]
 
3607
+             - m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5];
 
3608
+    inv[15] =  m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10]
 
3609
+             + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5];
 
3610
+
 
3611
+    det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12];
 
3612
+    if (det == 0)
 
3613
+        return false;
 
3614
+
 
3615
+    det = 1.0f / det;
 
3616
+
 
3617
+    for (i = 0; i < 16; i++)
 
3618
+        m[i] = inv[i] * det;
 
3619
+
 
3620
+    return true;
 
3621
+}
 
3622
+
 
3623
 /**
 
3624
  * Generate a 4x4 transformation matrix from glRotate parameters, and
 
3625
  * post-multiply the input matrix by it.
 
3626
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/paint.cpp linaro-gles2-debianpatches/plugins/opengl/src/paint.cpp
 
3627
--- compiz-0.9.7.8/plugins/opengl/src/paint.cpp 2012-04-26 08:47:01.000000000 +0200
 
3628
+++ linaro-gles2-debianpatches/plugins/opengl/src/paint.cpp     2012-04-20 11:41:59.241600000 +0200
 
3629
@@ -1,5 +1,6 @@
 
3630
 /*
 
3631
  * Copyright © 2005 Novell, Inc.
 
3632
+ * Copyright © 2011 Linaro, Ltd.
 
3633
  *
 
3634
  * Permission to use, copy, modify, distribute, and sell this software
 
3635
  * and its documentation for any purpose is hereby granted without
 
3636
@@ -20,7 +21,8 @@
 
3637
  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
3638
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
3639
  *
 
3640
- * Author: David Reveman <davidr@novell.com>
 
3641
+ * Authors: David Reveman <davidr@novell.com>
 
3642
+ *          Travis Watkins <travis.watkins@linaro.org>
 
3643
  */
 
3644
 
 
3645
 #include "privates.h"
 
3646
@@ -35,6 +37,8 @@
 
3647
 
 
3648
 #include <opengl/opengl.h>
 
3649
 
 
3650
+#include "privates.h"
 
3651
+
 
3652
 #define DEG2RAD (M_PI / 180.0f)
 
3653
 
 
3654
 GLScreenPaintAttrib defaultScreenPaintAttrib = {
 
3655
@@ -64,14 +68,16 @@
 
3656
 }
 
3657
 
 
3658
 void
 
3659
-PrivateGLScreen::paintBackground (const CompRegion &region,
 
3660
-                                 bool             transformed)
 
3661
+PrivateGLScreen::paintBackground (const GLMatrix   &transform,
 
3662
+                                  const CompRegion &region,
 
3663
+                                  bool             transformed)
 
3664
 {
 
3665
+    GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
 
3666
+    GLfloat         vertexData[18];
 
3667
+    GLushort        colorData[4];
 
3668
+
 
3669
     BoxPtr    pBox = const_cast <Region> (region.handle ())->rects;
 
3670
     int              n, nBox = const_cast <Region> (region.handle ())->numRects;
 
3671
-    GLfloat   *d;
 
3672
-
 
3673
-    boost::scoped_array <GLfloat> data;
 
3674
 
 
3675
     if (!nBox)
 
3676
        return;
 
3677
@@ -97,86 +103,111 @@
 
3678
 
 
3679
     if (backgroundTextures.empty ())
 
3680
     {
 
3681
-       data.reset (new GLfloat [nBox * 8]);
 
3682
-
 
3683
-       d = data.get ();
 
3684
+       streamingBuffer->begin (GL_TRIANGLES);
 
3685
        n = nBox;
 
3686
 
 
3687
        while (n--)
 
3688
        {
 
3689
-           *d++ = pBox->x1;
 
3690
-           *d++ = pBox->y2;
 
3691
-
 
3692
-           *d++ = pBox->x2;
 
3693
-           *d++ = pBox->y2;
 
3694
+           vertexData[0]  = pBox->x1;
 
3695
+           vertexData[1]  = pBox->y1;
 
3696
+           vertexData[2]  = 0.0f;
 
3697
+           vertexData[3]  = pBox->x1;
 
3698
+           vertexData[4]  = pBox->y2;
 
3699
+           vertexData[5]  = 0.0f;
 
3700
+           vertexData[6]  = pBox->x2;
 
3701
+           vertexData[7]  = pBox->y1;
 
3702
+           vertexData[8]  = 0.0f;
 
3703
+           vertexData[9]  = pBox->x1;
 
3704
+           vertexData[10] = pBox->y2;
 
3705
+           vertexData[11] = 0.0f;
 
3706
+           vertexData[12] = pBox->x2;
 
3707
+           vertexData[13] = pBox->y2;
 
3708
+           vertexData[14] = 0.0f;
 
3709
+
 
3710
+           vertexData[15] = pBox->x2;
 
3711
+           vertexData[16] = pBox->y1;
 
3712
+           vertexData[17] = 0.0f;
 
3713
 
 
3714
-           *d++ = pBox->x2;
 
3715
-           *d++ = pBox->y1;
 
3716
-
 
3717
-           *d++ = pBox->x1;
 
3718
-           *d++ = pBox->y1;
 
3719
+           streamingBuffer->addVertices (6, vertexData);
 
3720
 
 
3721
            pBox++;
 
3722
        }
 
3723
 
 
3724
-       glDisableClientState (GL_TEXTURE_COORD_ARRAY);
 
3725
-
 
3726
-       glVertexPointer (2, GL_FLOAT, sizeof (GLfloat) * 2, &data[0]);
 
3727
+       colorData[0] = colorData[1] = colorData[2] = 0;
 
3728
+       colorData[3] = std::numeric_limits <unsigned short>::max ();
 
3729
+       streamingBuffer->addColors (1, colorData);
 
3730
 
 
3731
-       glColor4us (0, 0, 0, std::numeric_limits<unsigned short>::max ());
 
3732
-       glDrawArrays (GL_QUADS, 0, nBox * 4);
 
3733
-       glColor4usv (defaultColor);
 
3734
-
 
3735
-       glEnableClientState (GL_TEXTURE_COORD_ARRAY);
 
3736
+       streamingBuffer->end ();
 
3737
+       streamingBuffer->render (transform);
 
3738
     }
 
3739
     else
 
3740
     {
 
3741
-       data.reset (new GLfloat [nBox * 16]);
 
3742
-
 
3743
-       d = data.get ();
 
3744
        n = nBox;
 
3745
 
 
3746
        for (unsigned int i = 0; i < backgroundTextures.size (); i++)
 
3747
        {
 
3748
+           GLfloat textureData[12];
 
3749
            GLTexture *bg = backgroundTextures[i];
 
3750
            CompRegion r = region & *bg;
 
3751
 
 
3752
            pBox = const_cast <Region> (r.handle ())->rects;
 
3753
            nBox = const_cast <Region> (r.handle ())->numRects;
 
3754
-           d = data.get ();
 
3755
            n = nBox;
 
3756
 
 
3757
+           streamingBuffer->begin (GL_TRIANGLES);
 
3758
+
 
3759
            while (n--)
 
3760
            {
 
3761
-               *d++ = COMP_TEX_COORD_X (bg->matrix (), pBox->x1);
 
3762
-               *d++ = COMP_TEX_COORD_Y (bg->matrix (), pBox->y2);
 
3763
-
 
3764
-               *d++ = pBox->x1;
 
3765
-               *d++ = pBox->y2;
 
3766
-
 
3767
-               *d++ = COMP_TEX_COORD_X (bg->matrix (), pBox->x2);
 
3768
-               *d++ = COMP_TEX_COORD_Y (bg->matrix (), pBox->y2);
 
3769
-
 
3770
-               *d++ = pBox->x2;
 
3771
-               *d++ = pBox->y2;
 
3772
-
 
3773
-               *d++ = COMP_TEX_COORD_X (bg->matrix (), pBox->x2);
 
3774
-               *d++ = COMP_TEX_COORD_Y (bg->matrix (), pBox->y1);
 
3775
+               GLfloat tx1 = COMP_TEX_COORD_X (bg->matrix (), pBox->x1);
 
3776
+               GLfloat tx2 = COMP_TEX_COORD_X (bg->matrix (), pBox->x2);
 
3777
+               GLfloat ty1 = COMP_TEX_COORD_Y (bg->matrix (), pBox->y1);
 
3778
+               GLfloat ty2 = COMP_TEX_COORD_Y (bg->matrix (), pBox->y2);
 
3779
+
 
3780
+               vertexData[0]  = pBox->x1;
 
3781
+               vertexData[1]  = pBox->y1;
 
3782
+               vertexData[2]  = 0.0f;
 
3783
+               vertexData[3]  = pBox->x1;
 
3784
+               vertexData[4]  = pBox->y2;
 
3785
+               vertexData[5]  = 0.0f;
 
3786
+               vertexData[6]  = pBox->x2;
 
3787
+               vertexData[7]  = pBox->y1;
 
3788
+               vertexData[8]  = 0.0f;
 
3789
+               vertexData[9]  = pBox->x1;
 
3790
+               vertexData[10] = pBox->y2;
 
3791
+               vertexData[11] = 0.0f;
 
3792
+               vertexData[12] = pBox->x2;
 
3793
+               vertexData[13] = pBox->y2;
 
3794
+               vertexData[14] = 0.0f;
 
3795
+
 
3796
+               vertexData[15] = pBox->x2;
 
3797
+               vertexData[16] = pBox->y1;
 
3798
+               vertexData[17] = 0.0f;
 
3799
+
 
3800
+               textureData[0]  = tx1;
 
3801
+               textureData[1]  = ty1;
 
3802
+
 
3803
+               textureData[2]  = tx1;
 
3804
+               textureData[3]  = ty2;
 
3805
+
 
3806
+               textureData[4]  = tx2;
 
3807
+               textureData[5]  = ty1;
 
3808
+
 
3809
+               textureData[6]  = tx1;
 
3810
+               textureData[7]  = ty2;
 
3811
 
 
3812
-               *d++ = pBox->x2;
 
3813
-               *d++ = pBox->y1;
 
3814
+               textureData[8]  = tx2;
 
3815
+               textureData[9]  = ty2;
 
3816
 
 
3817
-               *d++ = COMP_TEX_COORD_X (bg->matrix (), pBox->x1);
 
3818
-               *d++ = COMP_TEX_COORD_Y (bg->matrix (), pBox->y1);
 
3819
+               textureData[10] = tx2;
 
3820
+               textureData[11] = ty1;
 
3821
 
 
3822
-               *d++ = pBox->x1;
 
3823
-               *d++ = pBox->y1;
 
3824
+               streamingBuffer->addVertices (6, vertexData);
 
3825
+               streamingBuffer->addTexCoords (0, 6, textureData);
 
3826
 
 
3827
                pBox++;
 
3828
            }
 
3829
 
 
3830
-           glTexCoordPointer (2, GL_FLOAT, sizeof (GLfloat) * 4, &data[0]);
 
3831
-           glVertexPointer (2, GL_FLOAT, sizeof (GLfloat) * 4, &data[2]);
 
3832
+           streamingBuffer->end ();
 
3833
 
 
3834
            if (bg->name ())
 
3835
            {
 
3836
@@ -185,7 +216,7 @@
 
3837
                else
 
3838
                    bg->enable (GLTexture::Fast);
 
3839
 
 
3840
-               glDrawArrays (GL_QUADS, 0, nBox * 4);
 
3841
+               streamingBuffer->render (transform);
 
3842
 
 
3843
                bg->disable ();
 
3844
            }
 
3845
@@ -329,7 +360,9 @@
 
3846
        CompositeWindow::get (fullscreenWindow)->unredirect ();
 
3847
 
 
3848
     if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
 
3849
-       paintBackground (tmpRegion, (mask & PAINT_SCREEN_TRANSFORMED_MASK));
 
3850
+       paintBackground (transform,
 
3851
+                        tmpRegion,
 
3852
+                        (mask & PAINT_SCREEN_TRANSFORMED_MASK));
 
3853
 
 
3854
     /* paint all windows from bottom to top */
 
3855
     foreach (w, pl)
 
3856
@@ -377,6 +410,7 @@
 
3857
 {
 
3858
     WRAPABLE_HND_FUNCTN (glEnableOutputClipping, transform, region, output)
 
3859
 
 
3860
+    #ifndef USE_GLES
 
3861
     GLdouble h = screen->height ();
 
3862
 
 
3863
     GLdouble p1[2] = { static_cast<GLdouble> (region.handle ()->extents.x1),
 
3864
@@ -409,6 +443,7 @@
 
3865
     glEnable (GL_CLIP_PLANE3);
 
3866
 
 
3867
     glPopMatrix ();
 
3868
+    #endif
 
3869
 }
 
3870
 
 
3871
 void
 
3872
@@ -416,10 +451,12 @@
 
3873
 {
 
3874
     WRAPABLE_HND_FUNCTN (glDisableOutputClipping)
 
3875
 
 
3876
+    #ifndef USE_GLES
 
3877
     glDisable (GL_CLIP_PLANE0);
 
3878
     glDisable (GL_CLIP_PLANE1);
 
3879
     glDisable (GL_CLIP_PLANE2);
 
3880
     glDisable (GL_CLIP_PLANE3);
 
3881
+    #endif
 
3882
 }
 
3883
 
 
3884
 #define CLIP_PLANE_MASK (PAINT_SCREEN_TRANSFORMED_MASK | \
 
3885
@@ -449,26 +486,14 @@
 
3886
        glEnableOutputClipping (sTransform, region, output);
 
3887
 
 
3888
        sTransform.toScreenSpace (output, -sAttrib.zTranslate);
 
3889
-
 
3890
-       glPushMatrix ();
 
3891
-       glLoadMatrixf (sTransform.getMatrix ());
 
3892
-
 
3893
        priv->paintOutputRegion (sTransform, region, output, mask);
 
3894
 
 
3895
-       glPopMatrix ();
 
3896
-
 
3897
        glDisableOutputClipping ();
 
3898
     }
 
3899
     else
 
3900
     {
 
3901
        sTransform.toScreenSpace (output, -sAttrib.zTranslate);
 
3902
-
 
3903
-       glPushMatrix ();
 
3904
-       glLoadMatrixf (sTransform.getMatrix ());
 
3905
-
 
3906
        priv->paintOutputRegion (sTransform, region, output, mask);
 
3907
-
 
3908
-       glPopMatrix ();
 
3909
     }
 
3910
 }
 
3911
 
 
3912
@@ -503,13 +528,8 @@
 
3913
 
 
3914
        sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
 
3915
 
 
3916
-       glPushMatrix ();
 
3917
-       glLoadMatrixf (sTransform.getMatrix ());
 
3918
-
 
3919
        priv->paintOutputRegion (sTransform, region, output, mask);
 
3920
 
 
3921
-       glPopMatrix ();
 
3922
-
 
3923
        return true;
 
3924
     }
 
3925
     else if (mask & PAINT_SCREEN_FULL_MASK)
 
3926
@@ -525,182 +545,260 @@
 
3927
     }
 
3928
 }
 
3929
 
 
3930
-#define ADD_RECT(data, m, n, x1, y1, x2, y2)      \
 
3931
-    for (it = 0; it < n; it++)                    \
 
3932
-    {                                             \
 
3933
-        const GLTexture::Matrix &mat = m[it];     \
 
3934
-       *(data)++ = COMP_TEX_COORD_X (mat, x1);    \
 
3935
-       *(data)++ = COMP_TEX_COORD_Y (mat, y1);    \
 
3936
-    }                                             \
 
3937
-    *(data)++ = (x1);                             \
 
3938
-    *(data)++ = (y1);                             \
 
3939
-    *(data)++ = 0.0;                              \
 
3940
-    for (it = 0; it < n; it++)                    \
 
3941
-    {                                             \
 
3942
-        const GLTexture::Matrix &mat = m[it];     \
 
3943
-       *(data)++ = COMP_TEX_COORD_X (mat, x1);    \
 
3944
-       *(data)++ = COMP_TEX_COORD_Y (mat, y2);    \
 
3945
-    }                                             \
 
3946
-    *(data)++ = (x1);                             \
 
3947
-    *(data)++ = (y2);                             \
 
3948
-    *(data)++ = 0.0;                              \
 
3949
-    for (it = 0; it < n; it++)                    \
 
3950
-    {                                             \
 
3951
-        const GLTexture::Matrix &mat = m[it];     \
 
3952
-       *(data)++ = COMP_TEX_COORD_X (mat, x2);    \
 
3953
-       *(data)++ = COMP_TEX_COORD_Y (mat, y2);    \
 
3954
-    }                                             \
 
3955
-    *(data)++ = (x2);                             \
 
3956
-    *(data)++ = (y2);                             \
 
3957
-    *(data)++ = 0.0;                              \
 
3958
-    for (it = 0; it < n; it++)                    \
 
3959
-    {                                             \
 
3960
-        const GLTexture::Matrix &mat = m[it];     \
 
3961
-       *(data)++ = COMP_TEX_COORD_X (mat, x2);    \
 
3962
-       *(data)++ = COMP_TEX_COORD_Y (mat, y1);    \
 
3963
-    }                                             \
 
3964
-    *(data)++ = (x2);                             \
 
3965
-    *(data)++ = (y1);                             \
 
3966
-    *(data)++ = 0.0
 
3967
-
 
3968
-#define ADD_QUAD(data, m, n, x1, y1, x2, y2)           \
 
3969
-    for (it = 0; it < n; it++)                         \
 
3970
-    {                                                  \
 
3971
-        const GLTexture::Matrix &mat = m[it];          \
 
3972
-       *(data)++ = COMP_TEX_COORD_XY (mat, x1, y1);    \
 
3973
-       *(data)++ = COMP_TEX_COORD_YX (mat, x1, y1);    \
 
3974
-    }                                                  \
 
3975
-    *(data)++ = (x1);                                  \
 
3976
-    *(data)++ = (y1);                                  \
 
3977
-    *(data)++ = 0.0;                                   \
 
3978
-    for (it = 0; it < n; it++)                         \
 
3979
-    {                                                  \
 
3980
-        const GLTexture::Matrix &mat = m[it];          \
 
3981
-       *(data)++ = COMP_TEX_COORD_XY (mat, x1, y2);    \
 
3982
-       *(data)++ = COMP_TEX_COORD_YX (mat, x1, y2);    \
 
3983
-    }                                                  \
 
3984
-    *(data)++ = (x1);                                  \
 
3985
-    *(data)++ = (y2);                                  \
 
3986
-    *(data)++ = 0.0;                                   \
 
3987
-    for (it = 0; it < n; it++)                         \
 
3988
-    {                                                  \
 
3989
-        const GLTexture::Matrix &mat = m[it];          \
 
3990
-       *(data)++ = COMP_TEX_COORD_XY (mat, x2, y2);    \
 
3991
-       *(data)++ = COMP_TEX_COORD_YX (mat, x2, y2);    \
 
3992
-    }                                                  \
 
3993
-    *(data)++ = (x2);                                  \
 
3994
-    *(data)++ = (y2);                                  \
 
3995
-    *(data)++ = 0.0;                                   \
 
3996
-    for (it = 0; it < n; it++)                         \
 
3997
-    {                                                  \
 
3998
-        const GLTexture::Matrix &mat = m[it];          \
 
3999
-       *(data)++ = COMP_TEX_COORD_XY (mat, x2, y1);    \
 
4000
-       *(data)++ = COMP_TEX_COORD_YX (mat, x2, y1);    \
 
4001
-    }                                                  \
 
4002
-    *(data)++ = (x2);                                  \
 
4003
-    *(data)++ = (y1);                                  \
 
4004
-    *(data)++ = 0.0;
 
4005
-
 
4006
 void
 
4007
-GLWindow::glDrawGeometry ()
 
4008
+GLScreen::glPaintCompositedOutput (const CompRegion    &region,
 
4009
+                                  GLFramebufferObject *fbo,
 
4010
+                                  unsigned int         mask)
 
4011
 {
 
4012
-    WRAPABLE_HND_FUNCTN (glDrawGeometry)
 
4013
-
 
4014
-    int     texUnit = priv->geometry.texUnits;
 
4015
-    int     currentTexUnit = 0;
 
4016
-    int     stride = priv->geometry.vertexStride;
 
4017
-    GLfloat *vertices = priv->geometry.vertices + (stride - 3);
 
4018
+    WRAPABLE_HND_FUNCTN (glPaintCompositedOutput, region, fbo, mask)
 
4019
 
 
4020
-    stride *= sizeof (GLfloat);
 
4021
+    GLMatrix sTransform;
 
4022
+    std::vector<GLfloat> vertexData;
 
4023
+    std::vector<GLfloat> textureData;
 
4024
+    const GLTexture::Matrix & texmatrix = fbo->tex ()->matrix ();
 
4025
+    GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
 
4026
+
 
4027
+    streamingBuffer->begin (GL_TRIANGLES);
 
4028
+
 
4029
+    if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
 
4030
+    {
 
4031
+       GLfloat tx1 = COMP_TEX_COORD_X (texmatrix, 0.0f);
 
4032
+       GLfloat tx2 = COMP_TEX_COORD_X (texmatrix, screen->width ());
 
4033
+       GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, 0.0f);
 
4034
+       GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, screen->height ());
 
4035
+
 
4036
+       vertexData = {
 
4037
+           0.0f,                    0.0f,                     0.0f,
 
4038
+           0.0f,                    (float)screen->height (), 0.0f,
 
4039
+           (float)screen->width (), 0.0f,                     0.0f,
 
4040
+
 
4041
+           0.0f,                    (float)screen->height (), 0.0f,
 
4042
+           (float)screen->width (), (float)screen->height (), 0.0f,
 
4043
+           (float)screen->width (), 0.0f,                     0.0f,
 
4044
+       };
 
4045
+
 
4046
+       textureData = {
 
4047
+           tx1, ty1,
 
4048
+           tx1, ty2,
 
4049
+           tx2, ty1,
 
4050
+           tx1, ty2,
 
4051
+           tx2, ty2,
 
4052
+           tx2, ty1,
 
4053
+       };
 
4054
 
 
4055
-    glVertexPointer (3, GL_FLOAT, stride, vertices);
 
4056
-
 
4057
-    while (texUnit--)
 
4058
+       streamingBuffer->addVertices (6, &vertexData[0]);
 
4059
+       streamingBuffer->addTexCoords (0, 6, &textureData[0]);
 
4060
+    }
 
4061
+    else
 
4062
     {
 
4063
-       if (texUnit != currentTexUnit)
 
4064
+       BoxPtr pBox = const_cast <Region> (region.handle ())->rects;
 
4065
+       int nBox = const_cast <Region> (region.handle ())->numRects;
 
4066
+
 
4067
+       while (nBox--)
 
4068
        {
 
4069
-           (*GL::clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
 
4070
-           glEnableClientState (GL_TEXTURE_COORD_ARRAY);
 
4071
-           currentTexUnit = texUnit;
 
4072
+           GLfloat tx1 = COMP_TEX_COORD_X (texmatrix, pBox->x1);
 
4073
+           GLfloat tx2 = COMP_TEX_COORD_X (texmatrix, pBox->x2);
 
4074
+           GLfloat ty1 = 1.0 - COMP_TEX_COORD_Y (texmatrix, pBox->y1);
 
4075
+           GLfloat ty2 = 1.0 - COMP_TEX_COORD_Y (texmatrix, pBox->y2);
 
4076
+
 
4077
+           vertexData = {
 
4078
+               (float)pBox->x1, (float)pBox->y1, 0.0f,
 
4079
+               (float)pBox->x1, (float)pBox->y2, 0.0f,
 
4080
+               (float)pBox->x2, (float)pBox->y1, 0.0f,
 
4081
+
 
4082
+               (float)pBox->x1, (float)pBox->y2, 0.0f,
 
4083
+               (float)pBox->x2, (float)pBox->y2, 0.0f,
 
4084
+               (float)pBox->x2, (float)pBox->y1, 0.0f,
 
4085
+           };
 
4086
+
 
4087
+           textureData = {
 
4088
+               tx1, ty1,
 
4089
+               tx1, ty2,
 
4090
+               tx2, ty1,
 
4091
+               tx1, ty2,
 
4092
+               tx2, ty2,
 
4093
+               tx2, ty1,
 
4094
+           };
 
4095
+
 
4096
+           streamingBuffer->addVertices (6, &vertexData[0]);
 
4097
+           streamingBuffer->addTexCoords (0, 6, &textureData[0]);
 
4098
+           pBox++;
 
4099
        }
 
4100
-       vertices -= priv->geometry.texCoordSize;
 
4101
-       glTexCoordPointer (priv->geometry.texCoordSize,
 
4102
-                          GL_FLOAT, stride, vertices);
 
4103
     }
 
4104
 
 
4105
-    glDrawArrays (GL_QUADS, 0, priv->geometry.vCount);
 
4106
-
 
4107
-    /* disable all texture coordinate arrays except 0 */
 
4108
-    texUnit = priv->geometry.texUnits;
 
4109
-    if (texUnit > 1)
 
4110
-    {
 
4111
-       while (--texUnit)
 
4112
-       {
 
4113
-           (*GL::clientActiveTexture) (GL_TEXTURE0_ARB + texUnit);
 
4114
-           glDisableClientState (GL_TEXTURE_COORD_ARRAY);
 
4115
-       }
 
4116
+    streamingBuffer->end ();
 
4117
+    fbo->tex ()-> enable (GLTexture::Fast);
 
4118
+    sTransform.toScreenSpace (&screen->fullscreenOutput (), -DEFAULT_Z_CAMERA);
 
4119
+    streamingBuffer->render (sTransform);
 
4120
+    fbo->tex ()-> disable ();
 
4121
+}
 
4122
 
 
4123
-       (*GL::clientActiveTexture) (GL_TEXTURE0_ARB);
 
4124
+#define ADD_RECT(vertexBuffer, m, n, x1, y1, x2, y2) \
 
4125
+    GLfloat vertexData[18] = {                       \
 
4126
+       (float)x1, (float)y1, 0.0,                   \
 
4127
+       (float)x1, (float)y2, 0.0,                   \
 
4128
+       (float)x2, (float)y1, 0.0,                   \
 
4129
+       (float)x2, (float)y1, 0.0,                   \
 
4130
+       (float)x1, (float)y2, 0.0,                   \
 
4131
+       (float)x2, (float)y2, 0.0                    \
 
4132
+    };                                               \
 
4133
+    vertexBuffer->addVertices (6, vertexData);       \
 
4134
+                                                     \
 
4135
+    for (it = 0; it < n; it++)                       \
 
4136
+    {                                                \
 
4137
+       GLfloat data[2];                             \
 
4138
+       const GLTexture::Matrix &mat = m[it];        \
 
4139
+       data[0] = COMP_TEX_COORD_X (mat, x1);        \
 
4140
+       data[1] = COMP_TEX_COORD_Y (mat, y1);        \
 
4141
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4142
+    }                                                \
 
4143
+    for (it = 0; it < n; it++)                       \
 
4144
+    {                                                \
 
4145
+       GLfloat data[2];                             \
 
4146
+       const GLTexture::Matrix &mat = m[it];        \
 
4147
+       data[0] = COMP_TEX_COORD_X (mat, x1);        \
 
4148
+       data[1] = COMP_TEX_COORD_Y (mat, y2);        \
 
4149
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4150
+    }                                                \
 
4151
+    for (it = 0; it < n; it++)                       \
 
4152
+    {                                                \
 
4153
+       GLfloat data[2];                             \
 
4154
+       const GLTexture::Matrix &mat = m[it];        \
 
4155
+       data[0] = COMP_TEX_COORD_X (mat, x2);        \
 
4156
+       data[1] = COMP_TEX_COORD_Y (mat, y1);        \
 
4157
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4158
+    }                                                \
 
4159
+    for (it = 0; it < n; it++)                       \
 
4160
+    {                                                \
 
4161
+       GLfloat data[2];                             \
 
4162
+       const GLTexture::Matrix &mat = m[it];        \
 
4163
+       data[0] = COMP_TEX_COORD_X (mat, x2);        \
 
4164
+       data[1] = COMP_TEX_COORD_Y (mat, y1);        \
 
4165
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4166
+    }                                                \
 
4167
+    for (it = 0; it < n; it++)                       \
 
4168
+    {                                                \
 
4169
+       GLfloat data[2];                             \
 
4170
+       const GLTexture::Matrix &mat = m[it];        \
 
4171
+       data[0] = COMP_TEX_COORD_X (mat, x1);        \
 
4172
+       data[1] = COMP_TEX_COORD_Y (mat, y2);        \
 
4173
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4174
+    }                                                \
 
4175
+    for (it = 0; it < n; it++)                       \
 
4176
+    {                                                \
 
4177
+       GLfloat data[2];                             \
 
4178
+       const GLTexture::Matrix &mat = m[it];        \
 
4179
+       data[0] = COMP_TEX_COORD_X (mat, x2);        \
 
4180
+       data[1] = COMP_TEX_COORD_Y (mat, y2);        \
 
4181
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4182
+    }
 
4183
+
 
4184
+#define ADD_QUAD(vertexBuffer, m, n, x1, y1, x2, y2) \
 
4185
+    GLfloat vertexData[18] = {                       \
 
4186
+       (float)x1, (float)y1, 0.0,                   \
 
4187
+       (float)x1, (float)y2, 0.0,                   \
 
4188
+       (float)x2, (float)y1, 0.0,                   \
 
4189
+       (float)x2, (float)y1, 0.0,                   \
 
4190
+       (float)x1, (float)y2, 0.0,                   \
 
4191
+       (float)x2, (float)y2, 0.0                    \
 
4192
+    };                                               \
 
4193
+    vertexBuffer->addVertices (6, vertexData);       \
 
4194
+                                                     \
 
4195
+    for (it = 0; it < n; it++)                       \
 
4196
+    {                                                \
 
4197
+       GLfloat data[2];                             \
 
4198
+       const GLTexture::Matrix &mat = m[it];        \
 
4199
+       data[0] = COMP_TEX_COORD_XY (mat, x1, y1);   \
 
4200
+       data[1] = COMP_TEX_COORD_YX (mat, x1, y1);   \
 
4201
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4202
+    }                                                \
 
4203
+    for (it = 0; it < n; it++)                       \
 
4204
+    {                                                \
 
4205
+       GLfloat data[2];                             \
 
4206
+       const GLTexture::Matrix &mat = m[it];        \
 
4207
+       data[0] = COMP_TEX_COORD_XY (mat, x1, y2);   \
 
4208
+       data[1] = COMP_TEX_COORD_YX (mat, x1, y2);   \
 
4209
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4210
+    }                                                \
 
4211
+    for (it = 0; it < n; it++)                       \
 
4212
+    {                                                \
 
4213
+       GLfloat data[2];                             \
 
4214
+       const GLTexture::Matrix &mat = m[it];        \
 
4215
+       data[0] = COMP_TEX_COORD_XY (mat, x2, y1);   \
 
4216
+       data[1] = COMP_TEX_COORD_YX (mat, x2, y1);   \
 
4217
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4218
+    }                                                \
 
4219
+    for (it = 0; it < n; it++)                       \
 
4220
+    {                                                \
 
4221
+       GLfloat data[2];                             \
 
4222
+       const GLTexture::Matrix &mat = m[it];        \
 
4223
+       data[0] = COMP_TEX_COORD_XY (mat, x2, y1);   \
 
4224
+       data[1] = COMP_TEX_COORD_YX (mat, x2, y1);   \
 
4225
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4226
+    }                                                \
 
4227
+    for (it = 0; it < n; it++)                       \
 
4228
+    {                                                \
 
4229
+       GLfloat data[2];                             \
 
4230
+       const GLTexture::Matrix &mat = m[it];        \
 
4231
+       data[0] = COMP_TEX_COORD_XY (mat, x1, y2);   \
 
4232
+       data[1] = COMP_TEX_COORD_YX (mat, x1, y2);   \
 
4233
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4234
+    }                                                \
 
4235
+    for (it = 0; it < n; it++)                       \
 
4236
+    {                                                \
 
4237
+       GLfloat data[2];                             \
 
4238
+       const GLTexture::Matrix &mat = m[it];        \
 
4239
+       data[0] = COMP_TEX_COORD_XY (mat, x2, y2);   \
 
4240
+       data[1] = COMP_TEX_COORD_YX (mat, x2, y2);   \
 
4241
+       vertexBuffer->addTexCoords (it, 1, data);    \
 
4242
     }
 
4243
-}
 
4244
+
 
4245
 
 
4246
 static inline void
 
4247
-addSingleQuad (GLfloat      *&d,
 
4248
-              const        GLTexture::MatrixList &matrix,
 
4249
-              unsigned int nMatrix,
 
4250
-              int          x1,
 
4251
-              int          y1,
 
4252
-              int          x2,
 
4253
-              int          y2,
 
4254
-              int          &n,
 
4255
-              bool         rect)
 
4256
+addSingleQuad (GLVertexBuffer *vertexBuffer,
 
4257
+               const GLTexture::MatrixList &matrix,
 
4258
+               unsigned int nMatrix,
 
4259
+               int          x1,
 
4260
+               int          y1,
 
4261
+               int          x2,
 
4262
+               int          y2,
 
4263
+               int          &n,
 
4264
+               bool         rect)
 
4265
 {
 
4266
     unsigned int it;
 
4267
 
 
4268
     if (rect)
 
4269
     {
 
4270
-       ADD_RECT (d, matrix, nMatrix, x1, y1, x2, y2);
 
4271
+       ADD_RECT (vertexBuffer, matrix, nMatrix, x1, y1, x2, y2);
 
4272
     }
 
4273
     else
 
4274
     {
 
4275
-       ADD_QUAD (d, matrix, nMatrix, x1, y1, x2, y2);
 
4276
+       ADD_QUAD (vertexBuffer, matrix, nMatrix, x1, y1, x2, y2);
 
4277
     }
 
4278
     n++;
 
4279
 }
 
4280
 
 
4281
 static inline void
 
4282
-addQuads (GLfloat      *&d,
 
4283
-         const        GLTexture::MatrixList &matrix,
 
4284
-         unsigned int nMatrix,
 
4285
-         int          x1,
 
4286
-         int          y1,
 
4287
-         int          x2,
 
4288
-         int          y2,
 
4289
-         int          &n,
 
4290
-         int          vSize,
 
4291
-         bool         rect,
 
4292
-         GLWindow::Geometry &geometry,
 
4293
-         unsigned int maxGridWidth,
 
4294
-         unsigned int maxGridHeight)
 
4295
+addQuads (GLVertexBuffer *vertexBuffer,
 
4296
+          const GLTexture::MatrixList &matrix,
 
4297
+          unsigned int nMatrix,
 
4298
+          int          x1,
 
4299
+          int          y1,
 
4300
+          int          x2,
 
4301
+          int          y2,
 
4302
+          int          &n,
 
4303
+          bool         rect,
 
4304
+          unsigned int maxGridWidth,
 
4305
+          unsigned int maxGridHeight)
 
4306
 {
 
4307
     int nQuadsX = (maxGridWidth == MAXSHORT) ? 1 :
 
4308
        1 + (x2 - x1 - 1) / (int) maxGridWidth;  // ceil. division
 
4309
     int nQuadsY = (maxGridHeight == MAXSHORT) ? 1 :
 
4310
        1 + (y2 - y1 - 1) / (int) maxGridHeight;
 
4311
-    int newVertexSize = (n + nQuadsX * nQuadsY) * vSize * 4;
 
4312
-
 
4313
-    // Make sure enough vertices are allocated for nQuadsX * nQuadsY more quads
 
4314
-    if (newVertexSize > geometry.vertexSize)
 
4315
-    {
 
4316
-       if (!geometry.moreVertices (newVertexSize))
 
4317
-           return;
 
4318
-
 
4319
-       d = geometry.vertices + (n * vSize * 4);
 
4320
-    }
 
4321
 
 
4322
     if (nQuadsX == 1 && nQuadsY == 1)
 
4323
     {
 
4324
-       addSingleQuad (d, matrix, nMatrix, x1, y1, x2, y2, n, rect);
 
4325
+       addSingleQuad (vertexBuffer, matrix, nMatrix, x1, y1, x2, y2, n, rect);
 
4326
     }
 
4327
     else
 
4328
     {
 
4329
@@ -716,7 +814,8 @@
 
4330
            {
 
4331
                nx2 = MIN (nx1 + (int) quadWidth, x2);
 
4332
 
 
4333
-               addSingleQuad (d, matrix, nMatrix, nx1, ny1, nx2, ny2, n, rect);
 
4334
+               addSingleQuad (vertexBuffer, matrix, nMatrix,
 
4335
+                              nx1, ny1, nx2, ny2, n, rect);
 
4336
            }
 
4337
        }
 
4338
     }
 
4339
@@ -729,13 +828,11 @@
 
4340
                         unsigned int                maxGridWidth,
 
4341
                         unsigned int                maxGridHeight)
 
4342
 {
 
4343
-    WRAPABLE_HND_FUNCTN (glAddGeometry, matrix, region, clip)
 
4344
+    WRAPABLE_HND_FUNCTN (glAddGeometry, matrix, region, clip, maxGridWidth, maxGridHeight)
 
4345
 
 
4346
     BoxRec full;
 
4347
     int    nMatrix = matrix.size ();
 
4348
 
 
4349
-    priv->geometry.texUnits = nMatrix;
 
4350
-
 
4351
     full = clip.handle ()->extents;
 
4352
     if (region.handle ()->extents.x1 > full.x1)
 
4353
        full.x1 = region.handle ()->extents.x1;
 
4354
@@ -753,9 +850,7 @@
 
4355
        BoxPtr  pClip;
 
4356
        int     nClip;
 
4357
        BoxRec  cbox;
 
4358
-       int     vSize;
 
4359
        int     n, it, x1, y1, x2, y2;
 
4360
-       GLfloat *d;
 
4361
        bool    rect = true;
 
4362
 
 
4363
        for (it = 0; it < nMatrix; it++)
 
4364
@@ -770,18 +865,6 @@
 
4365
        pBox = const_cast <Region> (region.handle ())->rects;
 
4366
        nBox = const_cast <Region> (region.handle ())->numRects;
 
4367
 
 
4368
-       vSize = 3 + nMatrix * 2;
 
4369
-
 
4370
-       n = priv->geometry.vCount / 4;
 
4371
-
 
4372
-       if ((n + nBox) * vSize * 4 > priv->geometry.vertexSize)
 
4373
-       {
 
4374
-           if (!priv->geometry.moreVertices ((n + nBox) * vSize * 4))
 
4375
-               return;
 
4376
-       }
 
4377
-
 
4378
-       d = priv->geometry.vertices + (priv->geometry.vCount * vSize);
 
4379
-
 
4380
        while (nBox--)
 
4381
        {
 
4382
            x1 = pBox->x1;
 
4383
@@ -806,24 +889,15 @@
 
4384
 
 
4385
                if (nClip == 1)
 
4386
                {
 
4387
-                   addQuads (d, matrix, nMatrix,
 
4388
+                   addQuads (priv->vertexBuffer, matrix, nMatrix,
 
4389
                              x1, y1, x2, y2,
 
4390
-                             n, vSize, rect, priv->geometry,
 
4391
+                             n, rect,
 
4392
                              maxGridWidth, maxGridHeight);
 
4393
                }
 
4394
                else
 
4395
                {
 
4396
                    pClip = const_cast <Region> (clip.handle ())->rects;
 
4397
 
 
4398
-                   if (((n + nClip) * vSize * 4) > priv->geometry.vertexSize)
 
4399
-                   {
 
4400
-                       if (!priv->geometry.moreVertices ((n + nClip) *
 
4401
-                                                         vSize * 4))
 
4402
-                           return;
 
4403
-
 
4404
-                       d = priv->geometry.vertices + (n * vSize * 4);
 
4405
-                   }
 
4406
-
 
4407
                    while (nClip--)
 
4408
                    {
 
4409
                        cbox = *pClip;
 
4410
@@ -841,120 +915,32 @@
 
4411
 
 
4412
                        if (cbox.x1 < cbox.x2 && cbox.y1 < cbox.y2)
 
4413
                        {
 
4414
-                           addQuads (d, matrix, nMatrix,
 
4415
+                           addQuads (priv->vertexBuffer, matrix, nMatrix,
 
4416
                                      cbox.x1, cbox.y1, cbox.x2, cbox.y2,
 
4417
-                                     n, vSize, rect, priv->geometry,
 
4418
+                                     n, rect,
 
4419
                                      maxGridWidth, maxGridHeight);
 
4420
                        }
 
4421
                    }
 
4422
                }
 
4423
            }
 
4424
        }
 
4425
-
 
4426
-       priv->geometry.vCount       = n * 4;
 
4427
-       priv->geometry.vertexStride = vSize;
 
4428
-       priv->geometry.texCoordSize = 2;
 
4429
-    }
 
4430
-}
 
4431
-
 
4432
-static bool
 
4433
-enableFragmentProgramAndDrawGeometry (GLScreen          *gs,
 
4434
-                                     GLWindow           *w,
 
4435
-                                     GLTexture          *texture,
 
4436
-                                     GLFragment::Attrib &attrib,
 
4437
-                                     GLTexture::Filter  filter,
 
4438
-                                     unsigned int       mask)
 
4439
-{
 
4440
-    GLFragment::Attrib fa (attrib);
 
4441
-    bool               blending;
 
4442
-
 
4443
-    if (GL::canDoSaturated && attrib.getSaturation () != COLOR)
 
4444
-    {
 
4445
-       int param, function;
 
4446
-
 
4447
-       param    = fa.allocParameters (1);
 
4448
-       function =
 
4449
-           GLFragment::getSaturateFragmentFunction (texture, param);
 
4450
-
 
4451
-       fa.addFunction (function);
 
4452
-
 
4453
-       (*GL::programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, param,
 
4454
-                                     RED_SATURATION_WEIGHT,
 
4455
-                                     GREEN_SATURATION_WEIGHT,
 
4456
-                                     BLUE_SATURATION_WEIGHT,
 
4457
-                                     attrib.getSaturation () / 65535.0f);
 
4458
-    }
 
4459
-
 
4460
-    if (!fa.enable (&blending))
 
4461
-       return false;
 
4462
-
 
4463
-    texture->enable (filter);
 
4464
-
 
4465
-    if (mask & PAINT_WINDOW_BLEND_MASK)
 
4466
-    {
 
4467
-       if (blending)
 
4468
-           glEnable (GL_BLEND);
 
4469
-
 
4470
-       if (attrib.getOpacity () != OPAQUE || attrib.getBrightness () != BRIGHT)
 
4471
-       {
 
4472
-           GLushort color;
 
4473
-
 
4474
-           color = (attrib.getOpacity () * attrib.getBrightness ()) >> 16;
 
4475
-
 
4476
-           gs->setTexEnvMode (GL_MODULATE);
 
4477
-           glColor4us (color, color, color, attrib.getOpacity ());
 
4478
-
 
4479
-           w->glDrawGeometry ();
 
4480
-
 
4481
-           glColor4usv (defaultColor);
 
4482
-           gs->setTexEnvMode (GL_REPLACE);
 
4483
-       }
 
4484
-       else
 
4485
-       {
 
4486
-           w->glDrawGeometry ();
 
4487
-       }
 
4488
-
 
4489
-       if (blending)
 
4490
-           glDisable (GL_BLEND);
 
4491
-    }
 
4492
-    else if (attrib.getBrightness () != BRIGHT)
 
4493
-    {
 
4494
-       gs->setTexEnvMode (GL_MODULATE);
 
4495
-       glColor4us (attrib.getBrightness (), attrib.getBrightness (),
 
4496
-                   attrib.getBrightness (), BRIGHT);
 
4497
-
 
4498
-       w->glDrawGeometry ();
 
4499
-
 
4500
-       glColor4usv (defaultColor);
 
4501
-       gs->setTexEnvMode (GL_REPLACE);
 
4502
     }
 
4503
-    else
 
4504
-    {
 
4505
-       w->glDrawGeometry ();
 
4506
-    }
 
4507
-
 
4508
-    texture->disable ();
 
4509
-
 
4510
-    fa.disable ();
 
4511
-
 
4512
-    return true;
 
4513
 }
 
4514
 
 
4515
+#ifndef USE_GLES
 
4516
 static void
 
4517
-enableFragmentOperationsAndDrawGeometry (GLScreen          *gs,
 
4518
-                                        GLWindow           *w,
 
4519
-                                        GLTexture          *texture,
 
4520
-                                        GLFragment::Attrib &attrib,
 
4521
-                                        GLTexture::Filter  filter,
 
4522
-                                        unsigned int       mask)
 
4523
+enableLegacyOBSAndRender (GLScreen                  *gs,
 
4524
+                          GLWindow                  *w,
 
4525
+                          GLTexture                 *texture,
 
4526
+                          const GLMatrix            &transform,
 
4527
+                          const GLWindowPaintAttrib &attrib,
 
4528
+                          GLTexture::Filter         filter,
 
4529
+                          unsigned int              mask)
 
4530
 {
 
4531
-    if (GL::canDoSaturated && attrib.getSaturation () != COLOR)
 
4532
+    if (GL::canDoSaturated && attrib.saturation != COLOR)
 
4533
     {
 
4534
        GLfloat constant[4];
 
4535
 
 
4536
-       if (mask & PAINT_WINDOW_BLEND_MASK)
 
4537
-           glEnable (GL_BLEND);
 
4538
-
 
4539
        texture->enable (filter);
 
4540
 
 
4541
        glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
 
4542
@@ -985,7 +971,7 @@
 
4543
        glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
 
4544
        glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
 
4545
 
 
4546
-       if (GL::canDoSlightlySaturated && attrib.getSaturation () > 0)
 
4547
+       if (GL::canDoSlightlySaturated && attrib.saturation > 0)
 
4548
        {
 
4549
            glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
 
4550
            glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
 
4551
@@ -1016,20 +1002,20 @@
 
4552
            glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
 
4553
            glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
 
4554
 
 
4555
-           constant[3] = attrib.getSaturation () / 65535.0f;
 
4556
+           constant[3] = attrib.saturation / 65535.0f;
 
4557
 
 
4558
            glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
 
4559
 
 
4560
-           if (attrib.getOpacity () < OPAQUE ||
 
4561
-               attrib.getBrightness () != BRIGHT)
 
4562
+           if (attrib.opacity < OPAQUE ||
 
4563
+               attrib.brightness != BRIGHT)
 
4564
            {
 
4565
                GL::activeTexture (GL_TEXTURE3_ARB);
 
4566
 
 
4567
                texture->enable (filter);
 
4568
 
 
4569
-               constant[3] = attrib.getOpacity () / 65535.0f;
 
4570
+               constant[3] = attrib.opacity / 65535.0f;
 
4571
                constant[0] = constant[1] = constant[2] = constant[3] *
 
4572
-                   attrib.getBrightness () / 65535.0f;
 
4573
+                   attrib.brightness / 65535.0f;
 
4574
 
 
4575
                glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
 
4576
 
 
4577
@@ -1047,7 +1033,7 @@
 
4578
                glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
 
4579
                glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
 
4580
 
 
4581
-               w->glDrawGeometry ();
 
4582
+               w->vertexBuffer ()->render (transform, attrib);
 
4583
 
 
4584
                texture->disable ();
 
4585
 
 
4586
@@ -1057,7 +1043,7 @@
 
4587
            }
 
4588
            else
 
4589
            {
 
4590
-               w->glDrawGeometry ();
 
4591
+               w->vertexBuffer ()->render (transform, attrib);
 
4592
            }
 
4593
 
 
4594
            texture->disable ();
 
4595
@@ -1074,9 +1060,9 @@
 
4596
            glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
 
4597
            glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
 
4598
 
 
4599
-           constant[3] = attrib.getOpacity () / 65535.0f;
 
4600
+           constant[3] = attrib.opacity / 65535.0f;
 
4601
            constant[0] = constant[1] = constant[2] = constant[3] *
 
4602
-                         attrib.getBrightness ()/ 65535.0f;
 
4603
+                         attrib.brightness / 65535.0f;
 
4604
 
 
4605
            constant[0] = 0.5f + 0.5f * RED_SATURATION_WEIGHT   * constant[0];
 
4606
            constant[1] = 0.5f + 0.5f * GREEN_SATURATION_WEIGHT * constant[1];
 
4607
@@ -1084,7 +1070,7 @@
 
4608
 
 
4609
            glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
 
4610
 
 
4611
-           w->glDrawGeometry ();
 
4612
+           w->vertexBuffer ()->render (transform, attrib);
 
4613
        }
 
4614
 
 
4615
        texture->disable ();
 
4616
@@ -1097,9 +1083,6 @@
 
4617
 
 
4618
        glColor4usv (defaultColor);
 
4619
        gs->setTexEnvMode (GL_REPLACE);
 
4620
-
 
4621
-       if (mask & PAINT_WINDOW_BLEND_MASK)
 
4622
-           glDisable (GL_BLEND);
 
4623
     }
 
4624
     else
 
4625
     {
 
4626
@@ -1107,57 +1090,64 @@
 
4627
 
 
4628
        if (mask & PAINT_WINDOW_BLEND_MASK)
 
4629
        {
 
4630
-           glEnable (GL_BLEND);
 
4631
-           if (attrib.getOpacity ()!= OPAQUE ||
 
4632
-               attrib.getBrightness () != BRIGHT)
 
4633
+           if (attrib.opacity != OPAQUE ||
 
4634
+               attrib.brightness != BRIGHT)
 
4635
            {
 
4636
                GLushort color;
 
4637
 
 
4638
-               color = (attrib.getOpacity () * attrib.getBrightness ()) >> 16;
 
4639
+               color = (attrib.opacity * attrib.brightness) >> 16;
 
4640
 
 
4641
                gs->setTexEnvMode (GL_MODULATE);
 
4642
-               glColor4us (color, color, color, attrib.getOpacity ());
 
4643
+               glColor4us (color, color, color, attrib.opacity);
 
4644
 
 
4645
-               w->glDrawGeometry ();
 
4646
+               w->vertexBuffer ()->render (transform, attrib);
 
4647
 
 
4648
                glColor4usv (defaultColor);
 
4649
                gs->setTexEnvMode (GL_REPLACE);
 
4650
            }
 
4651
            else
 
4652
            {
 
4653
-               w->glDrawGeometry ();
 
4654
+               w->vertexBuffer ()->render (transform, attrib);
 
4655
            }
 
4656
-
 
4657
-           glDisable (GL_BLEND);
 
4658
        }
 
4659
-       else if (attrib.getBrightness () != BRIGHT)
 
4660
+       else if (attrib.brightness != BRIGHT)
 
4661
        {
 
4662
            gs->setTexEnvMode (GL_MODULATE);
 
4663
-           glColor4us (attrib.getBrightness (), attrib.getBrightness (),
 
4664
-                       attrib.getBrightness (), BRIGHT);
 
4665
+           glColor4us (attrib.brightness, attrib.brightness,
 
4666
+                       attrib.brightness, BRIGHT);
 
4667
 
 
4668
-           w->glDrawGeometry ();
 
4669
+           w->vertexBuffer ()->render (transform, attrib);
 
4670
 
 
4671
            glColor4usv (defaultColor);
 
4672
            gs->setTexEnvMode (GL_REPLACE);
 
4673
        }
 
4674
        else
 
4675
        {
 
4676
-           w->glDrawGeometry ();
 
4677
+           w->vertexBuffer ()->render (transform, attrib);
 
4678
        }
 
4679
 
 
4680
        texture->disable ();
 
4681
     }
 
4682
 }
 
4683
+#endif
 
4684
 
 
4685
 void
 
4686
-GLWindow::glDrawTexture (GLTexture          *texture,
 
4687
-                        GLFragment::Attrib &attrib,
 
4688
-                        unsigned int       mask)
 
4689
+GLWindow::glDrawTexture (GLTexture                 *texture,
 
4690
+                         const GLMatrix            &transform,
 
4691
+                        const GLWindowPaintAttrib &attrib,
 
4692
+                        unsigned int              mask)
 
4693
 {
 
4694
-    WRAPABLE_HND_FUNCTN (glDrawTexture, texture, attrib, mask)
 
4695
+    WRAPABLE_HND_FUNCTN (glDrawTexture, texture, transform, attrib, mask)
 
4696
 
 
4697
     GLTexture::Filter filter;
 
4698
+    GLboolean isBlendingEnabled = GL_FALSE;
 
4699
+
 
4700
+    // Enable blending if needed
 
4701
+    if (mask & PAINT_WINDOW_BLEND_MASK) {
 
4702
+       glGetBooleanv (GL_BLEND, &isBlendingEnabled);
 
4703
+       if (!isBlendingEnabled)
 
4704
+           glEnable(GL_BLEND);
 
4705
+    }
 
4706
 
 
4707
     if (mask & (PAINT_WINDOW_TRANSFORMED_MASK |
 
4708
                PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK))
 
4709
@@ -1165,24 +1155,36 @@
 
4710
     else
 
4711
        filter = priv->gScreen->filter (NOTHING_TRANS_FILTER);
 
4712
 
 
4713
-    if ((!attrib.hasFunctions () && (!priv->gScreen->lighting () ||
 
4714
-        attrib.getSaturation () == COLOR || attrib.getSaturation () == 0)) ||
 
4715
-       !enableFragmentProgramAndDrawGeometry (priv->gScreen, this, texture,
 
4716
-                                              attrib, filter, mask))
 
4717
-    {
 
4718
-       enableFragmentOperationsAndDrawGeometry (priv->gScreen, this, texture,
 
4719
-                                                attrib, filter, mask);
 
4720
-    }
 
4721
+    glActiveTexture(GL_TEXTURE0);
 
4722
+    texture->enable (filter);
 
4723
+
 
4724
+    #ifdef USE_GLES
 
4725
+    priv->vertexBuffer->render (transform, attrib);
 
4726
+    #else
 
4727
+
 
4728
+    if (!GL::vbo && !GL::shaders)
 
4729
+       enableLegacyOBSAndRender (priv->gScreen, this, texture, transform,
 
4730
+                                  attrib, filter, mask);
 
4731
+    else
 
4732
+       priv->vertexBuffer->render (transform, attrib);
 
4733
+    #endif
 
4734
+
 
4735
+    priv->shaders.clear ();
 
4736
+    texture->disable ();
 
4737
+
 
4738
+    // Reset blending to old value
 
4739
+    if ((mask & PAINT_WINDOW_BLEND_MASK) && !isBlendingEnabled)
 
4740
+       glDisable(GL_BLEND);
 
4741
 }
 
4742
 
 
4743
 bool
 
4744
-GLWindow::glDraw (const GLMatrix     &transform,
 
4745
-                 GLFragment::Attrib &fragment,
 
4746
-                 const CompRegion   &region,
 
4747
-                 unsigned int       mask)
 
4748
+GLWindow::glDraw (const GLMatrix            &transform,
 
4749
+                 const GLWindowPaintAttrib &attrib,
 
4750
+                 const CompRegion          &region,
 
4751
+                 unsigned int              mask)
 
4752
 {
 
4753
     WRAPABLE_HND_FUNCTN_RETURN (bool, glDraw, transform,
 
4754
-                             fragment, region, mask)
 
4755
+                             attrib, region, mask)
 
4756
 
 
4757
     const CompRegion &reg = (mask & PAINT_WINDOW_TRANSFORMED_MASK) ?
 
4758
                             infiniteRegion : region;
 
4759
@@ -1213,10 +1215,11 @@
 
4760
     if (priv->textures.size () == 1)
 
4761
     {
 
4762
        ml[0] = priv->matrices[0];
 
4763
-       priv->geometry.reset ();
 
4764
+       priv->vertexBuffer->begin ();
 
4765
        glAddGeometry (ml, priv->window->region (), reg);
 
4766
-       if (priv->geometry.vCount)
 
4767
-           glDrawTexture (priv->textures[0], fragment, mask);
 
4768
+       priv->vertexBuffer->end ();
 
4769
+
 
4770
+       glDrawTexture (priv->textures[0], transform, attrib, mask);
 
4771
     }
 
4772
     else
 
4773
     {
 
4774
@@ -1225,10 +1228,11 @@
 
4775
        for (unsigned int i = 0; i < priv->textures.size (); i++)
 
4776
        {
 
4777
            ml[0] = priv->matrices[i];
 
4778
-           priv->geometry.reset ();
 
4779
+           priv->vertexBuffer->begin ();
 
4780
            glAddGeometry (ml, priv->regions[i], reg);
 
4781
-           if (priv->geometry.vCount)
 
4782
-               glDrawTexture (priv->textures[i], fragment, mask);
 
4783
+           priv->vertexBuffer->end ();
 
4784
+
 
4785
+           glDrawTexture (priv->textures[i], transform, attrib, mask);
 
4786
        }
 
4787
     }
 
4788
 
 
4789
@@ -1243,7 +1247,6 @@
 
4790
 {
 
4791
     WRAPABLE_HND_FUNCTN_RETURN (bool, glPaint, attrib, transform, region, mask)
 
4792
 
 
4793
-    GLFragment::Attrib fragment (attrib);
 
4794
     bool               status;
 
4795
 
 
4796
     priv->lastPaint = attrib;
 
4797
@@ -1273,18 +1276,7 @@
 
4798
     if (mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK)
 
4799
        return true;
 
4800
 
 
4801
-    if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
 
4802
-        mask & PAINT_WINDOW_WITH_OFFSET_MASK)
 
4803
-    {
 
4804
-       glPushMatrix ();
 
4805
-       glLoadMatrixf (transform.getMatrix ());
 
4806
-    }
 
4807
-
 
4808
-    status = glDraw (transform, fragment, region, mask);
 
4809
-
 
4810
-    if (mask & PAINT_WINDOW_TRANSFORMED_MASK ||
 
4811
-        mask & PAINT_WINDOW_WITH_OFFSET_MASK)
 
4812
-       glPopMatrix ();
 
4813
+    status = glDraw (transform, attrib, region, mask);
 
4814
 
 
4815
     return status;
 
4816
 }
 
4817
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/privatefragment.h linaro-gles2-debianpatches/plugins/opengl/src/privatefragment.h
 
4818
--- compiz-0.9.7.8/plugins/opengl/src/privatefragment.h 2012-04-26 08:47:01.000000000 +0200
 
4819
+++ linaro-gles2-debianpatches/plugins/opengl/src/privatefragment.h     1970-01-01 01:00:00.000000000 +0100
 
4820
@@ -1,54 +0,0 @@
 
4821
-/*
 
4822
- * Copyright © 2008 Dennis Kasprzyk
 
4823
- * Copyright © 2007 Novell, Inc.
 
4824
- *
 
4825
- * Permission to use, copy, modify, distribute, and sell this software
 
4826
- * and its documentation for any purpose is hereby granted without
 
4827
- * fee, provided that the above copyright notice appear in all copies
 
4828
- * and that both that copyright notice and this permission notice
 
4829
- * appear in supporting documentation, and that the name of
 
4830
- * Dennis Kasprzyk not be used in advertising or publicity pertaining to
 
4831
- * distribution of the software without specific, written prior permission.
 
4832
- * Dennis Kasprzyk makes no representations about the suitability of this
 
4833
- * software for any purpose. It is provided "as is" without express or
 
4834
- * implied warranty.
 
4835
- *
 
4836
- * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
4837
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
4838
- * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
4839
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
4840
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
4841
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
4842
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
4843
- *
 
4844
- * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
 
4845
- *          David Reveman <davidr@novell.com>
 
4846
- */
 
4847
-
 
4848
-#ifndef _PRIVATEFRAGMENT_H
 
4849
-#define _PRIVATEFRAGMENT_H
 
4850
-
 
4851
-#include <vector>
 
4852
-
 
4853
-#include <opengl/fragment.h>
 
4854
-
 
4855
-namespace GLFragment {
 
4856
-
 
4857
-    class Function;
 
4858
-    class Program;
 
4859
-
 
4860
-    class Storage {
 
4861
-       public:
 
4862
-           Storage ();
 
4863
-           ~Storage ();
 
4864
-
 
4865
-       public:
 
4866
-           int lastFunctionId;
 
4867
-           std::vector<Function *> functions;
 
4868
-           std::vector<Program *> programs;
 
4869
-
 
4870
-           FunctionId saturateFunction[2][64];
 
4871
-    };
 
4872
-};
 
4873
-
 
4874
-#endif
 
4875
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/privates.h linaro-gles2-debianpatches/plugins/opengl/src/privates.h
 
4876
--- compiz-0.9.7.8/plugins/opengl/src/privates.h        2012-04-26 08:47:01.000000000 +0200
 
4877
+++ linaro-gles2-debianpatches/plugins/opengl/src/privates.h    2012-04-20 11:41:59.241600000 +0200
 
4878
@@ -32,8 +32,12 @@
 
4879
 #include <opengl/opengl.h>
 
4880
 #include <core/atoms.h>
 
4881
 
 
4882
-#include "privatefragment.h"
 
4883
+#ifdef USE_GLES
 
4884
+#include <opengl/framebufferobject.h>
 
4885
+#endif
 
4886
+
 
4887
 #include "privatetexture.h"
 
4888
+#include "privatevertexbuffer.h"
 
4889
 #include "opengl_options.h"
 
4890
 
 
4891
 extern CompOutput *targetOutput;
 
4892
@@ -75,8 +79,9 @@
 
4893
        void controlSwapVideoSync ();
 
4894
        void waitForVideoSync ();
 
4895
 
 
4896
-       void paintBackground (const CompRegion &region,
 
4897
-                             bool             transformed);
 
4898
+       void paintBackground (const GLMatrix   &transform,
 
4899
+                             const CompRegion &region,
 
4900
+                              bool             transformed);
 
4901
 
 
4902
        void paintOutputRegion (const GLMatrix   &transform,
 
4903
                                const CompRegion &region,
 
4904
@@ -94,7 +99,9 @@
 
4905
 
 
4906
        GLenum textureFilter;
 
4907
 
 
4908
+       #ifndef USE_GLES
 
4909
        GLFBConfig      glxPixmapFBConfigs[MAX_DEPTH + 1];
 
4910
+       #endif
 
4911
 
 
4912
        GLTexture::List backgroundTextures;
 
4913
        bool            backgroundLoaded;
 
4914
@@ -103,28 +110,41 @@
 
4915
 
 
4916
        CompPoint rasterPos;
 
4917
 
 
4918
-       GLFragment::Storage fragmentStorage;
 
4919
-
 
4920
-       GLfloat projection[16];
 
4921
+       GLMatrix *projection;
 
4922
 
 
4923
        bool clearBuffers;
 
4924
        bool lighting;
 
4925
 
 
4926
-       GL::GLXGetProcAddressProc getProcAddress;
 
4927
-
 
4928
+       #ifdef USE_GLES
 
4929
+       EGLContext ctx;
 
4930
+       EGLSurface surface;
 
4931
+       #else
 
4932
        GLXContext ctx;
 
4933
 
 
4934
+       GL::GLXGetProcAddressProc getProcAddress;
 
4935
+       #endif
 
4936
+
 
4937
+       GLFramebufferObject *scratchFbo;
 
4938
        CompRegion outputRegion;
 
4939
 
 
4940
        bool pendingCommands;
 
4941
 
 
4942
        XRectangle lastViewport;
 
4943
+       bool refreshSubBuffer;
 
4944
+       unsigned int lastMask;
 
4945
 
 
4946
        std::vector<GLTexture::BindPixmapProc> bindPixmap;
 
4947
        bool hasCompositing;
 
4948
 
 
4949
        GLIcon defaultIcon;
 
4950
 
 
4951
+       Window saveWindow; // hack for broken applications, see:
 
4952
+                          // https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/807487
 
4953
+
 
4954
+       GLProgramCache *programCache;
 
4955
+       GLShaderCache   shaderCache;
 
4956
+       GLVertexBuffer::AutoProgram *autoProgram;
 
4957
+
 
4958
        Pixmap rootPixmapCopy;
 
4959
        CompSize rootPixmapSize;
 
4960
 };
 
4961
@@ -169,10 +189,15 @@
 
4962
 
 
4963
        unsigned int lastMask;
 
4964
 
 
4965
-       GLWindow::Geometry geometry;
 
4966
+       GLVertexBuffer *vertexBuffer;
 
4967
+
 
4968
+       // map of shaders, plugin name is key, pair of vertex and fragment
 
4969
+       // shader source code is value
 
4970
+       std::list<const GLShaderData*> shaders;
 
4971
+       GLVertexBuffer::AutoProgram *autoProgram;
 
4972
 
 
4973
        std::list<GLIcon> icons;
 
4974
 };
 
4975
 
 
4976
-
 
4977
 #endif
 
4978
+
 
4979
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/privatetexture.h linaro-gles2-debianpatches/plugins/opengl/src/privatetexture.h
 
4980
--- compiz-0.9.7.8/plugins/opengl/src/privatetexture.h  2012-04-26 08:47:01.000000000 +0200
 
4981
+++ linaro-gles2-debianpatches/plugins/opengl/src/privatetexture.h      2012-04-20 11:41:59.241600000 +0200
 
4982
@@ -1,6 +1,7 @@
 
4983
 /*
 
4984
  * Copyright © 2008 Dennis Kasprzyk
 
4985
  * Copyright © 2007 Novell, Inc.
 
4986
+ * Copyright © 2011 Linaro Ltd.
 
4987
  *
 
4988
  * Permission to use, copy, modify, distribute, and sell this software
 
4989
  * and its documentation for any purpose is hereby granted without
 
4990
@@ -23,13 +24,21 @@
 
4991
  *
 
4992
  * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
 
4993
  *          David Reveman <davidr@novell.com>
 
4994
+ *          Travis Watkins <travis.watkins@linaro.org>
 
4995
  */
 
4996
 
 
4997
 #ifndef _PRIVATETEXTURE_H
 
4998
 #define _PRIVATETEXTURE_H
 
4999
 
 
5000
+#ifdef USE_GLES
 
5001
+#define SUPPORT_X11
 
5002
+#include <GLES2/gl2.h>
 
5003
+#include <EGL/egl.h>
 
5004
+#include <EGL/eglext.h>
 
5005
+#else
 
5006
 #include <GL/gl.h>
 
5007
 #include <GL/glx.h>
 
5008
+#endif
 
5009
 #include <opengl/texture.h>
 
5010
 #include <X11/extensions/Xdamage.h>
 
5011
 
 
5012
@@ -62,6 +71,28 @@
 
5013
        int               refCount;
 
5014
 };
 
5015
 
 
5016
+#ifdef USE_GLES
 
5017
+class EglTexture : public GLTexture {
 
5018
+    public:
 
5019
+       EglTexture ();
 
5020
+       ~EglTexture ();
 
5021
+
 
5022
+       void enable (Filter filter);
 
5023
+
 
5024
+       static List bindPixmapToTexture (Pixmap pixmap,
 
5025
+                                        int width,
 
5026
+                                        int height,
 
5027
+                                        int depth);
 
5028
+
 
5029
+    public:
 
5030
+       bool        damaged;
 
5031
+       Damage      damage;
 
5032
+       bool        updateMipMap;
 
5033
+};
 
5034
+
 
5035
+extern std::map<Damage, EglTexture*> boundPixmapTex;
 
5036
+#else
 
5037
+
 
5038
 class TfpTexture : public GLTexture {
 
5039
     public:
 
5040
        TfpTexture ();
 
5041
@@ -82,5 +113,6 @@
 
5042
 };
 
5043
 
 
5044
 extern std::map<Damage, TfpTexture*> boundPixmapTex;
 
5045
+#endif
 
5046
 
 
5047
 #endif
 
5048
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/privatevertexbuffer.h linaro-gles2-debianpatches/plugins/opengl/src/privatevertexbuffer.h
 
5049
--- compiz-0.9.7.8/plugins/opengl/src/privatevertexbuffer.h     1970-01-01 01:00:00.000000000 +0100
 
5050
+++ linaro-gles2-debianpatches/plugins/opengl/src/privatevertexbuffer.h 2012-04-20 11:41:59.241600000 +0200
 
5051
@@ -0,0 +1,138 @@
 
5052
+/*
 
5053
+ * Copyright © 2011 Linaro Ltd.
 
5054
+ *
 
5055
+ * Permission to use, copy, modify, distribute, and sell this software
 
5056
+ * and its documentation for any purpose is hereby granted without
 
5057
+ * fee, provided that the above copyright notice appear in all copies
 
5058
+ * and that both that copyright notice and this permission notice
 
5059
+ * appear in supporting documentation, and that the name of
 
5060
+ * Linaro Ltd. not be used in advertising or publicity pertaining to
 
5061
+ * distribution of the software without specific, written prior permission.
 
5062
+ * Linaro Ltd. makes no representations about the suitability of this
 
5063
+ * software for any purpose. It is provided "as is" without express or
 
5064
+ * implied warranty.
 
5065
+ *
 
5066
+ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
5067
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
5068
+ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
5069
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
5070
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
5071
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
5072
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
5073
+ *
 
5074
+ * Authors: Travis Watkins <travis.watkins@linaro.org>
 
5075
+ *          Frederic Plourde <frederic.plourde@collabora.co.uk>
 
5076
+ */
 
5077
+
 
5078
+#ifndef _VERTEXBUFFER_PRIVATE_H
 
5079
+#define _VERTEXBUFFER_PRIVATE_H
 
5080
+
 
5081
+#ifdef USE_GLES
 
5082
+#include <GLES2/gl2.h>
 
5083
+#else
 
5084
+#include <GL/gl.h>
 
5085
+#endif
 
5086
+
 
5087
+#include <opengl/program.h>
 
5088
+#include <typeinfo>
 
5089
+
 
5090
+class GLVertexBuffer;
 
5091
+
 
5092
+class AbstractUniform
 
5093
+{
 
5094
+   public:
 
5095
+       void virtual set(GLProgram* program) = 0;
 
5096
+};
 
5097
+
 
5098
+template < typename T, int C >
 
5099
+class Uniform: public AbstractUniform
 
5100
+{
 
5101
+    public:
 
5102
+       Uniform(const char *_name, ... );
 
5103
+       void set(GLProgram* program);
 
5104
+
 
5105
+    public:
 
5106
+       T a[C];
 
5107
+       std::string name;
 
5108
+};
 
5109
+
 
5110
+template < typename T, int C >
 
5111
+Uniform< T, C >::Uniform(const char *_name, ... )
 
5112
+{
 
5113
+    va_list arg_list;
 
5114
+    va_start( arg_list, _name );
 
5115
+    name = _name;
 
5116
+    for( int i = 0; i < C; i++ )
 
5117
+       a[i] = va_arg( arg_list, T );
 
5118
+    va_end( arg_list );
 
5119
+}
 
5120
+
 
5121
+template < typename T, int C >
 
5122
+void Uniform< T, C >::set(GLProgram* prog)
 
5123
+{
 
5124
+    const char* n = name.c_str();
 
5125
+
 
5126
+    // This will only get called from privateVertexBuffer::render
 
5127
+    // so we know we've got a valid, bound program here
 
5128
+    if (typeid(a[0]) == typeid(double))
 
5129
+    {
 
5130
+       switch (C)
 
5131
+       {
 
5132
+           case 1: prog->setUniform   (n, (GLfloat) a[0]); break;
 
5133
+           case 2: prog->setUniform2f (n, a[0], a[1]); break;
 
5134
+           case 3: prog->setUniform3f (n, a[0], a[1], a[2]); break;
 
5135
+           case 4: prog->setUniform4f (n, a[0], a[1], a[2], a[3]); break;
 
5136
+       }
 
5137
+    } else if (typeid(a[0]) == typeid(int))
 
5138
+    {
 
5139
+       switch (C)
 
5140
+       {
 
5141
+           case 1: prog->setUniform   (n, (GLint) a[0]); break;
 
5142
+           case 2: prog->setUniform2i (n, a[0], a[1]); break;
 
5143
+           case 3: prog->setUniform3i (n, a[0], a[1], a[2]); break;
 
5144
+           case 4: prog->setUniform4i (n, a[0], a[1], a[2], a[3]); break;
 
5145
+       }
 
5146
+    } else
 
5147
+    {
 
5148
+       compLogMessage ("opengl", CompLogLevelError, "Unknown uniform type!");
 
5149
+    }
 
5150
+}
 
5151
+
 
5152
+class GLVertexBuffer;
 
5153
+
 
5154
+class PrivateVertexBuffer
 
5155
+{
 
5156
+    public:
 
5157
+       PrivateVertexBuffer ();
 
5158
+       ~PrivateVertexBuffer ();
 
5159
+
 
5160
+       int render (const GLMatrix            *projection,
 
5161
+                   const GLMatrix            *modelview,
 
5162
+                   const GLWindowPaintAttrib *attrib);
 
5163
+       int legacyRender (const GLMatrix            &projection,
 
5164
+                         const GLMatrix            &modelview,
 
5165
+                         const GLWindowPaintAttrib &attrib);
 
5166
+
 
5167
+    public:
 
5168
+       static GLVertexBuffer *streamingBuffer;
 
5169
+
 
5170
+       std::vector<GLfloat> vertexData;
 
5171
+       std::vector<GLfloat> normalData;
 
5172
+       std::vector<GLfloat> colorData;
 
5173
+       std::vector<std::vector<GLfloat> > textureData;
 
5174
+
 
5175
+       GLProgram *program;
 
5176
+       GLenum primitiveType;
 
5177
+       GLenum usage;
 
5178
+
 
5179
+       GLuint vertexBuffer;
 
5180
+       GLuint normalBuffer;
 
5181
+       GLuint colorBuffer;
 
5182
+       GLuint textureBuffers[4];
 
5183
+       std::vector<AbstractUniform*> uniforms;
 
5184
+
 
5185
+       GLVertexBuffer::AutoProgram *autoProgram;
 
5186
+};
 
5187
+
 
5188
+#endif //_VERTEXBUFFER_PRIVATE_H
 
5189
+
 
5190
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/programcache.cpp linaro-gles2-debianpatches/plugins/opengl/src/programcache.cpp
 
5191
--- compiz-0.9.7.8/plugins/opengl/src/programcache.cpp  1970-01-01 01:00:00.000000000 +0100
 
5192
+++ linaro-gles2-debianpatches/plugins/opengl/src/programcache.cpp      2012-04-20 11:41:59.241600000 +0200
 
5193
@@ -0,0 +1,175 @@
 
5194
+/*
 
5195
+ * Copyright © 2011 Linaro Ltd.
 
5196
+ *
 
5197
+ * Permission to use, copy, modify, distribute, and sell this software
 
5198
+ * and its documentation for any purpose is hereby granted without
 
5199
+ * fee, provided that the above copyright notice appear in all copies
 
5200
+ * and that both that copyright notice and this permission notice
 
5201
+ * appear in supporting documentation, and that the name of
 
5202
+ * Linaro Ltd. not be used in advertising or publicity pertaining to
 
5203
+ * distribution of the software without specific, written prior permission.
 
5204
+ * Linaro Ltd. makes no representations about the suitability of this
 
5205
+ * software for any purpose. It is provided "as is" without express or
 
5206
+ * implied warranty.
 
5207
+ *
 
5208
+ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
5209
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
5210
+ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
5211
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
5212
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
5213
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
5214
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
5215
+ *
 
5216
+ * Authors: Travis Watkins <travis.watkins@linaro.org>
 
5217
+ */
 
5218
+
 
5219
+#include <opengl/programcache.h>
 
5220
+#include "privates.h"
 
5221
+
 
5222
+typedef std::list<std::string> access_history_t;
 
5223
+typedef std::pair<GLProgram*, access_history_t::iterator> value;
 
5224
+
 
5225
+static GLProgram *
 
5226
+compileProgram (std::string name, std::list<const GLShaderData*> shaders)
 
5227
+{
 
5228
+    std::list<const GLShaderData*>::const_iterator it;
 
5229
+    std::string vertex_shader;
 
5230
+    std::string fragment_shader;
 
5231
+    std::string vertex_functions = "";
 
5232
+    std::string vertex_function_calls = "";
 
5233
+    std::string fragment_functions = "";
 
5234
+    std::string fragment_function_calls = "";
 
5235
+    int vpos, vcallpos, fpos, fcallpos;
 
5236
+
 
5237
+    for (it = shaders.begin (); it != shaders.end (); it++)
 
5238
+    {
 
5239
+       //find the special shaders to put the rest in
 
5240
+       if ((*it)->vertexShader.find ("@VERTEX_FUNCTIONS@") != std::string::npos)
 
5241
+       {
 
5242
+           vertex_shader = (*it)->vertexShader;
 
5243
+       }
 
5244
+       else
 
5245
+       {
 
5246
+           if ((*it)->vertexShader.length ())
 
5247
+           {
 
5248
+               vertex_functions += (*it)->vertexShader;
 
5249
+               vertex_function_calls += (*it)->name + "_vertex();\n";
 
5250
+           }
 
5251
+       }
 
5252
+
 
5253
+       if ((*it)->fragmentShader.find ("@FRAGMENT_FUNCTIONS@") != std::string::npos)
 
5254
+       {
 
5255
+           fragment_shader = (*it)->fragmentShader;
 
5256
+       }
 
5257
+       else
 
5258
+       {
 
5259
+           if ((*it)->fragmentShader.length ())
 
5260
+           {
 
5261
+               fragment_functions += (*it)->fragmentShader;
 
5262
+               fragment_function_calls += (*it)->name + "_fragment();\n";
 
5263
+           }
 
5264
+       }
 
5265
+    }
 
5266
+
 
5267
+    // put shader functions and function calls into the main shader
 
5268
+    vpos = vertex_shader.find ("@VERTEX_FUNCTIONS@");
 
5269
+    vertex_shader.replace (vpos, 18, vertex_functions);
 
5270
+
 
5271
+    vcallpos = vertex_shader.find ("@VERTEX_FUNCTION_CALLS@");
 
5272
+    vertex_shader.replace (vcallpos, 23, vertex_function_calls);
 
5273
+
 
5274
+    fpos = fragment_shader.find ("@FRAGMENT_FUNCTIONS@");
 
5275
+    fragment_shader.replace (fpos, 20, fragment_functions);
 
5276
+
 
5277
+    fcallpos = fragment_shader.find ("@FRAGMENT_FUNCTION_CALLS@");
 
5278
+    fragment_shader.replace (fcallpos, 25, fragment_function_calls);
 
5279
+
 
5280
+    return new GLProgram (vertex_shader, fragment_shader);
 
5281
+}
 
5282
+
 
5283
+class PrivateProgramCache
 
5284
+{
 
5285
+    public:
 
5286
+       PrivateProgramCache (size_t);
 
5287
+
 
5288
+       const size_t                 capacity;
 
5289
+       access_history_t             access_history;
 
5290
+       std::map<std::string, value> cache;
 
5291
+
 
5292
+       void insert (std::string, GLProgram *);
 
5293
+       void evict ();
 
5294
+};
 
5295
+
 
5296
+GLProgramCache::GLProgramCache (size_t capacity) :
 
5297
+    priv (new PrivateProgramCache (capacity))
 
5298
+{
 
5299
+    assert (priv->capacity != 0);
 
5300
+}
 
5301
+
 
5302
+GLProgramCache::~GLProgramCache ()
 
5303
+{
 
5304
+    delete priv;
 
5305
+}
 
5306
 
5307
+GLProgram* GLProgramCache::operator () (std::list<const GLShaderData*> shaders)
 
5308
+{
 
5309
+    std::list<const GLShaderData*>::const_iterator name_it;
 
5310
+    std::string name;
 
5311
+
 
5312
+    for (name_it = shaders.begin(); name_it != shaders.end(); name_it++)
 
5313
+    {
 
5314
+       if (name.length () == 0)
 
5315
+           name += (*name_it)->name;
 
5316
+       else
 
5317
+           name += ":" + (*name_it)->name;
 
5318
+    }
 
5319
+
 
5320
+    std::map<std::string, value>::iterator it = priv->cache.find (name);
 
5321
 
5322
+    if (it == priv->cache.end ())
 
5323
+    {
 
5324
+       GLProgram *program = compileProgram (name, shaders);
 
5325
+       priv->insert (name, program);
 
5326
+       return program;
 
5327
+    }
 
5328
+    else
 
5329
+    {
 
5330
+       priv->access_history.splice (priv->access_history.end (),
 
5331
+                                    priv->access_history,
 
5332
+                                    (*it).second.second);
 
5333
+       (*it).second.second = priv->access_history.rbegin ().base ();
 
5334
+
 
5335
+       return (*it).second.first;
 
5336
+    }
 
5337
+}
 
5338
+
 
5339
+PrivateProgramCache::PrivateProgramCache (size_t c) :
 
5340
+    capacity (c)
 
5341
+{
 
5342
+}
 
5343
+
 
5344
+void PrivateProgramCache::insert (std::string name, GLProgram *program)
 
5345
+{
 
5346
+    assert (cache.find (name) == cache.end ());
 
5347
+
 
5348
+    if (cache.size () == capacity)
 
5349
+       evict ();
 
5350
+
 
5351
+    // update most recently used GLProgram
 
5352
+    access_history_t::iterator it = access_history.insert (access_history.end (), name);
 
5353
+
 
5354
+    cache.insert (std::make_pair (name, std::make_pair (program, it)));
 
5355
+}
 
5356
+
 
5357
+void PrivateProgramCache::evict ()
 
5358
+{
 
5359
+    assert (!access_history.empty ());
 
5360
+
 
5361
+    // find least recently used GLProgram
 
5362
+    std::map<std::string, value>::iterator it = cache.find (access_history.front ());
 
5363
+    assert (it != cache.end ());
 
5364
 
5365
+    cache.erase (it);
 
5366
+    access_history.pop_front ();
 
5367
+}
 
5368
+
 
5369
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/program.cpp linaro-gles2-debianpatches/plugins/opengl/src/program.cpp
 
5370
--- compiz-0.9.7.8/plugins/opengl/src/program.cpp       1970-01-01 01:00:00.000000000 +0100
 
5371
+++ linaro-gles2-debianpatches/plugins/opengl/src/program.cpp   2012-04-20 11:41:59.241600000 +0200
 
5372
@@ -0,0 +1,262 @@
 
5373
+/*
 
5374
+ * Copyright © 2011 Linaro Ltd.
 
5375
+ *
 
5376
+ * Permission to use, copy, modify, distribute, and sell this software
 
5377
+ * and its documentation for any purpose is hereby granted without
 
5378
+ * fee, provided that the above copyright notice appear in all copies
 
5379
+ * and that both that copyright notice and this permission notice
 
5380
+ * appear in supporting documentation, and that the name of
 
5381
+ * Linaro Ltd. not be used in advertising or publicity pertaining to
 
5382
+ * distribution of the software without specific, written prior permission.
 
5383
+ * Linaro Ltd. makes no representations about the suitability of this
 
5384
+ * software for any purpose. It is provided "as is" without express or
 
5385
+ * implied warranty.
 
5386
+ *
 
5387
+ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
5388
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
5389
+ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
5390
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
5391
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
5392
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
5393
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
5394
+ *
 
5395
+ * Authors: Travis Watkins <travis.watkins@linaro.org>
 
5396
+ */
 
5397
+
 
5398
+#include <iostream>
 
5399
+#include <fstream>
 
5400
+#include <opengl/opengl.h>
 
5401
+
 
5402
+class PrivateProgram
 
5403
+{
 
5404
+    public:
 
5405
+       GLuint program;
 
5406
+       bool valid;
 
5407
+};
 
5408
+
 
5409
+
 
5410
+void printShaderInfoLog (GLuint shader)
 
5411
+{
 
5412
+    GLint   length = 0;
 
5413
+    GLint   chars  = 0;
 
5414
+    GLchar *infoLog;
 
5415
+
 
5416
+    (*GL::getShaderiv) (shader, GL_INFO_LOG_LENGTH, &length);
 
5417
+
 
5418
+    if (length > 0)
 
5419
+    {
 
5420
+       infoLog = new GLchar[length];
 
5421
+       (*GL::getShaderInfoLog) (shader, length, &chars, infoLog);
 
5422
+       std::cout << infoLog << std::endl;
 
5423
+       delete[] infoLog;
 
5424
+    }
 
5425
+}
 
5426
+
 
5427
+void printProgramInfoLog(GLuint program)
 
5428
+{
 
5429
+    GLint   length = 0;
 
5430
+    GLint   chars  = 0;
 
5431
+    GLchar *infoLog;
 
5432
+
 
5433
+    (*GL::getProgramiv) (program, GL_INFO_LOG_LENGTH, &length);
 
5434
+
 
5435
+    if (length > 0)
 
5436
+    {
 
5437
+       infoLog = new GLchar[length];
 
5438
+       (*GL::getProgramInfoLog) (program, length, &chars, infoLog);
 
5439
+       std::cout << infoLog << std::endl;
 
5440
+       delete[] infoLog;
 
5441
+    }
 
5442
+}
 
5443
+
 
5444
+static bool compileShader (GLuint *shader, GLenum type, CompString &source)
 
5445
+{
 
5446
+    const GLchar *data;
 
5447
+    GLint         status;
 
5448
+
 
5449
+    data = (GLchar *)source.c_str ();
 
5450
+
 
5451
+    *shader = (*GL::createShader) (type);
 
5452
+    (*GL::shaderSource) (*shader, 1, &data, NULL);
 
5453
+    (*GL::compileShader) (*shader);
 
5454
+
 
5455
+    (*GL::getShaderiv) (*shader, GL_COMPILE_STATUS, &status);
 
5456
+    return (status == GL_TRUE);
 
5457
+}
 
5458
+
 
5459
+GLProgram::GLProgram (CompString &vertexShader, CompString &fragmentShader) :
 
5460
+    priv (new PrivateProgram ())
 
5461
+{
 
5462
+    GLuint vertex, fragment;
 
5463
+    GLint status;
 
5464
+
 
5465
+    priv->valid = false;
 
5466
+    priv->program = (*GL::createProgram) ();
 
5467
+
 
5468
+    if (!compileShader (&vertex, GL_VERTEX_SHADER, vertexShader))
 
5469
+    {
 
5470
+       printShaderInfoLog (vertex);
 
5471
+       std::cout << vertexShader << std::endl << std::endl;
 
5472
+       return;
 
5473
+    }
 
5474
+
 
5475
+    if (!compileShader (&fragment, GL_FRAGMENT_SHADER, fragmentShader))
 
5476
+    {
 
5477
+       printShaderInfoLog (fragment);
 
5478
+       std::cout << fragmentShader << std::endl << std::endl;
 
5479
+       return;
 
5480
+    }
 
5481
+
 
5482
+    (*GL::attachShader) (priv->program, vertex);
 
5483
+    (*GL::attachShader) (priv->program, fragment);
 
5484
+
 
5485
+    (*GL::linkProgram) (priv->program);
 
5486
+    (*GL::validateProgram) (priv->program);
 
5487
+
 
5488
+    (*GL::getProgramiv) (priv->program, GL_LINK_STATUS, &status);
 
5489
+    if (status == GL_FALSE)
 
5490
+    {
 
5491
+       printProgramInfoLog (priv->program);
 
5492
+       return;
 
5493
+    }
 
5494
+
 
5495
+    (*GL::deleteShader) (vertex);
 
5496
+    (*GL::deleteShader) (fragment);
 
5497
+
 
5498
+    priv->valid = true;
 
5499
+}
 
5500
+
 
5501
+GLProgram::~GLProgram ()
 
5502
+{
 
5503
+    (*GL::deleteProgram) (priv->program);
 
5504
+    delete priv;
 
5505
+}
 
5506
+
 
5507
+bool GLProgram::valid ()
 
5508
+{
 
5509
+    return priv->valid;
 
5510
+}
 
5511
+
 
5512
+void GLProgram::bind ()
 
5513
+{
 
5514
+    (*GL::useProgram) (priv->program);
 
5515
+}
 
5516
+
 
5517
+void GLProgram::unbind ()
 
5518
+{
 
5519
+    (*GL::useProgram) (0);
 
5520
+}
 
5521
+
 
5522
+bool GLProgram::setUniform (const char *name, GLfloat value)
 
5523
+{
 
5524
+    GLint location = (*GL::getUniformLocation) (priv->program, name);
 
5525
+    if (location == -1)
 
5526
+       return false;
 
5527
+
 
5528
+    (*GL::uniform1f) (location, value);
 
5529
+    return true;
 
5530
+}
 
5531
+
 
5532
+bool GLProgram::setUniform (const char *name, GLint value)
 
5533
+{
 
5534
+    GLint location = (*GL::getUniformLocation) (priv->program, name);
 
5535
+    if (location == -1)
 
5536
+       return false;
 
5537
+
 
5538
+    (*GL::uniform1i) (location, value);
 
5539
+    return true;
 
5540
+}
 
5541
+
 
5542
+bool GLProgram::setUniform (const char *name, const GLMatrix &value)
 
5543
+{
 
5544
+    GLint location = (*GL::getUniformLocation) (priv->program, name);
 
5545
+    if (location == -1)
 
5546
+       return false;
 
5547
+
 
5548
+    (*GL::uniformMatrix4fv) (location, 1, GL_FALSE, value.getMatrix ());
 
5549
+    return true;
 
5550
+}
 
5551
+
 
5552
+bool GLProgram::setUniform2f (const char *name,
 
5553
+                              GLfloat x,
 
5554
+                              GLfloat y)
 
5555
+{
 
5556
+    GLint location = (*GL::getUniformLocation) (priv->program, name);
 
5557
+    if (location == -1)
 
5558
+       return false;
 
5559
+
 
5560
+    (*GL::uniform2f) (location, x, y);
 
5561
+    return true;
 
5562
+}
 
5563
+
 
5564
+bool GLProgram::setUniform3f (const char *name,
 
5565
+                              GLfloat x,
 
5566
+                              GLfloat y,
 
5567
+                              GLfloat z)
 
5568
+{
 
5569
+    GLint location = (*GL::getUniformLocation) (priv->program, name);
 
5570
+    if (location == -1)
 
5571
+       return false;
 
5572
+
 
5573
+    (*GL::uniform3f) (location, x, y, z);
 
5574
+    return true;
 
5575
+}
 
5576
+
 
5577
+bool GLProgram::setUniform4f (const char *name,
 
5578
+                              GLfloat x,
 
5579
+                              GLfloat y,
 
5580
+                              GLfloat z,
 
5581
+                              GLfloat w)
 
5582
+{
 
5583
+    GLint location = (*GL::getUniformLocation) (priv->program, name);
 
5584
+    if (location == -1)
 
5585
+       return false;
 
5586
+
 
5587
+    (*GL::uniform4f) (location, x, y, z, w);
 
5588
+    return true;
 
5589
+}
 
5590
+
 
5591
+bool GLProgram::setUniform2i (const char *name,
 
5592
+                              GLint x,
 
5593
+                              GLint y)
 
5594
+{
 
5595
+    GLint location = (*GL::getUniformLocation) (priv->program, name);
 
5596
+    if (location == -1)
 
5597
+       return false;
 
5598
+
 
5599
+    (*GL::uniform2i) (location, x, y);
 
5600
+    return true;
 
5601
+}
 
5602
+
 
5603
+bool GLProgram::setUniform3i (const char *name,
 
5604
+                              GLint x,
 
5605
+                              GLint y,
 
5606
+                              GLint z)
 
5607
+{
 
5608
+    GLint location = (*GL::getUniformLocation) (priv->program, name);
 
5609
+    if (location == -1)
 
5610
+       return false;
 
5611
+
 
5612
+    (*GL::uniform3i) (location, x, y, z);
 
5613
+    return true;
 
5614
+}
 
5615
+
 
5616
+bool GLProgram::setUniform4i (const char *name,
 
5617
+                              GLint x,
 
5618
+                              GLint y,
 
5619
+                              GLint z,
 
5620
+                              GLint w)
 
5621
+{
 
5622
+    GLint location = (*GL::getUniformLocation) (priv->program, name);
 
5623
+    if (location == -1)
 
5624
+       return false;
 
5625
+
 
5626
+    (*GL::uniform4i) (location, x, y, z, w);
 
5627
+    return true;
 
5628
+}
 
5629
+
 
5630
+GLuint GLProgram::attributeLocation (const char *name)
 
5631
+{
 
5632
+    return (*GL::getAttribLocation) (priv->program, name);
 
5633
+}
 
5634
+
 
5635
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/screen.cpp linaro-gles2-debianpatches/plugins/opengl/src/screen.cpp
 
5636
--- compiz-0.9.7.8/plugins/opengl/src/screen.cpp        2012-04-26 12:39:13.700308461 +0200
 
5637
+++ linaro-gles2-debianpatches/plugins/opengl/src/screen.cpp    2012-04-20 11:41:59.241600000 +0200
 
5638
@@ -1,4 +1,5 @@
 
5639
 /*
 
5640
+ * Copyright © 2011 Linaro Ltd.
 
5641
  * Copyright © 2008 Dennis Kasprzyk
 
5642
  * Copyright © 2007 Novell, Inc.
 
5643
  *
 
5644
@@ -23,6 +24,7 @@
 
5645
  *
 
5646
  * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
 
5647
  *          David Reveman <davidr@novell.com>
 
5648
+ *          Travis Watkins <travis.watkins@linaro.org>
 
5649
  */
 
5650
 
 
5651
 #ifndef _GNU_SOURCE
 
5652
@@ -30,12 +32,28 @@
 
5653
 #endif
 
5654
 #include <errno.h>
 
5655
 
 
5656
+#ifndef _GNU_SOURCE
 
5657
+#define _GNU_SOURCE
 
5658
+#endif
 
5659
+#include <errno.h>
 
5660
+
 
5661
 #include "privates.h"
 
5662
 
 
5663
 #include <dlfcn.h>
 
5664
 #include <math.h>
 
5665
 
 
5666
 namespace GL {
 
5667
+    #ifdef USE_GLES
 
5668
+    EGLCreateImageKHRProc  createImage;
 
5669
+    EGLDestroyImageKHRProc destroyImage;
 
5670
+
 
5671
+    GLEGLImageTargetTexture2DOESProc eglImageTargetTexture;
 
5672
+
 
5673
+    EGLPostSubBufferNVProc postSubBuffer = NULL;
 
5674
+    #else
 
5675
+
 
5676
+    typedef int (*GLXSwapIntervalProc) (int interval);
 
5677
+
 
5678
     GLXBindTexImageProc      bindTexImage = NULL;
 
5679
     GLXReleaseTexImageProc   releaseTexImage = NULL;
 
5680
     GLXQueryDrawableProc     queryDrawable = NULL;
 
5681
@@ -47,18 +65,17 @@
 
5682
     GLXGetFBConfigAttribProc getFBConfigAttrib = NULL;
 
5683
     GLXCreatePixmapProc      createPixmap = NULL;
 
5684
     GLXDestroyPixmapProc     destroyPixmap = NULL;
 
5685
-
 
5686
-    GLActiveTextureProc       activeTexture = NULL;
 
5687
-    GLClientActiveTextureProc clientActiveTexture = NULL;
 
5688
-    GLMultiTexCoord2fProc     multiTexCoord2f = NULL;
 
5689
-
 
5690
     GLGenProgramsProc       genPrograms = NULL;
 
5691
     GLDeleteProgramsProc     deletePrograms = NULL;
 
5692
     GLBindProgramProc       bindProgram = NULL;
 
5693
     GLProgramStringProc             programString = NULL;
 
5694
     GLProgramParameter4fProc programEnvParameter4f = NULL;
 
5695
     GLProgramParameter4fProc programLocalParameter4f = NULL;
 
5696
-    GLGetProgramivProc       getProgramiv = NULL;
 
5697
+    #endif
 
5698
+
 
5699
+    GLActiveTextureProc       activeTexture = NULL;
 
5700
+    GLClientActiveTextureProc clientActiveTexture = NULL;
 
5701
+    GLMultiTexCoord2fProc     multiTexCoord2f = NULL;
 
5702
 
 
5703
     GLGenFramebuffersProc        genFramebuffers = NULL;
 
5704
     GLDeleteFramebuffersProc     deleteFramebuffers = NULL;
 
5705
@@ -67,16 +84,54 @@
 
5706
     GLFramebufferTexture2DProc   framebufferTexture2D = NULL;
 
5707
     GLGenerateMipmapProc         generateMipmap = NULL;
 
5708
 
 
5709
+    GLBindBufferProc    bindBuffer = NULL;
 
5710
+    GLDeleteBuffersProc deleteBuffers = NULL;
 
5711
+    GLGenBuffersProc    genBuffers = NULL;
 
5712
+    GLBufferDataProc    bufferData = NULL;
 
5713
+    GLBufferSubDataProc bufferSubData = NULL;
 
5714
+
 
5715
+    GLGetShaderivProc        getShaderiv = NULL;
 
5716
+    GLGetShaderInfoLogProc   getShaderInfoLog = NULL;
 
5717
+    GLGetProgramivProc       getProgramiv = NULL;
 
5718
+    GLGetProgramInfoLogProc  getProgramInfoLog = NULL;
 
5719
+    GLCreateShaderProc       createShader = NULL;
 
5720
+    GLShaderSourceProc       shaderSource = NULL;
 
5721
+    GLCompileShaderProc      compileShader = NULL;
 
5722
+    GLCreateProgramProc      createProgram = NULL;
 
5723
+    GLAttachShaderProc       attachShader = NULL;
 
5724
+    GLLinkProgramProc        linkProgram = NULL;
 
5725
+    GLValidateProgramProc    validateProgram = NULL;
 
5726
+    GLDeleteShaderProc       deleteShader = NULL;
 
5727
+    GLDeleteProgramProc      deleteProgram = NULL;
 
5728
+    GLUseProgramProc         useProgram = NULL;
 
5729
+    GLGetUniformLocationProc getUniformLocation = NULL;
 
5730
+    GLUniform1fProc          uniform1f = NULL;
 
5731
+    GLUniform1iProc          uniform1i = NULL;
 
5732
+    GLUniform2fProc          uniform2f = NULL;
 
5733
+    GLUniform2iProc          uniform2i = NULL;
 
5734
+    GLUniform3fProc          uniform3f = NULL;
 
5735
+    GLUniform3iProc          uniform3i = NULL;
 
5736
+    GLUniform4fProc          uniform4f = NULL;
 
5737
+    GLUniform4iProc          uniform4i = NULL;
 
5738
+    GLUniformMatrix4fvProc   uniformMatrix4fv = NULL;
 
5739
+    GLGetAttribLocationProc  getAttribLocation = NULL;
 
5740
+
 
5741
+    GLEnableVertexAttribArrayProc  enableVertexAttribArray = NULL;
 
5742
+    GLDisableVertexAttribArrayProc disableVertexAttribArray = NULL;
 
5743
+    GLVertexAttribPointerProc      vertexAttribPointer = NULL;
 
5744
+
 
5745
     bool  textureFromPixmap = true;
 
5746
     bool  textureRectangle = false;
 
5747
     bool  textureNonPowerOfTwo = false;
 
5748
+    bool  textureNonPowerOfTwoMipmap = false;
 
5749
     bool  textureEnvCombine = false;
 
5750
     bool  textureEnvCrossbar = false;
 
5751
     bool  textureBorderClamp = false;
 
5752
     bool  textureCompression = false;
 
5753
     GLint maxTextureSize = 0;
 
5754
     bool  fbo = false;
 
5755
-    bool  fragmentProgram = false;
 
5756
+    bool  vbo = false;
 
5757
+    bool  shaders = false;
 
5758
     GLint maxTextureUnits = 1;
 
5759
 
 
5760
     bool canDoSaturated = false;
 
5761
@@ -88,6 +143,25 @@
 
5762
 
 
5763
 CompOutput *targetOutput = NULL;
 
5764
 
 
5765
+/**
 
5766
+ * Callback object to create GLPrograms automatically when using GLVertexBuffer.
 
5767
+ */
 
5768
+class GLScreenAutoProgram : public GLVertexBuffer::AutoProgram
 
5769
+{
 
5770
+public:
 
5771
+    GLScreenAutoProgram (GLScreen *gScreen) : gScreen(gScreen) {}
 
5772
+
 
5773
+    GLProgram *getProgram (GLShaderParameters &params)
 
5774
+    {
 
5775
+        const GLShaderData *shaderData = gScreen->getShaderData (params);
 
5776
+        std::list<const GLShaderData *> tempShaders;
 
5777
+        tempShaders.push_back (shaderData);
 
5778
+        return gScreen->getProgram (tempShaders);
 
5779
+    }
 
5780
+
 
5781
+    GLScreen *gScreen;
 
5782
+};
 
5783
+
 
5784
 class DetectionWorkaround
 
5785
 {
 
5786
     public:
 
5787
@@ -106,6 +180,212 @@
 
5788
 GLScreen::glInitContext (XVisualInfo *visinfo)
 
5789
 {
 
5790
     DetectionWorkaround workaround;
 
5791
+    #ifdef USE_GLES
 
5792
+    Display             *xdpy;
 
5793
+    Window               overlay;
 
5794
+    EGLDisplay           dpy;
 
5795
+    EGLConfig            config;
 
5796
+    EGLint               major, minor;
 
5797
+    const char         *eglExtensions, *glExtensions;
 
5798
+    XWindowAttributes    attr;
 
5799
+    EGLint               count, visualid;
 
5800
+    EGLConfig            configs[1024];
 
5801
+    CompOption::Vector   o (0);
 
5802
+
 
5803
+    const EGLint config_attribs[] = {
 
5804
+       EGL_SURFACE_TYPE,         EGL_WINDOW_BIT,
 
5805
+       EGL_RED_SIZE,             1,
 
5806
+       EGL_GREEN_SIZE,           1,
 
5807
+       EGL_BLUE_SIZE,            1,
 
5808
+       EGL_ALPHA_SIZE,           0,
 
5809
+       EGL_RENDERABLE_TYPE,      EGL_OPENGL_ES2_BIT,
 
5810
+       EGL_CONFIG_CAVEAT,        EGL_NONE,
 
5811
+       EGL_NONE,
 
5812
+    };
 
5813
+
 
5814
+    const EGLint context_attribs[] = {
 
5815
+        EGL_CONTEXT_CLIENT_VERSION, 2,
 
5816
+        EGL_NONE
 
5817
+    };
 
5818
+
 
5819
+    xdpy = screen->dpy ();
 
5820
+    dpy = eglGetDisplay ((EGLNativeDisplayType)xdpy);
 
5821
+    if (!eglInitialize (dpy, &major, &minor))
 
5822
+    {
 
5823
+       screen->handleCompizEvent ("opengl", "fatal_fallback", o);
 
5824
+       return false;
 
5825
+    }
 
5826
+
 
5827
+    eglBindAPI (EGL_OPENGL_ES_API);
 
5828
+
 
5829
+    if (!eglChooseConfig (dpy, config_attribs, configs, 1024, &count))
 
5830
+    {
 
5831
+       screen->handleCompizEvent ("opengl", "fatal_fallback", o);
 
5832
+       return false;
 
5833
+    }
 
5834
+
 
5835
+    if (!XGetWindowAttributes (xdpy, screen->root (), &attr))
 
5836
+    {
 
5837
+       screen->handleCompizEvent ("opengl", "fatal_fallback", o);
 
5838
+       return false;
 
5839
+    }
 
5840
+
 
5841
+    visualid = XVisualIDFromVisual (attr.visual);
 
5842
+    config = configs[0];
 
5843
+    for (int i = 0; i < count; i++) {
 
5844
+        EGLint val;
 
5845
+        eglGetConfigAttrib (dpy, configs[i], EGL_NATIVE_VISUAL_ID, &val);
 
5846
+        if (visualid == val) {
 
5847
+            config = configs[i];
 
5848
+            break;
 
5849
+        }
 
5850
+    }
 
5851
+
 
5852
+    overlay = CompositeScreen::get (screen)->overlay ();
 
5853
+    priv->surface = eglCreateWindowSurface (dpy, config, overlay, 0);
 
5854
+    if (priv->surface == EGL_NO_SURFACE)
 
5855
+    {
 
5856
+       compLogMessage ("opengl", CompLogLevelFatal,
 
5857
+                       "eglCreateWindowSurface failed");
 
5858
+       screen->handleCompizEvent ("opengl", "fatal_fallback", o);
 
5859
+       return false;
 
5860
+    }
 
5861
+
 
5862
+    // Currently we rely unconditionally on preserving the buffer contents.
 
5863
+    eglSurfaceAttrib (dpy, priv->surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
 
5864
+
 
5865
+    priv->ctx = eglCreateContext (dpy, config, EGL_NO_CONTEXT, context_attribs);
 
5866
+    if (priv->ctx == EGL_NO_CONTEXT)
 
5867
+    {
 
5868
+       compLogMessage ("opengl", CompLogLevelFatal, "eglCreateContext failed");
 
5869
+       screen->handleCompizEvent ("opengl", "fatal_fallback", o);
 
5870
+       return false;
 
5871
+    }
 
5872
+
 
5873
+    if (!eglMakeCurrent (dpy, priv->surface, priv->surface, priv->ctx))
 
5874
+    {
 
5875
+       compLogMessage ("opengl", CompLogLevelFatal,
 
5876
+                       "eglMakeCurrent failed");
 
5877
+       screen->handleCompizEvent ("opengl", "fatal_fallback", o);
 
5878
+       return false;
 
5879
+    }
 
5880
+
 
5881
+    eglExtensions = (const char *) eglQueryString (dpy, EGL_EXTENSIONS);
 
5882
+    glExtensions = (const char *) glGetString (GL_EXTENSIONS);
 
5883
+
 
5884
+    if (!glExtensions || !eglExtensions)
 
5885
+    {
 
5886
+       compLogMessage ("opengl", CompLogLevelFatal,
 
5887
+                       "No valid GL extensions string found.");
 
5888
+       screen->handleCompizEvent ("opengl", "fatal_fallback", o);
 
5889
+       return false;
 
5890
+    }
 
5891
+
 
5892
+    GL::textureFromPixmap = true;
 
5893
+    GL::textureNonPowerOfTwo = true;
 
5894
+    GL::fbo = true;
 
5895
+    GL::vbo = true;
 
5896
+    GL::shaders = true;
 
5897
+    GL::maxTextureUnits = 4;
 
5898
+    glGetIntegerv (GL_MAX_TEXTURE_SIZE, &GL::maxTextureSize);
 
5899
+
 
5900
+    GL::createImage = (GL::EGLCreateImageKHRProc)
 
5901
+       eglGetProcAddress ("eglCreateImageKHR");
 
5902
+    GL::destroyImage = (GL::EGLDestroyImageKHRProc)
 
5903
+       eglGetProcAddress ("eglDestroyImageKHR");
 
5904
+    GL::eglImageTargetTexture = (GL::GLEGLImageTargetTexture2DOESProc)
 
5905
+       eglGetProcAddress ("glEGLImageTargetTexture2DOES");
 
5906
+
 
5907
+    if (!strstr (eglExtensions, "EGL_KHR_image_pixmap") ||
 
5908
+        !strstr (glExtensions, "GL_OES_EGL_image") ||
 
5909
+       !GL::createImage || !GL::destroyImage || !GL::eglImageTargetTexture)
 
5910
+    {
 
5911
+       compLogMessage ("opengl", CompLogLevelFatal,
 
5912
+                       "GL_OES_EGL_image is missing");
 
5913
+       screen->handleCompizEvent ("opengl", "fatal_fallback", o);
 
5914
+       return false;
 
5915
+    }
 
5916
+
 
5917
+// work around efika supporting GL_BGRA directly instead of via this extension
 
5918
+#ifndef GL_BGRA
 
5919
+    if (!strstr (glExtensions, "GL_EXT_texture_format_BGRA8888"))
 
5920
+    {
 
5921
+       compLogMessage ("opengl", CompLogLevelFatal,
 
5922
+                       "GL_EXT_texture_format_BGRA8888 is missing");
 
5923
+       screen->handleCompizEvent ("opengl", "fatal_fallback", o);
 
5924
+       return false;
 
5925
+    }
 
5926
+#endif
 
5927
+
 
5928
+    if (strstr (glExtensions, "GL_OES_texture_npot"))
 
5929
+       GL::textureNonPowerOfTwoMipmap = true;
 
5930
+
 
5931
+    if (strstr (eglExtensions, "EGL_NV_post_sub_buffer"))
 
5932
+       GL::postSubBuffer = (GL::EGLPostSubBufferNVProc)
 
5933
+           eglGetProcAddress ("eglPostSubBufferNV");
 
5934
+
 
5935
+    GL::activeTexture = glActiveTexture;
 
5936
+    GL::genFramebuffers = glGenFramebuffers;
 
5937
+    GL::deleteFramebuffers = glDeleteFramebuffers;
 
5938
+    GL::bindFramebuffer = glBindFramebuffer;
 
5939
+    GL::checkFramebufferStatus = glCheckFramebufferStatus;
 
5940
+    GL::framebufferTexture2D = glFramebufferTexture2D;
 
5941
+    GL::generateMipmap = glGenerateMipmap;
 
5942
+
 
5943
+    GL::bindBuffer = glBindBuffer;
 
5944
+    GL::deleteBuffers = glDeleteBuffers;
 
5945
+    GL::genBuffers = glGenBuffers;
 
5946
+    GL::bufferData = glBufferData;
 
5947
+    GL::bufferSubData = glBufferSubData;
 
5948
+
 
5949
+    GL::getShaderiv = glGetShaderiv;
 
5950
+    GL::getShaderInfoLog = glGetShaderInfoLog;
 
5951
+    GL::getProgramiv = glGetProgramiv;
 
5952
+    GL::getProgramInfoLog = glGetProgramInfoLog;
 
5953
+    GL::createShader = glCreateShader;
 
5954
+    GL::shaderSource = glShaderSource;
 
5955
+    GL::compileShader = glCompileShader;
 
5956
+    GL::createProgram = glCreateProgram;
 
5957
+    GL::attachShader = glAttachShader;
 
5958
+    GL::linkProgram = glLinkProgram;
 
5959
+    GL::validateProgram = glValidateProgram;
 
5960
+    GL::deleteShader = glDeleteShader;
 
5961
+    GL::deleteProgram = glDeleteProgram;
 
5962
+    GL::useProgram = glUseProgram;
 
5963
+    GL::getUniformLocation = glGetUniformLocation;
 
5964
+    GL::uniform1f = glUniform1f;
 
5965
+    GL::uniform1i = glUniform1i;
 
5966
+    GL::uniform2f = glUniform2f;
 
5967
+    GL::uniform2i = glUniform2i;
 
5968
+    GL::uniform3f = glUniform3f;
 
5969
+    GL::uniform3i = glUniform3i;
 
5970
+    GL::uniform4f = glUniform4f;
 
5971
+    GL::uniform4i = glUniform4i;
 
5972
+    GL::uniformMatrix4fv = glUniformMatrix4fv;
 
5973
+    GL::getAttribLocation = glGetAttribLocation;
 
5974
+
 
5975
+    GL::enableVertexAttribArray = glEnableVertexAttribArray;
 
5976
+    GL::disableVertexAttribArray = glDisableVertexAttribArray;
 
5977
+    GL::vertexAttribPointer = glVertexAttribPointer;
 
5978
+
 
5979
+    glClearColor (0.0, 0.0, 0.0, 1.0);
 
5980
+    glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
5981
+    glEnable (GL_BLEND);
 
5982
+    glEnable (GL_CULL_FACE);
 
5983
+
 
5984
+    priv->updateView ();
 
5985
+
 
5986
+    priv->lighting = false;
 
5987
+
 
5988
+    priv->filter[NOTHING_TRANS_FILTER] = GLTexture::Fast;
 
5989
+    priv->filter[SCREEN_TRANS_FILTER]  = GLTexture::Good;
 
5990
+    priv->filter[WINDOW_TRANS_FILTER]  = GLTexture::Good;
 
5991
+
 
5992
+    if (GL::textureFromPixmap)
 
5993
+       registerBindPixmap (EglTexture::bindPixmapToTexture);
 
5994
+
 
5995
+    #else
 
5996
+
 
5997
     Display             *dpy = screen->dpy ();
 
5998
     const char          *glExtensions;
 
5999
     GLfloat             globalAmbient[]  = { 0.1f, 0.1f,  0.1f, 0.1f };
 
6000
@@ -165,6 +445,7 @@
 
6001
 
 
6002
     if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
 
6003
        GL::textureNonPowerOfTwo = true;
 
6004
+    GL::textureNonPowerOfTwoMipmap = GL::textureNonPowerOfTwo;
 
6005
 
 
6006
     glGetIntegerv (GL_MAX_TEXTURE_SIZE, &GL::maxTextureSize);
 
6007
 
 
6008
@@ -221,33 +502,6 @@
 
6009
            glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &GL::maxTextureUnits);
 
6010
     }
 
6011
 
 
6012
-    if (strstr (glExtensions, "GL_ARB_fragment_program"))
 
6013
-    {
 
6014
-       GL::genPrograms = (GL::GLGenProgramsProc)
 
6015
-           getProcAddress ("glGenProgramsARB");
 
6016
-       GL::deletePrograms = (GL::GLDeleteProgramsProc)
 
6017
-           getProcAddress ("glDeleteProgramsARB");
 
6018
-       GL::bindProgram = (GL::GLBindProgramProc)
 
6019
-           getProcAddress ("glBindProgramARB");
 
6020
-       GL::programString = (GL::GLProgramStringProc)
 
6021
-           getProcAddress ("glProgramStringARB");
 
6022
-       GL::programEnvParameter4f = (GL::GLProgramParameter4fProc)
 
6023
-           getProcAddress ("glProgramEnvParameter4fARB");
 
6024
-       GL::programLocalParameter4f = (GL::GLProgramParameter4fProc)
 
6025
-           getProcAddress ("glProgramLocalParameter4fARB");
 
6026
-       GL::getProgramiv = (GL::GLGetProgramivProc)
 
6027
-           getProcAddress ("glGetProgramivARB");
 
6028
-
 
6029
-       if (GL::genPrograms             &&
 
6030
-           GL::deletePrograms          &&
 
6031
-           GL::bindProgram             &&
 
6032
-           GL::programString           &&
 
6033
-           GL::programEnvParameter4f   &&
 
6034
-           GL::programLocalParameter4f &&
 
6035
-           GL::getProgramiv)
 
6036
-           GL::fragmentProgram = true;
 
6037
-    }
 
6038
-
 
6039
     if (strstr (glExtensions, "GL_EXT_framebuffer_object"))
 
6040
     {
 
6041
        GL::genFramebuffers = (GL::GLGenFramebuffersProc)
 
6042
@@ -272,6 +526,63 @@
 
6043
            GL::fbo = true;
 
6044
     }
 
6045
 
 
6046
+    if (strstr (glExtensions, "GL_ARB_vertex_buffer_object"))
 
6047
+    {
 
6048
+       GL::bindBuffer = (GL::GLBindBufferProc)
 
6049
+           getProcAddress ("glBindBufferARB");
 
6050
+       GL::deleteBuffers = (GL::GLDeleteBuffersProc)
 
6051
+           getProcAddress ("glDeleteBuffersARB");
 
6052
+       GL::genBuffers = (GL::GLGenBuffersProc)
 
6053
+           getProcAddress ("glGenBuffersARB");
 
6054
+       GL::bufferData = (GL::GLBufferDataProc)
 
6055
+           getProcAddress ("glBufferDataARB");
 
6056
+       GL::bufferSubData = (GL::GLBufferSubDataProc)
 
6057
+           getProcAddress ("glBufferSubDataARB");
 
6058
+
 
6059
+       if (GL::bindBuffer    &&
 
6060
+           GL::deleteBuffers &&
 
6061
+           GL::genBuffers    &&
 
6062
+           GL::bufferData    &&
 
6063
+           GL::bufferSubData)
 
6064
+           GL::vbo = true;
 
6065
+    }
 
6066
+
 
6067
+    if (strstr (glExtensions, "GL_ARB_fragment_shader") &&
 
6068
+        strstr (glExtensions, "GL_ARB_vertex_shader"))
 
6069
+    {
 
6070
+       GL::getShaderiv = (GL::GLGetShaderivProc) getProcAddress ("glGetShaderiv");
 
6071
+       GL::getShaderInfoLog = (GL::GLGetShaderInfoLogProc) getProcAddress ("glGetShaderInfoLog");
 
6072
+       GL::getProgramiv = (GL::GLGetProgramivProc) getProcAddress ("glGetProgramiv");
 
6073
+       GL::getProgramInfoLog = (GL::GLGetProgramInfoLogProc) getProcAddress ("glGetProgramInfoLog");
 
6074
+       GL::createShader = (GL::GLCreateShaderProc) getProcAddress ("glCreateShader");
 
6075
+       GL::shaderSource = (GL::GLShaderSourceProc) getProcAddress ("glShaderSource");
 
6076
+       GL::compileShader = (GL::GLCompileShaderProc) getProcAddress ("glCompileShader");
 
6077
+       GL::createProgram = (GL::GLCreateProgramProc) getProcAddress ("glCreateProgram");
 
6078
+       GL::attachShader = (GL::GLAttachShaderProc) getProcAddress ("glAttachShader");
 
6079
+       GL::linkProgram = (GL::GLLinkProgramProc) getProcAddress ("glLinkProgram");
 
6080
+       GL::validateProgram = (GL::GLValidateProgramProc) getProcAddress ("glValidateProgram");
 
6081
+       GL::deleteShader = (GL::GLDeleteShaderProc) getProcAddress ("glDeleteShader");
 
6082
+       GL::deleteProgram = (GL::GLDeleteProgramProc) getProcAddress ("glDeleteProgram");
 
6083
+       GL::useProgram = (GL::GLUseProgramProc) getProcAddress ("glUseProgram");
 
6084
+       GL::getUniformLocation = (GL::GLGetUniformLocationProc) getProcAddress ("glGetUniformLocation");
 
6085
+       GL::uniform1f = (GL::GLUniform1fProc) getProcAddress ("glUniform1f");
 
6086
+       GL::uniform1i = (GL::GLUniform1iProc) getProcAddress ("glUniform1i");
 
6087
+       GL::uniform2f = (GL::GLUniform2fProc) getProcAddress ("glUniform2f");
 
6088
+       GL::uniform2i = (GL::GLUniform2iProc) getProcAddress ("glUniform2i");
 
6089
+       GL::uniform3f = (GL::GLUniform3fProc) getProcAddress ("glUniform3f");
 
6090
+       GL::uniform3i = (GL::GLUniform3iProc) getProcAddress ("glUniform3i");
 
6091
+       GL::uniform4f = (GL::GLUniform4fProc) getProcAddress ("glUniform4f");
 
6092
+       GL::uniform4i = (GL::GLUniform4iProc) getProcAddress ("glUniform4i");
 
6093
+       GL::uniformMatrix4fv = (GL::GLUniformMatrix4fvProc) getProcAddress ("glUniformMatrix4fv");
 
6094
+       GL::getAttribLocation = (GL::GLGetAttribLocationProc) getProcAddress ("glGetAttribLocation");
 
6095
+
 
6096
+       GL::enableVertexAttribArray = (GL::GLEnableVertexAttribArrayProc) getProcAddress ("glEnableVertexAttribArray");
 
6097
+       GL::disableVertexAttribArray = (GL::GLDisableVertexAttribArrayProc) getProcAddress ("glDisableVertexAttribArray");
 
6098
+       GL::vertexAttribPointer = (GL::GLVertexAttribPointerProc) getProcAddress ("glVertexAttribPointer");
 
6099
+
 
6100
+       GL::shaders = true;
 
6101
+    }
 
6102
+
 
6103
     if (strstr (glExtensions, "GL_ARB_texture_compression"))
 
6104
        GL::textureCompression = true;
 
6105
 
 
6106
@@ -313,6 +624,12 @@
 
6107
 
 
6108
     if (GL::textureFromPixmap)
 
6109
        registerBindPixmap (TfpTexture::bindPixmapToTexture);
 
6110
+#endif
 
6111
+
 
6112
+    priv->scratchFbo = new GLFramebufferObject;
 
6113
+    priv->scratchFbo->allocate (*screen, NULL, GL_BGRA);
 
6114
+
 
6115
+    GLVertexBuffer::streamingBuffer ()->setAutoProgram (priv->autoProgram);
 
6116
 
 
6117
     return true;
 
6118
 }
 
6119
@@ -322,9 +639,10 @@
 
6120
     PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI> (s),
 
6121
     priv (new PrivateGLScreen (this))
 
6122
 {
 
6123
+    XVisualInfo                 *visinfo = NULL;
 
6124
+#ifndef USE_GLES
 
6125
     Display             *dpy = s->dpy ();
 
6126
     XVisualInfo                 templ;
 
6127
-    XVisualInfo                 *visinfo;
 
6128
     GLXFBConfig                 *fbConfigs;
 
6129
     int                         defaultDepth, nvisinfo, nElements, value, i;
 
6130
     const char          *glxExtensions;
 
6131
@@ -574,6 +892,7 @@
 
6132
        setFailed ();
 
6133
     }
 
6134
 
 
6135
+#endif
 
6136
     if (!glInitContext (visinfo))
 
6137
        setFailed ();
 
6138
 }
 
6139
@@ -582,7 +901,22 @@
 
6140
 {
 
6141
     if (priv->hasCompositing)
 
6142
        CompositeScreen::get (screen)->unregisterPaintHandler ();
 
6143
+
 
6144
+    #ifdef USE_GLES
 
6145
+    Display *xdpy = screen->dpy ();
 
6146
+    EGLDisplay dpy = eglGetDisplay (xdpy);
 
6147
+
 
6148
+    eglMakeCurrent (dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 
6149
+    eglDestroyContext (dpy, priv->ctx);
 
6150
+    eglDestroySurface (dpy, priv->surface);
 
6151
+    eglTerminate (dpy);
 
6152
+    eglReleaseThread ();
 
6153
+    #else
 
6154
+
 
6155
     glXDestroyContext (screen->dpy (), priv->ctx);
 
6156
+    #endif
 
6157
+
 
6158
+    delete priv->scratchFbo;
 
6159
     delete priv;
 
6160
 }
 
6161
 
 
6162
@@ -593,14 +927,21 @@
 
6163
     backgroundTextures (),
 
6164
     backgroundLoaded (false),
 
6165
     rasterPos (0, 0),
 
6166
-    fragmentStorage (),
 
6167
+    projection (NULL),
 
6168
     clearBuffers (true),
 
6169
     lighting (false),
 
6170
+    #ifndef USE_GLES
 
6171
     getProcAddress (0),
 
6172
+    #endif
 
6173
+    scratchFbo (NULL),
 
6174
     outputRegion (),
 
6175
     pendingCommands (false),
 
6176
+    lastMask (0),
 
6177
     bindPixmap (),
 
6178
     hasCompositing (false),
 
6179
+    programCache (new GLProgramCache (30)),
 
6180
+    shaderCache (),
 
6181
+    autoProgram (new GLScreenAutoProgram(gs)),
 
6182
     rootPixmapCopy (None),
 
6183
     rootPixmapSize ()
 
6184
 {
 
6185
@@ -609,6 +950,8 @@
 
6186
 
 
6187
 PrivateGLScreen::~PrivateGLScreen ()
 
6188
 {
 
6189
+    delete programCache;
 
6190
+    delete autoProgram;
 
6191
     if (rootPixmapCopy)
 
6192
        XFreePixmap (screen->dpy (), rootPixmapCopy);
 
6193
 
 
6194
@@ -670,8 +1013,13 @@
 
6195
            {
 
6196
                XDamageNotifyEvent *de = (XDamageNotifyEvent *) event;
 
6197
 
 
6198
+               #ifdef USE_GLES
 
6199
+               std::map<Damage, EglTexture*>::iterator it =
 
6200
+                   boundPixmapTex.find (de->damage);
 
6201
+               #else
 
6202
                std::map<Damage, TfpTexture*>::iterator it =
 
6203
                    boundPixmapTex.find (de->damage);
 
6204
+               #endif
 
6205
                if (it != boundPixmapTex.end ())
 
6206
                {
 
6207
                    it->second->damaged = true;
 
6208
@@ -743,22 +1091,32 @@
 
6209
 void
 
6210
 PrivateGLScreen::updateView ()
 
6211
 {
 
6212
+    GLfloat projection_array[16];
 
6213
+
 
6214
+    #ifndef USE_GLES
 
6215
     glMatrixMode (GL_PROJECTION);
 
6216
     glLoadIdentity ();
 
6217
     glMatrixMode (GL_MODELVIEW);
 
6218
     glLoadIdentity ();
 
6219
     glDepthRange (0, 1);
 
6220
-    glViewport (-1, -1, 2, 2);
 
6221
     glRasterPos2f (0, 0);
 
6222
+    #endif
 
6223
+    glViewport (-1, -1, 2, 2);
 
6224
 
 
6225
     rasterPos = CompPoint (0, 0);
 
6226
 
 
6227
-    perspective (projection, 60.0f, 1.0f, 0.1f, 100.0f);
 
6228
+    perspective (projection_array, 60.0f, 1.0f, 0.1f, 100.0f);
 
6229
+
 
6230
+    if (projection != NULL)
 
6231
+       delete projection;
 
6232
+    projection = new GLMatrix (projection_array);
 
6233
 
 
6234
+    #ifndef USE_GLES
 
6235
     glMatrixMode (GL_PROJECTION);
 
6236
     glLoadIdentity ();
 
6237
-    glMultMatrixf (projection);
 
6238
+    glMultMatrixf (projection_array);
 
6239
     glMatrixMode (GL_MODELVIEW);
 
6240
+    #endif
 
6241
 
 
6242
     CompRegion region (screen->region ());
 
6243
     /* remove all output regions from visible screen region */
 
6244
@@ -777,9 +1135,11 @@
 
6245
 {
 
6246
     screen->outputChangeNotify ();
 
6247
 
 
6248
+    scratchFbo->allocate (*screen, NULL, GL_BGRA);
 
6249
     updateView ();
 
6250
 }
 
6251
 
 
6252
+#ifndef USE_GLES
 
6253
 GL::FuncPtr
 
6254
 GLScreen::getProcAddress (const char *name)
 
6255
 {
 
6256
@@ -805,6 +1165,7 @@
 
6257
 
 
6258
     return funcPtr;
 
6259
 }
 
6260
+#endif
 
6261
 
 
6262
 void
 
6263
 PrivateGLScreen::updateScreenBackground ()
 
6264
@@ -922,32 +1283,23 @@
 
6265
 
 
6266
        XFreeGC(dpy, gc);
 
6267
     }
 
6268
-
 
6269
-    if (!backgroundTextures.empty ())
 
6270
-    {
 
6271
-       foreach (GLTexture *t, backgroundTextures)
 
6272
-           if (t->target () == GL_TEXTURE_2D)
 
6273
-           {
 
6274
-               glBindTexture (t->target (), t->name ());
 
6275
-               glTexParameteri (t->target (), GL_TEXTURE_WRAP_S, GL_REPEAT);
 
6276
-               glTexParameteri (t->target (), GL_TEXTURE_WRAP_T, GL_REPEAT);
 
6277
-               glBindTexture (t->target (), 0);
 
6278
-           }
 
6279
-    }
 
6280
 }
 
6281
 
 
6282
 void
 
6283
 GLScreen::setTexEnvMode (GLenum mode)
 
6284
 {
 
6285
+    #ifndef USE_GLES
 
6286
     if (priv->lighting)
 
6287
        glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
6288
     else
 
6289
        glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode);
 
6290
+    #endif
 
6291
 }
 
6292
 
 
6293
 void
 
6294
 GLScreen::setLighting (bool lighting)
 
6295
 {
 
6296
+    #ifndef USE_GLES
 
6297
     if (priv->lighting != lighting)
 
6298
     {
 
6299
        if (!priv->optionGetLighting ())
 
6300
@@ -968,6 +1320,7 @@
 
6301
 
 
6302
        setTexEnvMode (GL_REPLACE);
 
6303
     }
 
6304
+    #endif
 
6305
 }
 
6306
 
 
6307
 bool
 
6308
@@ -1003,6 +1356,25 @@
 
6309
 GLScreenInterface::glDisableOutputClipping ()
 
6310
     WRAPABLE_DEF (glDisableOutputClipping)
 
6311
 
 
6312
+GLMatrix *
 
6313
+GLScreenInterface::projectionMatrix ()
 
6314
+    WRAPABLE_DEF (projectionMatrix)
 
6315
+
 
6316
+void
 
6317
+GLScreenInterface::glPaintCompositedOutput (const CompRegion    &region,
 
6318
+                                           GLFramebufferObject *fbo,
 
6319
+                                           unsigned int         mask)
 
6320
+    WRAPABLE_DEF (glPaintCompositedOutput, region, fbo, mask)
 
6321
+
 
6322
+
 
6323
+GLMatrix *
 
6324
+GLScreen::projectionMatrix ()
 
6325
+{
 
6326
+    WRAPABLE_HND_FUNCTN_RETURN (GLMatrix *, projectionMatrix)
 
6327
+
 
6328
+    return priv->projection;
 
6329
+}
 
6330
+
 
6331
 void
 
6332
 GLScreen::updateBackground ()
 
6333
 {
 
6334
@@ -1033,17 +1405,13 @@
 
6335
     priv->filter[num] = filter;
 
6336
 }
 
6337
 
 
6338
-GLFragment::Storage *
 
6339
-GLScreen::fragmentStorage ()
 
6340
-{
 
6341
-    return &priv->fragmentStorage;
 
6342
-}
 
6343
-
 
6344
+#ifndef USE_GLES
 
6345
 GLFBConfig*
 
6346
 GLScreen::glxPixmapFBConfig (unsigned int depth)
 
6347
 {
 
6348
     return &priv->glxPixmapFBConfigs[depth];
 
6349
 }
 
6350
+#endif
 
6351
 
 
6352
 void
 
6353
 GLScreen::clearOutput (CompOutput   *output,
 
6354
@@ -1056,16 +1424,13 @@
 
6355
        pBox->x2 != (int) screen->width () ||
 
6356
        pBox->y2 != (int) screen->height ())
 
6357
     {
 
6358
-       glPushAttrib (GL_SCISSOR_BIT);
 
6359
-
 
6360
        glEnable (GL_SCISSOR_TEST);
 
6361
        glScissor (pBox->x1,
 
6362
                   screen->height () - pBox->y2,
 
6363
                   pBox->x2 - pBox->x1,
 
6364
                   pBox->y2 - pBox->y1);
 
6365
        glClear (mask);
 
6366
-
 
6367
-       glPopAttrib ();
 
6368
+       glDisable (GL_SCISSOR_TEST);
 
6369
     }
 
6370
     else
 
6371
     {
 
6372
@@ -1088,12 +1453,33 @@
 
6373
                priv->lastViewport.height);
 
6374
 }
 
6375
 
 
6376
+#ifdef USE_GLES
 
6377
+EGLContext
 
6378
+GLScreen::getEGLContext ()
 
6379
+{
 
6380
+    return priv->ctx;
 
6381
+}
 
6382
+#endif
 
6383
+
 
6384
+GLProgram *
 
6385
+GLScreen::getProgram (std::list<const GLShaderData*> shaders)
 
6386
+{
 
6387
+    return (*priv->programCache)(shaders);
 
6388
+}
 
6389
+
 
6390
+const GLShaderData *
 
6391
+GLScreen::getShaderData (GLShaderParameters &params)
 
6392
+{
 
6393
+    return &priv->shaderCache.getShaderData(params);
 
6394
+}
 
6395
+
 
6396
 namespace GL
 
6397
 {
 
6398
 
 
6399
 void
 
6400
 waitForVideoSync ()
 
6401
 {
 
6402
+#ifndef USE_GLES
 
6403
     GL::unthrottledFrames++;
 
6404
     if (GL::waitVideoSync)
 
6405
     {
 
6406
@@ -1118,11 +1504,13 @@
 
6407
        if (GL::vsyncCount != oldCount)
 
6408
            GL::unthrottledFrames = 0;
 
6409
     }
 
6410
+#endif
 
6411
 }
 
6412
 
 
6413
 void
 
6414
 controlSwapVideoSync (bool sync)
 
6415
 {
 
6416
+#ifndef USE_GLES
 
6417
     // Docs: http://www.opengl.org/registry/specs/SGI/swap_control.txt
 
6418
     if (GL::swapInterval)
 
6419
     {
 
6420
@@ -1131,6 +1519,7 @@
 
6421
     }
 
6422
     else if (sync)
 
6423
        waitForVideoSync ();
 
6424
+#endif
 
6425
 }
 
6426
 
 
6427
 } // namespace GL
 
6428
@@ -1149,6 +1538,35 @@
 
6429
 {
 
6430
     XRectangle r;
 
6431
 
 
6432
+    // Blending is disabled by default. Each operation/plugin
 
6433
+    // should enable it (and reset it) as needed.
 
6434
+    glDisable(GL_BLEND);
 
6435
+
 
6436
+    GLFramebufferObject *oldFbo = NULL;
 
6437
+    bool useFbo = false;
 
6438
+
 
6439
+    oldFbo = scratchFbo->bind ();
 
6440
+    useFbo = scratchFbo->checkStatus () && scratchFbo->tex ();
 
6441
+    if (!useFbo) {
 
6442
+printf ("bailing!");
 
6443
+       GLFramebufferObject::rebind (oldFbo);
 
6444
+    }
 
6445
+
 
6446
+    refreshSubBuffer = ((lastMask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&
 
6447
+                        !(mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK) &&
 
6448
+                        (mask & COMPOSITE_SCREEN_DAMAGE_REGION_MASK));
 
6449
+
 
6450
+    if (refreshSubBuffer)
 
6451
+    {
 
6452
+       // FIXME: We shouldn't have to substract a 1X1 pixel region here !!
 
6453
+       // This is an ugly workaround for what appears to be a bug in the SGX
 
6454
+       // X11 driver (e.g. on Pandaboard OMAP4 platform).
 
6455
+       // Posting a fullscreen damage region to the SGX seems to reset the
 
6456
+       // framebuffer, causing the screen to blackout.
 
6457
+       cScreen->damageRegion (CompRegion (screen->fullscreenOutput ()) -
 
6458
+                               CompRegion (CompRect(0, 0, 1, 1)));
 
6459
+    }
 
6460
+
 
6461
     if (clearBuffers)
 
6462
     {
 
6463
        if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
 
6464
@@ -1175,7 +1593,11 @@
 
6465
            lastViewport = r;
 
6466
        }
 
6467
 
 
6468
+#ifdef USE_GLES
 
6469
+       if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK || !GL::postSubBuffer)
 
6470
+#else
 
6471
        if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
 
6472
+#endif
 
6473
        {
 
6474
            GLMatrix identity;
 
6475
 
 
6476
@@ -1189,6 +1611,9 @@
 
6477
        {
 
6478
            GLMatrix identity;
 
6479
 
 
6480
+           if (refreshSubBuffer)
 
6481
+               tmpRegion = CompRegion (*output);
 
6482
+
 
6483
            outputRegion = tmpRegion & CompRegion (*output);
 
6484
 
 
6485
            if (!gScreen->glPaintOutput (defaultScreenPaintAttrib,
 
6486
@@ -1204,15 +1629,38 @@
 
6487
                                        PAINT_SCREEN_FULL_MASK);
 
6488
 
 
6489
                tmpRegion += *output;
 
6490
-
 
6491
            }
 
6492
        }
 
6493
     }
 
6494
 
 
6495
     targetOutput = &screen->outputDevs ()[0];
 
6496
+    glFlush ();
 
6497
 
 
6498
-    if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
 
6499
+    if (useFbo)
 
6500
     {
 
6501
+       GLFramebufferObject::rebind (oldFbo);
 
6502
+
 
6503
+       // FIXME: does not work if screen dimensions exceed max texture size
 
6504
+       gScreen->glPaintCompositedOutput (tmpRegion, scratchFbo, mask);
 
6505
+    }
 
6506
+
 
6507
+    // FIXME: Actually fix the composite plugin to be more efficient;
 
6508
+    // If GL::swapInterval == NULL && GL::waitVideoSync != NULL then the
 
6509
+    // composite plugin should not be imposing any framerate restriction
 
6510
+    // (ie. blocking the CPU) at all. Because the framerate will be controlled
 
6511
+    // and optimized here:
 
6512
+#ifdef USE_GLES
 
6513
+    if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK || !GL::postSubBuffer)
 
6514
+#else
 
6515
+    if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
 
6516
+#endif
 
6517
+     {
 
6518
+       #ifdef USE_GLES
 
6519
+       Display *xdpy = screen->dpy ();
 
6520
+       eglSwapBuffers (eglGetDisplay (xdpy), surface);
 
6521
+       eglWaitGL ();
 
6522
+       XFlush (xdpy);
 
6523
+       #else
 
6524
        /*
 
6525
         * controlSwapVideoSync is much faster than waitForVideoSync because
 
6526
         * it won't block the CPU. The waiting is offloaded to the GPU.
 
6527
@@ -1220,6 +1668,7 @@
 
6528
         */
 
6529
        GL::controlSwapVideoSync (optionGetSyncToVblank ());
 
6530
        glXSwapBuffers (screen->dpy (), cScreen->output ());
 
6531
+       #endif
 
6532
     }
 
6533
     else
 
6534
     {
 
6535
@@ -1229,6 +1678,31 @@
 
6536
 
 
6537
        waitForVideoSync ();
 
6538
 
 
6539
+       #ifdef USE_GLES
 
6540
+       Display *xdpy = screen->dpy ();
 
6541
+
 
6542
+       if (GL::postSubBuffer)
 
6543
+       {
 
6544
+           while (nBox--)
 
6545
+           {
 
6546
+               y = screen->height () - pBox->y2;
 
6547
+
 
6548
+               (*GL::postSubBuffer) (eglGetDisplay (xdpy), surface,
 
6549
+                                     pBox->x1, y,
 
6550
+                                     pBox->x2 - pBox->x1,
 
6551
+                                     pBox->y2 - pBox->y1);
 
6552
+               pBox++;
 
6553
+           }
 
6554
+       }
 
6555
+       else
 
6556
+       {
 
6557
+           eglSwapBuffers (eglGetDisplay (xdpy), surface);
 
6558
+       }
 
6559
+
 
6560
+       eglWaitGL ();
 
6561
+       XFlush (xdpy);
 
6562
+
 
6563
+       #else
 
6564
        if (GL::copySubBuffer)
 
6565
        {
 
6566
            while (nBox--)
 
6567
@@ -1275,14 +1749,21 @@
 
6568
            glDisable (GL_SCISSOR_TEST);
 
6569
            glFlush ();
 
6570
        }
 
6571
+       #endif
 
6572
     }
 
6573
+
 
6574
+    lastMask = mask;
 
6575
 }
 
6576
 
 
6577
 bool
 
6578
 PrivateGLScreen::hasVSync ()
 
6579
 {
 
6580
+   #ifdef USE_GLES
 
6581
+   return false;
 
6582
+   #else
 
6583
     return GL::waitVideoSync && optionGetSyncToVblank () && 
 
6584
            GL::unthrottledFrames < 5;
 
6585
+   #endif
 
6586
 }
 
6587
 
 
6588
 bool
 
6589
@@ -1327,6 +1808,12 @@
 
6590
     }
 
6591
 }
 
6592
 
 
6593
+GLFramebufferObject *
 
6594
+GLScreen::fbo ()
 
6595
+{
 
6596
+    return priv->scratchFbo;
 
6597
+}
 
6598
+
 
6599
 GLTexture *
 
6600
 GLScreen::defaultIcon ()
 
6601
 {
 
6602
@@ -1359,13 +1846,10 @@
 
6603
 void
 
6604
 GLScreen::resetRasterPos ()
 
6605
 {
 
6606
+    #ifndef USE_GLES
 
6607
     glRasterPos2f (0, 0);
 
6608
+    #endif
 
6609
     priv->rasterPos.setX (0);
 
6610
     priv->rasterPos.setY (0);
 
6611
 }
 
6612
 
 
6613
-const float *
 
6614
-GLScreen::projectionMatrix ()
 
6615
-{
 
6616
-    return priv->projection;
 
6617
-}
 
6618
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/shadercache.cpp linaro-gles2-debianpatches/plugins/opengl/src/shadercache.cpp
 
6619
--- compiz-0.9.7.8/plugins/opengl/src/shadercache.cpp   1970-01-01 01:00:00.000000000 +0100
 
6620
+++ linaro-gles2-debianpatches/plugins/opengl/src/shadercache.cpp       2012-04-20 11:41:59.241600000 +0200
 
6621
@@ -0,0 +1,246 @@
 
6622
+/*
 
6623
+ * Copyright © 2012 Linaro Ltd.
 
6624
+ *
 
6625
+ * Permission to use, copy, modify, distribute, and sell this software
 
6626
+ * and its documentation for any purpose is hereby granted without
 
6627
+ * fee, provided that the above copyright notice appear in all copies
 
6628
+ * and that both that copyright notice and this permission notice
 
6629
+ * appear in supporting documentation, and that the name of
 
6630
+ * Linaro Ltd. not be used in advertising or publicity pertaining to
 
6631
+ * distribution of the software without specific, written prior permission.
 
6632
+ * Linaro Ltd. makes no representations about the suitability of this
 
6633
+ * software for any purpose. It is provided "as is" without express or
 
6634
+ * implied warranty.
 
6635
+ *
 
6636
+ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
6637
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
6638
+ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
6639
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
6640
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
6641
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
6642
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
6643
+ *
 
6644
+ * Authors: Alexandros Frantzis <alexandros.frantzis@linaro.org>
 
6645
+ */
 
6646
+#include <map>
 
6647
+#include <sstream>
 
6648
+
 
6649
+#include <opengl/shadercache.h>
 
6650
+
 
6651
+/** 
 
6652
+ * Compares two GLShaderParameters objects.
 
6653
+ */
 
6654
+class GLShaderParametersComparer
 
6655
+{
 
6656
+public:
 
6657
+    bool operator()(const GLShaderParameters &left, const GLShaderParameters &right) const
 
6658
+    {
 
6659
+        return left.hash() < right.hash();
 
6660
+    }
 
6661
+
 
6662
+};
 
6663
+
 
6664
+typedef std::map<GLShaderParameters, GLShaderData, GLShaderParametersComparer> ShaderMapType;
 
6665
+
 
6666
+/** 
 
6667
+ * Private data for GLPrivate
 
6668
+ */
 
6669
+class PrivateShaderCache
 
6670
+{
 
6671
+public:
 
6672
+    PrivateShaderCache() {}
 
6673
+
 
6674
+    ShaderMapType::const_iterator addShaderData(const GLShaderParameters &params);
 
6675
+
 
6676
+    std::string createVertexShader (const GLShaderParameters &params);
 
6677
+    std::string createFragmentShader (const GLShaderParameters &params);
 
6678
+
 
6679
+    ShaderMapType shaderMap;
 
6680
+};
 
6681
+
 
6682
+/**********************
 
6683
+ * GLShaderParameters *
 
6684
+ **********************/
 
6685
+
 
6686
+int
 
6687
+GLShaderParameters::hash() const
 
6688
+{
 
6689
+    return static_cast<int>(opacity) |
 
6690
+           (static_cast<int>(brightness) << 1) |
 
6691
+           (static_cast<int>(saturation) << 2) |
 
6692
+           (static_cast<int>(color) << 3) |
 
6693
+           (static_cast<int>(normal) << 5) |
 
6694
+           (static_cast<int>(numTextures) << 8);
 
6695
+}
 
6696
+
 
6697
+std::string
 
6698
+GLShaderParameters::id() const
 
6699
+{
 
6700
+    std::stringstream ss;
 
6701
+
 
6702
+    ss << (opacity ? "t" : "f");
 
6703
+    ss << (brightness ? "t" : "f");
 
6704
+    ss << (saturation ? "t" : "f");
 
6705
+    ss << (color == GLShaderVariableNone ? "n" :
 
6706
+           color == GLShaderVariableUniform ? "u" : "v");
 
6707
+
 
6708
+    ss << (normal == GLShaderVariableNone ? "n" :
 
6709
+           normal == GLShaderVariableUniform ? "u" : "v");
 
6710
+    ss << numTextures;
 
6711
+
 
6712
+    return ss.str();
 
6713
+}
 
6714
+
 
6715
+/*****************
 
6716
+ * GLShaderCache *
 
6717
+ *****************/
 
6718
+
 
6719
+GLShaderCache::GLShaderCache () :
 
6720
+    priv (new PrivateShaderCache ())
 
6721
+{
 
6722
+}
 
6723
+
 
6724
+const GLShaderData &
 
6725
+GLShaderCache::getShaderData (const GLShaderParameters &params)
 
6726
+{
 
6727
+    ShaderMapType::const_iterator iter;
 
6728
+
 
6729
+    // Try to find a cached shader pair that matches the parameters.
 
6730
+    // If we don't have it cached, create it.
 
6731
+    if ((iter = priv->shaderMap.find (params)) == priv->shaderMap.end ())
 
6732
+        iter = priv->addShaderData (params);
 
6733
+
 
6734
+    return iter->second;
 
6735
+}
 
6736
+
 
6737
+/**********************
 
6738
+ * PrivateShaderCache *
 
6739
+ **********************/
 
6740
+
 
6741
+ShaderMapType::const_iterator
 
6742
+PrivateShaderCache::addShaderData (const GLShaderParameters &params)
 
6743
+{
 
6744
+    GLShaderData shaderData;
 
6745
+
 
6746
+    shaderData.name = params.id ();
 
6747
+    shaderData.fragmentShader = createFragmentShader (params);
 
6748
+    shaderData.vertexShader = createVertexShader (params);
 
6749
+
 
6750
+    std::pair<ShaderMapType::iterator, bool> ret =
 
6751
+        shaderMap.insert(std::pair<GLShaderParameters, GLShaderData>(params,shaderData));
 
6752
+
 
6753
+    return ret.first;
 
6754
+}
 
6755
+
 
6756
+/** 
 
6757
+ * Creates a minimal vertex shader that can handle the GLShaderParameters.
 
6758
+ * 
 
6759
+ * @param params the GLShaderParameters the created shader should handle.
 
6760
+ * 
 
6761
+ * @return the shader string
 
6762
+ */
 
6763
+std::string
 
6764
+PrivateShaderCache::createVertexShader (const GLShaderParameters &params)
 
6765
+{
 
6766
+    std::stringstream ss;
 
6767
+
 
6768
+    ss << "#ifdef GL_ES\n" <<
 
6769
+          "precision mediump float;\n" <<
 
6770
+          "#endif\n";
 
6771
+
 
6772
+    ss << "uniform mat4 modelview;\n" <<
 
6773
+          "uniform mat4 projection;\n";
 
6774
+
 
6775
+    ss << "attribute vec3 position;\n" <<
 
6776
+          "attribute vec3 normal;\n" <<
 
6777
+          "attribute vec4 color;\n" <<
 
6778
+          "attribute vec2 texCoord0;\n" <<
 
6779
+          "attribute vec2 texCoord1;\n" <<
 
6780
+          "attribute vec2 texCoord2;\n" <<
 
6781
+          "attribute vec2 texCoord3;\n";
 
6782
+
 
6783
+    ss << "@VERTEX_FUNCTIONS@\n";
 
6784
+
 
6785
+    if (params.color == GLShaderVariableVarying)
 
6786
+        ss << "varying vec4 vColor;\n";
 
6787
+
 
6788
+    for (int i = 0; i < params.numTextures; i++)
 
6789
+        ss << "varying vec2 vTexCoord" << i << ";\n";
 
6790
+
 
6791
+    ss << "void main() {\n";
 
6792
+
 
6793
+    for (int i = 0; i < params.numTextures; i++)
 
6794
+        ss << "vTexCoord" << i << " = texCoord" << i <<";\n";
 
6795
+
 
6796
+    if (params.color == GLShaderVariableVarying)
 
6797
+        ss << "vColor = color;\n";
 
6798
+
 
6799
+    ss << "gl_Position = projection * modelview * vec4(position, 1.0);\n";
 
6800
+
 
6801
+    ss << "@VERTEX_FUNCTION_CALLS@\n}";
 
6802
+
 
6803
+    return ss.str();
 
6804
+}
 
6805
+
 
6806
+/** 
 
6807
+ * Creates a minimal fragment shader that can handle the GLShaderParameters.
 
6808
+ * 
 
6809
+ * @param params the GLShaderParameters the created shader should handle.
 
6810
+ * 
 
6811
+ * @return the shader string
 
6812
+ */
 
6813
+std::string
 
6814
+PrivateShaderCache::createFragmentShader (const GLShaderParameters &params)
 
6815
+{
 
6816
+    std::stringstream ss;
 
6817
+    ss << "#ifdef GL_ES\n" <<
 
6818
+          "precision mediump float;\n" <<
 
6819
+          "#endif\n";
 
6820
+
 
6821
+    ss << "uniform vec3 paintAttrib;\n";
 
6822
+
 
6823
+    for (int i = 0; i < params.numTextures; i++) {
 
6824
+        ss << "uniform sampler2D texture" << i << ";\n";
 
6825
+        ss << "varying vec2 vTexCoord" << i << ";\n";
 
6826
+    }
 
6827
+
 
6828
+    if (params.color == GLShaderVariableUniform)
 
6829
+        ss << "uniform vec4 singleColor;\n";
 
6830
+    else if (params.color == GLShaderVariableVarying)
 
6831
+        ss << "varying vec4 vColor;\n";
 
6832
+
 
6833
+    ss << "@FRAGMENT_FUNCTIONS@\n";
 
6834
+
 
6835
+    ss << "void main() {\n vec4 color = ";
 
6836
+
 
6837
+    if (params.color == GLShaderVariableUniform)
 
6838
+        ss << "singleColor *";
 
6839
+    else if (params.color == GLShaderVariableVarying)
 
6840
+        ss << "vColor *";
 
6841
+
 
6842
+    for (int i = 0; i < params.numTextures; i++)
 
6843
+        ss << " texture2D(texture" << i << ", vTexCoord" << i << ") *";
 
6844
+
 
6845
+    ss << " 1.0;\n";
 
6846
+
 
6847
+    if (params.saturation) {
 
6848
+       ss << "vec3 desaturated = color.rgb * vec3 (0.30, 0.59, 0.11);\n" <<
 
6849
+             "desaturated = vec3 (dot (desaturated, color.rgb));\n" <<
 
6850
+             "color.rgb = color.rgb * vec3 (paintAttrib.z) + desaturated *\n" <<
 
6851
+             "            vec3 (1.0 - paintAttrib.z);\n";
 
6852
+    }
 
6853
+
 
6854
+    if (params.brightness) {
 
6855
+       ss << "color.rgb = color.rgb * paintAttrib.y" <<
 
6856
+             (params.opacity ? " * paintAttrib.x;\n" : ";\n") <<
 
6857
+             (params.opacity ? "color.a = color.a * paintAttrib.x;\n" : "");
 
6858
+    }
 
6859
+    else if (params.opacity) {
 
6860
+       ss << "color = color * paintAttrib.x;\n";
 
6861
+    }
 
6862
+
 
6863
+    ss << "gl_FragColor = color;\n";
 
6864
+    ss << "@FRAGMENT_FUNCTION_CALLS@\n}";
 
6865
+
 
6866
+    return ss.str();
 
6867
+}
 
6868
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/texture.cpp linaro-gles2-debianpatches/plugins/opengl/src/texture.cpp
 
6869
--- compiz-0.9.7.8/plugins/opengl/src/texture.cpp       2012-04-26 08:47:01.000000000 +0200
 
6870
+++ linaro-gles2-debianpatches/plugins/opengl/src/texture.cpp   2012-04-20 11:41:59.241600000 +0200
 
6871
@@ -35,7 +35,11 @@
 
6872
 #include <privatetexture.h>
 
6873
 #include "privates.h"
 
6874
 
 
6875
+#ifdef USE_GLES
 
6876
+std::map<Damage, EglTexture*> boundPixmapTex;
 
6877
+#else
 
6878
 std::map<Damage, TfpTexture*> boundPixmapTex;
 
6879
+#endif
 
6880
 
 
6881
 static GLTexture::Matrix _identity_matrix = {
 
6882
     1.0f, 0.0f,
 
6883
@@ -150,7 +154,7 @@
 
6884
 bool
 
6885
 GLTexture::mipmap () const
 
6886
 {
 
6887
-    return priv->mipmap & priv->mipmapSupport;
 
6888
+    return priv->mipmap && priv->mipmapSupport;
 
6889
 }
 
6890
 
 
6891
 GLenum
 
6892
@@ -163,7 +167,9 @@
 
6893
 GLTexture::enable (GLTexture::Filter filter)
 
6894
 {
 
6895
     GLScreen *gs = GLScreen::get (screen);
 
6896
+#ifndef USE_GLES
 
6897
     glEnable (priv->target);
 
6898
+#endif
 
6899
     glBindTexture (priv->target, priv->name);
 
6900
 
 
6901
     if (filter == Fast)
 
6902
@@ -184,7 +190,7 @@
 
6903
     {
 
6904
        if (gs->textureFilter () == GL_LINEAR_MIPMAP_LINEAR)
 
6905
        {
 
6906
-           if (GL::textureNonPowerOfTwo && GL::fbo && priv->mipmap)
 
6907
+           if (mipmap ())
 
6908
            {
 
6909
                glTexParameteri (priv->target,
 
6910
                                 GL_TEXTURE_MIN_FILTER,
 
6911
@@ -226,7 +232,7 @@
 
6912
     {
 
6913
        if (priv->initial)
 
6914
        {
 
6915
-           (*GL::generateMipmap) (priv->target);
 
6916
+           GL::generateMipmap (priv->target);
 
6917
            priv->initial = false;
 
6918
        }
 
6919
     }
 
6920
@@ -236,7 +242,9 @@
 
6921
 GLTexture::disable ()
 
6922
 {
 
6923
     glBindTexture (priv->target, 0);
 
6924
+#ifndef USE_GLES
 
6925
     glDisable (priv->target);
 
6926
+#endif
 
6927
 }
 
6928
 
 
6929
 void
 
6930
@@ -295,20 +303,26 @@
 
6931
     rv[0] = t;
 
6932
 
 
6933
     GLTexture::Matrix matrix = _identity_matrix;
 
6934
-    CompOption        *opt;
 
6935
     GLint             internalFormat;
 
6936
     GLenum            target;
 
6937
     bool              mipmap;
 
6938
+    bool              pot = POWER_OF_TWO (width) && POWER_OF_TWO (height);
 
6939
 
 
6940
+    #ifdef USE_GLES
 
6941
+    target = GL_TEXTURE_2D;
 
6942
+    matrix.xx = 1.0f / width;
 
6943
+    matrix.yy = 1.0f / height;
 
6944
+    matrix.y0 = 0.0f;
 
6945
+    mipmap = GL::textureNonPowerOfTwoMipmap || pot;
 
6946
+    #else
 
6947
 
 
6948
-    if (GL::textureNonPowerOfTwo ||
 
6949
-       (POWER_OF_TWO (width) && POWER_OF_TWO (height)))
 
6950
+    if (GL::textureNonPowerOfTwo || pot)
 
6951
     {
 
6952
        target = GL_TEXTURE_2D;
 
6953
        matrix.xx = 1.0f / width;
 
6954
        matrix.yy = 1.0f / height;
 
6955
        matrix.y0 = 0.0f;
 
6956
-       mipmap = true;
 
6957
+       mipmap = GL::fbo && (GL::textureNonPowerOfTwoMipmap || pot);
 
6958
     }
 
6959
     else
 
6960
     {
 
6961
@@ -318,17 +332,26 @@
 
6962
        matrix.y0 = 0.0f;
 
6963
        mipmap = false;
 
6964
     }
 
6965
+    #endif
 
6966
 
 
6967
     t->setData (target, matrix, mipmap);
 
6968
     t->setGeometry (0, 0, width, height);
 
6969
 
 
6970
     glBindTexture (target, t->name ());
 
6971
 
 
6972
+    #ifdef USE_GLES
 
6973
+    // For GLES2 no format conversion is allowed, i.e., format must equal internalFormat
 
6974
+    internalFormat = format;
 
6975
+    #else
 
6976
+    internalFormat = GL_RGBA;
 
6977
+    #endif
 
6978
+
 
6979
+    #ifndef USE_GLES
 
6980
+    CompOption *opt;
 
6981
     opt = GLScreen::get (screen)->getOption ("texture_compression");
 
6982
     if (opt->value ().b () && GL::textureCompression)
 
6983
        internalFormat = GL_COMPRESSED_RGBA_ARB;
 
6984
-    else
 
6985
-       internalFormat =  GL_RGBA;
 
6986
+    #endif
 
6987
 
 
6988
     glTexImage2D (target, 0, internalFormat, width, height, 0,
 
6989
                  format, type, image);
 
6990
@@ -413,6 +436,106 @@
 
6991
     return GLTexture::List ();
 
6992
 }
 
6993
 
 
6994
+#ifdef USE_GLES
 
6995
+EglTexture::EglTexture () :
 
6996
+    damaged (true),
 
6997
+    damage (None),
 
6998
+    updateMipMap (true)
 
6999
+{
 
7000
+}
 
7001
+
 
7002
+EglTexture::~EglTexture ()
 
7003
+{
 
7004
+    GLuint temp = name ();
 
7005
+    glBindTexture (target (), name ());
 
7006
+
 
7007
+    glDeleteTextures (1, &temp);
 
7008
+
 
7009
+    glBindTexture (target (), 0);
 
7010
+
 
7011
+    boundPixmapTex.erase (damage);
 
7012
+    XDamageDestroy (screen->dpy (), damage);
 
7013
+}
 
7014
+
 
7015
+GLTexture::List
 
7016
+EglTexture::bindPixmapToTexture (Pixmap pixmap,
 
7017
+                                int    width,
 
7018
+                                int    height,
 
7019
+                                int    depth)
 
7020
+{
 
7021
+    if ((int) width > GL::maxTextureSize || (int) height > GL::maxTextureSize ||
 
7022
+        !GL::textureFromPixmap)
 
7023
+       return GLTexture::List ();
 
7024
+
 
7025
+    GLTexture::List   rv (1);
 
7026
+    EglTexture        *tex = NULL;
 
7027
+    EGLImageKHR       eglImage = NULL;
 
7028
+    GLTexture::Matrix matrix = _identity_matrix;
 
7029
+
 
7030
+    const EGLint img_attribs[] = {
 
7031
+       EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
 
7032
+       EGL_NONE
 
7033
+    };
 
7034
+
 
7035
+    eglImage = GL::createImage (eglGetDisplay (screen->dpy ()),
 
7036
+                                EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
 
7037
+                                (EGLClientBuffer)pixmap, img_attribs);
 
7038
+
 
7039
+    if (eglImage == EGL_NO_IMAGE_KHR)
 
7040
+    {
 
7041
+       compLogMessage ("core", CompLogLevelWarn,
 
7042
+                       "eglCreateImageKHR failed");
 
7043
+
 
7044
+       return GLTexture::List ();
 
7045
+    }
 
7046
+
 
7047
+    matrix.xx = 1.0f / width;
 
7048
+    matrix.yy = 1.0f / height;
 
7049
+    matrix.y0 = 0.0f;
 
7050
+
 
7051
+    tex = new EglTexture ();
 
7052
+    tex->setData (GL_TEXTURE_2D, matrix,
 
7053
+       GL::textureNonPowerOfTwoMipmap ||
 
7054
+       (POWER_OF_TWO (width) && POWER_OF_TWO (height)));
 
7055
+    tex->setGeometry (0, 0, width, height);
 
7056
+
 
7057
+    rv[0] = tex;
 
7058
+
 
7059
+    glBindTexture (GL_TEXTURE_2D, tex->name ());
 
7060
+
 
7061
+    GL::eglImageTargetTexture (GL_TEXTURE_2D, (GLeglImageOES)eglImage);
 
7062
+    GL::destroyImage (eglGetDisplay (screen->dpy ()), eglImage);
 
7063
+
 
7064
+    tex->setFilter (GL_NEAREST);
 
7065
+    tex->setWrap (GL_CLAMP_TO_EDGE);
 
7066
+
 
7067
+    glBindTexture (GL_TEXTURE_2D, 0);
 
7068
+
 
7069
+    tex->damage = XDamageCreate (screen->dpy (), pixmap,
 
7070
+                                XDamageReportRawRectangles);
 
7071
+    boundPixmapTex[tex->damage] = tex;
 
7072
+
 
7073
+    return rv;
 
7074
+}
 
7075
+
 
7076
+void
 
7077
+EglTexture::enable (GLTexture::Filter filter)
 
7078
+{
 
7079
+    glBindTexture (target (), name ());
 
7080
+    GLTexture::enable (filter);
 
7081
+    
 
7082
+    if (damaged)
 
7083
+       updateMipMap = true;
 
7084
+
 
7085
+    if (this->filter () == GL_LINEAR_MIPMAP_LINEAR && updateMipMap)
 
7086
+    {
 
7087
+       GL::generateMipmap (target ());
 
7088
+       updateMipMap = false;
 
7089
+    }
 
7090
+    damaged = false;
 
7091
+}
 
7092
+#else
 
7093
+
 
7094
 TfpTexture::TfpTexture () :
 
7095
     pixmap (0),
 
7096
     damaged (true),
 
7097
@@ -611,3 +734,5 @@
 
7098
     }
 
7099
     damaged = false;
 
7100
 }
 
7101
+#endif
 
7102
+
 
7103
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/vertexbuffer.cpp linaro-gles2-debianpatches/plugins/opengl/src/vertexbuffer.cpp
 
7104
--- compiz-0.9.7.8/plugins/opengl/src/vertexbuffer.cpp  1970-01-01 01:00:00.000000000 +0100
 
7105
+++ linaro-gles2-debianpatches/plugins/opengl/src/vertexbuffer.cpp      2012-04-20 11:41:59.241600000 +0200
 
7106
@@ -0,0 +1,550 @@
 
7107
+/*
 
7108
+ * Copyright © 2011 Linaro Ltd.
 
7109
+ *
 
7110
+ * Permission to use, copy, modify, distribute, and sell this software
 
7111
+ * and its documentation for any purpose is hereby granted without
 
7112
+ * fee, provided that the above copyright notice appear in all copies
 
7113
+ * and that both that copyright notice and this permission notice
 
7114
+ * appear in supporting documentation, and that the name of
 
7115
+ * Linaro Ltd. not be used in advertising or publicity pertaining to
 
7116
+ * distribution of the software without specific, written prior permission.
 
7117
+ * Linaro Ltd. makes no representations about the suitability of this
 
7118
+ * software for any purpose. It is provided "as is" without express or
 
7119
+ * implied warranty.
 
7120
+ *
 
7121
+ * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
7122
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
7123
+ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
7124
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
7125
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
7126
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
7127
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
7128
+ *
 
7129
+ * Authors: Travis Watkins <travis.watkins@linaro.org>
 
7130
+ *          Frederic Plourde <frederic.plourde@collabora.co.uk>
 
7131
+ *          Alexandros Frantzis <alexandros.frantzis@linaro.org>
 
7132
+ */
 
7133
+
 
7134
+#include <vector>
 
7135
+#include <iostream>
 
7136
+
 
7137
+#ifdef USE_GLES
 
7138
+#include <GLES2/gl2.h>
 
7139
+#else
 
7140
+#include <GL/gl.h>
 
7141
+#include <GL/glext.h>
 
7142
+#endif
 
7143
+
 
7144
+#include <opengl/vertexbuffer.h>
 
7145
+
 
7146
+#include "privates.h"
 
7147
+
 
7148
+GLVertexBuffer *PrivateVertexBuffer::streamingBuffer = NULL;
 
7149
+
 
7150
+GLVertexBuffer::GLVertexBuffer () :
 
7151
+    priv (new PrivateVertexBuffer ())
 
7152
+{
 
7153
+    priv->usage = GL_STATIC_DRAW;
 
7154
+}
 
7155
+
 
7156
+GLVertexBuffer::GLVertexBuffer (GLenum usage) :
 
7157
+    priv (new PrivateVertexBuffer ())
 
7158
+{
 
7159
+    priv->usage = usage;
 
7160
+}
 
7161
+
 
7162
+GLVertexBuffer::~GLVertexBuffer ()
 
7163
+{
 
7164
+    delete priv;
 
7165
+}
 
7166
+
 
7167
+GLVertexBuffer *GLVertexBuffer::streamingBuffer ()
 
7168
+{
 
7169
+    if (PrivateVertexBuffer::streamingBuffer == NULL)
 
7170
+       PrivateVertexBuffer::streamingBuffer = new GLVertexBuffer
 
7171
+                                                             (GL_STREAM_DRAW);
 
7172
+    return PrivateVertexBuffer::streamingBuffer;
 
7173
+}
 
7174
+
 
7175
+void GLVertexBuffer::begin (GLenum primitiveType)
 
7176
+{
 
7177
+    priv->primitiveType = primitiveType;
 
7178
+
 
7179
+    priv->vertexData.clear ();
 
7180
+    priv->normalData.clear ();
 
7181
+    priv->colorData.clear ();
 
7182
+    priv->textureData.clear ();
 
7183
+    priv->uniforms.clear ();
 
7184
+}
 
7185
+
 
7186
+void GLVertexBuffer::begin ()
 
7187
+{
 
7188
+    begin (GL_TRIANGLES);
 
7189
+}
 
7190
+
 
7191
+int GLVertexBuffer::end ()
 
7192
+{
 
7193
+    if (!GL::vbo)
 
7194
+       return 0;
 
7195
+
 
7196
+    if (!priv->vertexData.size ())
 
7197
+       return -1;
 
7198
+
 
7199
+    GL::bindBuffer (GL_ARRAY_BUFFER, priv->vertexBuffer);
 
7200
+    GL::bufferData (GL_ARRAY_BUFFER,
 
7201
+                    sizeof(GLfloat) * priv->vertexData.size (),
 
7202
+                    &priv->vertexData[0], priv->usage);
 
7203
+
 
7204
+    if (priv->normalData.size ())
 
7205
+    {
 
7206
+       GL::bindBuffer (GL_ARRAY_BUFFER, priv->normalBuffer);
 
7207
+       GL::bufferData (GL_ARRAY_BUFFER,
 
7208
+                       sizeof(GLfloat) * priv->normalData.size (),
 
7209
+                       &priv->normalData[0], priv->usage);
 
7210
+    }
 
7211
+
 
7212
+    if (priv->colorData.size ())
 
7213
+    {
 
7214
+       GL::bindBuffer (GL_ARRAY_BUFFER, priv->colorBuffer);
 
7215
+       GL::bufferData (GL_ARRAY_BUFFER,
 
7216
+                       sizeof(GLfloat) * priv->colorData.size (),
 
7217
+                       &priv->colorData[0], priv->usage);
 
7218
+    }
 
7219
+
 
7220
+    if (priv->textureData.size ())
 
7221
+    {
 
7222
+       for (unsigned int i = 0; i < priv->textureData.size (); i++)
 
7223
+       {
 
7224
+           GL::bindBuffer (GL_ARRAY_BUFFER, priv->textureBuffers[i]);
 
7225
+           GL::bufferData (GL_ARRAY_BUFFER,
 
7226
+                           sizeof(GLfloat) * priv->textureData[i].size (),
 
7227
+                           &priv->textureData[i][0], priv->usage);
 
7228
+       }
 
7229
+    }
 
7230
+
 
7231
+    GL::bindBuffer (GL_ARRAY_BUFFER, 0);
 
7232
+
 
7233
+    return 0;
 
7234
+}
 
7235
+
 
7236
+void GLVertexBuffer::addVertices (GLuint nVertices, GLfloat *vertices)
 
7237
+{
 
7238
+    priv->vertexData.reserve (priv->vertexData.size () + (nVertices * 3));
 
7239
+
 
7240
+    for (GLuint i = 0; i < nVertices * 3; i++)
 
7241
+    {
 
7242
+       priv->vertexData.push_back (vertices[i]);
 
7243
+    }
 
7244
+}
 
7245
+
 
7246
+void GLVertexBuffer::addNormals (GLuint nNormals, GLfloat *normals)
 
7247
+{
 
7248
+    priv->normalData.reserve (priv->normalData.size () + (nNormals * 3));
 
7249
+
 
7250
+    for (GLuint i = 0; i < nNormals * 3; i++)
 
7251
+    {
 
7252
+       priv->normalData.push_back (normals[i]);
 
7253
+    }
 
7254
+}
 
7255
+
 
7256
+void GLVertexBuffer::addColors (GLuint nColors, GLushort *colors)
 
7257
+{
 
7258
+    priv->colorData.reserve (priv->colorData.size () + (nColors * 4));
 
7259
+
 
7260
+    for (GLuint i = 0; i < nColors * 4; i++)
 
7261
+    {
 
7262
+       priv->colorData.push_back (colors[i] / 65535.0f);
 
7263
+    }
 
7264
+}
 
7265
+
 
7266
+void GLVertexBuffer::addTexCoords (GLuint texture,
 
7267
+                                   GLuint nTexcoords,
 
7268
+                                   GLfloat *texcoords)
 
7269
+{
 
7270
+    //four textures max (zero indexed)
 
7271
+    if (texture > 3)
 
7272
+       return;
 
7273
+
 
7274
+    while (texture >= priv->textureData.size ())
 
7275
+    {
 
7276
+       std::vector<GLfloat> temp;
 
7277
+       priv->textureData.push_back (temp);
 
7278
+    }
 
7279
+
 
7280
+    priv->textureData[texture].reserve (priv->textureData[texture].size () +
 
7281
+                                        (nTexcoords * 2));
 
7282
+
 
7283
+    for (GLuint i = 0; i < nTexcoords * 2; i++)
 
7284
+    {
 
7285
+       priv->textureData[texture].push_back (texcoords[i]);
 
7286
+    }
 
7287
+}
 
7288
+
 
7289
+void GLVertexBuffer::addUniform (const char *name, GLfloat value)
 
7290
+{
 
7291
+    // we're casting to double here to make our template va_arg happy
 
7292
+    Uniform<double, 1>* uniform = new Uniform<double, 1>(name, (double)value);
 
7293
+    priv->uniforms.push_back (uniform);
 
7294
+}
 
7295
+
 
7296
+void GLVertexBuffer::addUniform (const char *name, GLint value)
 
7297
+{
 
7298
+    Uniform<GLint, 1>* uniform = new Uniform<GLint, 1>(name, value);
 
7299
+    priv->uniforms.push_back (uniform);
 
7300
+}
 
7301
+
 
7302
+bool GLVertexBuffer::addUniform (const char *name, const GLMatrix &value)
 
7303
+{
 
7304
+    //#warning Add 'addUniform' support to GLMatrix type !
 
7305
+    return true;
 
7306
+}
 
7307
+
 
7308
+void GLVertexBuffer::addUniform2f (const char *name,
 
7309
+                                   GLfloat x,
 
7310
+                                   GLfloat y)
 
7311
+{
 
7312
+    // we're casting to double here to make our template va_arg happy
 
7313
+    Uniform<double, 2>* uniform = new Uniform<double, 2>(name,
 
7314
+                                                        (double)x,
 
7315
+                                                        (double)y);
 
7316
+    priv->uniforms.push_back (uniform);
 
7317
+}
 
7318
+
 
7319
+void GLVertexBuffer::addUniform3f (const char *name,
 
7320
+                                   GLfloat x,
 
7321
+                                   GLfloat y,
 
7322
+                                   GLfloat z)
 
7323
+{
 
7324
+     // we're casting to double here to make our template va_arg happy
 
7325
+    Uniform<double, 3>* uniform = new Uniform<double, 3>(name,
 
7326
+                                                        (double)x,
 
7327
+                                                        (double)y,
 
7328
+                                                        (double)z);
 
7329
+    priv->uniforms.push_back (uniform);
 
7330
+}
 
7331
+
 
7332
+void GLVertexBuffer::addUniform4f (const char *name,
 
7333
+                                   GLfloat x,
 
7334
+                                   GLfloat y,
 
7335
+                                   GLfloat z,
 
7336
+                                   GLfloat w)
 
7337
+{
 
7338
+    // we're casting to double here to make our template va_arg happy
 
7339
+    Uniform<double, 4>* uniform = new Uniform<double, 4>(name,
 
7340
+                                                        (double)x,
 
7341
+                                                        (double)y,
 
7342
+                                                        (double)z,
 
7343
+                                                        (double)w);
 
7344
+    priv->uniforms.push_back (uniform);
 
7345
+}
 
7346
+
 
7347
+void GLVertexBuffer::addUniform2i (const char *name,
 
7348
+                                   GLint x,
 
7349
+                                   GLint y)
 
7350
+{
 
7351
+    Uniform<GLint, 2>* uniform = new Uniform<GLint, 2>(name, x, y);
 
7352
+    priv->uniforms.push_back (uniform);
 
7353
+}
 
7354
+
 
7355
+void GLVertexBuffer::addUniform3i (const char *name,
 
7356
+                                   GLint x,
 
7357
+                                   GLint y,
 
7358
+                                   GLint z)
 
7359
+{
 
7360
+    Uniform<GLint, 3>* uniform = new Uniform<GLint, 3>(name, x, y, z);
 
7361
+    priv->uniforms.push_back (uniform);
 
7362
+}
 
7363
+
 
7364
+void GLVertexBuffer::addUniform4i (const char *name,
 
7365
+                                   GLint x,
 
7366
+                                   GLint y,
 
7367
+                                   GLint z,
 
7368
+                                   GLint w)
 
7369
+{
 
7370
+    Uniform<GLint, 4>* uniform = new Uniform<GLint, 4>(name, x, y, z, w);
 
7371
+    priv->uniforms.push_back (uniform);
 
7372
+}
 
7373
+
 
7374
+void GLVertexBuffer::setProgram (GLProgram *program)
 
7375
+{
 
7376
+    priv->program = program;
 
7377
+}
 
7378
+
 
7379
+void GLVertexBuffer::setAutoProgram (AutoProgram *autoProgram)
 
7380
+{
 
7381
+    priv->autoProgram = autoProgram;
 
7382
+}
 
7383
+
 
7384
+int GLVertexBuffer::render ()
 
7385
+{
 
7386
+    if (GL::vbo && GL::shaders)
 
7387
+       return priv->render (NULL, NULL, NULL);
 
7388
+    else
 
7389
+       return -1;
 
7390
+}
 
7391
+
 
7392
+int GLVertexBuffer::render (const GLMatrix &modelview)
 
7393
+{
 
7394
+    const GLWindowPaintAttrib attrib = { OPAQUE, BRIGHT, COLOR, 0, 0, 0, 0 };
 
7395
+
 
7396
+    return render (modelview, attrib);
 
7397
+}
 
7398
+
 
7399
+int GLVertexBuffer::render (const GLMatrix            &modelview,
 
7400
+                            const GLWindowPaintAttrib &attrib)
 
7401
+{
 
7402
+    GLScreen *gScreen = GLScreen::get (screen);
 
7403
+    GLMatrix *projection = gScreen->projectionMatrix ();
 
7404
+
 
7405
+    return render (*projection, modelview, attrib);
 
7406
+}
 
7407
+
 
7408
+int GLVertexBuffer::render (const GLMatrix            &projection,
 
7409
+                            const GLMatrix            &modelview,
 
7410
+                            const GLWindowPaintAttrib &attrib)
 
7411
+{
 
7412
+    if (!priv->vertexData.size ())
 
7413
+       return -1;
 
7414
+
 
7415
+    if (GL::vbo && GL::shaders)
 
7416
+       return priv->render (&projection, &modelview, &attrib);
 
7417
+    else
 
7418
+       return priv->legacyRender (projection, modelview, attrib);
 
7419
+}
 
7420
+
 
7421
+PrivateVertexBuffer::PrivateVertexBuffer () :
 
7422
+    program (NULL)
 
7423
+{
 
7424
+    if (!GL::vbo)
 
7425
+       return;
 
7426
+
 
7427
+    GL::genBuffers (1, &vertexBuffer);
 
7428
+    GL::genBuffers (1, &normalBuffer);
 
7429
+    GL::genBuffers (1, &colorBuffer);
 
7430
+    GL::genBuffers (4, &textureBuffers[0]);
 
7431
+}
 
7432
+
 
7433
+PrivateVertexBuffer::~PrivateVertexBuffer ()
 
7434
+{
 
7435
+    if (!GL::vbo)
 
7436
+       return;
 
7437
+
 
7438
+    GL::deleteBuffers (1, &vertexBuffer);
 
7439
+    GL::deleteBuffers (1, &normalBuffer);
 
7440
+    GL::deleteBuffers (1, &colorBuffer);
 
7441
+    GL::deleteBuffers (4, &textureBuffers[0]);
 
7442
+}
 
7443
+
 
7444
+int PrivateVertexBuffer::render (const GLMatrix            *projection,
 
7445
+                                 const GLMatrix            *modelview,
 
7446
+                                 const GLWindowPaintAttrib *attrib)
 
7447
+{
 
7448
+    GLfloat attribs[3] = {1, 1, 1};
 
7449
+    GLint positionIndex = -1;
 
7450
+    GLint normalIndex = -1;
 
7451
+    GLint colorIndex = -1;
 
7452
+    GLint texCoordIndex[4] = {-1, -1, -1, -1};
 
7453
+    GLProgram *tmpProgram = program;
 
7454
+
 
7455
+    // If we don't have an explicitly set program, try to get one
 
7456
+    // using the AutoProgram callback object.
 
7457
+    if (tmpProgram == NULL && autoProgram) {
 
7458
+       // Convert attrib to shader parameters
 
7459
+       GLShaderParameters params;
 
7460
+
 
7461
+       params.opacity = attrib->opacity != OPAQUE;
 
7462
+       params.brightness = attrib->brightness != BRIGHT;
 
7463
+       params.saturation = attrib->saturation != COLOR;
 
7464
+       params.color = colorData.size () == 4 ? GLShaderVariableUniform :
 
7465
+                      colorData.size () >  4 ? GLShaderVariableVarying :
 
7466
+                                               GLShaderVariableNone;
 
7467
+       params.normal = normalData.size () <= 4 ? GLShaderVariableUniform :
 
7468
+                                                 GLShaderVariableVarying;
 
7469
+       params.numTextures = textureData.size ();
 
7470
+
 
7471
+       // Get a program matching the parameters
 
7472
+       tmpProgram = autoProgram->getProgram(params);
 
7473
+    }
 
7474
+
 
7475
+    if (tmpProgram == NULL)
 
7476
+    {
 
7477
+       std::cerr << "no program defined!" << std::endl;
 
7478
+       return -1;
 
7479
+    }
 
7480
+
 
7481
+    tmpProgram->bind ();
 
7482
+    if (!tmpProgram->valid ())
 
7483
+    {
 
7484
+       return -1;
 
7485
+    }
 
7486
+
 
7487
+    if (projection)
 
7488
+       tmpProgram->setUniform ("projection", *projection);
 
7489
+
 
7490
+    if (modelview)
 
7491
+       tmpProgram->setUniform ("modelview", *modelview);
 
7492
+
 
7493
+    positionIndex = tmpProgram->attributeLocation ("position");
 
7494
+    (*GL::enableVertexAttribArray) (positionIndex);
 
7495
+    (*GL::bindBuffer) (GL_ARRAY_BUFFER, vertexBuffer);
 
7496
+    (*GL::vertexAttribPointer) (positionIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
 
7497
+
 
7498
+    //use default normal
 
7499
+    if (normalData.size () == 0)
 
7500
+    {
 
7501
+       tmpProgram->setUniform3f ("singleNormal", 0.0f, 0.0f, -1.0f);
 
7502
+    }
 
7503
+    // special case a single normal and apply it to the entire operation
 
7504
+    else if (normalData.size () == 3)
 
7505
+    {
 
7506
+       tmpProgram->setUniform3f ("singleNormal",
 
7507
+                              normalData[0], normalData[1], normalData[2]);
 
7508
+    }
 
7509
+    else if (normalData.size () > 3)
 
7510
+    {
 
7511
+       normalIndex = tmpProgram->attributeLocation ("normal");
 
7512
+       (*GL::enableVertexAttribArray) (normalIndex);
 
7513
+       (*GL::bindBuffer) (GL_ARRAY_BUFFER, normalBuffer);
 
7514
+       (*GL::vertexAttribPointer) (normalIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
 
7515
+    }
 
7516
+
 
7517
+    // special case a single color and apply it to the entire operation
 
7518
+    if (colorData.size () == 4)
 
7519
+    {
 
7520
+       tmpProgram->setUniform4f ("singleColor", colorData[0],
 
7521
+                              colorData[1], colorData[2], colorData[3]);
 
7522
+    }
 
7523
+    else if (colorData.size () > 4)
 
7524
+    {
 
7525
+       colorIndex = tmpProgram->attributeLocation ("color");
 
7526
+       (*GL::enableVertexAttribArray) (colorIndex);
 
7527
+       (*GL::bindBuffer) (GL_ARRAY_BUFFER, colorBuffer);
 
7528
+       (*GL::vertexAttribPointer) (colorIndex, 4, GL_FLOAT, GL_FALSE, 0, 0);
 
7529
+    }
 
7530
+
 
7531
+    for (int i = textureData.size () - 1; i >= 0; i--)
 
7532
+    {
 
7533
+       char name[10];
 
7534
+
 
7535
+       snprintf (name, 10, "texCoord%d", i);
 
7536
+       texCoordIndex[i] = tmpProgram->attributeLocation (name);
 
7537
+
 
7538
+       (*GL::enableVertexAttribArray) (texCoordIndex[i]);
 
7539
+       (*GL::bindBuffer) (GL_ARRAY_BUFFER, textureBuffers[i]);
 
7540
+       (*GL::vertexAttribPointer) (texCoordIndex[i], 2, GL_FLOAT, GL_FALSE, 0, 0);
 
7541
+
 
7542
+       snprintf (name, 9, "texture%d", i);
 
7543
+       tmpProgram->setUniform (name, i);
 
7544
+    }
 
7545
+
 
7546
+    // set per-plugin uniforms
 
7547
+    for (unsigned int i = 0; i < uniforms.size (); i++)
 
7548
+    {
 
7549
+       uniforms[i]->set (program);
 
7550
+    }
 
7551
+
 
7552
+    //convert paint attribs to 0-1 range
 
7553
+    if (attrib)
 
7554
+    {
 
7555
+       attribs[0] = attrib->opacity  / 65535.0f;
 
7556
+       attribs[1] = attrib->brightness / 65535.0f;
 
7557
+       attribs[2] = attrib->saturation / 65535.0f;
 
7558
+       tmpProgram->setUniform3f ("paintAttrib", attribs[0], attribs[1], attribs[2]);
 
7559
+    }
 
7560
+
 
7561
+    glDrawArrays (primitiveType, 0, vertexData.size () / 3);
 
7562
+
 
7563
+    for (int i = 0; i < 4; ++i)
 
7564
+    {
 
7565
+       if (texCoordIndex[i] != -1)
 
7566
+           (*GL::disableVertexAttribArray) (texCoordIndex[i]);
 
7567
+    }
 
7568
+
 
7569
+    if (colorIndex != -1)
 
7570
+       (*GL::disableVertexAttribArray) (colorIndex);
 
7571
+
 
7572
+    if (normalIndex != -1)
 
7573
+       (*GL::disableVertexAttribArray) (normalIndex);
 
7574
+
 
7575
+    (*GL::disableVertexAttribArray) (positionIndex);
 
7576
+
 
7577
+    GL::bindBuffer (GL_ARRAY_BUFFER, 0);
 
7578
+    tmpProgram->unbind ();
 
7579
+
 
7580
+    return 0;
 
7581
+}
 
7582
+
 
7583
+int PrivateVertexBuffer::legacyRender (const GLMatrix            &projection,
 
7584
+                                       const GLMatrix            &modelview,
 
7585
+                                       const GLWindowPaintAttrib &attrib)
 
7586
+{
 
7587
+    #ifndef USE_GLES
 
7588
+    glMatrixMode (GL_PROJECTION);
 
7589
+    glPushMatrix ();
 
7590
+    glLoadMatrixf (projection.getMatrix ());
 
7591
+
 
7592
+    glMatrixMode (GL_MODELVIEW);
 
7593
+    glPushMatrix ();
 
7594
+    glLoadMatrixf (modelview.getMatrix ());
 
7595
+
 
7596
+    glEnableClientState (GL_VERTEX_ARRAY);
 
7597
+    glVertexPointer (3, GL_FLOAT, 0, &vertexData[0]);
 
7598
+
 
7599
+    //use default normal
 
7600
+    if (normalData.size () == 0)
 
7601
+    {
 
7602
+       glNormal3f (0.0f, 0.0f, -1.0f);
 
7603
+    }
 
7604
+    // special case a single normal and apply it to the entire operation
 
7605
+    else if (normalData.size () == 3)
 
7606
+    {
 
7607
+       glNormal3fv (&normalData[0]);
 
7608
+    }
 
7609
+    else if (normalData.size () > 3)
 
7610
+    {
 
7611
+       glEnableClientState (GL_NORMAL_ARRAY);
 
7612
+       glNormalPointer (GL_FLOAT, 0, &normalData[0]);
 
7613
+    }
 
7614
+
 
7615
+    // special case a single color and apply it to the entire operation
 
7616
+    if (colorData.size () == 4)
 
7617
+    {
 
7618
+       glColor4fv (&colorData[0]);
 
7619
+    }
 
7620
+    else if (colorData.size () > 4)
 
7621
+    {
 
7622
+       glEnableClientState (GL_COLOR_ARRAY);
 
7623
+       glColorPointer (4, GL_FLOAT, 0, &colorData[0]);
 
7624
+    }
 
7625
+
 
7626
+    for (int i = textureData.size () - 1; i >= 0; i--)
 
7627
+    {
 
7628
+       GL::clientActiveTexture (GL_TEXTURE0_ARB + i);
 
7629
+       glEnableClientState (GL_TEXTURE_COORD_ARRAY);
 
7630
+       glTexCoordPointer (2, GL_FLOAT, 0, &textureData[i][0]);
 
7631
+    }
 
7632
+
 
7633
+    glDrawArrays (primitiveType, 0, vertexData.size () / 3);
 
7634
+
 
7635
+    glDisableClientState (GL_VERTEX_ARRAY);
 
7636
+    glDisableClientState (GL_NORMAL_ARRAY);
 
7637
+    glDisableClientState (GL_COLOR_ARRAY);
 
7638
+
 
7639
+    for (int i = textureData.size (); i > 0; i--)
 
7640
+    {
 
7641
+       GL::clientActiveTexture (GL_TEXTURE0_ARB + i);
 
7642
+       glDisableClientState (GL_TEXTURE_COORD_ARRAY);
 
7643
+    }
 
7644
+
 
7645
+    GL::clientActiveTexture (GL_TEXTURE0_ARB);
 
7646
+
 
7647
+    glMatrixMode (GL_PROJECTION);
 
7648
+    glPopMatrix ();
 
7649
+
 
7650
+    glMatrixMode (GL_MODELVIEW);
 
7651
+    glPopMatrix ();
 
7652
+    #endif
 
7653
+
 
7654
+    return 0;
 
7655
+}
 
7656
+
 
7657
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/opengl/src/window.cpp linaro-gles2-debianpatches/plugins/opengl/src/window.cpp
 
7658
--- compiz-0.9.7.8/plugins/opengl/src/window.cpp        2012-04-26 08:47:01.000000000 +0200
 
7659
+++ linaro-gles2-debianpatches/plugins/opengl/src/window.cpp    2012-04-20 11:41:59.241600000 +0200
 
7660
@@ -46,6 +46,28 @@
 
7661
     delete priv;
 
7662
 }
 
7663
 
 
7664
+
 
7665
+/**
 
7666
+ * Callback object to create GLPrograms automatically when using GLVertexBuffer.
 
7667
+ */
 
7668
+class GLWindowAutoProgram : public GLVertexBuffer::AutoProgram
 
7669
+{
 
7670
+public:
 
7671
+    GLWindowAutoProgram (PrivateGLWindow *pWindow) : pWindow(pWindow) {}
 
7672
+
 
7673
+    GLProgram *getProgram (GLShaderParameters &params)
 
7674
+    {
 
7675
+       GLScreen *gScreen = pWindow->gScreen;
 
7676
+
 
7677
+       const GLShaderData *shaderData = gScreen->getShaderData (params);
 
7678
+       pWindow->shaders.push_back (shaderData);
 
7679
+       return gScreen->getProgram (pWindow->shaders);
 
7680
+    }
 
7681
+
 
7682
+    PrivateGLWindow *pWindow;
 
7683
+
 
7684
+};
 
7685
+
 
7686
 PrivateGLWindow::PrivateGLWindow (CompWindow *w,
 
7687
                                  GLWindow   *gw) :
 
7688
     window (w),
 
7689
@@ -57,7 +79,8 @@
 
7690
     updateReg (true),
 
7691
     clip (),
 
7692
     bindFailed (false),
 
7693
-    geometry (),
 
7694
+    vertexBuffer (new GLVertexBuffer ()),
 
7695
+    autoProgram(new GLWindowAutoProgram(this)),
 
7696
     icons ()
 
7697
 {
 
7698
     paint.xScale       = 1.0f;
 
7699
@@ -67,10 +90,13 @@
 
7700
 
 
7701
     WindowInterface::setHandler (w);
 
7702
     CompositeWindowInterface::setHandler (cWindow);
 
7703
+    vertexBuffer->setAutoProgram(autoProgram);
 
7704
 }
 
7705
 
 
7706
 PrivateGLWindow::~PrivateGLWindow ()
 
7707
 {
 
7708
+    delete vertexBuffer;
 
7709
+    delete autoProgram;
 
7710
 }
 
7711
 
 
7712
 void
 
7713
@@ -105,6 +131,21 @@
 
7714
        compLogMessage ("opengl", CompLogLevelInfo,
 
7715
                        "Couldn't bind redirected window 0x%x to "
 
7716
                        "texture\n", (int) priv->window->id ());
 
7717
+
 
7718
+       if (priv->cWindow->size ().width () > GL::maxTextureSize ||
 
7719
+           priv->cWindow->size ().height ()  > GL::maxTextureSize)
 
7720
+       {
 
7721
+           compLogMessage ("opengl", CompLogLevelWarn,
 
7722
+                           "Bug in window 0x%x (identifying as %s)", (int) priv->window->id (), priv->window->resName ().size () ? priv->window->resName ().c_str () : "(none available)");
 
7723
+           compLogMessage ("opengl", CompLogLevelWarn,
 
7724
+                           "This window tried to create an absurdly large window %i x %i\n", priv->cWindow->size ().width (), priv->cWindow->size ().height ());
 
7725
+           compLogMessage ("opengl", CompLogLevelWarn,
 
7726
+                           "Unforunately, that's not supported on your hardware, because you have a maximum texture size of %i", GL::maxTextureSize);
 
7727
+           compLogMessage ("opengl", CompLogLevelWarn, "you should probably file a bug against that application");
 
7728
+           compLogMessage ("opengl", CompLogLevelWarn, "for now, we're going to hide tht window so that it doesn't break your desktop\n");
 
7729
+
 
7730
+           XReparentWindow (screen->dpy (), priv->window->id (), GLScreen::get (screen)->priv->saveWindow, 0, 0);
 
7731
+       }
 
7732
     }
 
7733
 
 
7734
     priv->setWindowMatrix ();
 
7735
@@ -132,11 +173,11 @@
 
7736
     WRAPABLE_DEF (glPaint, attrib, transform, region, mask)
 
7737
 
 
7738
 bool
 
7739
-GLWindowInterface::glDraw (const GLMatrix     &transform,
 
7740
-                          GLFragment::Attrib &fragment,
 
7741
-                          const CompRegion   &region,
 
7742
-                          unsigned int       mask)
 
7743
-    WRAPABLE_DEF (glDraw, transform, fragment, region, mask)
 
7744
+GLWindowInterface::glDraw (const GLMatrix            &transform,
 
7745
+                          const GLWindowPaintAttrib &attrib,
 
7746
+                          const CompRegion          &region,
 
7747
+                          unsigned int              mask)
 
7748
+    WRAPABLE_DEF (glDraw, transform, attrib, region, mask)
 
7749
 
 
7750
 void
 
7751
 GLWindowInterface::glAddGeometry (const GLTexture::MatrixList &matrix,
 
7752
@@ -148,14 +189,11 @@
 
7753
                  maxGridWidth, maxGridHeight)
 
7754
 
 
7755
 void
 
7756
-GLWindowInterface::glDrawTexture (GLTexture          *texture,
 
7757
-                                 GLFragment::Attrib &fragment,
 
7758
-                                 unsigned int       mask)
 
7759
-    WRAPABLE_DEF (glDrawTexture, texture, fragment, mask)
 
7760
-
 
7761
-void
 
7762
-GLWindowInterface::glDrawGeometry ()
 
7763
-    WRAPABLE_DEF (glDrawGeometry)
 
7764
+GLWindowInterface::glDrawTexture (GLTexture                 *texture,
 
7765
+                                  const GLMatrix            &transform,
 
7766
+                                 const GLWindowPaintAttrib &attrib,
 
7767
+                                 unsigned int              mask)
 
7768
+    WRAPABLE_DEF (glDrawTexture, texture, transform, attrib, mask)
 
7769
 
 
7770
 const CompRegion &
 
7771
 GLWindow::clip () const
 
7772
@@ -223,76 +261,10 @@
 
7773
     priv->paint.saturation = cw->saturation ();
 
7774
 }
 
7775
 
 
7776
-GLWindow::Geometry &
 
7777
-GLWindow::geometry ()
 
7778
-{
 
7779
-    return priv->geometry;
 
7780
-}
 
7781
-
 
7782
-GLWindow::Geometry::Geometry () :
 
7783
-    vertices (NULL),
 
7784
-    vertexSize (0),
 
7785
-    vertexStride (0),
 
7786
-    indices (NULL),
 
7787
-    indexSize (0),
 
7788
-    vCount (0),
 
7789
-    texUnits (0),
 
7790
-    texCoordSize (0),
 
7791
-    indexCount (0)
 
7792
-{
 
7793
-}
 
7794
-
 
7795
-GLWindow::Geometry::~Geometry ()
 
7796
-{
 
7797
-    if (vertices)
 
7798
-       free (vertices);
 
7799
-
 
7800
-    if (indices)
 
7801
-       free (indices);
 
7802
-}
 
7803
-
 
7804
-void
 
7805
-GLWindow::Geometry::reset ()
 
7806
-{
 
7807
-    vCount = indexCount = 0;
 
7808
-}
 
7809
-
 
7810
-bool
 
7811
-GLWindow::Geometry::moreVertices (int newSize)
 
7812
-{
 
7813
-    if (newSize > vertexSize)
 
7814
-    {
 
7815
-       GLfloat *nVertices;
 
7816
-
 
7817
-       nVertices = (GLfloat *)
 
7818
-           realloc (vertices, sizeof (GLfloat) * newSize);
 
7819
-       if (!nVertices)
 
7820
-           return false;
 
7821
-
 
7822
-       vertices = nVertices;
 
7823
-       vertexSize = newSize;
 
7824
-    }
 
7825
-
 
7826
-    return true;
 
7827
-}
 
7828
-
 
7829
-bool
 
7830
-GLWindow::Geometry::moreIndices (int newSize)
 
7831
+GLVertexBuffer *
 
7832
+GLWindow::vertexBuffer ()
 
7833
 {
 
7834
-    if (newSize > indexSize)
 
7835
-    {
 
7836
-       GLushort *nIndices;
 
7837
-
 
7838
-       nIndices = (GLushort *)
 
7839
-           realloc (indices, sizeof (GLushort) * newSize);
 
7840
-       if (!nIndices)
 
7841
-           return false;
 
7842
-
 
7843
-       indices = nIndices;
 
7844
-       indexSize = newSize;
 
7845
-    }
 
7846
-
 
7847
-    return true;
 
7848
+    return priv->vertexBuffer;
 
7849
 }
 
7850
 
 
7851
 const GLTexture::List &
 
7852
@@ -335,6 +307,19 @@
 
7853
 }
 
7854
 
 
7855
 void
 
7856
+GLWindow::addShaders (std::string name,
 
7857
+                      std::string vertex_shader,
 
7858
+                      std::string fragment_shader)
 
7859
+{
 
7860
+    GLShaderData *data = new GLShaderData;
 
7861
+    data->name = name;
 
7862
+    data->vertexShader = vertex_shader;
 
7863
+    data->fragmentShader = fragment_shader;
 
7864
+
 
7865
+    priv->shaders.push_back(data);
 
7866
+}
 
7867
+
 
7868
+void
 
7869
 PrivateGLWindow::updateFrameRegion (CompRegion &region)
 
7870
 {
 
7871
     window->updateFrameRegion (region);
 
7872
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/resize/src/resize.cpp linaro-gles2-debianpatches/plugins/resize/src/resize.cpp
 
7873
--- compiz-0.9.7.8/plugins/resize/src/resize.cpp        2012-04-26 08:47:01.000000000 +0200
 
7874
+++ linaro-gles2-debianpatches/plugins/resize/src/resize.cpp    2012-04-20 11:41:59.241600000 +0200
 
7875
@@ -1525,60 +1525,114 @@
 
7876
                                unsigned short            *borderColor,
 
7877
                                unsigned short            *fillColor)
 
7878
 {
 
7879
-    BoxRec        box;
 
7880
-    GLMatrix      sTransform (transform);
 
7881
-    GLint         origSrc, origDst;
 
7882
-    float_t       fc[4], bc[4];
 
7883
+    GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
 
7884
 
 
7885
+    BoxRec         box;
 
7886
+    GLMatrix       sTransform (transform);
 
7887
+    GLfloat         vertexData [12];
 
7888
+    GLfloat         vertexData2[24];
 
7889
+    GLint          origSrc, origDst;
 
7890
+    GLushort       fc[4], bc[4];
 
7891
+
 
7892
+#ifdef USE_GLES
 
7893
+    GLint           origSrcAlpha, origDstAlpha;
 
7894
+    glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);
 
7895
+    glGetIntegerv (GL_BLEND_DST_RGB, &origDst);
 
7896
+    glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);
 
7897
+    glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);
 
7898
+#else
 
7899
     glGetIntegerv (GL_BLEND_SRC, &origSrc);
 
7900
     glGetIntegerv (GL_BLEND_DST, &origDst);
 
7901
+#endif
 
7902
 
 
7903
     /* Premultiply the alpha values */
 
7904
-    
 
7905
-    bc[3] = (float) borderColor[3] / (float) 65535.0f;
 
7906
+    bc[3] =  (float) borderColor[3] / (float) 65535.0f;
 
7907
     bc[0] = ((float) borderColor[0] / 65535.0f) * bc[3];
 
7908
     bc[1] = ((float) borderColor[1] / 65535.0f) * bc[3];
 
7909
     bc[2] = ((float) borderColor[2] / 65535.0f) * bc[3];
 
7910
 
 
7911
     getPaintRectangle (&box);
 
7912
 
 
7913
-    glPushMatrix ();
 
7914
+    vertexData[0]  = box.x1;
 
7915
+    vertexData[1]  = box.y1;
 
7916
+    vertexData[2]  = 0.0f;
 
7917
+    vertexData[3]  = box.x1;
 
7918
+    vertexData[4]  = box.y2;
 
7919
+    vertexData[5]  = 0.0f;
 
7920
+    vertexData[6]  = box.x2;
 
7921
+    vertexData[7]  = box.y1;
 
7922
+    vertexData[8]  = 0.0f;
 
7923
+    vertexData[9]  = box.x2;
 
7924
+    vertexData[10] = box.y2;
 
7925
+    vertexData[11] = 0.0f;
 
7926
+
 
7927
+    // FIXME: this is a quick work-around.
 
7928
+    // GL_LINE_LOOP and GL_LINE_STRIP primitive types in the SGX Pvr X11 driver
 
7929
+    // take special number of vertices (and reorder them). Thus, usage of
 
7930
+    // those line primitive is currently not supported by our GLVertexBuffer
 
7931
+    // implementation. This is a quick workaround to make it all work until
 
7932
+    // we come up with a better GLVertexBuffer::render(...) function.
 
7933
+
 
7934
+    vertexData2[0]  = box.x1;
 
7935
+    vertexData2[1]  = box.y1;
 
7936
+    vertexData2[2]  = 0.0f;
 
7937
+    vertexData2[3]  = box.x1;
 
7938
+    vertexData2[4]  = box.y2;
 
7939
+    vertexData2[5]  = 0.0f;
 
7940
+    vertexData2[6]  = box.x1;
 
7941
+    vertexData2[7]  = box.y2;
 
7942
+    vertexData2[8]  = 0.0f;
 
7943
+    vertexData2[9]  = box.x2;
 
7944
+    vertexData2[10] = box.y2;
 
7945
+    vertexData2[11] = 0.0f;
 
7946
+    vertexData2[12] = box.x2;
 
7947
+    vertexData2[13] = box.y2;
 
7948
+    vertexData2[14] = 0.0f;
 
7949
+    vertexData2[15] = box.x2;
 
7950
+    vertexData2[16] = box.y1;
 
7951
+    vertexData2[17] = 0.0f;
 
7952
+    vertexData2[18] = box.x2;
 
7953
+    vertexData2[19] = box.y1;
 
7954
+    vertexData2[20] = 0.0f;
 
7955
+    vertexData2[21] = box.x1;
 
7956
+    vertexData2[22] = box.y1;
 
7957
+    vertexData2[23] = 0.0f;
 
7958
 
 
7959
     sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
 
7960
 
 
7961
-    glLoadMatrixf (sTransform.getMatrix ());
 
7962
-
 
7963
-    glDisableClientState (GL_TEXTURE_COORD_ARRAY);
 
7964
-    glEnable (GL_BLEND);
 
7965
     glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
7966
 
 
7967
     /* fill rectangle */
 
7968
     if (fillColor)
 
7969
     {
 
7970
-       fc[3] = (float) fillColor[3] / (float) 65535.0f;
 
7971
-       fc[0] = ((float) fillColor[0] / 65535.0f) * fc[3];
 
7972
-       fc[1] = ((float) fillColor[1] / 65535.0f) * fc[3];
 
7973
-       fc[2] = ((float) fillColor[2] / 65535.0f) * fc[3];
 
7974
-
 
7975
-       glColor4f (fc[0], fc[1], fc[2], fc[3]);
 
7976
-       glRecti (box.x1, box.y2, box.x2, box.y1);
 
7977
+       fc[3] = fillColor[3];
 
7978
+       fc[0] = fillColor[0] * fc[3];
 
7979
+       fc[1] = fillColor[1] * fc[3];
 
7980
+       fc[2] = fillColor[2] * fc[3];
 
7981
+
 
7982
+       streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
7983
+       streamingBuffer->addColors (1, fc);
 
7984
+       streamingBuffer->addVertices (4, &vertexData[0]);
 
7985
+       streamingBuffer->end ();
 
7986
+       streamingBuffer->render (sTransform);
 
7987
     }
 
7988
 
 
7989
     /* draw outline */
 
7990
-    glColor4f (bc[0], bc[1], bc[2], bc[3]);
 
7991
     glLineWidth (2.0);
 
7992
-    glBegin (GL_LINE_LOOP);
 
7993
-    glVertex2i (box.x1, box.y1);
 
7994
-    glVertex2i (box.x2, box.y1);
 
7995
-    glVertex2i (box.x2, box.y2);
 
7996
-    glVertex2i (box.x1, box.y2);
 
7997
-    glEnd ();
 
7998
-
 
7999
-    /* clean up */
 
8000
-    glColor4usv (defaultColor);
 
8001
-    glDisable (GL_BLEND);
 
8002
-    glEnableClientState (GL_TEXTURE_COORD_ARRAY);
 
8003
-    glPopMatrix ();
 
8004
+    streamingBuffer->begin (GL_LINES);
 
8005
+    streamingBuffer->addColors (1, borderColor);
 
8006
+    streamingBuffer->addVertices (8, &vertexData2[0]);
 
8007
+    streamingBuffer->end ();
 
8008
+    streamingBuffer->render (sTransform);
 
8009
+
 
8010
+    cScreen->damageScreen ();
 
8011
+
 
8012
+#ifdef USE_GLES
 
8013
+    glBlendFuncSeparate (origSrc, origDst,
 
8014
+                         origSrcAlpha, origDstAlpha);
 
8015
+#else
 
8016
+    glBlendFunc (origSrc, origDst);
 
8017
+#endif
 
8018
 }
 
8019
 
 
8020
 bool
 
8021
@@ -1589,6 +1643,7 @@
 
8022
                             unsigned int              mask)
 
8023
 {
 
8024
     bool status;
 
8025
+    GLboolean isBlendingEnabled;
 
8026
 
 
8027
     if (w)
 
8028
     {
 
8029
@@ -1605,6 +1660,9 @@
 
8030
        border = optionGetBorderColor ();
 
8031
        fill   = optionGetFillColor ();
 
8032
 
 
8033
+       glGetBooleanv (GL_BLEND, &isBlendingEnabled);
 
8034
+       glEnable (GL_BLEND);
 
8035
+
 
8036
        switch (mode) {
 
8037
            case ResizeOptions::ModeOutline:
 
8038
                glPaintRectangle (sAttrib, transform, output, border, NULL);
 
8039
@@ -1614,6 +1672,9 @@
 
8040
            default:
 
8041
                break;
 
8042
        }
 
8043
+
 
8044
+       if (!isBlendingEnabled)
 
8045
+           glDisable (GL_BLEND);
 
8046
     }
 
8047
 
 
8048
     return status;
 
8049
@@ -1641,9 +1702,9 @@
 
8050
        status = gWindow->glPaint (attrib, transform, region,
 
8051
                                   mask | PAINT_WINDOW_NO_CORE_INSTANCE_MASK);
 
8052
 
 
8053
-       GLFragment::Attrib fragment (gWindow->lastPaintAttrib ());
 
8054
+       GLWindowPaintAttrib lastAttrib (gWindow->lastPaintAttrib ());
 
8055
 
 
8056
-       if (window->alpha () || fragment.getOpacity () != OPAQUE)
 
8057
+       if (window->alpha () || lastAttrib.opacity != OPAQUE)
 
8058
            mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
 
8059
 
 
8060
        rScreen->getPaintRectangle (&box);
 
8061
@@ -1661,13 +1722,8 @@
 
8062
                              (rScreen->geometry.y - y) / yScale - yOrigin,
 
8063
                              0.0f);
 
8064
 
 
8065
-       glPushMatrix ();
 
8066
-       glLoadMatrixf (wTransform.getMatrix ());
 
8067
-
 
8068
-       gWindow->glDraw (wTransform, fragment, region,
 
8069
+       gWindow->glDraw (wTransform, lastAttrib, region,
 
8070
                         mask | PAINT_WINDOW_TRANSFORMED_MASK);
 
8071
-
 
8072
-       glPopMatrix ();
 
8073
     }
 
8074
     else
 
8075
     {
 
8076
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/rotate/CMakeLists.txt linaro-gles2-debianpatches/plugins/rotate/CMakeLists.txt
 
8077
--- compiz-0.9.7.8/plugins/rotate/CMakeLists.txt        2012-04-26 08:47:01.000000000 +0200
 
8078
+++ linaro-gles2-debianpatches/plugins/rotate/CMakeLists.txt    2012-04-20 11:41:59.241600000 +0200
 
8079
@@ -2,4 +2,4 @@
 
8080
 
 
8081
 include (CompizPlugin)
 
8082
 
 
8083
-compiz_plugin(rotate PLUGINDEPS composite opengl cube)
 
8084
\ Kein Zeilenumbruch am Dateiende.
 
8085
+#compiz_plugin(rotate PLUGINDEPS composite opengl cube)
 
8086
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/scale/src/scale.cpp linaro-gles2-debianpatches/plugins/scale/src/scale.cpp
 
8087
--- compiz-0.9.7.8/plugins/scale/src/scale.cpp  2012-04-26 08:47:01.000000000 +0200
 
8088
+++ linaro-gles2-debianpatches/plugins/scale/src/scale.cpp      2012-04-20 11:41:59.241600000 +0200
 
8089
@@ -226,26 +226,19 @@
 
8090
            GLTexture::MatrixList ml (1);
 
8091
 
 
8092
            ml[0] = icon->matrix ();
 
8093
-           priv->gWindow->geometry ().reset ();
 
8094
+           priv->gWindow->vertexBuffer ()->begin ();
 
8095
 
 
8096
            if (width && height)
 
8097
                priv->gWindow->glAddGeometry (ml, iconReg, iconReg);
 
8098
 
 
8099
-           if (priv->gWindow->geometry ().vCount)
 
8100
-           {
 
8101
-               GLFragment::Attrib fragment (sAttrib);
 
8102
-               GLMatrix           wTransform (transform);
 
8103
+           priv->gWindow->vertexBuffer ()->end ();
 
8104
 
 
8105
-               wTransform.scale (scale, scale, 1.0f);
 
8106
-               wTransform.translate (x / scale, y / scale, 0.0f);
 
8107
-
 
8108
-               glPushMatrix ();
 
8109
-               glLoadMatrixf (wTransform.getMatrix ());
 
8110
+           GLMatrix           wTransform (transform);
 
8111
 
 
8112
-               priv->gWindow->glDrawTexture (icon, fragment, mask);
 
8113
+           wTransform.scale (scale, scale, 1.0f);
 
8114
+           wTransform.translate (x / scale, y / scale, 0.0f);
 
8115
 
 
8116
-               glPopMatrix ();
 
8117
-           }
 
8118
+           priv->gWindow->glDrawTexture (icon, wTransform, sAttrib, mask);
 
8119
        }
 
8120
     }
 
8121
 }
 
8122
@@ -392,13 +385,13 @@
 
8123
 
 
8124
        if (scaled)
 
8125
        {
 
8126
-           GLFragment::Attrib fragment (gWindow->lastPaintAttrib ());
 
8127
+           GLWindowPaintAttrib lastAttrib (gWindow->lastPaintAttrib ());
 
8128
            GLMatrix           wTransform (transform);
 
8129
 
 
8130
            if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
 
8131
                return false;
 
8132
 
 
8133
-           if (window->alpha () || fragment.getOpacity () != OPAQUE)
 
8134
+           if (window->alpha () || lastAttrib.opacity != OPAQUE)
 
8135
                mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
 
8136
 
 
8137
            wTransform.translate (window->x (), window->y (), 0.0f);
 
8138
@@ -406,14 +399,9 @@
 
8139
            wTransform.translate (tx / scale - window->x (),
 
8140
                                  ty / scale - window->y (), 0.0f);
 
8141
 
 
8142
-           glPushMatrix ();
 
8143
-           glLoadMatrixf (wTransform.getMatrix ());
 
8144
-
 
8145
-           gWindow->glDraw (wTransform, fragment, region,
 
8146
+           gWindow->glDraw (wTransform, lastAttrib, region,
 
8147
                             mask | PAINT_WINDOW_TRANSFORMED_MASK);
 
8148
 
 
8149
-           glPopMatrix ();
 
8150
-
 
8151
            sWindow->scalePaintDecoration (sAttrib, transform, region, mask);
 
8152
        }
 
8153
     }
 
8154
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/screenshot/src/screenshot.cpp linaro-gles2-debianpatches/plugins/screenshot/src/screenshot.cpp
 
8155
--- compiz-0.9.7.8/plugins/screenshot/src/screenshot.cpp        2012-04-26 08:47:01.000000000 +0200
 
8156
+++ linaro-gles2-debianpatches/plugins/screenshot/src/screenshot.cpp    2012-04-20 11:41:59.241600000 +0200
 
8157
@@ -249,6 +249,10 @@
 
8158
                           CompOutput                *output,
 
8159
                           unsigned int               mask)
 
8160
 {
 
8161
+    GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
 
8162
+    GLMatrix        transform (matrix);
 
8163
+    GLfloat         vertexData[12];
 
8164
+    GLushort        colorData[4];
 
8165
     bool status;
 
8166
 
 
8167
     status = gScreen->glPaintOutput (attrib, matrix, region, output, mask);
 
8168
@@ -264,31 +268,54 @@
 
8169
 
 
8170
        if (mGrabIndex)
 
8171
        {
 
8172
-           glPushMatrix ();
 
8173
+           vertexData[0]  = x1;
 
8174
+           vertexData[1]  = y1;
 
8175
+           vertexData[2]  = 0.0f;
 
8176
+           vertexData[3]  = x1;
 
8177
+           vertexData[4]  = y2;
 
8178
+           vertexData[5]  = 0.0f;
 
8179
+           vertexData[6]  = x2;
 
8180
+           vertexData[7]  = y1;
 
8181
+           vertexData[8]  = 0.0f;
 
8182
+           vertexData[9]  = x2;
 
8183
+           vertexData[10] = y2;
 
8184
+           vertexData[11] = 0.0f;
 
8185
+
 
8186
+           colorData[0] = 0x2fff;
 
8187
+           colorData[1] = 0x2fff;
 
8188
+           colorData[2] = 0x4fff;
 
8189
+           colorData[3] = 0x4fff;
 
8190
+
 
8191
+
 
8192
+           transform.translate (-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
 
8193
+           transform.scale (1.0f / output->width (),
 
8194
+                            -1.0f / output->height (),
 
8195
+                            1.0f);
 
8196
+           transform.translate (-output->region ()->extents.x1,
 
8197
+                                -output->region ()->extents.y2,
 
8198
+                                0.0f);
 
8199
+
 
8200
+           streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
8201
+
 
8202
+           streamingBuffer->addColors (1, colorData);
 
8203
+           streamingBuffer->addVertices (4, vertexData);
 
8204
+
 
8205
+           streamingBuffer->end ();
 
8206
+           streamingBuffer->render (transform);
 
8207
+
 
8208
+           streamingBuffer->begin (GL_LINE_LOOP);
 
8209
+
 
8210
+           vertexData[6]  = x2;
 
8211
+           vertexData[7]  = y2;
 
8212
+           vertexData[9]  = x2;
 
8213
+           vertexData[10] = y1;
 
8214
+           colorData [3]  = 0x9fff;
 
8215
 
 
8216
-           glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
 
8217
-           glScalef (1.0f  / output->width (),
 
8218
-                     -1.0f / output->height (),
 
8219
-                     1.0f);
 
8220
-           glTranslatef (-output->region ()->extents.x1,
 
8221
-                         -output->region ()->extents.y2,
 
8222
-                         0.0f);
 
8223
-
 
8224
-           glDisableClientState (GL_TEXTURE_COORD_ARRAY);
 
8225
-           glEnable (GL_BLEND);
 
8226
-           glColor4us (0x2fff, 0x2fff, 0x4fff, 0x4fff);
 
8227
-           glRecti (x1, y2, x2, y1);
 
8228
-           glColor4us (0x2fff, 0x2fff, 0x4fff, 0x9fff);
 
8229
-           glBegin (GL_LINE_LOOP);
 
8230
-           glVertex2i (x1, y1);
 
8231
-           glVertex2i (x2, y1);
 
8232
-           glVertex2i (x2, y2);
 
8233
-           glVertex2i (x1, y2);
 
8234
-           glEnd ();
 
8235
-           glColor4usv (defaultColor);
 
8236
-           glDisable (GL_BLEND);
 
8237
-           glEnableClientState (GL_TEXTURE_COORD_ARRAY);
 
8238
-           glPopMatrix ();
 
8239
+           streamingBuffer->addColors (1, colorData);
 
8240
+           streamingBuffer->addVertices (4, vertexData);
 
8241
+
 
8242
+           streamingBuffer->end ();
 
8243
+           streamingBuffer->render (transform);
 
8244
        }
 
8245
     }
 
8246
 
 
8247
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/switcher/src/switcher.cpp linaro-gles2-debianpatches/plugins/switcher/src/switcher.cpp
 
8248
--- compiz-0.9.7.8/plugins/switcher/src/switcher.cpp    2012-04-26 08:47:01.000000000 +0200
 
8249
+++ linaro-gles2-debianpatches/plugins/switcher/src/switcher.cpp        2012-04-20 11:41:59.241600000 +0200
 
8250
@@ -31,25 +31,33 @@
 
8251
 
 
8252
 static float _boxVertices[] =
 
8253
 {
 
8254
-    -(WIDTH >> 1), 0,
 
8255
-    -(WIDTH >> 1), BOX_WIDTH,
 
8256
-     (WIDTH >> 1), BOX_WIDTH,
 
8257
-     (WIDTH >> 1), 0,
 
8258
-
 
8259
-    -(WIDTH >> 1),            BOX_WIDTH,
 
8260
-    -(WIDTH >> 1),            HEIGHT - BOX_WIDTH,
 
8261
-    -(WIDTH >> 1) + BOX_WIDTH, HEIGHT - BOX_WIDTH,
 
8262
-    -(WIDTH >> 1) + BOX_WIDTH, 0,
 
8263
-
 
8264
-     (WIDTH >> 1) - BOX_WIDTH, BOX_WIDTH,
 
8265
-     (WIDTH >> 1) - BOX_WIDTH, HEIGHT - BOX_WIDTH,
 
8266
-     (WIDTH >> 1),            HEIGHT - BOX_WIDTH,
 
8267
-     (WIDTH >> 1),            0,
 
8268
-
 
8269
-    -(WIDTH >> 1), HEIGHT - BOX_WIDTH,
 
8270
-    -(WIDTH >> 1), HEIGHT,
 
8271
-     (WIDTH >> 1), HEIGHT,
 
8272
-     (WIDTH >> 1), HEIGHT - BOX_WIDTH
 
8273
+    -(WIDTH >> 1), BOX_WIDTH, 0.0f,
 
8274
+     (WIDTH >> 1), BOX_WIDTH, 0.0f,
 
8275
+    -(WIDTH >> 1), 0.0f,      0.0f,
 
8276
+    -(WIDTH >> 1), 0.0f,      0.0f,
 
8277
+     (WIDTH >> 1), BOX_WIDTH, 0.0f,
 
8278
+     (WIDTH >> 1), 0.0f,      0.0f,
 
8279
+
 
8280
+    -(WIDTH >> 1),             HEIGHT - BOX_WIDTH, 0.0f,
 
8281
+    -(WIDTH >> 1) + BOX_WIDTH, HEIGHT - BOX_WIDTH, 0.0f,
 
8282
+    -(WIDTH >> 1),             BOX_WIDTH,          0.0f,
 
8283
+    -(WIDTH >> 1),             BOX_WIDTH,          0.0f,
 
8284
+    -(WIDTH >> 1) + BOX_WIDTH, HEIGHT - BOX_WIDTH, 0.0f,
 
8285
+    -(WIDTH >> 1) + BOX_WIDTH, BOX_WIDTH,          0.0f,
 
8286
+
 
8287
+     (WIDTH >> 1) - BOX_WIDTH, HEIGHT - BOX_WIDTH, 0.0f,
 
8288
+     (WIDTH >> 1),             HEIGHT - BOX_WIDTH, 0.0f,
 
8289
+     (WIDTH >> 1) - BOX_WIDTH, BOX_WIDTH,          0.0f,
 
8290
+     (WIDTH >> 1) - BOX_WIDTH, BOX_WIDTH,          0.0f,
 
8291
+     (WIDTH >> 1),             HEIGHT - BOX_WIDTH, 0.0f,
 
8292
+     (WIDTH >> 1),             BOX_WIDTH,          0.0f,
 
8293
+
 
8294
+    -(WIDTH >> 1), HEIGHT,             0.0f,
 
8295
+     (WIDTH >> 1), HEIGHT,             0.0f,
 
8296
+    -(WIDTH >> 1), HEIGHT - BOX_WIDTH, 0.0f,
 
8297
+    -(WIDTH >> 1), HEIGHT - BOX_WIDTH, 0.0f,
 
8298
+     (WIDTH >> 1), HEIGHT,             0.0f,
 
8299
+     (WIDTH >> 1), HEIGHT - BOX_WIDTH, 0.0f,
 
8300
 };
 
8301
 
 
8302
 
 
8303
@@ -799,9 +807,6 @@
 
8304
 
 
8305
            sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
 
8306
 
 
8307
-           glPushMatrix ();
 
8308
-           glLoadMatrixf (sTransform.getMatrix ());
 
8309
-
 
8310
            if (!switcher->destroyed () &&
 
8311
                switcher->isViewable () &&
 
8312
                sw->cWindow->damaged ())
 
8313
@@ -809,8 +814,6 @@
 
8314
                sw->gWindow->glPaint (sw->gWindow->paintAttrib (),
 
8315
                                      sTransform, infiniteRegion, 0);
 
8316
            }
 
8317
-
 
8318
-           glPopMatrix ();
 
8319
        }
 
8320
     }
 
8321
     else
 
8322
@@ -950,8 +953,10 @@
 
8323
                       const CompRegion          &region,
 
8324
                       unsigned int              mask)
 
8325
 {
 
8326
-    int               zoomType = NORMAL_WINDOW_MASK;
 
8327
-    bool       status;
 
8328
+    GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
 
8329
+    GLMatrix        wTransform (transform);
 
8330
+    int             zoomType = NORMAL_WINDOW_MASK;
 
8331
+    bool            status;
 
8332
 
 
8333
     if (window->id () == sScreen->popupWindow)
 
8334
     {
 
8335
@@ -975,17 +980,14 @@
 
8336
        x = x1 + sScreen->pos;
 
8337
        y = g.y () + SPACE;
 
8338
 
 
8339
-       glPushAttrib (GL_SCISSOR_BIT);
 
8340
-
 
8341
        glEnable (GL_SCISSOR_TEST);
 
8342
        glScissor (x1, 0, x2 - x1, screen->height ());
 
8343
 
 
8344
        foreach (CompWindow *w, sScreen->windows)
 
8345
        {
 
8346
            if (x + WIDTH > x1)
 
8347
-               SwitchWindow::get (w)->paintThumb (
 
8348
-                   gWindow->lastPaintAttrib (), transform,
 
8349
-                   mask, x, y);
 
8350
+               SwitchWindow::get (w)->paintThumb (gWindow->lastPaintAttrib (),
 
8351
+                                                  transform, mask, x, y);
 
8352
            x += WIDTH;
 
8353
        }
 
8354
 
 
8355
@@ -994,31 +996,30 @@
 
8356
            if (x > x2)
 
8357
                break;
 
8358
 
 
8359
-            SwitchWindow::get (w)->paintThumb (
 
8360
-               gWindow->lastPaintAttrib (), transform,
 
8361
-               mask, x, y);
 
8362
+            SwitchWindow::get (w)->paintThumb (gWindow->lastPaintAttrib (),
 
8363
+                                              transform, mask, x, y);
 
8364
            x += WIDTH;
 
8365
        }
 
8366
 
 
8367
-       glPopAttrib ();
 
8368
+       glDisable (GL_SCISSOR_TEST);
 
8369
 
 
8370
        cx = g.x () + (g.width () >> 1);
 
8371
+       wTransform.translate (cx, y, 0.0f);
 
8372
 
 
8373
-       glDisableClientState (GL_TEXTURE_COORD_ARRAY);
 
8374
-       glEnable (GL_BLEND);
 
8375
        for (i = 0; i < 4; i++)
 
8376
+       {
 
8377
            color[i] = (unsigned int)sScreen->fgColor[i] *
 
8378
-                      gWindow->lastPaintAttrib ().opacity /
 
8379
-                      0xffff;
 
8380
-       glColor4usv (color);
 
8381
-       glPushMatrix ();
 
8382
-       glTranslatef (cx, y, 0.0f);
 
8383
-       glVertexPointer (2, GL_FLOAT, 0, _boxVertices);
 
8384
-       glDrawArrays (GL_QUADS, 0, 16);
 
8385
-       glPopMatrix ();
 
8386
-       glColor4usv (defaultColor);
 
8387
-       glDisable (GL_BLEND);
 
8388
-       glEnableClientState (GL_TEXTURE_COORD_ARRAY);
 
8389
+                      gWindow->lastPaintAttrib ().opacity /
 
8390
+                      0xffff;
 
8391
+       }
 
8392
+
 
8393
+       streamingBuffer->begin (GL_TRIANGLES);
 
8394
+
 
8395
+       streamingBuffer->addColors (1, color);
 
8396
+       streamingBuffer->addVertices (24, _boxVertices);
 
8397
+
 
8398
+       streamingBuffer->end ();
 
8399
+       streamingBuffer->render (wTransform, attrib);
 
8400
     }
 
8401
     else if (window == sScreen->selectedWindow)
 
8402
     {
 
8403
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/water/CMakeLists.txt linaro-gles2-debianpatches/plugins/water/CMakeLists.txt
 
8404
--- compiz-0.9.7.8/plugins/water/CMakeLists.txt 2012-04-26 08:47:01.000000000 +0200
 
8405
+++ linaro-gles2-debianpatches/plugins/water/CMakeLists.txt     2012-04-20 11:41:59.241600000 +0200
 
8406
@@ -2,4 +2,4 @@
 
8407
 
 
8408
 include (CompizPlugin)
 
8409
 
 
8410
-compiz_plugin(water PLUGINDEPS composite opengl)
 
8411
\ Kein Zeilenumbruch am Dateiende.
 
8412
+compiz_plugin(water PLUGINDEPS composite opengl)
 
8413
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/water/src/shaders.h linaro-gles2-debianpatches/plugins/water/src/shaders.h
 
8414
--- compiz-0.9.7.8/plugins/water/src/shaders.h  1970-01-01 01:00:00.000000000 +0100
 
8415
+++ linaro-gles2-debianpatches/plugins/water/src/shaders.h      2012-04-20 11:41:59.241600000 +0200
 
8416
@@ -0,0 +1,201 @@
 
8417
+/*
 
8418
+ * Copyright © 2011 Collabora Ltd.
 
8419
+ *
 
8420
+ * Permission to use, copy, modify, distribute, and sell this software
 
8421
+ * and its documentation for any purpose is hereby granted without
 
8422
+ * fee, provided that the above copyright notice appear in all copies
 
8423
+ * and that both that copyright notice and this permission notice
 
8424
+ * appear in supporting documentation, and that the name of
 
8425
+ * Collabora Ltd. not be used in advertising or publicity pertaining to
 
8426
+ * distribution of the software without specific, written prior permission.
 
8427
+ * Collabora Ltd. makes no representations about the suitability of this
 
8428
+ * software for any purpose. It is provided "as is" without express or
 
8429
+ * implied warranty.
 
8430
+ *
 
8431
+ * COLLABORA LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
8432
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
8433
+ * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
8434
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
8435
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
8436
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
8437
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
8438
+ *
 
8439
+ * Authors: Frederic Plourde <frederic.plourde@collabora.co.uk>
 
8440
+ */
 
8441
+
 
8442
+#ifndef _COMPIZ_WATERSHADERS_H
 
8443
+#define _COMPIZ_WATERSHADERS_H
 
8444
+
 
8445
+
 
8446
+// This vertex shader is used to set water vertices ...
 
8447
+static std::string set_water_vertices_vertex_shader = "                     \n\
 
8448
+#ifdef GL_ES                                                                \n\
 
8449
+precision mediump float;                                                    \n\
 
8450
+#endif                                                                      \n\
 
8451
+                                                                            \n\
 
8452
+attribute vec3 position;                                                    \n\
 
8453
+                                                                            \n\
 
8454
+void main ()                                                                \n\
 
8455
+{                                                                           \n\
 
8456
+    gl_PointSize = 3.0;                                                     \n\
 
8457
+    gl_Position = vec4(position, 1.0);                                      \n\
 
8458
+                                                                            \n\
 
8459
+}";
 
8460
+
 
8461
+// This fragment shader is used to draw water primitives ...
 
8462
+// we're only setting the height here, so we only care about the .w coord.
 
8463
+static std::string set_water_vertices_fragment_shader = "                   \n\
 
8464
+#ifdef GL_ES                                                                \n\
 
8465
+precision mediump float;                                                    \n\
 
8466
+#endif                                                                      \n\
 
8467
+                                                                            \n\
 
8468
+uniform float color;                                                        \n\
 
8469
+                                                                            \n\
 
8470
+void main ()                                                                \n\
 
8471
+{                                                                           \n\
 
8472
+    gl_FragColor = vec4(0.0, 0.0, 0.0, color);                              \n\
 
8473
+}";
 
8474
+
 
8475
+
 
8476
+
 
8477
+
 
8478
+// This vertex shader is used to update water vertices...
 
8479
+static std::string update_water_vertices_vertex_shader = "                  \n\
 
8480
+#ifdef GL_ES                                                                \n\
 
8481
+precision mediump float;                                                    \n\
 
8482
+#endif                                                                      \n\
 
8483
+                                                                            \n\
 
8484
+attribute vec3 position;                                                    \n\
 
8485
+attribute vec2 texCoord0;                                                   \n\
 
8486
+                                                                            \n\
 
8487
+varying vec2 vTexCoord0;                                                    \n\
 
8488
+                                                                            \n\
 
8489
+void main ()                                                                \n\
 
8490
+{                                                                           \n\
 
8491
+    vTexCoord0 = texCoord0;                                                 \n\
 
8492
+    gl_Position = vec4(position, 1.0);                                      \n\
 
8493
+                                                                            \n\
 
8494
+}";
 
8495
+
 
8496
+// This fragment shader is used to compute new normal + height of water vertices.
 
8497
+// here we're using two input textures, previous and current.
 
8498
+static std::string update_water_vertices_fragment_shader = "                \n\
 
8499
+#ifdef GL_ES                                                                \n\
 
8500
+precision mediump float;                                                    \n\
 
8501
+#endif                                                                      \n\
 
8502
+                                                                            \n\
 
8503
+uniform sampler2D prevTex;                                                  \n\
 
8504
+uniform sampler2D currTex;                                                  \n\
 
8505
+                                                                            \n\
 
8506
+varying vec2 vTexCoord0;                                                    \n\
 
8507
+                                                                            \n\
 
8508
+uniform float timeLapse;                                                    \n\
 
8509
+uniform float fade;                                                         \n\
 
8510
+                                                                            \n\
 
8511
+void main ()                                                                \n\
 
8512
+{                                                                           \n\
 
8513
+    vec2 t01, t21, t10, t12;                                                \n\
 
8514
+    vec4 c01, c21, c10, c12;                                                \n\
 
8515
+    vec4 curr, prev, v;                                                     \n\
 
8516
+    float accel;                                                            \n\
 
8517
+                                                                            \n\
 
8518
+    // fetch current and previous normals                                   \n\
 
8519
+    prev = texture%s (prevTex, vTexCoord0);                                 \n\
 
8520
+    curr = texture%s (currTex, vTexCoord0);                                 \n\
 
8521
+                                                                            \n\
 
8522
+    // sample offsets                                                       \n\
 
8523
+    t01 = vTexCoord0 + vec2 (- %f, 0.0);                                    \n\
 
8524
+    t21 = vTexCoord0 + vec2 (  %f, 0.0);                                    \n\
 
8525
+    t10 = vTexCoord0 + vec2 ( 0.0,- %f);                                    \n\
 
8526
+    t12 = vTexCoord0 + vec2 ( 0.0,  %f);                                    \n\
 
8527
+                                                                            \n\
 
8528
+    // fetch necessary samples                                              \n\
 
8529
+    c01 = texture%s (currTex, t01);                                         \n\
 
8530
+    c21 = texture%s (currTex, t21);                                         \n\
 
8531
+    c10 = texture%s (currTex, t10);                                         \n\
 
8532
+    c12 = texture%s (currTex, t12);                                         \n\
 
8533
+                                                                            \n\
 
8534
+    // x/y normals from height                                              \n\
 
8535
+    v = vec4 (0.0, 0.0, 0.75, 0.0);                                         \n\
 
8536
+    v.x = c01.w - c21.w;                                                    \n\
 
8537
+    v.y = c12.w - c10.w;                                                    \n\
 
8538
+                                                                            \n\
 
8539
+    // bumpiness                                                            \n\
 
8540
+    v = normalize (v);                                                      \n\
 
8541
+                                                                            \n\
 
8542
+    // add scale and bias                                                   \n\
 
8543
+    v = (v * 0.5) + 0.5;                                                    \n\
 
8544
+                                                                            \n\
 
8545
+    // done with computing the normal, continue with computing              \n\
 
8546
+    // the next height value                                                \n\
 
8547
+    accel = (curr.w * -4.0) + (c10.w + c12.w + c01.w + c21.w);              \n\
 
8548
+                                                                            \n\
 
8549
+    // store new height in alpha component                                  \n\
 
8550
+    v.w = (accel * timeLapse) + ((curr.w * 2.0) - prev.w);                  \n\
 
8551
+                                                                            \n\
 
8552
+    // fade out height                                                      \n\
 
8553
+    v.w *= fade;                                                            \n\
 
8554
+                                                                            \n\
 
8555
+    gl_FragColor = v;                                                       \n\
 
8556
+}";
 
8557
+
 
8558
+
 
8559
+
 
8560
+
 
8561
+// This vertex shader is used when painting our bump map FX over
 
8562
+// final composited screen FBO
 
8563
+static std::string paint_water_vertices_vertex_shader = "                   \n\
 
8564
+#ifdef GL_ES                                                                \n\
 
8565
+precision mediump float;                                                    \n\
 
8566
+#endif                                                                      \n\
 
8567
+                                                                            \n\
 
8568
+attribute vec3 position;                                                    \n\
 
8569
+attribute vec2 texCoord0;                                                   \n\
 
8570
+                                                                            \n\
 
8571
+varying vec2 vTexCoord0;                                                    \n\
 
8572
+                                                                            \n\
 
8573
+void main ()                                                                \n\
 
8574
+{                                                                           \n\
 
8575
+    vTexCoord0 = texCoord0;                                                 \n\
 
8576
+    gl_Position = vec4(position, 1.0);                                      \n\
 
8577
+                                                                            \n\
 
8578
+}";
 
8579
+
 
8580
+// This fragment shader is used to produce our dot3 bump mapping output,
 
8581
+// blended over final composited glScreen FBO.
 
8582
+// here we're using two input textures :
 
8583
+//   1) The final composited FBO color attachment over which we're
 
8584
+//      applying our bump map FX (baseTex)
 
8585
+//   2) The updated bump map (waveTex)
 
8586
+static std::string paint_water_vertices_fragment_shader = "                 \n\
 
8587
+#ifdef GL_ES                                                                \n\
 
8588
+precision mediump float;                                                    \n\
 
8589
+#endif                                                                      \n\
 
8590
+                                                                            \n\
 
8591
+uniform sampler2D baseTex;                                                  \n\
 
8592
+uniform sampler2D waveTex;                                                  \n\
 
8593
+                                                                            \n\
 
8594
+varying vec2 vTexCoord0;                                                    \n\
 
8595
+                                                                            \n\
 
8596
+uniform vec3  lightVec;                                                     \n\
 
8597
+uniform float offsetScale;                                                  \n\
 
8598
+                                                                            \n\
 
8599
+void main ()                                                                \n\
 
8600
+{                                                                           \n\
 
8601
+    vec4 normal = texture2D (waveTex, vTexCoord0);                          \n\
 
8602
+    float height = normal.w;                                                \n\
 
8603
+    float diffuse = 0.75;                                                   \n\
 
8604
+    vec4 offset;                                                            \n\
 
8605
+                                                                            \n\
 
8606
+    normal = normalize ((normal * 2.0) - 1.0);                              \n\
 
8607
+                                                                            \n\
 
8608
+    offset.x = normal.x * height * offsetScale/%d.0;                        \n\
 
8609
+    offset.y = normal.y * height * offsetScale/%d.0;                        \n\
 
8610
+    vec4 baseColor  = texture2D (baseTex, vTexCoord0 + offset.xy);          \n\
 
8611
+                                                                            \n\
 
8612
+    float diffFact = dot (normal.xyz, vec3(lightVec.xy, 0.0)) * diffuse;    \n\
 
8613
+    gl_FragColor = vec4 (vec3 (baseColor) + diffFact, 1.0);                 \n\
 
8614
+}";
 
8615
+
 
8616
+#endif // _COMPIZ_WATERSHADERS_H
 
8617
+
 
8618
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/water/src/water.cpp linaro-gles2-debianpatches/plugins/water/src/water.cpp
 
8619
--- compiz-0.9.7.8/plugins/water/src/water.cpp  2012-04-26 08:47:01.000000000 +0200
 
8620
+++ linaro-gles2-debianpatches/plugins/water/src/water.cpp      2012-04-20 11:41:59.241600000 +0200
 
8621
@@ -21,6 +21,7 @@
 
8622
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
8623
  *
 
8624
  * Author: David Reveman <davidr@novell.com>
 
8625
+ *         Frederic Plourde <frederic.plourde@collabora.co.uk>
 
8626
  */
 
8627
 
 
8628
 #include "water.h"
 
8629
@@ -33,270 +34,33 @@
 
8630
 static int waterLastPointerX = 0;
 
8631
 static int waterLastPointerY = 0;
 
8632
 
 
8633
-static const char *waterFpString =
 
8634
-    "!!ARBfp1.0"
 
8635
-
 
8636
-    "PARAM param = program.local[0];"
 
8637
-    "ATTRIB t11  = fragment.texcoord[0];"
 
8638
-
 
8639
-    "TEMP t01, t21, t10, t12;"
 
8640
-    "TEMP c11, c01, c21, c10, c12;"
 
8641
-    "TEMP prev, v, temp, accel;"
 
8642
-
 
8643
-    "TEX prev, t11, texture[0], %s;"
 
8644
-    "TEX c11,  t11, texture[1], %s;"
 
8645
-
 
8646
-    /* sample offsets */
 
8647
-    "ADD t01, t11, { - %f, 0.0, 0.0, 0.0 };"
 
8648
-    "ADD t21, t11, {   %f, 0.0, 0.0, 0.0 };"
 
8649
-    "ADD t10, t11, { 0.0, - %f, 0.0, 0.0 };"
 
8650
-    "ADD t12, t11, { 0.0,   %f, 0.0, 0.0 };"
 
8651
-
 
8652
-    /* fetch nesseccary samples */
 
8653
-    "TEX c01, t01, texture[1], %s;"
 
8654
-    "TEX c21, t21, texture[1], %s;"
 
8655
-    "TEX c10, t10, texture[1], %s;"
 
8656
-    "TEX c12, t12, texture[1], %s;"
 
8657
-
 
8658
-    /* x/y normals from height */
 
8659
-    "MOV v, { 0.0, 0.0, 0.75, 0.0 };"
 
8660
-    "SUB v.x, c12.w, c10.w;"
 
8661
-    "SUB v.y, c01.w, c21.w;"
 
8662
-
 
8663
-    /* bumpiness */
 
8664
-    "MUL v, v, 1.5;"
 
8665
-
 
8666
-    /* normalize */
 
8667
-    "MAD temp, v.x, v.x, 1.0;"
 
8668
-    "MAD temp, v.y, v.y, temp;"
 
8669
-    "RSQ temp, temp.x;"
 
8670
-    "MUL v, v, temp;"
 
8671
-
 
8672
-    /* add scale and bias to normal */
 
8673
-    "MAD v, v, 0.5, 0.5;"
 
8674
-
 
8675
-    /* done with computing the normal, continue with computing the next
 
8676
-       height value */
 
8677
-    "ADD accel, c10, c12;"
 
8678
-    "ADD accel, c01, accel;"
 
8679
-    "ADD accel, c21, accel;"
 
8680
-    "MAD accel, -4.0, c11, accel;"
 
8681
-
 
8682
-    /* store new height in alpha component */
 
8683
-    "MAD v.w, 2.0, c11, -prev.w;"
 
8684
-    "MAD v.w, accel, param.x, v.w;"
 
8685
-
 
8686
-    /* fade out height */
 
8687
-    "MUL v.w, v.w, param.y;"
 
8688
-
 
8689
-    "MOV result.color, v;"
 
8690
-
 
8691
-    "END";
 
8692
-
 
8693
-static bool
 
8694
-loadFragmentProgram (GLuint    *program,
 
8695
-                    const char *string)
 
8696
-{
 
8697
-    GLint errorPos;
 
8698
-
 
8699
-    /* clear errors */
 
8700
-    glGetError ();
 
8701
-
 
8702
-    if (!*program)
 
8703
-       GL::genPrograms (1, program);
 
8704
-
 
8705
-    GL::bindProgram (GL_FRAGMENT_PROGRAM_ARB, *program);
 
8706
-    GL::programString (GL_FRAGMENT_PROGRAM_ARB,
 
8707
-                      GL_PROGRAM_FORMAT_ASCII_ARB,
 
8708
-                      strlen (string), string);
 
8709
-
 
8710
-    glGetIntegerv (GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
 
8711
-    if (glGetError () != GL_NO_ERROR || errorPos != -1)
 
8712
-    {
 
8713
-       compLogMessage ("water", CompLogLevelError,
 
8714
-                       "failed to load bump map program");
 
8715
-
 
8716
-       GL::deletePrograms (1, program);
 
8717
-       *program = 0;
 
8718
-
 
8719
-       return false;
 
8720
-    }
 
8721
-
 
8722
-    return true;
 
8723
-}
 
8724
-
 
8725
-static int
 
8726
-loadWaterProgram ()
 
8727
-{
 
8728
-    char buffer[1024];
 
8729
-
 
8730
-    WATER_SCREEN (screen);
 
8731
-
 
8732
-    if (ws->target == GL_TEXTURE_2D)
 
8733
-       sprintf (buffer, waterFpString,
 
8734
-                "2D", "2D",
 
8735
-                1.0f / ws->width,  1.0f / ws->width,
 
8736
-                1.0f / ws->height, 1.0f / ws->height,
 
8737
-                "2D", "2D", "2D", "2D");
 
8738
-    else
 
8739
-       sprintf (buffer, waterFpString,
 
8740
-                "RECT", "RECT",
 
8741
-                1.0f, 1.0f, 1.0f, 1.0f,
 
8742
-                "RECT", "RECT", "RECT", "RECT");
 
8743
-
 
8744
-    return loadFragmentProgram (&ws->program, buffer);
 
8745
-}
 
8746
-
 
8747
-GLFragment::FunctionId
 
8748
-WaterScreen::getBumpMapFragmentFunction (GLTexture *texture,
 
8749
-                                        int       unit,
 
8750
-                                        int       param)
 
8751
-{
 
8752
-    GLFragment::FunctionData data;
 
8753
-    int                      target;
 
8754
-    WaterFunction            function;
 
8755
-
 
8756
-    if (texture->target () == GL_TEXTURE_2D)
 
8757
-       target = COMP_FETCH_TARGET_2D;
 
8758
-    else
 
8759
-       target = COMP_FETCH_TARGET_RECT;
 
8760
-
 
8761
-    foreach (WaterFunction &f, bumpMapFunctions)
 
8762
-    {
 
8763
-       if (f.param  == param &&
 
8764
-           f.unit   == unit  &&
 
8765
-           f.target == target)
 
8766
-           return f.id;
 
8767
-    }
 
8768
-
 
8769
-    static const char *temp[] = { "normal", "temp", "total", "bump", "offset" };
 
8770
-
 
8771
-    for (unsigned int i = 0; i < sizeof (temp) / sizeof (temp[0]); i++)
 
8772
-       data.addTempHeaderOp (temp[i]);
 
8773
-
 
8774
-    data.addDataOp (
 
8775
-       /* get normal from normal map */
 
8776
-       "TEX normal, fragment.texcoord[%d], texture[%d], %s;"
 
8777
-
 
8778
-       /* save height */
 
8779
-       "MOV offset, normal;"
 
8780
-
 
8781
-       /* remove scale and bias from normal */
 
8782
-       "MAD normal, normal, 2.0, -1.0;"
 
8783
-
 
8784
-       /* normalize the normal map */
 
8785
-       "DP3 temp, normal, normal;"
 
8786
-       "RSQ temp, temp.x;"
 
8787
-       "MUL normal, normal, temp;"
 
8788
-
 
8789
-       /* scale down normal by height and constant and use as
 
8790
-           offset in texture */
 
8791
-       "MUL offset, normal, offset.w;"
 
8792
-       "MUL offset, offset, program.env[%d];",
 
8793
-
 
8794
-       unit, unit,
 
8795
-       (this->target == GL_TEXTURE_2D) ? "2D" : "RECT",
 
8796
-       param);
 
8797
-
 
8798
-    data.addFetchOp ("output", "offset.yxzz", target);
 
8799
-
 
8800
-    data.addDataOp (
 
8801
-       /* normal dot lightdir, this should eventually be
 
8802
-           changed to a real light vector */
 
8803
-       "DP3 bump, normal, { 0.707, 0.707, 0.0, 0.0 };"
 
8804
-       "MUL bump, bump, state.light[0].diffuse;");
 
8805
-
 
8806
-
 
8807
-    data.addColorOp ("output", "output");
 
8808
-
 
8809
-    data.addDataOp (
 
8810
-       /* diffuse per-vertex lighting, opacity and brightness
 
8811
-           and add lightsource bump color */
 
8812
-       "ADD output, output, bump;");
 
8813
-
 
8814
-    if (!data.status ())
 
8815
-       return 0;
 
8816
-
 
8817
-
 
8818
-    function.id = data.createFragmentFunction ("water");
 
8819
-
 
8820
-    function.target = target;
 
8821
-    function.param  = param;
 
8822
-    function.unit   = unit;
 
8823
-
 
8824
-    bumpMapFunctions.push_back (function);
 
8825
-
 
8826
-    return function.id;
 
8827
-}
 
8828
-
 
8829
-void
 
8830
-WaterScreen::allocTexture (int index)
 
8831
-{
 
8832
-    glGenTextures (1, &texture[index]);
 
8833
-    glBindTexture (target, texture[index]);
 
8834
-
 
8835
-    glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
8836
-    glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
8837
-    glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 
8838
-    glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
8839
-
 
8840
-    glTexImage2D (target, 0, GL_RGBA, width, height, 0, GL_BGRA,
 
8841
-#if IMAGE_BYTE_ORDER == MSBFirst
 
8842
-                 GL_UNSIGNED_INT_8_8_8_8_REV,
 
8843
-#else
 
8844
-                 GL_UNSIGNED_BYTE,
 
8845
-#endif
 
8846
-                 t0);
 
8847
-
 
8848
-    glBindTexture (target, 0);
 
8849
-}
 
8850
+GLfloat WaterScreen::vertexData [18] = {
 
8851
+    -1.0f, -1.0f, 0.0f,
 
8852
+     1.0f, -1.0f, 0.0f,
 
8853
+    -1.0f,  1.0f, 0.0f,
 
8854
+    -1.0f,  1.0f, 0.0f,
 
8855
+     1.0f, -1.0f, 0.0f,
 
8856
+     1.0f,  1.0f, 0.0f,
 
8857
+};
 
8858
+
 
8859
+GLfloat WaterScreen::textureData [12] = {
 
8860
+    0.0f, 0.0f,
 
8861
+    1.0f, 0.0f,
 
8862
+    0.0f, 1.0f,
 
8863
+    0.0f, 1.0f,
 
8864
+    1.0f, 0.0f,
 
8865
+    1.0f, 1.0f,
 
8866
+};
 
8867
 
 
8868
 bool
 
8869
-WaterScreen::fboPrologue (int tIndex)
 
8870
+WaterScreen::fboPrologue (int fIndex)
 
8871
 {
 
8872
-    if (!fbo)
 
8873
+    if (!useFbo)
 
8874
        return false;
 
8875
 
 
8876
-    if (!texture[tIndex])
 
8877
-       allocTexture (tIndex);
 
8878
-
 
8879
-    GL::bindFramebuffer (GL_FRAMEBUFFER_EXT, fbo);
 
8880
-
 
8881
-    GL::framebufferTexture2D (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
 
8882
-                             target, texture[tIndex], 0);
 
8883
-
 
8884
-    glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
 
8885
-    glReadBuffer (GL_COLOR_ATTACHMENT0_EXT);
 
8886
-
 
8887
-    /* check status the first time */
 
8888
-    if (!fboStatus)
 
8889
-    {
 
8890
-       fboStatus = GL::checkFramebufferStatus (GL_FRAMEBUFFER_EXT);
 
8891
-       if (fboStatus != GL_FRAMEBUFFER_COMPLETE_EXT)
 
8892
-       {
 
8893
-           compLogMessage ("water", CompLogLevelError,
 
8894
-                           "framebuffer incomplete");
 
8895
-
 
8896
-           GL::bindFramebuffer (GL_FRAMEBUFFER_EXT, 0);
 
8897
-           GL::deleteFramebuffers (1, &fbo);
 
8898
-
 
8899
-           glDrawBuffer (GL_BACK);
 
8900
-           glReadBuffer (GL_BACK);
 
8901
-
 
8902
-           fbo = 0;
 
8903
-
 
8904
-           return false;
 
8905
-       }
 
8906
-    }
 
8907
-
 
8908
-    glViewport (0, 0, width, height);
 
8909
-    glMatrixMode (GL_PROJECTION);
 
8910
-    glPushMatrix ();
 
8911
-    glLoadIdentity ();
 
8912
-    glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
 
8913
-    glMatrixMode (GL_MODELVIEW);
 
8914
-    glPushMatrix ();
 
8915
-    glLoadIdentity ();
 
8916
+    oldFbo = waterFbo[fIndex]->bind ();
 
8917
+    glGetIntegerv(GL_VIEWPORT,  &oldViewport[0]);
 
8918
+    glViewport (0, 0, texWidth, texHeight);
 
8919
 
 
8920
     return true;
 
8921
 }
 
8922
@@ -304,424 +68,115 @@
 
8923
 void
 
8924
 WaterScreen::fboEpilogue ()
 
8925
 {
 
8926
-    GL::bindFramebuffer (GL_FRAMEBUFFER_EXT, 0);
 
8927
-
 
8928
-    glMatrixMode (GL_PROJECTION);
 
8929
-    glLoadIdentity ();
 
8930
-    glMatrixMode (GL_MODELVIEW);
 
8931
-    glLoadIdentity ();
 
8932
-    glDepthRange (0, 1);
 
8933
-    glViewport (-1, -1, 2, 2);
 
8934
-
 
8935
-    gScreen->resetRasterPos ();
 
8936
-
 
8937
-    gScreen->setDefaultViewport ();
 
8938
-
 
8939
-    glMatrixMode (GL_PROJECTION);
 
8940
-    glPopMatrix ();
 
8941
-    glMatrixMode (GL_MODELVIEW);
 
8942
-    glPopMatrix ();
 
8943
-
 
8944
-    glDrawBuffer (GL_BACK);
 
8945
-    glReadBuffer (GL_BACK);
 
8946
-}
 
8947
-
 
8948
-bool
 
8949
-WaterScreen::fboUpdate (float dt, float fade)
 
8950
-{
 
8951
-    if (!fboPrologue (TINDEX (this, 1)))
 
8952
-       return false;
 
8953
-
 
8954
-    if (!texture[TINDEX (this, 2)])
 
8955
-       allocTexture (TINDEX (this, 2));
 
8956
-
 
8957
-    if (!texture[TINDEX (this, 0)])
 
8958
-       allocTexture (TINDEX (this, 0));
 
8959
-
 
8960
-    glEnable (target);
 
8961
-
 
8962
-    GL::activeTexture (GL_TEXTURE0_ARB);
 
8963
-    glBindTexture (target, texture[TINDEX (this, 2)]);
 
8964
-
 
8965
-    glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 
8966
-    glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
8967
-    GL::activeTexture (GL_TEXTURE1_ARB);
 
8968
-    glBindTexture (target, texture[TINDEX (this, 0)]);
 
8969
-    glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 
8970
-    glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
8971
-
 
8972
-    glEnable (GL_FRAGMENT_PROGRAM_ARB);
 
8973
-    GL::bindProgram (GL_FRAGMENT_PROGRAM_ARB, program);
 
8974
-
 
8975
-    GL::programLocalParameter4f (GL_FRAGMENT_PROGRAM_ARB, 0,
 
8976
-                                dt * K, fade, 1.0f, 1.0f);
 
8977
-
 
8978
-    glBegin (GL_QUADS);
 
8979
-
 
8980
-    glTexCoord2f (0.0f, 0.0f);
 
8981
-    glVertex2f   (0.0f, 0.0f);
 
8982
-    glTexCoord2f (tx, 0.0f);
 
8983
-    glVertex2f   (1.0f, 0.0f);
 
8984
-    glTexCoord2f (tx, ty);
 
8985
-    glVertex2f   (1.0f, 1.0f);
 
8986
-    glTexCoord2f (0.0f, ty);
 
8987
-    glVertex2f   (0.0f, 1.0f);
 
8988
-
 
8989
-    glEnd ();
 
8990
-
 
8991
-    glDisable (GL_FRAGMENT_PROGRAM_ARB);
 
8992
-
 
8993
-    glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
8994
-    glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
8995
-    glBindTexture (target, 0);
 
8996
-    GL::activeTexture (GL_TEXTURE0_ARB);
 
8997
-    glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
8998
-    glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
8999
-    glBindTexture (target, 0);
 
9000
-
 
9001
-    glDisable (target);
 
9002
-
 
9003
-    fboEpilogue ();
 
9004
-
 
9005
-    /* increment texture index */
 
9006
-    tIndex = TINDEX (this, 1);
 
9007
-
 
9008
-    return true;
 
9009
-}
 
9010
-
 
9011
-bool
 
9012
-WaterScreen::fboVertices (GLenum type,
 
9013
-                         XPoint *p,
 
9014
-                         int    n,
 
9015
-                         float  v)
 
9016
-{
 
9017
-    if (!fboPrologue (TINDEX (this, 0)))
 
9018
-       return false;
 
9019
-
 
9020
-    glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
 
9021
-    glColor4f (0.0f, 0.0f, 0.0f, v);
 
9022
-
 
9023
-    glPointSize (3.0f);
 
9024
-    glLineWidth (1.0f);
 
9025
-
 
9026
-    glScalef (1.0f / width, 1.0f / height, 1.0);
 
9027
-    glTranslatef (0.5f, 0.5f, 0.0f);
 
9028
-
 
9029
-    glBegin (type);
 
9030
-
 
9031
-    while (n--)
 
9032
-    {
 
9033
-       glVertex2i (p->x, p->y);
 
9034
-       p++;
 
9035
-    }
 
9036
-
 
9037
-    glEnd ();
 
9038
-
 
9039
-    glColor4usv (defaultColor);
 
9040
-    glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 
9041
-
 
9042
-    fboEpilogue ();
 
9043
-
 
9044
-    return true;
 
9045
+    GLFramebufferObject::rebind (oldFbo);
 
9046
+    glViewport (oldViewport[0], oldViewport[1], oldViewport[2], oldViewport[3]);
 
9047
 }
 
9048
 
 
9049
 void
 
9050
-WaterScreen::softwareUpdate (float dt, float fade)
 
9051
+WaterScreen::waterUpdate (float dt)
 
9052
 {
 
9053
-    float         *dTmp;
 
9054
-    int           i, j;
 
9055
-    float         v0, v1, inv;
 
9056
-    float         accel, value;
 
9057
-    unsigned char *t0, *t;
 
9058
-    int           dWidth, dHeight;
 
9059
-    float         *d01, *d10, *d11, *d12;
 
9060
-
 
9061
-    if (!texture[TINDEX (this, 0)])
 
9062
-       allocTexture (TINDEX (this, 0));
 
9063
-
 
9064
-    dt *= K * 2.0f;
 
9065
-    fade *= 0.99f;
 
9066
-
 
9067
-    dWidth  = width  + 2;
 
9068
-    dHeight = height + 2;
 
9069
-
 
9070
-#define D(d, j) (*((d) + (j)))
 
9071
-
 
9072
-    d01 = d0 + dWidth;
 
9073
-    d10 = d1;
 
9074
-    d11 = d10 + dWidth;
 
9075
-    d12 = d11 + dWidth;
 
9076
-
 
9077
-    for (i = 1; i < dHeight - 1; i++)
 
9078
-    {
 
9079
-       for (j = 1; j < dWidth - 1; j++)
 
9080
-       {
 
9081
-           accel = dt * (D (d10, j)     +
 
9082
-                         D (d12, j)     +
 
9083
-                         D (d11, j - 1) +
 
9084
-                         D (d11, j + 1) - 4.0f * D (d11, j));
 
9085
-
 
9086
-           value = (2.0f * D (d11, j) - D (d01, j) + accel) * fade;
 
9087
-
 
9088
-           value = CLAMP (value, 0.0f, 1.0f);
 
9089
-
 
9090
-           D (d01, j) = value;
 
9091
-       }
 
9092
-
 
9093
-       d01 += dWidth;
 
9094
-       d10 += dWidth;
 
9095
-       d11 += dWidth;
 
9096
-       d12 += dWidth;
 
9097
-    }
 
9098
-
 
9099
-    /* update border */
 
9100
-    memcpy (d0, d0 + dWidth, dWidth * sizeof (GLfloat));
 
9101
-    memcpy (d0 + dWidth * (dHeight - 1),
 
9102
-           d0 + dWidth * (dHeight - 2),
 
9103
-           dWidth * sizeof (GLfloat));
 
9104
-
 
9105
-    d01 = d0 + dWidth;
 
9106
-
 
9107
-    for (i = 1; i < dHeight - 1; i++)
 
9108
-    {
 
9109
-       D (d01, 0)          = D (d01, 1);
 
9110
-       D (d01, dWidth - 1) = D (d01, dWidth - 2);
 
9111
-
 
9112
-       d01 += dWidth;
 
9113
-    }
 
9114
-
 
9115
-    d10 = d1;
 
9116
-    d11 = d10 + dWidth;
 
9117
-    d12 = d11 + dWidth;
 
9118
-
 
9119
-    t0 = this->t0;
 
9120
+    GLfloat fade = 1.0f;
 
9121
 
 
9122
-    /* update texture */
 
9123
-    for (i = 0; i < height; i++)
 
9124
+    if (count < 1000)
 
9125
     {
 
9126
-       for (j = 0; j < width; j++)
 
9127
-       {
 
9128
-           v0 = (D (d12, j)     - D (d10, j))     * 1.5f;
 
9129
-           v1 = (D (d11, j - 1) - D (d11, j + 1)) * 1.5f;
 
9130
-
 
9131
-           /* 0.5 for scale */
 
9132
-           inv = 0.5f / sqrtf (v0 * v0 + v1 * v1 + 1.0f);
 
9133
-
 
9134
-           /* add scale and bias to normal */
 
9135
-           v0 = v0 * inv + 0.5f;
 
9136
-           v1 = v1 * inv + 0.5f;
 
9137
-
 
9138
-           /* store normal map in RGB components */
 
9139
-           t = t0 + (j * 4);
 
9140
-           t[0] = (unsigned char) ((inv + 0.5f) * 255.0f);
 
9141
-           t[1] = (unsigned char) (v1 * 255.0f);
 
9142
-           t[2] = (unsigned char) (v0 * 255.0f);
 
9143
-
 
9144
-           /* store height in A component */
 
9145
-           t[3] = (unsigned char) (D (d11, j) * 255.0f);
 
9146
-       }
 
9147
-
 
9148
-       d10 += dWidth;
 
9149
-       d11 += dWidth;
 
9150
-       d12 += dWidth;
 
9151
-
 
9152
-       t0 += width * 4;
 
9153
+       if (count > 1)
 
9154
+           fade = 0.90f + (float) count / 10000.0f;
 
9155
+       else
 
9156
+           fade = 0.0f;
 
9157
     }
 
9158
 
 
9159
-#undef D
 
9160
-
 
9161
-    /* swap height maps */
 
9162
-    dTmp   = d0;
 
9163
-    d0 = d1;
 
9164
-    d1 = dTmp;
 
9165
+    if (!fboPrologue (INDEX (this, 1)))
 
9166
+       return;
 
9167
 
 
9168
-    if (texture[TINDEX (this, 0)])
 
9169
-    {
 
9170
-       glBindTexture (target, texture[TINDEX (this, 0)]);
 
9171
-       glTexImage2D (target, 0, GL_RGBA, width, height, 0, GL_BGRA,
 
9172
-#if IMAGE_BYTE_ORDER == MSBFirst
 
9173
-                     GL_UNSIGNED_INT_8_8_8_8_REV,
 
9174
-#else
 
9175
-                     GL_UNSIGNED_BYTE,
 
9176
-#endif
 
9177
-                     this->t0);
 
9178
-    }
 
9179
-}
 
9180
+    glEnable (GL_TEXTURE_2D);
 
9181
 
 
9182
+    vertexBuffer[UPDATE]->begin ();
 
9183
+    vertexBuffer[UPDATE]->addVertices  (6, &vertexData[0]);
 
9184
+    vertexBuffer[UPDATE]->addTexCoords (0, 6, &textureData[0]);
 
9185
+    vertexBuffer[UPDATE]->end ();
 
9186
+
 
9187
+    // TODO: use GLTexture facilities here, instead of manually setting active
 
9188
+    //       texture, especially when there will be texture unit support
 
9189
+    glActiveTexture (GL_TEXTURE0);
 
9190
+    waterFbo[INDEX (this, 2)]->tex ()->setFilter (GL_NEAREST);
 
9191
+    glBindTexture (GL_TEXTURE_2D, waterFbo[INDEX (this, 2)]->tex ()->name ());
 
9192
+
 
9193
+    glActiveTexture (GL_TEXTURE1);
 
9194
+    waterFbo[INDEX (this, 0)]->tex ()->setFilter (GL_NEAREST);
 
9195
+    glBindTexture (GL_TEXTURE_2D, waterFbo[INDEX (this, 0)]->tex ()->name ());
 
9196
+
 
9197
+    vertexBuffer[UPDATE]->addUniform ("prevTex", 0);
 
9198
+    vertexBuffer[UPDATE]->addUniform ("currTex", 1);
 
9199
+    vertexBuffer[UPDATE]->addUniform ("timeLapse", dt * K);
 
9200
+    vertexBuffer[UPDATE]->addUniform ("fade", fade);
 
9201
+
 
9202
+    GLboolean isBlendingEnabled;
 
9203
+    glGetBooleanv (GL_BLEND, &isBlendingEnabled);
 
9204
+    glDisable (GL_BLEND);
 
9205
+    vertexBuffer[UPDATE]->render ();
 
9206
+    if (isBlendingEnabled)
 
9207
+       glEnable (GL_BLEND);
 
9208
 
 
9209
-#define SET(x, y, v) *((d1) + (width + 2) * (y + 1) + (x + 1)) = (v)
 
9210
+    glActiveTexture (GL_TEXTURE0);
 
9211
+    glBindTexture (GL_TEXTURE_2D, 0);
 
9212
 
 
9213
-void
 
9214
-WaterScreen::softwarePoints (XPoint *p,
 
9215
-                            int     n,
 
9216
-                            float   add)
 
9217
-{
 
9218
-    while (n--)
 
9219
-    {
 
9220
-       SET (p->x - 1, p->y - 1, add);
 
9221
-       SET (p->x, p->y - 1, add);
 
9222
-       SET (p->x + 1, p->y - 1, add);
 
9223
+    glActiveTexture (GL_TEXTURE1);
 
9224
+    glBindTexture (GL_TEXTURE_2D, 0);
 
9225
 
 
9226
-       SET (p->x - 1, p->y, add);
 
9227
-       SET (p->x, p->y, add);
 
9228
-       SET (p->x + 1, p->y, add);
 
9229
+    glDisable (GL_TEXTURE_2D);
 
9230
 
 
9231
-       SET (p->x - 1, p->y + 1, add);
 
9232
-       SET (p->x, p->y + 1, add);
 
9233
-       SET (p->x + 1, p->y + 1, add);
 
9234
+    fboEpilogue ();
 
9235
 
 
9236
-       p++;
 
9237
-    }
 
9238
+    /* increment texture index */
 
9239
+    fboIndex = INDEX (this, 1);
 
9240
 }
 
9241
 
 
9242
-/* bresenham */
 
9243
 void
 
9244
-WaterScreen::softwareLines (XPoint *p,
 
9245
+WaterScreen::waterVertices (GLenum type,
 
9246
+                           XPoint *p,
 
9247
                            int    n,
 
9248
                            float  v)
 
9249
 {
 
9250
-    int         x1, y1, x2, y2;
 
9251
-    bool steep;
 
9252
-    int  tmp;
 
9253
-    int  deltaX, deltaY;
 
9254
-    int  error = 0;
 
9255
-    int  yStep;
 
9256
-    int  x, y;
 
9257
-
 
9258
-#define SWAP(v0, v1) \
 
9259
-    tmp = v0;       \
 
9260
-    v0 = v1;        \
 
9261
-    v1 = tmp
 
9262
-
 
9263
-    while (n > 1)
 
9264
-    {
 
9265
-       x1 = p->x;
 
9266
-       y1 = p->y;
 
9267
-
 
9268
-       p++;
 
9269
-       n--;
 
9270
-
 
9271
-       x2 = p->x;
 
9272
-       y2 = p->y;
 
9273
-
 
9274
-       p++;
 
9275
-       n--;
 
9276
-
 
9277
-       steep = abs (y2 - y1) > abs (x2 - x1);
 
9278
-       if (steep)
 
9279
-       {
 
9280
-           SWAP (x1, y1);
 
9281
-           SWAP (x2, y2);
 
9282
-       }
 
9283
-
 
9284
-       if (x1 > x2)
 
9285
-       {
 
9286
-           SWAP (x1, x2);
 
9287
-           SWAP (y1, y2);
 
9288
-       }
 
9289
-
 
9290
-#undef SWAP
 
9291
-
 
9292
-       deltaX = x2 - x1;
 
9293
-       deltaY = abs (y2 - y1);
 
9294
-
 
9295
-       y = y1;
 
9296
-       if (y1 < y2)
 
9297
-           yStep = 1;
 
9298
-       else
 
9299
-           yStep = -1;
 
9300
-
 
9301
-       for (x = x1; x <= x2; x++)
 
9302
-       {
 
9303
-           if (steep)
 
9304
-           {
 
9305
-               SET (y, x, v);
 
9306
-           }
 
9307
-           else
 
9308
-           {
 
9309
-               SET (x, y, v);
 
9310
-           }
 
9311
-
 
9312
-           error += deltaY;
 
9313
-           if (2 * error >= deltaX)
 
9314
-           {
 
9315
-               y += yStep;
 
9316
-               error -= deltaX;
 
9317
-           }
 
9318
-       }
 
9319
-    }
 
9320
-}
 
9321
-
 
9322
-#undef SET
 
9323
-
 
9324
-void
 
9325
-WaterScreen::softwareVertices (GLenum type,
 
9326
-                              XPoint *p,
 
9327
-                              int    n,
 
9328
-                              float  v)
 
9329
-{
 
9330
-    switch (type) {
 
9331
-       case GL_POINTS:
 
9332
-           softwarePoints (p, n, v);
 
9333
-           break;
 
9334
-       case GL_LINES:
 
9335
-           softwareLines (p, n, v);
 
9336
-           break;
 
9337
-    }
 
9338
-}
 
9339
-
 
9340
-void
 
9341
-WaterScreen::waterUpdate (float dt)
 
9342
-{
 
9343
-    GLfloat fade = 1.0f;
 
9344
-
 
9345
-    if (count < 1000)
 
9346
-    {
 
9347
-       if (count > 1)
 
9348
-           fade = 0.90f + count / 10000.0f;
 
9349
-       else
 
9350
-           fade = 0.0f;
 
9351
-    }
 
9352
+    if (!fboPrologue (INDEX (this, 0)))
 
9353
+       return;
 
9354
 
 
9355
-    if (!fboUpdate (dt, fade))
 
9356
-       softwareUpdate (dt, fade);
 
9357
-}
 
9358
+    glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
 
9359
+    glLineWidth (1.0f);
 
9360
 
 
9361
-void
 
9362
-WaterScreen::scaleVertices (XPoint *p, int n)
 
9363
-{
 
9364
-    while (n--)
 
9365
+    if (GL::vbo && GL::shaders)
 
9366
     {
 
9367
-       p[n].x = (width  * p[n].x) / screen->width ();
 
9368
-       p[n].y = (height * p[n].y) / screen->height ();
 
9369
+       vertexBuffer[SET]->begin (type);
 
9370
+       float data[3];
 
9371
+       for (int i = 0; i < n; i++)
 
9372
+       {
 
9373
+           data[0] = (((float) p->x / (float) screen->width ())  * 2.0f) - 1.0f;
 
9374
+           data[1] = ((((float) screen->height () - (float) p->y)/
 
9375
+                       (float) screen->height ()) * 2.0f) - 1.0f;
 
9376
+           data[2] = 0.0f;
 
9377
+           p++;
 
9378
+           vertexBuffer[SET]->addVertices  (1, &data[0]);
 
9379
+       }
 
9380
+       vertexBuffer[SET]->end();
 
9381
+
 
9382
+       vertexBuffer[SET]->addUniform ("color", v);
 
9383
+       GLboolean isBlendingEnabled;
 
9384
+       glGetBooleanv (GL_BLEND, &isBlendingEnabled);
 
9385
+       glDisable (GL_BLEND);
 
9386
+       vertexBuffer[SET]->render ();
 
9387
+       if (isBlendingEnabled)
 
9388
+           glEnable (GL_BLEND);
 
9389
     }
 
9390
-}
 
9391
-
 
9392
-void
 
9393
-WaterScreen::waterVertices (GLenum type,
 
9394
-                           XPoint *p,
 
9395
-                           int    n,
 
9396
-                           float  v)
 
9397
-{
 
9398
-    if (!GL::fragmentProgram)
 
9399
-       return;
 
9400
 
 
9401
-    scaleVertices (p, n);
 
9402
+    glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 
9403
 
 
9404
-    if (!fboVertices (type, p, n, v))
 
9405
-       softwareVertices (type, p, n, v);
 
9406
+    fboEpilogue ();
 
9407
 
 
9408
     if (count <= 0)
 
9409
     {
 
9410
-       WaterWindow *ww;
 
9411
-
 
9412
        cScreen->preparePaintSetEnabled (this, true);
 
9413
+       gScreen->glPaintOutputSetEnabled (this, true);
 
9414
+       gScreen->glPaintCompositedOutputSetEnabled (this, true);
 
9415
        cScreen->donePaintSetEnabled (this, true);
 
9416
-       foreach (CompWindow *w, screen->windows ())
 
9417
-       {
 
9418
-           ww = WaterWindow::get (w);
 
9419
-           ww->gWindow->glDrawTextureSetEnabled (ww, true);
 
9420
-       }
 
9421
     }
 
9422
 
 
9423
     if (count < 3000)
 
9424
@@ -758,15 +213,21 @@
 
9425
 }
 
9426
 
 
9427
 void
 
9428
-WaterScreen::waterReset ()
 
9429
+WaterScreen::waterSetup ()
 
9430
 {
 
9431
-    int size, i, j;
 
9432
-
 
9433
-    height = TEXTURE_SIZE;
 
9434
-    width  = (height * screen->width ()) / screen->height ();
 
9435
-
 
9436
+    int size;
 
9437
+    char buf[8192];
 
9438
+    std::string buffer;
 
9439
+
 
9440
+    texHeight = TEXTURE_SIZE;
 
9441
+    texWidth  = (texHeight * screen->width ()) / screen->height ();
 
9442
+
 
9443
+#ifdef USE_GLES
 
9444
+    target = GL_TEXTURE_2D;
 
9445
+    tx = ty = 1.0f;
 
9446
+#else
 
9447
     if (GL::textureNonPowerOfTwo ||
 
9448
-       (POWER_OF_TWO (width) && POWER_OF_TWO (height)))
 
9449
+       (POWER_OF_TWO (texWidth) && POWER_OF_TWO (texHeight)))
 
9450
     {
 
9451
        target = GL_TEXTURE_2D;
 
9452
        tx = ty = 1.0f;
 
9453
@@ -774,38 +235,15 @@
 
9454
     else
 
9455
     {
 
9456
        target = GL_TEXTURE_RECTANGLE_NV;
 
9457
-       tx = width;
 
9458
-       ty = height;
 
9459
-    }
 
9460
-
 
9461
-    if (!GL::fragmentProgram)
 
9462
-       return;
 
9463
-
 
9464
-    if (GL::fbo)
 
9465
-    {
 
9466
-       loadWaterProgram ();
 
9467
-       if (!fbo)
 
9468
-           GL::genFramebuffers (1, &fbo);
 
9469
-    }
 
9470
-
 
9471
-    fboStatus = 0;
 
9472
-
 
9473
-    for (i = 0; i < TEXTURE_NUM; i++)
 
9474
-    {
 
9475
-       if (texture[i])
 
9476
-       {
 
9477
-           glDeleteTextures (1, &texture[i]);
 
9478
-           texture[i] = 0;
 
9479
-       }
 
9480
+       tx = texWidth;
 
9481
+       ty = texHeight;
 
9482
     }
 
9483
+#endif
 
9484
 
 
9485
-    if (data)
 
9486
-       free (data);
 
9487
-
 
9488
-    size = (width + 2) * (height + 2);
 
9489
+    size = (texWidth + 2) * (texHeight + 2);
 
9490
 
 
9491
     data = calloc (1, (sizeof (float) * size * 2) +
 
9492
-                  (sizeof (GLubyte) * width * height * 4));
 
9493
+                  (sizeof (GLubyte) * texWidth * texHeight * 4));
 
9494
     if (!data)
 
9495
        return;
 
9496
 
 
9497
@@ -813,89 +251,112 @@
 
9498
     d1 = (d0 + (size));
 
9499
     t0 = (unsigned char *) (d1 + (size));
 
9500
 
 
9501
-    for (i = 0; i < height; i++)
 
9502
+    if (GL::fbo)
 
9503
     {
 
9504
-       for (j = 0; j < width; j++)
 
9505
+       program[SET]    = new GLProgram (set_water_vertices_vertex_shader,
 
9506
+                                        set_water_vertices_fragment_shader);
 
9507
+
 
9508
+       if (target == GL_TEXTURE_2D)
 
9509
+           sprintf (buf, update_water_vertices_fragment_shader.c_str (),
 
9510
+                    "2D", "2D",
 
9511
+                    1.0f / (float) texWidth,  1.0f / (float) texWidth,
 
9512
+                    1.0f / (float) texHeight, 1.0f / (float) texHeight,
 
9513
+                    "2D", "2D", "2D", "2D");
 
9514
+       else
 
9515
+           sprintf (buf, update_water_vertices_fragment_shader.c_str (),
 
9516
+                    "RECT", "RECT",
 
9517
+                    1.0f, 1.0f, 1.0f, 1.0f,
 
9518
+                    "RECT", "RECT", "RECT", "RECT");
 
9519
+
 
9520
+       buffer.assign (buf);
 
9521
+       program[UPDATE] = new GLProgram (update_water_vertices_vertex_shader,
 
9522
+                                        buffer);
 
9523
+
 
9524
+       sprintf (buf, paint_water_vertices_fragment_shader.c_str (),
 
9525
+                    screen->width (), screen->height ());
 
9526
+
 
9527
+       buffer.assign (buf);
 
9528
+       program[PAINT]  = new GLProgram (paint_water_vertices_vertex_shader,
 
9529
+                                        buffer);
 
9530
+
 
9531
+       vertexBuffer[SET] = new GLVertexBuffer (GL_DYNAMIC_DRAW);
 
9532
+       vertexBuffer[SET]->setProgram (program[SET]);
 
9533
+
 
9534
+       vertexBuffer[UPDATE] = new GLVertexBuffer (GL_STATIC_DRAW);
 
9535
+       vertexBuffer[UPDATE]->setProgram (program[UPDATE]);
 
9536
+
 
9537
+       vertexBuffer[PAINT] = new GLVertexBuffer (GL_STATIC_DRAW);
 
9538
+       vertexBuffer[PAINT]->setProgram (program[PAINT]);
 
9539
+    }
 
9540
+
 
9541
+    if (GL::fbo)
 
9542
+    {
 
9543
+       CompSize size(texWidth, texHeight);
 
9544
+       for (int i = 0; i < TEXTURE_NUM; i++)
 
9545
        {
 
9546
-           (t0 + (width * 4 * i + j * 4))[0] = 0xff;
 
9547
+           waterFbo[i] = new GLFramebufferObject ();
 
9548
+           waterFbo[i]->allocate (size, (char *) t0,
 
9549
+                                  GL_BGRA, GL_UNSIGNED_BYTE);
 
9550
+           // check if FBOs are working. If not, fallback to software textures
 
9551
+           oldFbo = waterFbo[i]->bind ();
 
9552
+           waterFbo[i]->rebind (oldFbo);
 
9553
+           if (!waterFbo[i]->checkStatus ())
 
9554
+           {
 
9555
+               useFbo = false;
 
9556
+               delete waterFbo[i];
 
9557
+               break;
 
9558
+           }
 
9559
        }
 
9560
     }
 
9561
 }
 
9562
 
 
9563
 void
 
9564
-WaterWindow::glDrawTexture (GLTexture          *texture,
 
9565
-                           GLFragment::Attrib &attrib,
 
9566
-                           unsigned int       mask)
 
9567
+WaterScreen::glPaintCompositedOutput (const CompRegion    &region,
 
9568
+                                     GLFramebufferObject *fbo,
 
9569
+                                     unsigned int         mask)
 
9570
 {
 
9571
-    if (wScreen->count)
 
9572
+    if (count)
 
9573
     {
 
9574
-       GLFragment::Attrib     fa (attrib);
 
9575
-       bool                   lighting = wScreen->gScreen->lighting ();
 
9576
-       int                    param, unit;
 
9577
-       GLFragment::FunctionId function;
 
9578
-       GLfloat                plane[4];
 
9579
-
 
9580
-       param = fa.allocParameters (1);
 
9581
-       unit  = fa.allocTextureUnits (1);
 
9582
-
 
9583
-       function = wScreen->getBumpMapFragmentFunction (texture, unit, param);
 
9584
-       if (function)
 
9585
+       if (GL::vbo && GL::shaders)
 
9586
        {
 
9587
-           fa.addFunction (function);
 
9588
-
 
9589
-           gScreen->setLighting (true);
 
9590
-
 
9591
-           GL::activeTexture (GL_TEXTURE0_ARB + unit);
 
9592
-
 
9593
-           glBindTexture (wScreen->target,
 
9594
-                          wScreen->texture[TINDEX (wScreen, 0)]);
 
9595
-
 
9596
-           plane[1] = plane[2] = 0.0f;
 
9597
-           plane[0] = wScreen->tx / (GLfloat) screen->width ();
 
9598
-           plane[3] = 0.0f;
 
9599
-
 
9600
-           glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
 
9601
-           glTexGenfv (GL_S, GL_EYE_PLANE, plane);
 
9602
-           glEnable (GL_TEXTURE_GEN_S);
 
9603
-
 
9604
-           plane[0] = plane[2] = 0.0f;
 
9605
-           plane[1] = wScreen->ty / (GLfloat) screen->height ();
 
9606
-           plane[3] = 0.0f;
 
9607
-
 
9608
-           glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
 
9609
-           glTexGenfv (GL_T, GL_EYE_PLANE, plane);
 
9610
-           glEnable (GL_TEXTURE_GEN_T);
 
9611
+           GLFramebufferObject::rebind (oldFbo);
 
9612
+           glViewport (oldViewport[0], oldViewport[1],
 
9613
+                       oldViewport[2], oldViewport[3]);
 
9614
+
 
9615
+           vertexBuffer[PAINT]->begin ();
 
9616
+           vertexBuffer[PAINT]->addVertices (6, &vertexData[0]);
 
9617
+           vertexBuffer[PAINT]->addTexCoords (0, 6, &textureData[0]);
 
9618
+           vertexBuffer[PAINT]->end ();
 
9619
+
 
9620
+           glEnable (GL_TEXTURE_2D);
 
9621
+
 
9622
+           glActiveTexture (GL_TEXTURE0);
 
9623
+           fbo->tex ()->setFilter (GL_LINEAR);
 
9624
+           glBindTexture (GL_TEXTURE_2D, fbo->tex ()->name ());
 
9625
+           vertexBuffer[PAINT]->addUniform ("baseTex", 0);
 
9626
+
 
9627
+           glActiveTexture (GL_TEXTURE1);
 
9628
+           waterFbo[INDEX (this, 0)]->tex ()->setFilter (GL_LINEAR);
 
9629
+           glBindTexture (GL_TEXTURE_2D,
 
9630
+                       waterFbo[INDEX (this, 0)]->tex ()->name ());
 
9631
+           vertexBuffer[PAINT]->addUniform ("waveTex", 1);
 
9632
+
 
9633
+           vertexBuffer[PAINT]->addUniform3f ("lightVec",
 
9634
+                                       lightVec[0],
 
9635
+                                       lightVec[1],
 
9636
+                                       lightVec[2]);
 
9637
+           vertexBuffer[PAINT]->addUniform ("offsetScale", offsetScale);
 
9638
+           GLboolean isBlendingEnabled;
 
9639
+           glGetBooleanv (GL_BLEND, &isBlendingEnabled);
 
9640
+           glDisable (GL_BLEND);
 
9641
+           vertexBuffer[PAINT]->render ();
 
9642
+           if (isBlendingEnabled)
 
9643
+               glEnable (GL_BLEND);
 
9644
 
 
9645
-           GL::activeTexture (GL_TEXTURE0_ARB);
 
9646
-
 
9647
-           GL::programEnvParameter4f (GL_FRAGMENT_PROGRAM_ARB, param,
 
9648
-                                      texture->matrix ().yy *
 
9649
-                                      wScreen->offsetScale,
 
9650
-                                      -texture->matrix ().xx *
 
9651
-                                      wScreen->offsetScale,
 
9652
-                                      0.0f, 0.0f);
 
9653
-       }
 
9654
-
 
9655
-       /* to get appropriate filtering of texture */
 
9656
-       mask |= PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
 
9657
-
 
9658
-       gWindow->glDrawTexture (texture, fa, mask);
 
9659
-
 
9660
-       if (function)
 
9661
-       {
 
9662
-           GL::activeTexture (GL_TEXTURE0_ARB + unit);
 
9663
-           glDisable (GL_TEXTURE_GEN_T);
 
9664
-           glDisable (GL_TEXTURE_GEN_S);
 
9665
-           glBindTexture (wScreen->target, 0);
 
9666
-           GL::activeTexture (GL_TEXTURE0_ARB);
 
9667
-
 
9668
-           gScreen->setLighting (lighting);
 
9669
+           glBindTexture (GL_TEXTURE_2D, 0);
 
9670
+           glDisable (GL_TEXTURE_2D);
 
9671
        }
 
9672
     }
 
9673
-    else
 
9674
-    {
 
9675
-       gWindow->glDrawTexture (texture, attrib, mask);
 
9676
-    }
 
9677
 }
 
9678
 
 
9679
 /* TODO: a way to control the speed */
 
9680
@@ -976,8 +437,6 @@
 
9681
                    p[0].y = screen->height ();
 
9682
                }
 
9683
 
 
9684
-               /* software rasterizer doesn't support triangles yet so wiper
 
9685
-                  effect will only work with FBOs right now */
 
9686
                waterVertices (GL_TRIANGLES, p, 3, 0.0f);
 
9687
            }
 
9688
 
 
9689
@@ -985,7 +444,7 @@
 
9690
 
 
9691
        }
 
9692
 
 
9693
-       waterUpdate (0.8f);
 
9694
+       waterUpdate (0.8);
 
9695
     }
 
9696
 
 
9697
     cScreen->preparePaint (msSinceLastPaint);
 
9698
@@ -998,15 +457,10 @@
 
9699
        cScreen->damageScreen ();
 
9700
     else
 
9701
     {
 
9702
-       WaterWindow *ww;
 
9703
-
 
9704
        cScreen->preparePaintSetEnabled (this, false);
 
9705
+       gScreen->glPaintOutputSetEnabled (this, false);
 
9706
+       gScreen->glPaintCompositedOutputSetEnabled (this, false);
 
9707
        cScreen->donePaintSetEnabled (this, false);
 
9708
-       foreach (CompWindow *w, screen->windows ())
 
9709
-       {
 
9710
-           ww = WaterWindow::get (w);
 
9711
-           ww->gWindow->glDrawTextureSetEnabled (ww, false);
 
9712
-       }
 
9713
     }
 
9714
 
 
9715
     cScreen->donePaint ();
 
9716
@@ -1029,7 +483,6 @@
 
9717
 
 
9718
        cScreen->damageScreen ();
 
9719
     }
 
9720
-
 
9721
 }
 
9722
 
 
9723
 static bool
 
9724
@@ -1059,7 +512,7 @@
 
9725
            p.x = waterLastPointerX = xRoot;
 
9726
            p.y = waterLastPointerY = yRoot;
 
9727
 
 
9728
-           ws->waterVertices (GL_POINTS, &p, 1, 0.8f);
 
9729
+           ws->waterVertices (GL_POINTS, &p, 1, 1.0f);
 
9730
 
 
9731
            ws->cScreen->damageScreen ();
 
9732
        }
 
9733
@@ -1263,7 +716,7 @@
 
9734
 {
 
9735
     switch (num) {
 
9736
        case WaterOptions::OffsetScale:
 
9737
-           offsetScale = optionGetOffsetScale () * 50.0f;
 
9738
+           offsetScale = optionGetOffsetScale () * 10.0f;
 
9739
            break;
 
9740
        case WaterOptions::RainDelay:
 
9741
            if (rainTimer.active ())
 
9742
@@ -1272,6 +725,15 @@
 
9743
                                    (float)optionGetRainDelay () * 1.2);
 
9744
            }
 
9745
            break;
 
9746
+       case WaterOptions::LightVecX:
 
9747
+           lightVec[0] = optionGetLightVecX();
 
9748
+           break;
 
9749
+       case WaterOptions::LightVecY:
 
9750
+           lightVec[1] = optionGetLightVecY();
 
9751
+           break;
 
9752
+       case WaterOptions::LightVecZ:
 
9753
+           lightVec[2] = optionGetLightVecZ();
 
9754
+           break;
 
9755
        default:
 
9756
            break;
 
9757
     }
 
9758
@@ -1282,21 +744,20 @@
 
9759
     cScreen (CompositeScreen::get (screen)),
 
9760
     gScreen (GLScreen::get (screen)),
 
9761
     grabIndex (0),
 
9762
-    width (0),
 
9763
-    height (0),
 
9764
 
 
9765
-    program (0),
 
9766
+    oldFbo (NULL),
 
9767
+    fboIndex (0),
 
9768
+    useFbo (true),
 
9769
+
 
9770
+    texWidth (0),
 
9771
+    texHeight (0),
 
9772
 
 
9773
-    tIndex (0),
 
9774
     target (0),
 
9775
     tx (0),
 
9776
     ty (0),
 
9777
 
 
9778
     count (0),
 
9779
 
 
9780
-    fbo (0),
 
9781
-    fboStatus (0),
 
9782
-
 
9783
     data (NULL),
 
9784
     d0 (NULL),
 
9785
     d1 (NULL),
 
9786
@@ -1304,20 +765,22 @@
 
9787
 
 
9788
     wiperAngle (0),
 
9789
     wiperSpeed (0),
 
9790
-
 
9791
-    bumpMapFunctions ()
 
9792
+    lightVec(GLVector(optionGetLightVecX(),
 
9793
+                     optionGetLightVecY(),
 
9794
+                     optionGetLightVecZ()))
 
9795
 {
 
9796
-    offsetScale = optionGetOffsetScale () * 50.0f;
 
9797
-
 
9798
-    memset (texture, 0, sizeof (GLuint) * TEXTURE_NUM);
 
9799
+    offsetScale = optionGetOffsetScale () * 10.0f;
 
9800
 
 
9801
     wiperTimer.setCallback (boost::bind (&WaterScreen::wiperTimeout, this));
 
9802
     rainTimer.setCallback (boost::bind (&WaterScreen::rainTimeout, this));
 
9803
 
 
9804
-    waterReset ();
 
9805
+    waterSetup ();
 
9806
 
 
9807
     optionSetOffsetScaleNotify (boost::bind (&WaterScreen::optionChange, this, _2));
 
9808
-    optionSetRainDelayNotify (boost::bind (&WaterScreen::optionChange, this, _2));
 
9809
+    optionSetRainDelayNotify   (boost::bind (&WaterScreen::optionChange, this, _2));
 
9810
+    optionSetLightVecXNotify   (boost::bind (&WaterScreen::optionChange, this, _2));
 
9811
+    optionSetLightVecYNotify   (boost::bind (&WaterScreen::optionChange, this, _2));
 
9812
+    optionSetLightVecZNotify   (boost::bind (&WaterScreen::optionChange, this, _2));
 
9813
 
 
9814
     optionSetInitiateKeyInitiate (waterInitiate);
 
9815
     optionSetInitiateKeyTerminate (waterTerminate);
 
9816
@@ -1329,29 +792,28 @@
 
9817
 
 
9818
     ScreenInterface::setHandler (screen, false);
 
9819
     CompositeScreenInterface::setHandler (cScreen, false);
 
9820
+    GLScreenInterface::setHandler (gScreen, false);
 
9821
 }
 
9822
 
 
9823
 WaterScreen::~WaterScreen ()
 
9824
 {
 
9825
-    if (fbo)
 
9826
-       GL::deleteFramebuffers (1, &fbo);
 
9827
+    if (program[SET])
 
9828
+       delete program[SET];
 
9829
+
 
9830
+    if (program[UPDATE])
 
9831
+       delete program[UPDATE];
 
9832
+
 
9833
+    if (program[PAINT])
 
9834
+       delete program[PAINT];
 
9835
 
 
9836
-    for (unsigned int i = 0; i < TEXTURE_NUM; i++)
 
9837
+    for (int i = 0; i < TEXTURE_NUM; i++)
 
9838
     {
 
9839
-       if (texture[i])
 
9840
-           glDeleteTextures (1, &texture[i]);
 
9841
+       if (waterFbo[i])
 
9842
+           delete waterFbo[i];
 
9843
     }
 
9844
 
 
9845
-    if (program)
 
9846
-       GL::deletePrograms (1, &program);
 
9847
-
 
9848
     if (data)
 
9849
        free (data);
 
9850
-
 
9851
-    foreach (WaterFunction &f, bumpMapFunctions)
 
9852
-    {
 
9853
-       GLFragment::destroyFragmentFunction (f.id);
 
9854
-    }
 
9855
 }
 
9856
 
 
9857
 bool
 
9858
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/water/src/water.h linaro-gles2-debianpatches/plugins/water/src/water.h
 
9859
--- compiz-0.9.7.8/plugins/water/src/water.h    2012-04-26 08:47:01.000000000 +0200
 
9860
+++ linaro-gles2-debianpatches/plugins/water/src/water.h        2012-04-20 11:41:59.241600000 +0200
 
9861
@@ -21,6 +21,7 @@
 
9862
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
9863
  *
 
9864
  * Author: David Reveman <davidr@novell.com>
 
9865
+ *         Frederic Plourde <frederic.plourde@collabora.co.uk>
 
9866
  */
 
9867
 
 
9868
 #include "water_options.h"
 
9869
@@ -29,6 +30,8 @@
 
9870
 
 
9871
 #include <composite/composite.h>
 
9872
 #include <opengl/opengl.h>
 
9873
+#include <opengl/framebufferobject.h>
 
9874
+#include "shaders.h"
 
9875
 
 
9876
 
 
9877
 #define WATER_SCREEN(s) \
 
9878
@@ -38,27 +41,22 @@
 
9879
 
 
9880
 #define K 0.1964f
 
9881
 
 
9882
-#define TEXTURE_NUM 3
 
9883
+#define TEXTURE_NUM  3
 
9884
+#define PROG_NUM 3
 
9885
 
 
9886
-#define TINDEX(ws, i) (((ws)->tIndex + (i)) % TEXTURE_NUM)
 
9887
+#define INDEX(ws, i) (((ws)->fboIndex + (i)) % TEXTURE_NUM)
 
9888
 
 
9889
-#define WATER_INITIATE_MODIFIERS_DEFAULT (ControlMask | CompSuperMask)
 
9890
-
 
9891
-struct WaterFunction {
 
9892
-    GLFragment::FunctionId id;
 
9893
-
 
9894
-    int target;
 
9895
-    int param;
 
9896
-    int unit;
 
9897
-};
 
9898
+enum programTypes { SET, UPDATE, PAINT};
 
9899
 
 
9900
 class WaterScreen :
 
9901
     public ScreenInterface,
 
9902
+    public GLScreenInterface,
 
9903
     public CompositeScreenInterface,
 
9904
     public PluginClassHandler<WaterScreen,CompScreen>,
 
9905
     public WaterOptions
 
9906
 {
 
9907
     public:
 
9908
+
 
9909
        WaterScreen (CompScreen *screen);
 
9910
        ~WaterScreen ();
 
9911
 
 
9912
@@ -66,34 +64,23 @@
 
9913
 
 
9914
        void handleEvent (XEvent *);
 
9915
 
 
9916
+       void glPaintCompositedOutput (const CompRegion    &region,
 
9917
+                                     GLFramebufferObject *fbo,
 
9918
+                                     unsigned int         mask);
 
9919
        void preparePaint (int);
 
9920
        void donePaint ();
 
9921
 
 
9922
-       GLFragment::FunctionId
 
9923
-       getBumpMapFragmentFunction (GLTexture *texture,
 
9924
-                                   int       unit,
 
9925
-                                   int       param);
 
9926
-
 
9927
-       void allocTexture (int index);
 
9928
-
 
9929
-       bool fboPrologue (int tIndex);
 
9930
+       bool fboPrologue (int fboIndex);
 
9931
        void fboEpilogue ();
 
9932
-       bool fboUpdate (float dt, float fade);
 
9933
-       bool fboVertices (GLenum type, XPoint *p, int n, float v);
 
9934
+       bool fboUpdate   (float dt, float fade);
 
9935
 
 
9936
-       void softwareUpdate (float dt, float fade);
 
9937
-       void softwarePoints (XPoint *p, int n, float add);
 
9938
-       void softwareLines (XPoint *p, int n, float v);
 
9939
-       void softwareVertices (GLenum type, XPoint *p, int n, float v);
 
9940
-
 
9941
-       void waterUpdate (float dt);
 
9942
-       void scaleVertices (XPoint *p, int n);
 
9943
+       void waterUpdate   (float dt);
 
9944
        void waterVertices (GLenum type, XPoint *p, int n, float v);
 
9945
 
 
9946
        bool rainTimeout ();
 
9947
        bool wiperTimeout ();
 
9948
 
 
9949
-       void waterReset ();
 
9950
+       void waterSetup ();
 
9951
 
 
9952
        void handleMotionEvent ();
 
9953
 
 
9954
@@ -104,20 +91,26 @@
 
9955
 
 
9956
        CompScreen::GrabHandle grabIndex;
 
9957
 
 
9958
-       int width, height;
 
9959
+       GLProgram      *program[PROG_NUM];
 
9960
+       GLVertexBuffer *vertexBuffer[PROG_NUM];
 
9961
+
 
9962
+       static GLfloat vertexData[18];
 
9963
 
 
9964
-       GLuint program;
 
9965
-       GLuint texture[TEXTURE_NUM];
 
9966
+       static GLfloat textureData[12];
 
9967
 
 
9968
-       int     tIndex;
 
9969
+       GLFramebufferObject *waterFbo[TEXTURE_NUM];
 
9970
+
 
9971
+       GLFramebufferObject *oldFbo;
 
9972
+       GLint oldViewport[4];
 
9973
+       int    fboIndex;
 
9974
+       bool   useFbo;
 
9975
+
 
9976
+       int texWidth, texHeight;
 
9977
        GLenum  target;
 
9978
        GLfloat tx, ty;
 
9979
 
 
9980
        int count;
 
9981
 
 
9982
-       GLuint fbo;
 
9983
-       GLint  fboStatus;
 
9984
-
 
9985
        void          *data;
 
9986
        float         *d0;
 
9987
        float         *d1;
 
9988
@@ -129,37 +122,14 @@
 
9989
        float wiperAngle;
 
9990
        float wiperSpeed;
 
9991
 
 
9992
-       std::vector<WaterFunction> bumpMapFunctions;
 
9993
-};
 
9994
-
 
9995
-class WaterWindow :
 
9996
-    public GLWindowInterface,
 
9997
-    public PluginClassHandler<WaterWindow,CompWindow>
 
9998
-{
 
9999
-    public:
 
10000
-       WaterWindow (CompWindow *window) :
 
10001
-           PluginClassHandler<WaterWindow,CompWindow> (window),
 
10002
-           window (window),
 
10003
-           gWindow (GLWindow::get (window)),
 
10004
-           wScreen (WaterScreen::get (screen)),
 
10005
-           gScreen (GLScreen::get (screen))
 
10006
-       {
 
10007
-           GLWindowInterface::setHandler (gWindow, false);
 
10008
-       }
 
10009
-
 
10010
-       void glDrawTexture (GLTexture *texture, GLFragment::Attrib &,
 
10011
-                           unsigned int);
 
10012
-
 
10013
-       CompWindow  *window;
 
10014
-       GLWindow    *gWindow;
 
10015
-       WaterScreen *wScreen;
 
10016
-       GLScreen    *gScreen;
 
10017
+       GLVector lightVec;
 
10018
 };
 
10019
 
 
10020
 class WaterPluginVTable :
 
10021
-    public CompPlugin::VTableForScreenAndWindow<WaterScreen,WaterWindow>
 
10022
+    public CompPlugin::VTableForScreen<WaterScreen>
 
10023
 {
 
10024
     public:
 
10025
 
 
10026
        bool init ();
 
10027
 };
 
10028
+
 
10029
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/water/water.xml.in linaro-gles2-debianpatches/plugins/water/water.xml.in
 
10030
--- compiz-0.9.7.8/plugins/water/water.xml.in   2012-04-26 08:47:01.000000000 +0200
 
10031
+++ linaro-gles2-debianpatches/plugins/water/water.xml.in       2012-04-20 11:41:59.241600000 +0200
 
10032
@@ -49,6 +49,30 @@
 
10033
                <min>1</min>
 
10034
                <max>3600000</max>
 
10035
            </option>
 
10036
+           <option name="light_vec_x" type="float">
 
10037
+               <_short>lightVec X</_short>
 
10038
+               <_long>Light vector X coordinate</_long>
 
10039
+               <default>1.0</default>
 
10040
+               <min>-1</min>
 
10041
+               <max>1</max>
 
10042
+               <precision>0.1</precision>
 
10043
+           </option>
 
10044
+           <option name="light_vec_y" type="float">
 
10045
+               <_short>lightVec Y</_short>
 
10046
+               <_long>Light vector Y coordinate</_long>
 
10047
+               <default>1.0</default>
 
10048
+               <min>-1</min>
 
10049
+               <max>1</max>
 
10050
+               <precision>0.1</precision>
 
10051
+           </option>
 
10052
+           <option name="light_vec_z" type="float">
 
10053
+               <_short>lightVec Z</_short>
 
10054
+               <_long>Light vector Z coordinate</_long>
 
10055
+               <default>1.0</default>
 
10056
+               <min>0.1</min>
 
10057
+               <max>1</max>
 
10058
+               <precision>0.1</precision>
 
10059
+           </option>
 
10060
            <option name="title_wave" type="bell">
 
10061
                <_short>Title wave</_short>
 
10062
                <_long>Wave effect from window title</_long>
 
10063
diff -Nur '--exclude=.*' '--exclude=debian' compiz-0.9.7.8/plugins/wobbly/CMakeLists.txt linaro-gles2-debianpatches/plugins/wobbly/CMakeLists.txt
 
10064
--- compiz-0.9.7.8/plugins/wobbly/CMakeLists.txt        2012-04-26 08:47:01.000000000 +0200
 
10065
+++ linaro-gles2-debianpatches/plugins/wobbly/CMakeLists.txt    2012-04-20 11:41:59.241600000 +0200
 
10066
@@ -2,4 +2,4 @@
 
10067
 
 
10068
 include (CompizPlugin)
 
10069
 
 
10070
-compiz_plugin(wobbly PLUGINDEPS composite opengl)
 
10071
+#compiz_plugin(wobbly PLUGINDEPS composite opengl)