Merge lp:~amaranth/compiz-core/gles into lp:compiz-core/0.9.5

Proposed by Travis Watkins
Status: Superseded
Proposed branch: lp:~amaranth/compiz-core/gles
Merge into: lp:compiz-core/0.9.5
Diff against target: 6779 lines (+2760/-2251)
50 files modified
CMakeLists.txt (+13/-0)
cmake/CMakeLists.txt (+2/-0)
cmake/CompizCommon.cmake (+12/-0)
cmake/CompizPlugin.cmake (+14/-10)
cmake/FindOpenGLES2.cmake (+51/-0)
cmake/base.cmake (+3/-1)
cmake/plugin_extensions/CompizOpenGLFixups.cmake (+22/-0)
include/core/rect.h (+2/-0)
plugins/annotate/src/annotate.cpp (+133/-77)
plugins/clone/src/clone.cpp (+0/-5)
plugins/compiztoolbox/src/compiztoolbox.cpp (+14/-28)
plugins/copytex/src/copytex.cpp (+9/-0)
plugins/cube/src/cube.cpp (+0/-4)
plugins/decor/src/decor.cpp (+17/-15)
plugins/decor/src/decor.h (+1/-1)
plugins/imgsvg/src/imgsvg.cpp (+12/-9)
plugins/imgsvg/src/imgsvg.h (+2/-1)
plugins/obs/src/obs.cpp (+9/-8)
plugins/obs/src/obs.h (+1/-1)
plugins/opengl/CMakeLists.txt (+9/-4)
plugins/opengl/compiz-opengl.pc.in (+2/-2)
plugins/opengl/include/opengl/fragment.h (+0/-124)
plugins/opengl/include/opengl/matrix.h (+2/-0)
plugins/opengl/include/opengl/opengl.h (+126/-65)
plugins/opengl/include/opengl/program.h (+68/-0)
plugins/opengl/include/opengl/programcache.h (+51/-0)
plugins/opengl/include/opengl/texture.h (+4/-0)
plugins/opengl/include/opengl/vertexbuffer.h (+83/-0)
plugins/opengl/opengl.xml.in (+1/-1)
plugins/opengl/src/fragment.cpp (+0/-1145)
plugins/opengl/src/matrix.cpp (+54/-0)
plugins/opengl/src/paint.cpp (+291/-418)
plugins/opengl/src/privatefragment.h (+0/-54)
plugins/opengl/src/privates.h (+22/-10)
plugins/opengl/src/privatetexture.h (+32/-0)
plugins/opengl/src/privatevertexbuffer.h (+71/-0)
plugins/opengl/src/program.cpp (+225/-0)
plugins/opengl/src/programcache.cpp (+175/-0)
plugins/opengl/src/screen.cpp (+316/-27)
plugins/opengl/src/shaders.h (+130/-0)
plugins/opengl/src/texture.cpp (+126/-3)
plugins/opengl/src/vertexbuffer.cpp (+414/-0)
plugins/opengl/src/window.cpp (+29/-84)
plugins/resize/src/resize.cpp (+56/-37)
plugins/scale/src/scale.cpp (+12/-24)
plugins/screenshot/src/screenshot.cpp (+50/-25)
plugins/switcher/src/switcher.cpp (+41/-48)
plugins/zoom/src/zoom.cpp (+41/-19)
src/event.cpp (+11/-0)
src/plugin.cpp (+1/-1)
To merge this branch: bzr merge lp:~amaranth/compiz-core/gles
Reviewer Review Type Date Requested Status
Sam Spilsbury Pending
Review via email: mp+71084@code.launchpad.net

This proposal has been superseded by a proposal from 2012-01-23.

Description of the change

This branch contains the code to make compiz work on GLES. This includes several changes to the compiz API.

* GLVertexBuffer class added for managing vertices, normals, texture coordinates, and colors
* GLProgram class added for managing GLSL programs
* GLProgramCache class added for managing per-plugin GLSL programs efficiently, uses an LRU cache
  to avoid recompiling recently used GLSL programs all the time
* GLFragment class removed as fragment programs are no longer used (replaced with GLSL programs)
* GL_BLEND now always enabled when rendering as almost everything was enabling it anyway
* EGL context setup added
* EglTexture class added to use EGL_image extension instead of GLX_EXT_texture_from_pixmap for GLES

Things left to do for a complete port:

  * properly check for GLSL support on desktop, currently assumes if you have VBO support you
    have GLSL support
  * port blur, wobbly, rotate, cube, and water plugins
    * wobbly, cube, and rotate should be fairly straightforward, water and blur need updated to
      use GLSL instead of fragment programs

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :
Download full text (8.3 KiB)

1682 + int render (const GLMatrix &modelview,
1683 + const GLWindowPaintAttrib &attrib);
1684 +
1685 + int render (const GLMatrix &projection,
1686 + const GLMatrix &modelview,
1687 + const GLWindowPaintAttrib &attrib);

Probably for the sake of API confusion, it might be worth swapping the order of projection and modelview in this case, so you have

1685 + int render (const GLMatrix &modelview,
1686 + const GLMatrix &projection,
1687 + const GLWindowPaintAttrib &attrib);

--

1586 + GLProgram* operator () (std::list<GLShaderData*>);

Can that take a const std::list <GLShaderData *> & ?

1116 +#if !defined(GL_BGRA)
1117 + #if !defined(GL_BGRA_EXT)
1118 + #error GL_BGRA support is required
1119 + #else
1120 + #define GL_BGRA GL_BGRA_EXT
1121 + #endif
1122 +#endif

This can probably be detected in CMake by using try_compile () [1]

1703 - <default>true</default>
1704 + <default>false</default>

Does this need to be off by default?

1678 + void setProgram (GLProgram *program);
1679 +
1680 + int render (const GLMatrix &modelview);
1681 +
1682 + int render (const GLMatrix &modelview,
1683 + const GLWindowPaintAttrib &attrib);
1684 +
1685 + int render (const GLMatrix &projection,
1686 + const GLMatrix &modelview,
1687 + const GLWindowPaintAttrib &attrib);

The semantics of this are odd. Is GLVertexBuffer meant to be a stateful object which holds on to the state of what its rendering? In that case, it might be more appropriate to have a:

void setProjection ();
void setModelView ();
void setAttrib ();

However, on another though, perhaps all of these arguments are redundant. If glPushMatrix, glLoadMatrixf and glPopMatrix are all parts of the deprecated API, and PrivateGLVertexBuffer::render is really doing this:

+ GLfloat params[4] = {0, 0, 0, 0};
+ GLfloat attribs[3] = {1, 1, 1};
+ GLint index = 0;
+

+ program->setUniform ("projection", projection);
+ program->setUniform ("modelview", modelview);

+ //convert paint attribs to 0-1 range
+ attribs[0] = attrib.opacity / 65535.0f;
+ attribs[1] = attrib.brightness / 65535.0f;
+ attribs[2] = attrib.saturation / 65535.0f;
+ program->setUniform3f ("paintAttrib", attribs[0], attribs[1], attribs[2]);
+

Then it might make more sense to have helper objects in the OpenGL plugin to handle that so that you don't need to pass matrices or paint attributes to the GLVertexBuffer at render time and we don't need to continue to expand the ::render () function argument list should we add more things to the core profile.

The helper object might just server to build a GLProgram with that stuff built in so that it can be passed directly to GLVertexBuffer at render time. Just a thought.

+ #ifdef USE_GLES
+ Display *xdpy = screen->dpy ();
+
+ glFlush ();
+ if (mask & COMPOSITE_SCREEN_DAMAGE_ALL_MASK)
+ {
+ eglSwapBuffers (eglGetDisplay (xdpy), surface);
+ }
+ else
+ {
+ #warning use proper extension for this
+ eglSwapBuffers (eglGetDisplay (xdpy), surface);
+ }
+ eglW...

Read more...

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Is there a reason nothing has happened here since Aug/Sep 2011?

Unmerged revisions

2782. By Travis Watkins

merge in gles git branch

2781. By Ville Syrjala <email address hidden>

[PATCH] Don't unredirect overlay windows until we have set the new
bounding shape for the output window.

Unredirecting them before this time meant that they were stacked
underneath the overlay window and changing the bounding shape of
the output window would cause an expose event to be sent to
the overlay window causing a breif flicker as it redraws.

Unredirecting after this means that no expose event is sent because
the backing store is only set again after the bounding shape of the
output window has been changed

2780. By Sam Spilsbury

Merge trunk

2779. By Sam Spilsbury

Merge in doc for decor

Preview Diff

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

Subscribers

People subscribed via source and target branches