Merge lp:~compiz-linaro-team/compiz/gles2 into lp:compiz/0.9.8

Proposed by Daniel van Vugt
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3378
Merged at revision: 3320
Proposed branch: lp:~compiz-linaro-team/compiz/gles2
Merge into: lp:compiz/0.9.8
Diff against target: 16838 lines (+7498/-4718)
104 files modified
cmake/CMakeLists.txt (+2/-0)
cmake/CompizCommon.cmake (+12/-0)
cmake/CompizPlugin.cmake (+14/-10)
cmake/FindCompiz.cmake (+1/-1)
cmake/FindOpenGLES2.cmake (+51/-0)
cmake/base.cmake (+3/-0)
cmake/plugin_extensions/CompizOpenGLFixups.cmake (+22/-0)
include/core/wrapsystem.h (+8/-0)
plugins/CMakeLists.txt (+30/-0)
plugins/animation/CMakeLists.txt (+3/-5)
plugins/animation/include/animation/animation.h (+1/-1)
plugins/animation/include/animation/animeffect.h (+3/-3)
plugins/animation/include/animation/grid.h (+0/-2)
plugins/animation/src/animation.cpp (+85/-27)
plugins/animation/src/grid.cpp (+25/-258)
plugins/animation/src/private.h (+3/-3)
plugins/annotate/src/annotate.cpp (+149/-71)
plugins/blur/CMakeLists.txt (+12/-12)
plugins/clone/src/clone.cpp (+0/-5)
plugins/compiztoolbox/src/compiztoolbox.cpp (+5/-18)
plugins/copytex/src/copytex.cpp (+9/-0)
plugins/cube/include/cube/cube.h (+9/-6)
plugins/cube/src/cube.cpp (+85/-80)
plugins/decor/src/decor.cpp (+29/-27)
plugins/decor/src/decor.h (+2/-2)
plugins/expo/CMakeLists.txt (+4/-8)
plugins/expo/src/expo.cpp (+256/-111)
plugins/expo/src/expo.h (+3/-4)
plugins/ezoom/src/ezoom.cpp (+118/-52)
plugins/grid/src/grid.cpp (+108/-53)
plugins/imgsvg/src/imgsvg.cpp (+9/-6)
plugins/imgsvg/src/imgsvg.h (+2/-1)
plugins/kdecompat/src/kdecompat.cpp (+7/-22)
plugins/mag/src/mag.cpp (+102/-73)
plugins/mag/src/mag.h (+2/-0)
plugins/neg/src/neg.cpp (+33/-106)
plugins/neg/src/neg.h (+3/-6)
plugins/obs/src/obs.cpp (+8/-7)
plugins/obs/src/obs.h (+1/-1)
plugins/opengl/CMakeLists.txt (+14/-4)
plugins/opengl/compiz-opengl.pc.in (+1/-1)
plugins/opengl/include/opengl/doublebuffer.h (+39/-0)
plugins/opengl/include/opengl/fragment.h (+0/-125)
plugins/opengl/include/opengl/framebufferobject.h (+104/-0)
plugins/opengl/include/opengl/matrix.h (+2/-0)
plugins/opengl/include/opengl/opengl.h (+441/-73)
plugins/opengl/include/opengl/program.h (+75/-0)
plugins/opengl/include/opengl/programcache.h (+51/-0)
plugins/opengl/include/opengl/shadercache.h (+100/-0)
plugins/opengl/include/opengl/texture.h (+5/-0)
plugins/opengl/include/opengl/vector.h (+3/-3)
plugins/opengl/include/opengl/vertexbuffer.h (+130/-0)
plugins/opengl/opengl.xml.in (+15/-0)
plugins/opengl/src/doublebuffer/CMakeLists.txt (+31/-0)
plugins/opengl/src/doublebuffer/src/double-buffer.cpp (+76/-0)
plugins/opengl/src/doublebuffer/tests/CMakeLists.txt (+24/-0)
plugins/opengl/src/doublebuffer/tests/test-opengl-double-buffer.cpp (+98/-0)
plugins/opengl/src/fragment.cpp (+0/-1146)
plugins/opengl/src/framebufferobject.cpp (+221/-0)
plugins/opengl/src/matrix.cpp (+54/-0)
plugins/opengl/src/paint.cpp (+472/-443)
plugins/opengl/src/privatefragment.h (+0/-54)
plugins/opengl/src/privates.h (+101/-13)
plugins/opengl/src/privatetexture.h (+32/-0)
plugins/opengl/src/privatevertexbuffer.h (+149/-0)
plugins/opengl/src/program.cpp (+262/-0)
plugins/opengl/src/programcache.cpp (+175/-0)
plugins/opengl/src/screen.cpp (+938/-154)
plugins/opengl/src/shadercache.cpp (+246/-0)
plugins/opengl/src/texture.cpp (+152/-22)
plugins/opengl/src/vector.cpp (+2/-2)
plugins/opengl/src/vertexbuffer.cpp (+634/-0)
plugins/opengl/src/window.cpp (+65/-83)
plugins/resize/src/resize.cpp (+84/-31)
plugins/resizeinfo/src/resizeinfo.cpp (+45/-27)
plugins/resizeinfo/src/resizeinfo.h (+2/-1)
plugins/ring/src/ring.cpp (+19/-37)
plugins/ring/src/ring.h (+1/-1)
plugins/scale/src/scale.cpp (+10/-17)
plugins/scaleaddon/src/scaleaddon.cpp (+51/-21)
plugins/scaleaddon/src/scaleaddon.h (+2/-2)
plugins/scalefilter/src/scalefilter.cpp (+1/-6)
plugins/screenshot/src/screenshot.cpp (+47/-20)
plugins/shift/src/shift.cpp (+95/-98)
plugins/shift/src/shift.h (+1/-1)
plugins/staticswitcher/src/staticswitcher.cpp (+156/-64)
plugins/staticswitcher/src/staticswitcher.h (+5/-3)
plugins/switcher/src/switcher.cpp (+45/-42)
plugins/text/include/text/text.h (+2/-1)
plugins/text/src/text.cpp (+53/-24)
plugins/thumbnail/src/thumbnail.cpp (+301/-118)
plugins/thumbnail/src/thumbnail.h (+3/-1)
plugins/wall/src/wall.cpp (+60/-46)
plugins/wall/src/wall.h (+1/-1)
plugins/water/src/shaders.h (+200/-0)
plugins/water/src/water.cpp (+281/-801)
plugins/water/src/water.h (+33/-63)
plugins/water/water.xml.in (+26/-2)
plugins/wobbly/src/wobbly.cpp (+20/-176)
plugins/wobbly/src/wobbly.h (+0/-1)
plugins/workarounds/src/workarounds.cpp (+14/-0)
plugins/workarounds/src/workarounds.h (+4/-0)
plugins/workspacenames/src/workspacenames.cpp (+4/-8)
plugins/workspacenames/src/workspacenames.h (+1/-1)
To merge this branch: bzr merge lp:~compiz-linaro-team/compiz/gles2
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Sam Spilsbury Approve
Tim Penhey Pending
Alan Griffiths Pending
jenkins continuous-integration Pending
Review via email: mp+120361@code.launchpad.net

This proposal supersedes a proposal from 2012-08-10.

Commit message

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
* GLShaderCache class added for managing dynamically created shader source
  code.
* GLFragment class removed as fragment programs are no longer used (replaced
  with GLSL programs)
* EGL context setup added
* EglTexture class added to use EGL_image extension instead of
  GLX_EXT_texture_from_pixmap for GLES

Description of the change

WARNING: The Preview diff is incomplete due to Launchpad limitations. Please click Download diff to get the whole thing.

BUGS: Yes, there a quite a few still but I think they're acceptable now. The full list of known bugs in this branch is: https://bugs.launchpad.net/compiz/+bugs?field.tag=gles
and the bugs it causes in Unity:
https://bugs.launchpad.net/unity/+bugs?field.tag=gles

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal
Download full text (17.9 KiB)

The diff is quite large, however it should be possible still to do a code review:

+static bool
+unproject (float winx, float winy, float winz,
+ const GLMatrix &modelview,
+ const GLMatrix &projection,
+ const GLint viewport[4],
+ float *objx, float *objy, float *objz)
+{
+ GLMatrix finalMatrix = projection * modelview;
+ float in[4], out[4];
+
+ if (!finalMatrix.invert ())
+ return false;
+
+ in[0] = winx;
+ in[1] = winy;
+ in[2] = winz;
+ in[3] = 1.0;
+
+ /* Map x and y from window coordinates */
+ in[0] = (in[0] - viewport[0]) / viewport[2];
+ in[1] = (in[1] - viewport[1]) / viewport[3];
+
+ /* Map to range -1 to 1 */
+ in[0] = in[0] * 2 - 1;
+ in[1] = in[1] * 2 - 1;
+ in[2] = in[2] * 2 - 1;
+
+ for (int i = 0; i < 4; i++)
+ {
+ out[i] = in[0] * finalMatrix[i] +
+ in[1] * finalMatrix[4 + i] +
+ in[2] * finalMatrix[8 + i] +
+ in[3] * finalMatrix[12 + i];
+ }
+
+ if (out[3] == 0.0)
+ return false;
+
+ out[0] /= out[3];
+ out[1] /= out[3];
+ out[2] /= out[3];
+
+ *objx = out[0];
+ *objy = out[1];
+ *objz = out[2];
+
+ return true;
+}
+

+static bool
+project (float objx, float objy, float objz,
+ const float modelview[16], const float projection[16],
+ const GLint viewport[4],
+ float *winx, float *winy, float *winz)
+{
+ unsigned int i;
+ float in[4];
+ float out[4];
+
+ in[0] = objx;
+ in[1] = objy;
+ in[2] = objz;
+ in[3] = 1.0;
+
+ for (i = 0; i < 4; i++) {
+ out[i] =
+ in[0] * modelview[i] +
+ in[1] * modelview[4 + i] +
+ in[2] * modelview[8 + i] +
+ in[3] * modelview[12 + i];
+ }
+
+ for (i = 0; i < 4; i++) {
+ in[i] =
+ out[0] * projection[i] +
+ out[1] * projection[4 + i] +
+ out[2] * projection[8 + i] +
+ out[3] * projection[12 + i];
+ }
+
+ if (in[3] == 0.0)
+ return false;
+
+ in[0] /= in[3];
+ in[1] /= in[3];
+ in[2] /= in[3];
+ /* Map x, y and z to range 0-1 */
+ in[0] = in[0] * 0.5 + 0.5;
+ in[1] = in[1] * 0.5 + 0.5;
+ in[2] = in[2] * 0.5 + 0.5;
+
+ /* Map x,y to viewport */
+ in[0] = in[0] * viewport[2] + viewport[0];
+ in[1] = in[1] * viewport[3] + viewport[1];
+
+ *winx = in[0];
+ *winy = in[1];
+ *winz = in[2];
+ return true;
+}

This is re-usable in cube and should be put somewhere. GLMatrix?

=== added file 'cmake/FindOpenGLES2.cmake'
--- cmake/FindOpenGLES2.cmake 1970-01-01 00:00:00 +0000
+++ cmake/FindOpenGLES2.cmake 2012-08-10 08:27:48 +0000
@@ -0,0 +1,51 @@
+# - Try to find OpenGLES
+# Once done this will define
+#
+# OPENGLES2_FOUND - system has OpenGLES
+# OPENGLES2_INCLUDE_DIR - the GLES include directory
+# OPENGLES2_LIBRARY - the GLES library
+# OPENGLES2_LIBRARIES - Link this to use OpenGLES
+#
+
+FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
+ /usr/openwin/share/include
+ /opt/graphics/OpenGL/include /usr/X11R6/include
+ /usr/include
+)
+
+FIND_LIBRARY(OPENGLES2_LIBRARY
+ NAMES GLESv2
+ PATHS /opt/graphics/OpenGL/lib
+ /usr/openwin/lib
+ /usr/shlib /usr/X11R6/lib
+ /usr/lib
+)
+
+FIND_L...

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Thanks Sam. Please try to keep your comments a manageable size. Or make each point in a new comment.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Initially I thought *project should go in GLMatrix too. However then I cleaned up project() and realized it should not be using GLMatrix. It looks like unproject similarly should not be using GLMatrix. Though *project() should probably live somewhere in the opengl plugin, I agree.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Set to work in progress again.

We cannot realistically consider merging this until the incompatibilities with Unity are also fixed:
https://bugs.launchpad.net/unity/+bugs?field.tag=gles

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> 2. It's ugly, bad design. Member data should not be repeatedly passed as
     a parameter. I know there is a limitation in the current wrapping/
     interface design that makes it impossible to access vertexBuffer as a
     member, but that's no excuse for making the code worse than it already
     was.

Can you clarify this please? It didn't come up in the original review and I'm suprised you've put it as a reason for reverting it now.

While passing member data through function arguments is not great, it at least restricts the scope in which that data can be accessed, which is the correct thing to do.

I can understand reverting it in the meantime because unity is difficult to port with ifdefs, but if you're going to do so please consult with the person who wrote it (who happens to live in the same timezone as you, so its really not an issue to do so) for advice on how to handle it rather than taking the unilateral approach of just reverting code.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I was extremely frustrated yesterday and just wanted the code to build. I wasn't feeling like consulting.

Sorry, I thought it did come up in the original review. I was thinking it all along but (as usual) failed to articulate all of my thoughts into words.

It's foreseeable that I will approve the changes again. But not until Unity has been updated to support them first. That would be enclosed in "#if COMPIZ_OPENGL_ABI >= 6", I imagine.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> I was extremely frustrated yesterday and just wanted the code to build. I
> wasn't feeling like consulting.
>
> Sorry, I thought it did come up in the original review. I was thinking it all
> along but (as usual) failed to articulate all of my thoughts into words.
>
> It's foreseeable that I will approve the changes again. But not until Unity
> has been updated to support them first. That would be enclosed in "#if
> COMPIZ_OPENGL_ABI >= 6", I imagine.

Okay, thanks. Noted, will re-propose the unrevert of those changes at an appropriate time.

Cheers,

Sam

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

OK, I /think/ the worst of the Unity regressions are now fixed, or at least with fixes proposed:
https://bugs.launchpad.net/unity/+bugs?field.tag=gles

Let's open this for review again. But be aware I may not action some of the optional cleanups (already mentioned) before this branch lands.

Revision history for this message
Omer Akram (om26er) wrote :

Nice work btw, working through all those regression along the way :-)

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Tested on nouveau, intel and ongoing testing was done on ARM/PowerVR too.

I'm happy enough for this to go in as-is, obviously it isn't yet release quality, however we need to put it in before feature freeze.

Things I would like to see actioned during the rest of the release period.

1. Tests. Tests. Tests
 a. Specifically on the behaviour of GLVertexBuffer, GLFramebufferObject and GLShaderCache
 b. No need for test coverage on areas where the API changed
2. GLVertexBuffer begin/end - that's bad design we need to fix it
3. Need to remove direct access to GLVertexBuffer in GLWindow
4. Sort out the mipmapping story on mesa drivers (add a driver workaround?)
5. project/unproject need to go somewhere common
6. Port/Drop blur
7. Port the rest of mag.
8. compiz-opengl-impl.h
9. Remove spurious ifdefs
10. Remove the options to control rendering features.

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

A couple of new blockers were found/introduced today :(

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Revision history for this message
Daniel van Vugt (vanvugt) :
review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-compiz-core/66/console reported an error when processing this lp:~compiz-linaro-team/compiz/gles2 branch.
Not merging it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmake/CMakeLists.txt'
--- cmake/CMakeLists.txt 2012-07-29 03:23:28 +0000
+++ cmake/CMakeLists.txt 2012-08-22 06:16:22 +0000
@@ -17,6 +17,8 @@
17 plugin_extensions/CompizGenInstallData.cmake)17 plugin_extensions/CompizGenInstallData.cmake)
18list (APPEND _PluginExtensionFiles18list (APPEND _PluginExtensionFiles
19 plugin_extensions/CompizGenInstallImages.cmake)19 plugin_extensions/CompizGenInstallImages.cmake)
20list (APPEND _PluginExtensionFiles
21 plugin_extensions/CompizOpenGLFixups.cmake)
2022
21if (USE_GCONF)23if (USE_GCONF)
22 list (APPEND _files CompizGconf.cmake)24 list (APPEND _files CompizGconf.cmake)
2325
=== modified file 'cmake/CompizCommon.cmake'
--- cmake/CompizCommon.cmake 2012-08-16 03:24:02 +0000
+++ cmake/CompizCommon.cmake 2012-08-22 06:16:22 +0000
@@ -18,6 +18,7 @@
1818
19set (CMAKE_SKIP_RPATH FALSE)19set (CMAKE_SKIP_RPATH FALSE)
2020
21option (BUILD_GLES "Build against GLESv2 instead of GL" OFF)
21option (COMPIZ_BUILD_WITH_RPATH "Leave as ON unless building packages" ON)22option (COMPIZ_BUILD_WITH_RPATH "Leave as ON unless building packages" ON)
22option (COMPIZ_RUN_LDCONFIG "Leave OFF unless you need to run ldconfig after install")23option (COMPIZ_RUN_LDCONFIG "Leave OFF unless you need to run ldconfig after install")
23option (COMPIZ_PACKAGING_ENABLED "Enable to manually set prefix, exec_prefix, libdir, includedir, datadir" OFF)24option (COMPIZ_PACKAGING_ENABLED "Enable to manually set prefix, exec_prefix, libdir, includedir, datadir" OFF)
@@ -70,6 +71,17 @@
70 set(IS_BZR_REPO 0)71 set(IS_BZR_REPO 0)
71endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr)72endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr)
7273
74set (USE_GLES ${BUILD_GLES})
75
76if (USE_GLES)
77 find_package(OpenGLES2)
78
79 if (NOT OPENGLES2_FOUND)
80 set (USE_GLES 0)
81 message (SEND_ERROR "OpenGLESv2 not found")
82 endif (NOT OPENGLES2_FOUND)
83endif (USE_GLES)
84
73# Parse arguments passed to a function into several lists separated by85# Parse arguments passed to a function into several lists separated by
74# upper-case identifiers and options that do not have an associated list e.g.:86# upper-case identifiers and options that do not have an associated list e.g.:
75#87#
7688
=== modified file 'cmake/CompizPlugin.cmake'
--- cmake/CompizPlugin.cmake 2012-05-24 00:55:17 +0000
+++ cmake/CompizPlugin.cmake 2012-08-22 06:16:22 +0000
@@ -257,6 +257,16 @@
257 NO_DEFAULT_PATH257 NO_DEFAULT_PATH
258 )258 )
259259
260 set (COMPIZ_CURRENT_PLUGIN ${plugin})
261 set (COMPIZ_CURRENT_XML_FILE ${_translated_xml})
262
263 # find extension files
264 file (GLOB _extension_files "${COMPIZ_CMAKE_MODULE_PATH}/plugin_extensions/*.cmake")
265
266 foreach (_file ${_extension_files})
267 include (${_file})
268 endforeach ()
269
260 # generate pkgconfig file and install it and the plugin header file270 # generate pkgconfig file and install it and the plugin header file
261 if (_${plugin}_pkg AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin})271 if (_${plugin}_pkg AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin})
262 if ("${PLUGIN_BUILDTYPE}" STREQUAL "local")272 if ("${PLUGIN_BUILDTYPE}" STREQUAL "local")
@@ -269,11 +279,15 @@
269 set (VERSION 0.0.1-git)279 set (VERSION 0.0.1-git)
270 endif (NOT VERSION)280 endif (NOT VERSION)
271281
282 #add CFLAGSADD so pkg-config file has correct flags
283 set (COMPIZ_CFLAGS ${COMPIZ_CFLAGS} ${${_PLUGIN}_CFLAGSADD})
284
272 compiz_configure_file (285 compiz_configure_file (
273 ${_${plugin}_pkg}286 ${_${plugin}_pkg}
274 ${CMAKE_BINARY_DIR}/generated/compiz-${plugin}.pc287 ${CMAKE_BINARY_DIR}/generated/compiz-${plugin}.pc
275 COMPIZ_REQUIRES288 COMPIZ_REQUIRES
276 COMPIZ_CFLAGS289 COMPIZ_CFLAGS
290 PKGCONFIG_LIBS
277 )291 )
278292
279 install (293 install (
@@ -287,16 +301,6 @@
287 endif ()301 endif ()
288 endif ()302 endif ()
289303
290 set (COMPIZ_CURRENT_PLUGIN ${plugin})
291 set (COMPIZ_CURRENT_XML_FILE ${_translated_xml})
292
293 # find extension files
294 file (GLOB _extension_files "${COMPIZ_CMAKE_MODULE_PATH}/plugin_extensions/*.cmake")
295
296 foreach (_file ${_extension_files})
297 include (${_file})
298 endforeach ()
299
300 # find files for build304 # find files for build
301 file (GLOB _h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")305 file (GLOB _h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")
302 file (GLOB _h_ins_files "${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}/*.h")306 file (GLOB _h_ins_files "${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}/*.h")
303307
=== modified file 'cmake/FindCompiz.cmake'
--- cmake/FindCompiz.cmake 2012-07-29 03:23:28 +0000
+++ cmake/FindCompiz.cmake 2012-08-22 06:16:22 +0000
@@ -89,7 +89,7 @@
89 if (COMPIZ_FOUND AND _compiz_def_macro)89 if (COMPIZ_FOUND AND _compiz_def_macro)
90 # everything found. Set module path and include defaults module90 # everything found. Set module path and include defaults module
91 set (COMPIZ_CMAKE_MODULE_PATH ${COMPIZ_PREFIX}/share/compiz/cmake)91 set (COMPIZ_CMAKE_MODULE_PATH ${COMPIZ_PREFIX}/share/compiz/cmake)
92 set (CMAKE_MODULE_PATH ${COMPIZ_CMAKE_MODULE_PATH})92 set (CMAKE_MODULE_PATH ${COMPIZ_CMAKE_MODULE_PATH} ${CMAKE_MODULE_PATH})
93 include (CompizDefaults)93 include (CompizDefaults)
94 else ()94 else ()
95 set (COMPIZ_FOUND 0)95 set (COMPIZ_FOUND 0)
9696
=== added file 'cmake/FindOpenGLES2.cmake'
--- cmake/FindOpenGLES2.cmake 1970-01-01 00:00:00 +0000
+++ cmake/FindOpenGLES2.cmake 2012-08-22 06:16:22 +0000
@@ -0,0 +1,51 @@
1# - Try to find OpenGLES
2# Once done this will define
3#
4# OPENGLES2_FOUND - system has OpenGLES
5# OPENGLES2_INCLUDE_DIR - the GLES include directory
6# OPENGLES2_LIBRARY - the GLES library
7# OPENGLES2_LIBRARIES - Link this to use OpenGLES
8#
9
10FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
11 /usr/openwin/share/include
12 /opt/graphics/OpenGL/include /usr/X11R6/include
13 /usr/include
14)
15
16FIND_LIBRARY(OPENGLES2_LIBRARY
17 NAMES GLESv2
18 PATHS /opt/graphics/OpenGL/lib
19 /usr/openwin/lib
20 /usr/shlib /usr/X11R6/lib
21 /usr/lib
22)
23
24FIND_LIBRARY(OPENGLES2_EGL_LIBRARY
25 NAMES EGL
26 PATHS /usr/shlib /usr/X11R6/lib
27 /usr/lib
28)
29
30# On Unix OpenGL most certainly always requires X11.
31# Feel free to tighten up these conditions if you don't
32# think this is always true.
33# It's not true on OSX.
34
35IF (OPENGLES2_LIBRARY)
36 IF(NOT X11_FOUND)
37 INCLUDE(FindX11)
38 ENDIF(NOT X11_FOUND)
39 IF (X11_FOUND)
40 IF (NOT APPLE)
41 SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES})
42 ENDIF (NOT APPLE)
43 ENDIF (X11_FOUND)
44ENDIF(OPENGLES2_LIBRARY)
45
46SET( OPENGLES2_FOUND "NO" )
47IF(OPENGLES2_LIBRARY AND OPENGLES2_EGL_LIBRARY)
48 SET( OPENGLES2_LIBRARIES ${OPENGLES2_LIBRARY} ${OPENGLES2_EGL_LIBRARY} ${OPENGLES2_LIBRARIES})
49 SET( OPENGLES2_FOUND "YES" )
50ENDIF(OPENGLES2_LIBRARY AND OPENGLES2_EGL_LIBRARY)
51
052
=== modified file 'cmake/base.cmake'
--- cmake/base.cmake 2012-05-24 00:55:17 +0000
+++ cmake/base.cmake 2012-08-22 06:16:22 +0000
@@ -24,6 +24,7 @@
24 compiz_print_configure_header ("Compiz")24 compiz_print_configure_header ("Compiz")
25 compiz_color_message ("\n${_escape}[4mOptional features:${_escape}[0m\n")25 compiz_color_message ("\n${_escape}[4mOptional features:${_escape}[0m\n")
2626
27 compiz_print_result_message ("GLESv2" USE_GLES)
27 compiz_print_result_message ("gtk window decorator" USE_GTK)28 compiz_print_result_message ("gtk window decorator" USE_GTK)
28 compiz_print_result_message ("metacity theme support" USE_METACITY)29 compiz_print_result_message ("metacity theme support" USE_METACITY)
29 compiz_print_result_message ("gconf schemas" USE_GCONF)30 compiz_print_result_message ("gconf schemas" USE_GCONF)
@@ -50,11 +51,13 @@
50 endif ()51 endif ()
51 install (FILES52 install (FILES
52 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCompiz.cmake53 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCompiz.cmake
54 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindOpenGLES2.cmake
53 DESTINATION55 DESTINATION
54 ${CMAKE_INSTALL_PREFIX}/share/cmake-${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}/)56 ${CMAKE_INSTALL_PREFIX}/share/cmake-${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}/)
55 add_custom_target (findcompiz_install57 add_custom_target (findcompiz_install
56 ${CMAKE_COMMAND} -E make_directory ${CMAKE_ROOT}/Modules &&58 ${CMAKE_COMMAND} -E make_directory ${CMAKE_ROOT}/Modules &&
57 ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindCompiz.cmake ${CMAKE_ROOT}/Modules59 ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindCompiz.cmake ${CMAKE_ROOT}/Modules
60 ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindOpenGLES2.cmake ${CMAKE_ROOT}/Modules
58 )61 )
59 find_file (_find_compizconfig FindCompizConfig.cmake PATHS ${CMAKE_ROOT}/Modules ${ARGN})62 find_file (_find_compizconfig FindCompizConfig.cmake PATHS ${CMAKE_ROOT}/Modules ${ARGN})
60 if (NOT _find_compizconfig)63 if (NOT _find_compizconfig)
6164
=== added file 'cmake/plugin_extensions/CompizOpenGLFixups.cmake'
--- cmake/plugin_extensions/CompizOpenGLFixups.cmake 1970-01-01 00:00:00 +0000
+++ cmake/plugin_extensions/CompizOpenGLFixups.cmake 2012-08-22 06:16:22 +0000
@@ -0,0 +1,22 @@
1
2# modify pkg-config libs for opengl based on if we found GLES or not
3if (${COMPIZ_CURRENT_PLUGIN} STREQUAL "opengl")
4 if (USE_GLES)
5 set (PKGCONFIG_LIBS "-lGLESv2 -lEGL")
6 else (USE_GLES)
7 set (PKGCONFIG_LIBS "-lGL")
8 endif (USE_GLES)
9endif (${COMPIZ_CURRENT_PLUGIN} STREQUAL "opengl")
10
11# if plugin is using opengl plugin check for GLES library and set correct define
12if (NOT "${${_PLUGIN}_PLUGINDEPS}" STREQUAL "")
13 string (REGEX MATCH "opengl" opengl_found ${${_PLUGIN}_PLUGINDEPS})
14
15 if (opengl_found STREQUAL "opengl")
16 if (USE_GLES)
17 set (${_PLUGIN}_CFLAGSADD ${${_PLUGIN}_CFLAGSADD} " -DUSE_GLES")
18 string (REPLACE ";" " " ${_PLUGIN}_CFLAGSADD ${${_PLUGIN}_CFLAGSADD})
19 endif (USE_GLES)
20 endif (opengl_found STREQUAL "opengl")
21endif (NOT "${${_PLUGIN}_PLUGINDEPS}" STREQUAL "")
22
023
=== modified file 'include/core/wrapsystem.h'
--- include/core/wrapsystem.h 2012-05-14 16:55:59 +0000
+++ include/core/wrapsystem.h 2012-08-22 06:16:22 +0000
@@ -52,6 +52,10 @@
52 } \52 } \
53 enum { func ## Index = num };53 enum { func ## Index = num };
5454
55// For compatability ignore num and forward
56#define WRAPABLE_HND_FUNC(num, func, ...) \
57 WRAPABLE_HND_FUNCTN(func, __VA_ARGS__)
58
55// New macro that doesn't need magic number59// New macro that doesn't need magic number
56#define WRAPABLE_HND_FUNCTN(func, ...) \60#define WRAPABLE_HND_FUNCTN(func, ...) \
57{ \61{ \
@@ -69,6 +73,10 @@
69 mCurrFunction[num] = curr; \73 mCurrFunction[num] = curr; \
70}74}
7175
76// For compatability ignore num and forward
77#define WRAPABLE_HND_FUNC_RETURN(num, rtype, func, ...) \
78 WRAPABLE_HND_FUNCTN_RETURN(rtype, func, __VA_ARGS__)
79
72// New macro that doesn't need magic number80// New macro that doesn't need magic number
73#define WRAPABLE_HND_FUNCTN_RETURN(rtype, func, ...) \81#define WRAPABLE_HND_FUNCTN_RETURN(rtype, func, ...) \
74{ \82{ \
7583
=== modified file 'plugins/CMakeLists.txt'
--- plugins/CMakeLists.txt 2012-06-24 09:00:27 +0000
+++ plugins/CMakeLists.txt 2012-08-22 06:16:22 +0000
@@ -25,4 +25,34 @@
25 ${CMAKE_CURRENT_SOURCE_DIR}/../logmessage/include25 ${CMAKE_CURRENT_SOURCE_DIR}/../logmessage/include
26)26)
2727
28# temporarily disable plugins that aren't ported yed
29set (COMPIZ_DISABLE_PLUGIN_ANIMATIONADDON ON)
30set (COMPIZ_DISABLE_PLUGIN_BICUBIC ON)
31set (COMPIZ_DISABLE_PLUGIN_BLUR ON)
32set (COMPIZ_DISABLE_PLUGIN_COLORFILTER ON)
33set (COMPIZ_DISABLE_PLUGIN_CUBEADDON ON)
34set (COMPIZ_DISABLE_PLUGIN_GEARS ON)
35set (COMPIZ_DISABLE_PLUGIN_GROUP ON)
36set (COMPIZ_DISABLE_PLUGIN_LOGINOUT ON)
37set (COMPIZ_DISABLE_PLUGIN_REFLEX ON)
38set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON)
39set (COMPIZ_DISABLE_PLUGIN_STACKSWITCH ON)
40set (COMPIZ_DISABLE_PLUGIN_WALLPAPER ON)
41set (COMPIZ_DISABLE_PLUGIN_TRIP ON)
42
43# disable plugins which won't work on ES2 builds
44if (BUILD_GLES)
45
46 set (COMPIZ_DISABLE_PLUGIN_TD ON)
47 set (COMPIZ_DISABLE_PLUGIN_COLORFILTER ON)
48 set (COMPIZ_DISABLE_PLUGIN_MBLUR ON)
49 set (COMPIZ_DISABLE_PLUGIN_BENCH ON)
50 set (COMPIZ_DISABLE_PLUGIN_FIREPAINT ON)
51 set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON)
52 set (COMPIZ_DISABLE_PLUGIN_WIDGET ON)
53 set (COMPIZ_DISABLE_PLUGIN_SHOWMOUSE ON)
54 set (COMPIZ_DISABLE_PLUGIN_SPLASH ON)
55
56endif (BUILD_GLES)
57
28compiz_add_plugins_in_folder (${CMAKE_CURRENT_SOURCE_DIR})58compiz_add_plugins_in_folder (${CMAKE_CURRENT_SOURCE_DIR})
2959
=== modified file 'plugins/animation/CMakeLists.txt'
--- plugins/animation/CMakeLists.txt 2012-05-16 17:40:41 +0000
+++ plugins/animation/CMakeLists.txt 2012-08-22 06:16:22 +0000
@@ -1,7 +1,5 @@
1find_package (Compiz REQUIRED)1find_package (Compiz REQUIRED)
2include (CompizPlugin)2include (CompizPlugin)
3include (FindOpenGL)3
44compiz_plugin (animation PLUGINDEPS composite opengl)
5if (OPENGL_GLU_FOUND)5
6 compiz_plugin (animation PLUGINDEPS composite opengl LIBRARIES ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
7endif (OPENGL_GLU_FOUND)
86
=== modified file 'plugins/animation/include/animation/animation.h'
--- plugins/animation/include/animation/animation.h 2012-08-16 09:47:15 +0000
+++ plugins/animation/include/animation/animation.h 2012-08-22 06:16:22 +0000
@@ -3,8 +3,8 @@
33
4#define ANIMATION_ABI 200912054#define ANIMATION_ABI 20091205
55
6#include <core/core.h>
6#include <core/pluginclasshandler.h>7#include <core/pluginclasshandler.h>
7#include <opengl/fragment.h>
88
9typedef enum9typedef enum
10{10{
1111
=== modified file 'plugins/animation/include/animation/animeffect.h'
--- plugins/animation/include/animation/animeffect.h 2012-08-20 14:24:34 +0000
+++ plugins/animation/include/animation/animeffect.h 2012-08-22 06:16:22 +0000
@@ -88,7 +88,7 @@
88 88
89 int mOverrideProgressDir; ///< 0: default dir, 1: forward, 2: backward89 int mOverrideProgressDir; ///< 0: default dir, 1: forward, 2: backward
90 90
91 GLFragment::Attrib mCurPaintAttrib;91 GLWindowPaintAttrib mCurPaintAttrib;
92 GLushort mStoredOpacity;92 GLushort mStoredOpacity;
93 WindowEvent mCurWindowEvent;93 WindowEvent mCurWindowEvent;
94 bool mInitialized; ///< whether the animation is initialized (in preparePaint)94 bool mInitialized; ///< whether the animation is initialized (in preparePaint)
@@ -195,7 +195,7 @@
195 virtual ExtensionPluginInfo *getExtensionPluginInfo ();195 virtual ExtensionPluginInfo *getExtensionPluginInfo ();
196196
197 void drawTexture (GLTexture *texture,197 void drawTexture (GLTexture *texture,
198 GLFragment::Attrib &attrib,198 const GLWindowPaintAttrib &attrib,
199 unsigned int mask);199 unsigned int mask);
200200
201 // Utility methods201 // Utility methods
@@ -221,7 +221,7 @@
221 GLMatrix &transform);221 GLMatrix &transform);
222 void setInitialized () { mInitialized = true; }222 void setInitialized () { mInitialized = true; }
223 inline bool initialized () { return mInitialized; }223 inline bool initialized () { return mInitialized; }
224 inline void setCurPaintAttrib (GLFragment::Attrib &newAttrib)224 inline void setCurPaintAttrib (const GLWindowPaintAttrib &newAttrib)
225 { mCurPaintAttrib = newAttrib; }225 { mCurPaintAttrib = newAttrib; }
226};226};
227#endif227#endif
228228
=== modified file 'plugins/animation/include/animation/grid.h'
--- plugins/animation/include/animation/grid.h 2012-04-10 06:13:37 +0000
+++ plugins/animation/include/animation/grid.h 2012-08-22 06:16:22 +0000
@@ -78,8 +78,6 @@
78 /// ( http://www.r3.nu/~cass/qcoord/ )78 /// ( http://www.r3.nu/~cass/qcoord/ )
79 bool mUseQTexCoord;79 bool mUseQTexCoord;
8080
81 GLWindow::Geometry mGeometry; ///< geometry for grid mesh
82
83 virtual bool using3D () { return false; }81 virtual bool using3D () { return false; }
8482
85 virtual bool requiresTransformedWindow () const { return true; }83 virtual bool requiresTransformedWindow () const { return true; }
8684
=== modified file 'plugins/animation/src/animation.cpp'
--- plugins/animation/src/animation.cpp 2012-08-20 14:24:34 +0000
+++ plugins/animation/src/animation.cpp 2012-08-22 06:16:22 +0000
@@ -26,6 +26,10 @@
26 * Particle system added by : (C) 2006 Dennis Kasprzyk26 * Particle system added by : (C) 2006 Dennis Kasprzyk
27 * E-mail : onestone@beryl-project.org27 * E-mail : onestone@beryl-project.org
28 *28 *
29 * Ported to GLES by : Travis Watkins
30 * (C) 2011 Linaro Limited
31 * E-mail : travis.watkins@linaro.org
32 *
29 * This program is free software; you can redistribute it and/or33 * This program is free software; you can redistribute it and/or
30 * modify it under the terms of the GNU General Public License34 * modify it under the terms of the GNU General Public License
31 * as published by the Free Software Foundation; either version 235 * as published by the Free Software Foundation; either version 2
@@ -80,8 +84,9 @@
80 *84 *
81 */85 */
8286
83#include <GL/glu.h>
84#include <core/atoms.h>87#include <core/atoms.h>
88#include <core/core.h>
89#include <opengl/opengl.h>
85#include <sys/time.h>90#include <sys/time.h>
86#include <assert.h>91#include <assert.h>
87#include "private.h"92#include "private.h"
@@ -807,6 +812,58 @@
807 coordsTransformed[GLVector::y]);812 coordsTransformed[GLVector::y]);
808}813}
809814
815static bool
816project (float objx, float objy, float objz,
817 const float modelview[16], const float projection[16],
818 const GLint viewport[4],
819 float *winx, float *winy, float *winz)
820{
821 unsigned int i;
822 float in[4];
823 float out[4];
824
825 in[0] = objx;
826 in[1] = objy;
827 in[2] = objz;
828 in[3] = 1.0;
829
830 for (i = 0; i < 4; i++) {
831 out[i] =
832 in[0] * modelview[i] +
833 in[1] * modelview[4 + i] +
834 in[2] * modelview[8 + i] +
835 in[3] * modelview[12 + i];
836 }
837
838 for (i = 0; i < 4; i++) {
839 in[i] =
840 out[0] * projection[i] +
841 out[1] * projection[4 + i] +
842 out[2] * projection[8 + i] +
843 out[3] * projection[12 + i];
844 }
845
846 if (in[3] == 0.0)
847 return false;
848
849 in[0] /= in[3];
850 in[1] /= in[3];
851 in[2] /= in[3];
852 /* Map x, y and z to range 0-1 */
853 in[0] = in[0] * 0.5 + 0.5;
854 in[1] = in[1] * 0.5 + 0.5;
855 in[2] = in[2] * 0.5 + 0.5;
856
857 /* Map x,y to viewport */
858 in[0] = in[0] * viewport[2] + viewport[0];
859 in[1] = in[1] * viewport[3] + viewport[1];
860
861 *winx = in[0];
862 *winy = in[1];
863 *winz = in[2];
864 return true;
865}
866
810/// Either points or objects should be non-0.867/// Either points or objects should be non-0.
811bool868bool
812AnimWindow::expandBBWithPoints3DTransform (CompOutput &output,869AnimWindow::expandBBWithPoints3DTransform (CompOutput &output,
@@ -815,27 +872,24 @@
815 GridAnim::GridModel::GridObject *objects,872 GridAnim::GridModel::GridObject *objects,
816 unsigned int nPoints)873 unsigned int nPoints)
817{874{
818 GLdouble dModel[16];875 GLfloat x, y, z;
819 GLdouble dProjection[16];
820 GLdouble x, y, z;
821 for (unsigned int i = 0; i < 16; i++)
822 {
823 dModel[i] = transform[i];
824 dProjection[i] = GLScreen::get (::screen)->projectionMatrix ()[i];
825 }
826 GLint viewport[4] =876 GLint viewport[4] =
827 {output.region ()->extents.x1,877 {output.region ()->extents.x1,
828 output.region ()->extents.y1,878 output.region ()->extents.y1,
829 output.width (),879 output.width (),
830 output.height ()};880 output.height ()};
831881
882 const float *projection =
883 GLScreen::get (::screen)->projectionMatrix ()->getMatrix ();
884
832 if (points) // use points885 if (points) // use points
833 {886 {
834 for (; nPoints; nPoints--, points += 3)887 for (; nPoints; nPoints--, points += 3)
835 {888 {
836 if (!gluProject (points[0], points[1], points[2],889 if (!project (points[0], points[1], points[2],
837 dModel, dProjection, viewport,890 transform.getMatrix (), projection,
838 &x, &y, &z))891 viewport,
892 &x, &y, &z))
839 return false;893 return false;
840894
841 expandBBWithPoint (x + 0.5, (::screen->height () - y) + 0.5);895 expandBBWithPoint (x + 0.5, (::screen->height () - y) + 0.5);
@@ -846,11 +900,12 @@
846 GridAnim::GridModel::GridObject *object = objects;900 GridAnim::GridModel::GridObject *object = objects;
847 for (; nPoints; nPoints--, object++)901 for (; nPoints; nPoints--, object++)
848 {902 {
849 if (!gluProject (object->position ().x (),903 if (!project (object->position ().x (),
850 object->position ().y (),904 object->position ().y (),
851 object->position ().z (),905 object->position ().z (),
852 dModel, dProjection, viewport,906 transform.getMatrix (), projection,
853 &x, &y, &z))907 viewport,
908 &x, &y, &z))
854 return false;909 return false;
855910
856 expandBBWithPoint (x + 0.5, (::screen->height () - y) + 0.5);911 expandBBWithPoint (x + 0.5, (::screen->height () - y) + 0.5);
@@ -906,15 +961,10 @@
906void961void
907PrivateAnimWindow::damageThisAndLastStepRegion ()962PrivateAnimWindow::damageThisAndLastStepRegion ()
908{963{
909#ifdef COMPIZ_OPENGL_SWAPBUFFERS_ALWAYS // when LP: #901097 is fixed
910 // Find union of the regions for this step and last step964 // Find union of the regions for this step and last step
911 CompRegion totalRegionToDamage (mStepRegion + mLastStepRegion);965 CompRegion totalRegionToDamage (mStepRegion + mLastStepRegion);
912966
913 mPAScreen->cScreen->damageRegion (totalRegionToDamage);967 mPAScreen->cScreen->damageRegion (totalRegionToDamage);
914#else
915 // Ugly fix for LP: #930192 while LP: #901097 is not resolved
916 mPAScreen->cScreen->damageScreen ();
917#endif
918}968}
919969
920CompOutput &970CompOutput &
@@ -1435,7 +1485,7 @@
1435{1485{
1436 gWindow->glPaintSetEnabled (this, enabling);1486 gWindow->glPaintSetEnabled (this, enabling);
1437 gWindow->glAddGeometrySetEnabled (this, enabling);1487 gWindow->glAddGeometrySetEnabled (this, enabling);
1438 gWindow->glDrawGeometrySetEnabled (this, enabling);1488 //gWindow->glDrawGeometrySetEnabled (this, enabling);
1439 gWindow->glDrawTextureSetEnabled (this, enabling);1489 gWindow->glDrawTextureSetEnabled (this, enabling);
1440}1490}
14411491
@@ -1509,7 +1559,8 @@
15091559
1510void1560void
1511PrivateAnimWindow::glDrawTexture (GLTexture *texture,1561PrivateAnimWindow::glDrawTexture (GLTexture *texture,
1512 GLFragment::Attrib &attrib,1562 const GLMatrix &transform,
1563 const GLWindowPaintAttrib &attrib,
1513 unsigned int mask)1564 unsigned int mask)
1514{1565{
1515 if (mCurAnimation)1566 if (mCurAnimation)
@@ -1517,9 +1568,10 @@
1517 mCurAnimation->setCurPaintAttrib (attrib);1568 mCurAnimation->setCurPaintAttrib (attrib);
1518 }1569 }
15191570
1520 gWindow->glDrawTexture (texture, attrib, mask);1571 gWindow->glDrawTexture (texture, transform, attrib, mask);
1521}1572}
15221573
1574#if 0 // Not ported yet
1523void1575void
1524PrivateAnimWindow::glDrawGeometry ()1576PrivateAnimWindow::glDrawGeometry ()
1525{1577{
@@ -1533,10 +1585,11 @@
1533 gWindow->glDrawGeometry ();1585 gWindow->glDrawGeometry ();
1534 }1586 }
1535}1587}
1588#endif
15361589
1537void1590void
1538Animation::drawTexture (GLTexture *texture,1591Animation::drawTexture (GLTexture *texture,
1539 GLFragment::Attrib &attrib,1592 const GLWindowPaintAttrib &attrib,
1540 unsigned int mask)1593 unsigned int mask)
1541{1594{
1542 mCurPaintAttrib = attrib;1595 mCurPaintAttrib = attrib;
@@ -1545,7 +1598,9 @@
1545void1598void
1546Animation::drawGeometry ()1599Animation::drawGeometry ()
1547{1600{
1601#if 0 // Not ported yet
1548 mAWindow->priv->gWindow->glDrawGeometry ();1602 mAWindow->priv->gWindow->glDrawGeometry ();
1603#endif
1549}1604}
15501605
1551bool1606bool
@@ -1614,13 +1669,16 @@
16141669
1615 if (mCurAnimation->postPaintWindowUsed ())1670 if (mCurAnimation->postPaintWindowUsed ())
1616 {1671 {
1672#if 0 // Not ported yet
1617 // Transform to make post-paint coincide with the window1673 // Transform to make post-paint coincide with the window
1618 glPushMatrix ();1674 glPushMatrix ();
1619 glLoadMatrixf (wTransform.getMatrix ());1675 glLoadMatrixf (wTransform.getMatrix ());
16201676#endif
1621 mCurAnimation->postPaintWindow ();1677 mCurAnimation->postPaintWindow ();
16221678
1679#if 0 // Not ported yet
1623 glPopMatrix ();1680 glPopMatrix ();
1681#endif
1624 }1682 }
16251683
1626 return status;1684 return status;
16271685
=== modified file 'plugins/animation/src/grid.cpp'
--- plugins/animation/src/grid.cpp 2010-10-23 15:41:33 +0000
+++ plugins/animation/src/grid.cpp 2012-08-22 06:16:22 +0000
@@ -19,6 +19,8 @@
19 * Hexagon tessellator added by : Mike Slegeir19 * Hexagon tessellator added by : Mike Slegeir
20 * E-mail : mikeslegeir@mail.utexas.edu>20 * E-mail : mikeslegeir@mail.utexas.edu>
21 *21 *
22 * Ported to GLVertexBuffer by: Daniel van Vugt <daniel.van.vugt@canonical.com>
23 *
22 * This program is free software; you can redistribute it and/or24 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License25 * modify it under the terms of the GNU General Public License
24 * as published by the Free Software Foundation; either version 226 * as published by the Free Software Foundation; either version 2
@@ -217,34 +219,19 @@
217 unsigned int maxGridWidth,219 unsigned int maxGridWidth,
218 unsigned int maxGridHeight)220 unsigned int maxGridHeight)
219{221{
220 unsigned int nMatrix = matrix.size ();222
221 int nVertices, nIndices;223 GLfloat *v, *vMax;
222 GLushort *i;224 int y1, x2, y2;
223 GLfloat *v;
224 int x1, y1, x2, y2;
225 float winContentsY, winContentsHeight;225 float winContentsY, winContentsHeight;
226 float deformedX, deformedY;226 float deformedX, deformedY;
227 float deformedZ = 0;227 float deformedZ = 0;
228 int nVertX, nVertY;
229 int vSize;228 int vSize;
230 float gridW, gridH;229 float gridW, gridH;
231 bool rect = true;
232 bool notUsing3dCoords = !using3D ();230 bool notUsing3dCoords = !using3D ();
233231
234 if (region.isEmpty ()) // nothing to do232 if (region.isEmpty ()) // nothing to do
235 return;233 return;
236234
237 GLWindow::Geometry &geometry = GLWindow::get (mWindow)->geometry ();
238
239 for (unsigned int it = 0; it < nMatrix; it++)
240 {
241 if (matrix[it].xy != 0.0f || matrix[it].yx != 0.0f)
242 {
243 rect = false;
244 break;
245 }
246 }
247
248 CompRect outRect (mAWindow->savedRectsValid () ?235 CompRect outRect (mAWindow->savedRectsValid () ?
249 mAWindow->savedOutRect () :236 mAWindow->savedOutRect () :
250 mWindow->outputRect ());237 mWindow->outputRect ());
@@ -262,30 +249,15 @@
262 winContentsY = oy + outExtents.top;249 winContentsY = oy + outExtents.top;
263 winContentsHeight = oheight - outExtents.top - outExtents.bottom;250 winContentsHeight = oheight - outExtents.top - outExtents.bottom;
264251
265 geometry.texUnits = (int)nMatrix;252 GLWindow *gWindow = GLWindow::get (mWindow);
266253 GLVertexBuffer *vertexBuffer = gWindow->vertexBuffer ();
267 if (geometry.vCount == 0)254 vSize = vertexBuffer->getVertexStride ();
268 {255
269 // reset256 // Indentation kept to provide a clean diff with the old code, for now...
270 geometry.indexCount = 0;257 {
271 geometry.texCoordSize = 4;258 y1 = outRect.y1 ();
272 }259 x2 = outRect.x2 ();
273 geometry.vertexStride = 3 + geometry.texUnits * geometry.texCoordSize;260 y2 = outRect.y2 ();
274 vSize = geometry.vertexStride;
275
276 nVertices = geometry.vCount;
277 nIndices = geometry.indexCount;
278
279 v = geometry.vertices + (nVertices * vSize);
280 i = geometry.indices + nIndices;
281
282 // For each clip passed to this function
283 foreach (const CompRect &pClip, region.rects ())
284 {
285 x1 = pClip.x1 ();
286 y1 = pClip.y1 ();
287 x2 = pClip.x2 ();
288 y2 = pClip.y2 ();
289261
290 gridW = (float)owidth / (mGridWidth - 1);262 gridW = (float)owidth / (mGridWidth - 1);
291263
@@ -310,64 +282,22 @@
310 else282 else
311 gridH = (float)oheight / (mGridHeight - 1);283 gridH = (float)oheight / (mGridHeight - 1);
312284
313 // nVertX, nVertY: number of vertices for this clip in x and y dimensions285 int oldCount = vertexBuffer->countVertices ();
314 // + 2 to avoid running short of vertices in some cases286 gWindow->glAddGeometry (matrix, region, clip, gridW, gridH);
315 nVertX = ceil ((x2 - x1) / gridW) + 2;287 int newCount = vertexBuffer->countVertices ();
316 nVertY = (gridH ? ceil ((y2 - y1) / gridH) : 0) + 2;288 v = vertexBuffer->getVertices () + (oldCount * vSize);
317289 vMax = vertexBuffer->getVertices () + (newCount * vSize);
318 // Allocate 4 indices for each quad290
319 int newIndexSize = nIndices + ((nVertX - 1) * (nVertY - 1) * 4);
320
321 if (newIndexSize > geometry.indexSize)
322 {
323 if (!geometry.moreIndices (newIndexSize))
324 return;
325
326 i = geometry.indices + nIndices;
327 }
328 // Assign quad vertices to indices
329 for (int jy = 0; jy < nVertY - 1; jy++)
330 {
331 for (int jx = 0; jx < nVertX - 1; jx++)
332 {
333 *i++ = nVertices + nVertX * (2 * jy + 1) + jx;
334 *i++ = nVertices + nVertX * (2 * jy + 1) + jx + 1;
335 *i++ = nVertices + nVertX * 2 * jy + jx + 1;
336 *i++ = nVertices + nVertX * 2 * jy + jx;
337
338 nIndices += 4;
339 }
340 }
341
342 // Allocate vertices
343 int newVertexSize =
344 (nVertices + nVertX * (2 * nVertY - 2)) * vSize;
345 if (newVertexSize > geometry.vertexSize)
346 {
347 if (!geometry.moreVertices (newVertexSize))
348 return;
349
350 v = geometry.vertices + (nVertices * vSize);
351 }
352
353 float rowTexCoordQ = 1;
354 float prevRowCellWidth = 0; // this initial value won't be used
355 float rowCellWidth = 0;
356 int clipRowSize = nVertX * vSize;
357
358 // For each vertex291 // For each vertex
359 float y = y1;292 for (; v < vMax; v += vSize)
360 for (int jy = 0; jy < nVertY; jy++)
361 {293 {
294 float x = v[0];
295 float y = v[1];
362 float topiyFloat;296 float topiyFloat;
363 bool applyOffsets = true;
364297
365 if (y > y2)298 if (y > y2)
366 y = y2;299 y = y2;
367300
368 // Do calculations for y here to avoid repeating
369 // them unnecessarily in the x loop
370
371 if (mCurWindowEvent == WindowEventShade ||301 if (mCurWindowEvent == WindowEventShade ||
372 mCurWindowEvent == WindowEventUnshade)302 mCurWindowEvent == WindowEventUnshade)
373 {303 {
@@ -375,7 +305,6 @@
375 {305 {
376 topiyFloat = (y - oy) / mDecorTopHeight;306 topiyFloat = (y - oy) / mDecorTopHeight;
377 topiyFloat = MIN (topiyFloat, 0.999); // avoid 1.0307 topiyFloat = MIN (topiyFloat, 0.999); // avoid 1.0
378 applyOffsets = false;
379 }308 }
380 else if (y2 > winContentsY + winContentsHeight) // if at bottom309 else if (y2 > winContentsY + winContentsHeight) // if at bottom
381 {310 {
@@ -383,7 +312,6 @@
383 (mDecorBottomHeight ? (y - winContentsY -312 (mDecorBottomHeight ? (y - winContentsY -
384 winContentsHeight) /313 winContentsHeight) /
385 mDecorBottomHeight : 0);314 mDecorBottomHeight : 0);
386 applyOffsets = false;
387 }315 }
388 else // in window contents (only in Y coords)316 else // in window contents (only in Y coords)
389 {317 {
@@ -406,8 +334,7 @@
406334
407 // End of calculations for y335 // End of calculations for y
408336
409 float x = x1;337 // Indentation kept to provide a clean diff with the old code...
410 for (int jx = 0; jx < nVertX; jx++)
411 {338 {
412 if (x > x2)339 if (x > x2)
413 x = x2;340 x = x2;
@@ -461,179 +388,19 @@
461 deformedY = inyRest * hor1y + iny * hor2y;388 deformedY = inyRest * hor1y + iny * hor2y;
462 deformedZ = inyRest * hor1z + iny * hor2z;389 deformedZ = inyRest * hor1z + iny * hor2z;
463390
464 // Texture coordinates (s, t, r, q)
465
466 if (mUseQTexCoord)
467 {
468 if (jx == 1)
469 rowCellWidth = deformedX - v[-3];
470
471 // do only once per row for all rows except row 0
472 if (jy > 0 && jx == 1)
473 {
474 rowTexCoordQ = (rowCellWidth / prevRowCellWidth);
475
476 for (unsigned int it = 0; it < nMatrix; it++, v += 4)
477 {
478 // update first column
479 // (since we didn't know rowTexCoordQ before)
480 v[-vSize] *= rowTexCoordQ; // multiply s & t by q
481 v[-vSize + 1] *= rowTexCoordQ;
482 v[-vSize + 3] = rowTexCoordQ; // copy q
483 }
484 v -= nMatrix * 4;
485 }
486 }
487
488 // Loop for each texture element
489 // (4 texture coordinates for each one)
490 for (unsigned int it = 0; it < nMatrix; it++, v += 4)
491 {
492 float offsetY = 0;
493
494 if (rect)
495 {
496 if (applyOffsets && y < y2)
497 offsetY = objToTopLeft->mOffsetTexCoordForQuadAfter.y ();
498 v[0] = COMP_TEX_COORD_X (matrix[it], x); // s
499 v[1] = COMP_TEX_COORD_Y (matrix[it], y + offsetY); // t
500 }
501 else
502 {
503 if (applyOffsets && y < y2)
504 // FIXME:
505 // The correct y offset below produces wrong
506 // texture coordinates for some reason.
507 offsetY = 0;
508 // offsetY = objToTopLeft->offsetTexCoordForQuadAfter.y;
509 v[0] = COMP_TEX_COORD_XY (matrix[it], x, y + offsetY); // s
510 v[1] = COMP_TEX_COORD_YX (matrix[it], x, y + offsetY); // t
511 }
512 v[2] = 0; // r
513
514 if (0 < jy && jy < nVertY - 1)
515 {
516 // copy s, t, r to duplicate row
517 memcpy (v + clipRowSize, v, 3 * sizeof (GLfloat));
518 v[3 + clipRowSize] = 1; // q
519 }
520
521 if (applyOffsets &&
522 objToTopLeft->mOffsetTexCoordForQuadBefore.y () != 0)
523 {
524 // After copying to next row, update texture y coord
525 // by following object's offset
526 offsetY = objToTopLeft->mOffsetTexCoordForQuadBefore.y ();
527 if (rect)
528 {
529 v[1] = COMP_TEX_COORD_Y (matrix[it], y + offsetY);
530 }
531 else
532 {
533 v[0] = COMP_TEX_COORD_XY (matrix[it],
534 x, y + offsetY);
535 v[1] = COMP_TEX_COORD_YX (matrix[it],
536 x, y + offsetY);
537 }
538 }
539 if (mUseQTexCoord)
540 {
541 v[3] = rowTexCoordQ; // q
542
543 if (jx > 0) // since column 0 is updated when jx == 1
544 {
545 // multiply s & t by q
546 v[0] *= rowTexCoordQ;
547 v[1] *= rowTexCoordQ;
548 }
549 }
550 else
551 {
552 v[3] = 1; // q
553 }
554 }
555
556 v[0] = deformedX;391 v[0] = deformedX;
557 v[1] = deformedY;392 v[1] = deformedY;
558 v[2] = deformedZ;393 v[2] = deformedZ;
559394
560 // Copy vertex coordinates to duplicate row
561 if (0 < jy && jy < nVertY - 1)
562 memcpy (v + clipRowSize, v, 3 * sizeof (GLfloat));
563
564 nVertices++;
565
566 // increment x properly (so that coordinates fall on grid intersections)
567 x = rightix * gridW + ox;
568
569 v += 3; // move on to next vertex
570 }
571 if (mUseQTexCoord)
572 prevRowCellWidth = rowCellWidth;
573
574 if (0 < jy && jy < nVertY - 1)
575 {
576 v += clipRowSize; // skip the duplicate row
577 nVertices += nVertX;
578 }
579 // increment y properly (so that coordinates fall on grid intersections)
580 if (mCurWindowEvent == WindowEventShade ||
581 mCurWindowEvent == WindowEventUnshade)
582 {
583 y += gridH;
584 }
585 else
586 {
587 y = bottomiy * gridH + oy;
588 }395 }
589 }396 }
590 }397 }
591 geometry.vCount = nVertices;
592 geometry.indexCount = nIndices;
593}398}
594399
595void400void
596GridAnim::drawGeometry ()401GridAnim::drawGeometry ()
597{402{
598 GLWindow::Geometry &geometry = GLWindow::get (mWindow)->geometry ();403 // Deprecated
599
600 int texUnit = geometry.texUnits;
601 int currentTexUnit = 0;
602 int stride = geometry.vertexStride;
603 GLfloat *vertices = geometry.vertices + (stride - 3);
604
605 stride *= (int) sizeof (GLfloat);
606
607 glVertexPointer (3, GL_FLOAT, stride, vertices);
608
609 while (texUnit--)
610 {
611 if (texUnit != currentTexUnit)
612 {
613 (*GL::clientActiveTexture) ((GLenum)(GL_TEXTURE0_ARB + texUnit));
614 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
615 currentTexUnit = texUnit;
616 }
617 vertices -= geometry.texCoordSize;
618 glTexCoordPointer (geometry.texCoordSize,
619 GL_FLOAT, stride, vertices);
620 }
621
622 glDrawElements (GL_QUADS, geometry.indexCount,
623 GL_UNSIGNED_SHORT, geometry.indices);
624
625 // disable all texture coordinate arrays except 0
626 texUnit = geometry.texUnits;
627 if (texUnit > 1)
628 {
629 while (--texUnit)
630 {
631 (*GL::clientActiveTexture) ((GLenum)(GL_TEXTURE0_ARB + texUnit));
632 glDisableClientState (GL_TEXTURE_COORD_ARRAY);
633 }
634
635 (*GL::clientActiveTexture) (GL_TEXTURE0_ARB);
636 }
637}404}
638405
639GridTransformAnim::GridTransformAnim (CompWindow *w,406GridTransformAnim::GridTransformAnim (CompWindow *w,
640407
=== modified file 'plugins/animation/src/private.h'
--- plugins/animation/src/private.h 2012-05-27 04:32:55 +0000
+++ plugins/animation/src/private.h 2012-08-22 06:16:22 +0000
@@ -407,9 +407,9 @@
407 void glAddGeometry (const GLTexture::MatrixList &,407 void glAddGeometry (const GLTexture::MatrixList &,
408 const CompRegion &, const CompRegion &,408 const CompRegion &, const CompRegion &,
409 unsigned int = MAXSHORT, unsigned int = MAXSHORT);409 unsigned int = MAXSHORT, unsigned int = MAXSHORT);
410 void glDrawTexture (GLTexture *texture, GLFragment::Attrib &,410 void glDrawTexture (GLTexture *texture, const GLMatrix &,
411 unsigned int);411 const GLWindowPaintAttrib &, unsigned int);
412 void glDrawGeometry ();412 //void glDrawGeometry ();
413};413};
414414
415class RollUpAnim :415class RollUpAnim :
416416
=== modified file 'plugins/annotate/src/annotate.cpp'
--- plugins/annotate/src/annotate.cpp 2012-07-30 09:20:41 +0000
+++ plugins/annotate/src/annotate.cpp 2012-08-22 06:16:22 +0000
@@ -629,11 +629,14 @@
629629
630 if (status)630 if (status)
631 {631 {
632 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
633 GLfloat vertexData[18];
634 GLfloat textureData[12];
632 CompRect rect;635 CompRect rect;
633 GLMatrix sTransform = transform;636 GLMatrix sTransform = transform;
634 int numRect;637 int numRect;
635 int pos = 0;638 int pos = 0;
636 float vectorX, vectorY, offset;639 float offset;
637 int angle;640 int angle;
638641
639 offset = optionGetStrokeWidth () / 2;642 offset = optionGetStrokeWidth () / 2;
@@ -641,10 +644,6 @@
641 /* This replaced prepareXCoords (s, output, -DEFAULT_Z_CAMERA) */644 /* This replaced prepareXCoords (s, output, -DEFAULT_Z_CAMERA) */
642 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);645 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
643646
644 glPushMatrix ();
645 glLoadMatrixf (sTransform.getMatrix ());
646
647 glDisableClientState (GL_TEXTURE_COORD_ARRAY);
648 glEnable (GL_BLEND);647 glEnable (GL_BLEND);
649648
650 if (content && !region.isEmpty ())649 if (content && !region.isEmpty ())
@@ -656,34 +655,66 @@
656655
657 tex->enable (GLTexture::Fast);656 tex->enable (GLTexture::Fast);
658657
659 glBegin (GL_QUADS);658 streamingBuffer->begin (GL_TRIANGLES);
660659
661 while (numRect--)660 while (numRect--)
662 {661 {
663 glTexCoord2f (662 GLfloat tx1 = COMP_TEX_COORD_X (tex->matrix (),
664 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x1 ()),663 rect.at (pos).x1 ());
665 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y2 ()));664 GLfloat tx2 = COMP_TEX_COORD_X (tex->matrix (),
666 glVertex2i (rect.at (pos).x1 (), rect.at (pos).y2 ());665 rect.at (pos).x2 ());
667666 GLfloat ty1 = COMP_TEX_COORD_Y (tex->matrix (),
668 glTexCoord2f (667 rect.at (pos).y1 ());
669 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x2 ()),668 GLfloat ty2 = COMP_TEX_COORD_Y (tex->matrix (),
670 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y2 ()));669 rect.at (pos).y2 ());
671 glVertex2i (rect.at (pos).x2 (), rect.at (pos).y2 ());670
672671 vertexData[0] = rect.at (pos).x1 ();
673 glTexCoord2f (672 vertexData[1] = rect.at (pos).y1 ();
674 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x2 ()),673 vertexData[2] = 0.0f;
675 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y1 ()));674 vertexData[3] = rect.at (pos).x1 ();
676 glVertex2i (rect.at (pos).x2 (), rect.at (pos).y1 ());675 vertexData[4] = rect.at (pos).y2 ();
677676 vertexData[5] = 0.0f;
678 glTexCoord2f (677 vertexData[6] = rect.at (pos).x2 ();
679 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x1 ()),678 vertexData[7] = rect.at (pos).y1 ();
680 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y1 ()));679 vertexData[8] = 0.0f;
681 glVertex2i (rect.at (pos).x1 (), rect.at (pos).y1 ());680 vertexData[9] = rect.at (pos).x1 ();
682681 vertexData[10] = rect.at (pos).y2 ();
682 vertexData[11] = 0.0f;
683
684 vertexData[12] = rect.at (pos).x2 ();
685 vertexData[13] = rect.at (pos).y2 ();
686 vertexData[14] = 0.0f;
687
688 vertexData[15] = rect.at (pos).x2 ();
689 vertexData[16] = rect.at (pos).y1 ();
690 vertexData[17] = 0.0f;
691
692 textureData[0] = tx1;
693 textureData[1] = ty1;
694
695 textureData[2] = tx1;
696 textureData[3] = ty2;
697
698 textureData[4] = tx2;
699 textureData[5] = ty1;
700
701 textureData[6] = tx1;
702 textureData[7] = ty2;
703
704 textureData[8] = tx2;
705 textureData[9] = ty2;
706
707 textureData[10] = tx2;
708 textureData[11] = ty1;
709
710 streamingBuffer->addVertices (6, vertexData);
711 streamingBuffer->addTexCoords (0, 6, textureData);
683 pos++;712 pos++;
684 }713 }
685714
686 glEnd ();715 streamingBuffer->end ();
716 streamingBuffer->render (sTransform);
717
687 tex->disable ();718 tex->disable ();
688 }719 }
689 }720 }
@@ -691,85 +722,132 @@
691 switch (drawMode)722 switch (drawMode)
692 {723 {
693 case LineMode:724 case LineMode:
694 glColor4usv (optionGetStrokeColor ());
695 glLineWidth (optionGetStrokeWidth ());725 glLineWidth (optionGetStrokeWidth ());
696 glBegin (GL_LINES);726
697 glVertex2i (initialPointerX, initialPointerY);727 streamingBuffer->begin (GL_LINES);
698 glVertex2i (lineVector.x (), lineVector.y ());728
699 glEnd ();729 streamingBuffer->addColors (1, optionGetStrokeColor ());
730
731 vertexData[0] = initialPointerX;
732 vertexData[1] = initialPointerY;
733 vertexData[2] = 0.0f;
734 vertexData[3] = lineVector.x ();
735 vertexData[4] = lineVector.y ();
736 vertexData[5] = 0.0f;
737 streamingBuffer->addVertices (2, vertexData);
738
739 streamingBuffer->end ();
740 streamingBuffer->render (sTransform);
700 break;741 break;
701742
702 case RectangleMode:743 case RectangleMode:
744 vertexData[0] = rectangle.x1 ();
745 vertexData[1] = rectangle.y1 ();
746 vertexData[2] = 0.0f;
747 vertexData[3] = rectangle.x1 ();
748 vertexData[4] = rectangle.y2 ();
749 vertexData[5] = 0.0f;
750 vertexData[6] = rectangle.x2 ();
751 vertexData[7] = rectangle.y1 ();
752 vertexData[8] = 0.0f;
753 vertexData[9] = rectangle.x2 ();
754 vertexData[10] = rectangle.y2 ();
755 vertexData[11] = 0.0f;
756
703 /* fill rectangle */757 /* fill rectangle */
704 glColor4usv (optionGetFillColor ());758 streamingBuffer->begin (GL_TRIANGLE_STRIP);
705 glRecti (rectangle.x1 (), rectangle.y2 (),759
706 rectangle.x2 (), rectangle.y1 ());760 streamingBuffer->addColors (1, optionGetFillColor ());
761 streamingBuffer->addVertices (4, vertexData);
762
763 streamingBuffer->end ();
764 streamingBuffer->render (sTransform);
707765
708 /* draw rectangle outline */766 /* draw rectangle outline */
709 glColor4usv (optionGetStrokeColor ());767/* streamingBuffer->begin ();
710 glRecti (rectangle.x1 () - offset, rectangle.y2 (),768
711 rectangle.x1 () + offset, rectangle.y1 ());769 streamingBuffer->addColors (1, optionGetStrokeColor ());
770
771 vertexData[0] = rectangle.x1 () - offset;
772 vertexData[3] = rectangle.x1 () - offset;
773 streamingBuffer->addVertices (4, vertexData);
774
712 glRecti (rectangle.x2 () - offset, rectangle.y2 (),775 glRecti (rectangle.x2 () - offset, rectangle.y2 (),
713 rectangle.x2 () + offset, rectangle.y1 ());776 rectangle.x2 () + offset, rectangle.y1 ());
714 glRecti (rectangle.x1 () - offset, rectangle.y1 () + offset,777 glRecti (rectangle.x1 () - offset, rectangle.y1 () + offset,
715 rectangle.x2 () + offset, rectangle.y1 () - offset);778 rectangle.x2 () + offset, rectangle.y1 () - offset);
716 glRecti (rectangle.x1 () - offset, rectangle.y2 () + offset,779 glRecti (rectangle.x1 () - offset, rectangle.y2 () + offset,
717 rectangle.x2 () + offset, rectangle.y2 () - offset);780 rectangle.x2 () + offset, rectangle.y2 () - offset);*/
718 break;781 break;
719782
720 case EllipseMode:783 case EllipseMode:
721 /* fill ellipse */784 /* fill ellipse */
722 glColor4usv (optionGetFillColor ());785 streamingBuffer->begin (GL_TRIANGLE_FAN);
723786
724 glBegin (GL_TRIANGLE_FAN);787 streamingBuffer->addColors (1, optionGetFillColor ());
725 glVertex2d (ellipse.center.x (), ellipse.center.y ());788
789 vertexData[0] = ellipse.center.x ();
790 vertexData[1] = ellipse.center.y ();
791 vertexData[2] = 0.0f;
792 streamingBuffer->addVertices (1, vertexData);
793
726 for (angle = 0; angle <= 360; angle += 1)794 for (angle = 0; angle <= 360; angle += 1)
727 {795 {
728 vectorX = ellipse.center.x () +796 vertexData[0] = ellipse.center.x () +
729 (ellipse.radiusX * sinf (angle * DEG2RAD));797 (ellipse.radiusX * sinf (angle * DEG2RAD));
730 vectorY = ellipse.center.y () +798 vertexData[1] = ellipse.center.y () +
731 (ellipse.radiusY * cosf (angle * DEG2RAD));799 (ellipse.radiusY * cosf (angle * DEG2RAD));
732 glVertex2d (vectorX, vectorY);800 streamingBuffer->addVertices (1, vertexData);
733 }801 }
734 glVertex2d (ellipse.center.x (), ellipse.center.y () +802
735 ellipse.radiusY);803 vertexData[0] = ellipse.center.x ();
736 glEnd();804 vertexData[1] = ellipse.center.y () + ellipse.radiusY;
805 streamingBuffer->addVertices (1, vertexData);
806
807 streamingBuffer->end ();
808 streamingBuffer->render (sTransform);
737809
738 /* draw ellipse outline */810 /* draw ellipse outline */
739 glColor4usv (optionGetStrokeColor ());
740 glLineWidth (optionGetStrokeWidth ());811 glLineWidth (optionGetStrokeWidth ());
741812
742 glBegin (GL_TRIANGLE_STRIP);813 streamingBuffer->begin (GL_TRIANGLE_STRIP);
743 glVertex2d (ellipse.center.x (), ellipse.center.y () +814
744 ellipse.radiusY - offset);815 streamingBuffer->addColors (1, optionGetStrokeColor ());
816
817
818 vertexData[0] = ellipse.center.x ();
819 vertexData[1] = ellipse.center.y () + ellipse.radiusY - offset;
820 vertexData[2] = 0.0f;
821 streamingBuffer->addVertices (1, vertexData);
822
745 for (angle = 360; angle >= 0; angle -= 1)823 for (angle = 360; angle >= 0; angle -= 1)
746 {824 {
747 vectorX = ellipse.center.x () + ((ellipse.radiusX -825 vertexData[0] = ellipse.center.x () + ((ellipse.radiusX -
748 offset) * sinf (angle * DEG2RAD));826 offset) * sinf (angle * DEG2RAD));
749 vectorY = ellipse.center.y () + ((ellipse.radiusY -827 vertexData[1] = ellipse.center.y () + ((ellipse.radiusY -
750 offset) * cosf (angle * DEG2RAD));828 offset) * cosf (angle * DEG2RAD));
751 glVertex2d (vectorX, vectorY);829 vertexData[2] = 0.0f;
752 vectorX = ellipse.center.x () + ((ellipse.radiusX +830 vertexData[3] = ellipse.center.x () + ((ellipse.radiusX +
753 offset) * sinf (angle * DEG2RAD));831 offset) * sinf (angle * DEG2RAD));
754 vectorY = ellipse.center.y () + ((ellipse.radiusY +832 vertexData[4] = ellipse.center.y () + ((ellipse.radiusY +
755 offset) * cosf (angle * DEG2RAD));833 offset) * cosf (angle * DEG2RAD));
756 glVertex2d (vectorX, vectorY);834 vertexData[5] = 0.0f;
835 streamingBuffer->addVertices (2, vertexData);
757 }836 }
758 glVertex2d (ellipse.center.x (), ellipse.center.y () +837
759 ellipse.radiusY + offset);838 vertexData[0] = ellipse.center.x ();
760 glEnd();839 vertexData[1] = ellipse.center.y () + ellipse.radiusY + offset;
840 streamingBuffer->addVertices (1, vertexData);
841
842 streamingBuffer->end ();
843 streamingBuffer->render (sTransform);
761 break;844 break;
762845
763 default:846 default:
764 break;847 break;
765 }848 }
766849
767 /* clean up */
768 glColor4usv (defaultColor);
769 glDisable (GL_BLEND);850 glDisable (GL_BLEND);
770 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
771
772 glPopMatrix ();
773 }851 }
774852
775 return status;853 return status;
776854
=== modified file 'plugins/blur/CMakeLists.txt'
--- plugins/blur/CMakeLists.txt 2011-01-24 06:28:52 +0000
+++ plugins/blur/CMakeLists.txt 2012-08-22 06:16:22 +0000
@@ -2,15 +2,15 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5find_package (OpenGL)5#find_package (OpenGL)
66
7if (OPENGL_GLU_FOUND)7#if (OPENGL_GLU_FOUND)
8 compiz_plugin(blur PLUGINDEPS composite opengl LIBRARIES decoration ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})8# compiz_plugin(blur PLUGINDEPS composite opengl LIBRARIES decoration ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
99
10 if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)10# if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)
11 set_target_properties (11# set_target_properties (
12 blur PROPERTIES12# blur PROPERTIES
13 INSTALL_RPATH "${COMPIZ_LIBDIR}"13# INSTALL_RPATH "${COMPIZ_LIBDIR}"
14 )14# )
15 endif (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)15# endif (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)
16endif ()16#endif ()
1717
=== modified file 'plugins/clone/src/clone.cpp'
--- plugins/clone/src/clone.cpp 2012-07-30 09:20:41 +0000
+++ plugins/clone/src/clone.cpp 2012-08-22 06:16:22 +0000
@@ -295,9 +295,6 @@
295 0.0f);295 0.0f);
296 sTransform.scale (zoomX, zoomY, 1.0f);296 sTransform.scale (zoomX, zoomY, 1.0f);
297297
298 glPushMatrix ();
299 glLoadMatrixf (sTransform.getMatrix ());
300
301 filter = gScreen->textureFilter ();298 filter = gScreen->textureFilter ();
302299
303 if (offset == 0.0f)300 if (offset == 0.0f)
@@ -325,8 +322,6 @@
325 }322 }
326323
327 gScreen->setTextureFilter (filter);324 gScreen->setTextureFilter (filter);
328
329 glPopMatrix ();
330 }325 }
331326
332 return status;327 return status;
333328
=== modified file 'plugins/compiztoolbox/src/compiztoolbox.cpp'
--- plugins/compiztoolbox/src/compiztoolbox.cpp 2012-07-30 11:20:17 +0000
+++ plugins/compiztoolbox/src/compiztoolbox.cpp 2012-08-22 06:16:22 +0000
@@ -465,9 +465,7 @@
465 sAttrib.yTranslate = wy - g.y () +465 sAttrib.yTranslate = wy - g.y () +
466 window->border ().top * sAttrib.yScale;466 window->border ().top * sAttrib.yScale;
467467
468 GLFragment::Attrib fragment (sAttrib);468 if (window->alpha () || sAttrib.opacity != OPAQUE)
469
470 if (window->alpha () || fragment.getOpacity () != OPAQUE)
471 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;469 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
472470
473 wTransform.translate (g.x (), g.y (), 0.0f);471 wTransform.translate (g.x (), g.y (), 0.0f);
@@ -476,9 +474,6 @@
476 sAttrib.yTranslate / sAttrib.yScale - g.y (),474 sAttrib.yTranslate / sAttrib.yScale - g.y (),
477 0.0f);475 0.0f);
478476
479 glPushMatrix ();
480 glLoadMatrixf (wTransform.getMatrix ());
481
482 filter = gScreen->textureFilter ();477 filter = gScreen->textureFilter ();
483478
484 if (baseScreen->getMipmap ())479 if (baseScreen->getMipmap ())
@@ -488,13 +483,11 @@
488 very ugly but necessary until the vertex stage has been made483 very ugly but necessary until the vertex stage has been made
489 fully pluggable. */484 fully pluggable. */
490 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);485 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);
491 gWindow->glDraw (wTransform, fragment, infiniteRegion, mask);486 gWindow->glDraw (wTransform, sAttrib, infiniteRegion, mask);
492 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);487 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);
493488
494 gScreen->setTextureFilter (filter);489 gScreen->setTextureFilter (filter);
495490
496 glPopMatrix ();
497
498 if (iconMode != HideIcon)491 if (iconMode != HideIcon)
499 {492 {
500 icon = gWindow->getIcon (MAX_ICON_SIZE, MAX_ICON_SIZE);493 icon = gWindow->getIcon (MAX_ICON_SIZE, MAX_ICON_SIZE);
@@ -535,15 +528,14 @@
535 sAttrib.xTranslate = wx - g.x ();528 sAttrib.xTranslate = wx - g.x ();
536 sAttrib.yTranslate = wy - g.y ();529 sAttrib.yTranslate = wy - g.y ();
537530
538 gWindow->geometry ().reset ();531 gWindow->vertexBuffer ()->begin ();
539532
540 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);533 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);
541 gWindow->glAddGeometry (matrix, iconReg, infiniteRegion);534 gWindow->glAddGeometry (matrix, iconReg, infiniteRegion);
542 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);535 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);
543536
544 if (gWindow->geometry ().vCount)537 if (gWindow->vertexBuffer ()->end ())
545 {538 {
546 GLFragment::Attrib fragment (sAttrib);
547 GLMatrix wTransform (transform);539 GLMatrix wTransform (transform);
548540
549 wTransform.translate (g.x (), g.y (), 0.0f);541 wTransform.translate (g.x (), g.y (), 0.0f);
@@ -552,12 +544,7 @@
552 sAttrib.yTranslate / sAttrib.yScale - g.y (),544 sAttrib.yTranslate / sAttrib.yScale - g.y (),
553 0.0f);545 0.0f);
554546
555 glPushMatrix ();547 gWindow->glDrawTexture (icon, wTransform, sAttrib, mask);
556 glLoadMatrixf (wTransform.getMatrix ());
557
558 gWindow->glDrawTexture (icon, fragment, mask);
559
560 glPopMatrix ();
561 }548 }
562 }549 }
563}550}
564551
=== modified file 'plugins/copytex/src/copytex.cpp'
--- plugins/copytex/src/copytex.cpp 2012-06-24 10:12:15 +0000
+++ plugins/copytex/src/copytex.cpp 2012-08-22 06:16:22 +0000
@@ -112,6 +112,14 @@
112 GLenum target;112 GLenum target;
113 GLTexture::Matrix matrix = _identity_matrix;113 GLTexture::Matrix matrix = _identity_matrix;
114114
115#ifdef USE_GLES
116 target = GL_TEXTURE_2D;
117 matrix.xx = 1.0f / dim.width ();
118 matrix.yy = 1.0f / dim.height ();
119 matrix.x0 = -dim.x () * matrix.xx;
120 matrix.y0 = -dim.y () * matrix.yy;
121#else
122
115 if (GL::textureNonPowerOfTwo ||123 if (GL::textureNonPowerOfTwo ||
116 (POWER_OF_TWO (dim.width ()) && POWER_OF_TWO (dim.height ())))124 (POWER_OF_TWO (dim.width ()) && POWER_OF_TWO (dim.height ())))
117 {125 {
@@ -129,6 +137,7 @@
129 matrix.x0 = -dim.x ();137 matrix.x0 = -dim.x ();
130 matrix.y0 = -dim.y ();138 matrix.y0 = -dim.y ();
131 }139 }
140#endif
132141
133 setData (target, matrix, false);142 setData (target, matrix, false);
134 setGeometry (dim.x1 (), dim.y1 (), dim.x2 () - dim.x1 (), dim.y2 () - dim.y1 ());143 setGeometry (dim.x1 (), dim.y1 (), dim.x2 () - dim.x1 (), dim.y2 () - dim.y1 ());
135144
=== modified file 'plugins/cube/include/cube/cube.h'
--- plugins/cube/include/cube/cube.h 2012-01-18 16:26:45 +0000
+++ plugins/cube/include/cube/cube.h 2012-08-22 06:16:22 +0000
@@ -62,15 +62,18 @@
62 virtual void cubePaintTop (const GLScreenPaintAttrib &sAttrib,62 virtual void cubePaintTop (const GLScreenPaintAttrib &sAttrib,
63 const GLMatrix &transform,63 const GLMatrix &transform,
64 CompOutput *output,64 CompOutput *output,
65 int size);65 int size,
66 const GLVector &normal);
66 virtual void cubePaintBottom (const GLScreenPaintAttrib &sAttrib,67 virtual void cubePaintBottom (const GLScreenPaintAttrib &sAttrib,
67 const GLMatrix &transform,68 const GLMatrix &transform,
68 CompOutput *output,69 CompOutput *output,
69 int size);70 int size,
71 const GLVector &normal);
70 virtual void cubePaintInside (const GLScreenPaintAttrib &sAttrib,72 virtual void cubePaintInside (const GLScreenPaintAttrib &sAttrib,
71 const GLMatrix &transform,73 const GLMatrix &transform,
72 CompOutput *output,74 CompOutput *output,
73 int size);75 int size,
76 const GLVector &normal);
74 virtual bool cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib,77 virtual bool cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib,
75 const GLMatrix &transform,78 const GLMatrix &transform,
76 CompOutput *output,79 CompOutput *output,
@@ -120,13 +123,13 @@
120 float, float);123 float, float);
121 WRAPABLE_HND (2, CubeScreenInterface, void, cubePaintTop,124 WRAPABLE_HND (2, CubeScreenInterface, void, cubePaintTop,
122 const GLScreenPaintAttrib &, const GLMatrix &,125 const GLScreenPaintAttrib &, const GLMatrix &,
123 CompOutput *, int);126 CompOutput *, int, const GLVector &);
124 WRAPABLE_HND (3, CubeScreenInterface, void, cubePaintBottom,127 WRAPABLE_HND (3, CubeScreenInterface, void, cubePaintBottom,
125 const GLScreenPaintAttrib &, const GLMatrix &,128 const GLScreenPaintAttrib &, const GLMatrix &,
126 CompOutput *, int);129 CompOutput *, int, const GLVector &);
127 WRAPABLE_HND (4, CubeScreenInterface, void, cubePaintInside,130 WRAPABLE_HND (4, CubeScreenInterface, void, cubePaintInside,
128 const GLScreenPaintAttrib &, const GLMatrix &,131 const GLScreenPaintAttrib &, const GLMatrix &,
129 CompOutput *, int);132 CompOutput *, int, const GLVector &);
130 WRAPABLE_HND (5, CubeScreenInterface, bool, cubeCheckOrientation,133 WRAPABLE_HND (5, CubeScreenInterface, bool, cubeCheckOrientation,
131 const GLScreenPaintAttrib &, const GLMatrix &,134 const GLScreenPaintAttrib &, const GLMatrix &,
132 CompOutput *, std::vector<GLVector> &);135 CompOutput *, std::vector<GLVector> &);
133136
=== modified file 'plugins/cube/src/cube.cpp'
--- plugins/cube/src/cube.cpp 2012-01-16 09:50:28 +0000
+++ plugins/cube/src/cube.cpp 2012-08-22 06:16:22 +0000
@@ -55,22 +55,25 @@
55CubeScreenInterface::cubePaintTop (const GLScreenPaintAttrib &sAttrib,55CubeScreenInterface::cubePaintTop (const GLScreenPaintAttrib &sAttrib,
56 const GLMatrix &transform,56 const GLMatrix &transform,
57 CompOutput *output,57 CompOutput *output,
58 int size)58 int size,
59 WRAPABLE_DEF (cubePaintTop, sAttrib, transform, output, size)59 const GLVector &normal)
60 WRAPABLE_DEF (cubePaintTop, sAttrib, transform, output, size, normal)
60 61
61void62void
62CubeScreenInterface::cubePaintBottom (const GLScreenPaintAttrib &sAttrib,63CubeScreenInterface::cubePaintBottom (const GLScreenPaintAttrib &sAttrib,
63 const GLMatrix &transform,64 const GLMatrix &transform,
64 CompOutput *output,65 CompOutput *output,
65 int size)66 int size,
66 WRAPABLE_DEF (cubePaintBottom, sAttrib, transform, output, size)67 const GLVector &normal)
68 WRAPABLE_DEF (cubePaintBottom, sAttrib, transform, output, size, normal)
6769
68void70void
69CubeScreenInterface::cubePaintInside (const GLScreenPaintAttrib &sAttrib,71CubeScreenInterface::cubePaintInside (const GLScreenPaintAttrib &sAttrib,
70 const GLMatrix &transform,72 const GLMatrix &transform,
71 CompOutput *output,73 CompOutput *output,
72 int size)74 int size,
73 WRAPABLE_DEF (cubePaintInside, sAttrib, transform, output, size)75 const GLVector &normal)
76 WRAPABLE_DEF (cubePaintInside, sAttrib, transform, output, size, normal)
7477
75bool78bool
76CubeScreenInterface::cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib,79CubeScreenInterface::cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib,
@@ -433,6 +436,7 @@
433 }436 }
434}437}
435438
439#ifndef USE_GLES
436static bool440static bool
437fillCircleTable (GLfloat **ppSint,441fillCircleTable (GLfloat **ppSint,
438 GLfloat **ppCost,442 GLfloat **ppCost,
@@ -467,10 +471,12 @@
467471
468 return true;472 return true;
469}473}
474#endif
470475
471void476void
472PrivateCubeScreen::updateSkydomeList (GLfloat fRadius)477PrivateCubeScreen::updateSkydomeList (GLfloat fRadius)
473{478{
479#ifndef USE_GLES
474 GLint iSlices = 128;480 GLint iSlices = 128;
475 GLint iStacks = 64;481 GLint iStacks = 64;
476 GLfloat afTexCoordX[4];482 GLfloat afTexCoordX[4];
@@ -532,6 +538,7 @@
532 afTexCoordX[3] = 1.0f;538 afTexCoordX[3] = 1.0f;
533 afTexCoordY[3] = 1.0f;539 afTexCoordY[3] = 1.0f;
534540
541
535 if (!mSkyListId)542 if (!mSkyListId)
536 mSkyListId = glGenLists (1);543 mSkyListId = glGenLists (1);
537544
@@ -616,6 +623,8 @@
616 free (cost1);623 free (cost1);
617 free (sint2);624 free (sint2);
618 free (cost2);625 free (cost2);
626
627#endif
619}628}
620629
621bool630bool
@@ -818,7 +827,7 @@
818{827{
819 WRAPABLE_HND_FUNCTN_RETURN (bool, cubeCheckOrientation, sAttrib, transform, output, points)828 WRAPABLE_HND_FUNCTN_RETURN (bool, cubeCheckOrientation, sAttrib, transform, output, points)
820 GLMatrix sTransform = transform;829 GLMatrix sTransform = transform;
821 GLMatrix mvp, pm (priv->gScreen->projectionMatrix ());830 GLMatrix mvp, pm (priv->gScreen->projectionMatrix ()->getMatrix ());
822 GLVector pntA, pntB, pntC;831 GLVector pntA, pntB, pntC;
823 GLVector vecA, vecB, ortho;832 GLVector vecA, vecB, ortho;
824 bool rv = false;833 bool rv = false;
@@ -1063,7 +1072,7 @@
1063 if (priv->mSky.size () > 0)1072 if (priv->mSky.size () > 0)
1064 {1073 {
1065 priv->gScreen->setLighting (false);1074 priv->gScreen->setLighting (false);
10661075#ifndef USE_GLES
1067 glPushMatrix ();1076 glPushMatrix ();
10681077
1069 if (priv->optionGetSkydomeAnimated () &&1078 if (priv->optionGetSkydomeAnimated () &&
@@ -1079,6 +1088,7 @@
10791088
1080 glCallList (priv->mSkyListId);1089 glCallList (priv->mSkyListId);
1081 glPopMatrix ();1090 glPopMatrix ();
1091#endif
1082 }1092 }
1083 else1093 else
1084 {1094 {
@@ -1090,9 +1100,10 @@
1090CubeScreen::cubePaintTop (const GLScreenPaintAttrib &sAttrib,1100CubeScreen::cubePaintTop (const GLScreenPaintAttrib &sAttrib,
1091 const GLMatrix &transform,1101 const GLMatrix &transform,
1092 CompOutput *output,1102 CompOutput *output,
1093 int size)1103 int size,
1104 const GLVector &normal)
1094{1105{
1095 WRAPABLE_HND_FUNCTN (cubePaintTop, sAttrib, transform, output, size)1106 WRAPABLE_HND_FUNCTN (cubePaintTop, sAttrib, transform, output, size, normal)
10961107
1097 GLScreenPaintAttrib sa = sAttrib;1108 GLScreenPaintAttrib sa = sAttrib;
1098 GLMatrix sTransform = transform;1109 GLMatrix sTransform = transform;
@@ -1105,51 +1116,49 @@
1105 color = priv->optionGetTopColor ();1116 color = priv->optionGetTopColor ();
1106 opacity = priv->mDesktopOpacity * color[3] / 0xffff;1117 opacity = priv->mDesktopOpacity * color[3] / 0xffff;
11071118
1108 glColor4us (color[0] * opacity / 0xffff,1119 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
1109 color[1] * opacity / 0xffff,1120 std::vector <GLushort> colorData;
1110 color[2] * opacity / 0xffff,
1111 opacity);
11121121
1113 glPushMatrix ();1122 colorData.push_back (color[0] * opacity / 0xffff);
1123 colorData.push_back (color[1] * opacity / 0xffff);
1124 colorData.push_back (color[2] * opacity / 0xffff);
1125 colorData.push_back (opacity);
11141126
1115 sa.yRotate += (360.0f / size) * (priv->mXRotations + 1);1127 sa.yRotate += (360.0f / size) * (priv->mXRotations + 1);
11161128
1117 priv->gScreen->glApplyTransform (sa, output, &sTransform);1129 priv->gScreen->glApplyTransform (sa, output, &sTransform);
11181130
1119 glLoadMatrixf (sTransform.getMatrix ());1131 sTransform.translate (priv->mOutputXOffset, -priv->mOutputYOffset, 0.0f);
1120 glTranslatef (priv->mOutputXOffset, -priv->mOutputYOffset, 0.0f);1132 sTransform.scale (priv->mOutputXScale, priv->mOutputYScale, 1.0f);
1121 glScalef (priv->mOutputXScale, priv->mOutputYScale, 1.0f);
11221133
1123 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))1134 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))
1124 {1135 {
1136#ifndef USE_GLES
1125 priv->gScreen->setTexEnvMode (GL_MODULATE);1137 priv->gScreen->setTexEnvMode (GL_MODULATE);
1126 glEnable (GL_BLEND);1138#endif
1127 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);1139 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1128 }1140 }
11291141
1130 glVertexPointer (3, GL_FLOAT, 0, priv->mVertices);1142 bool withTexture = priv->mInvert == 1 && size == 4 && priv->mTexture.size ();
11311143
1132 if (priv->mInvert == 1 && size == 4 && priv->mTexture.size ())1144 if (withTexture)
1133 {
1134 priv->mTexture[0]->enable (GLTexture::Good);1145 priv->mTexture[0]->enable (GLTexture::Good);
1135 glTexCoordPointer (2, GL_FLOAT, 0, priv->mTc);1146
1136 glDrawArrays (GL_TRIANGLE_FAN, 0, priv->mNVertices >> 1);1147 streamingBuffer->begin (GL_TRIANGLE_FAN);
1148 streamingBuffer->addColors (1, &(colorData[0]));
1149 streamingBuffer->addVertices (priv->mNVertices >> 1, priv->mVertices);
1150 streamingBuffer->addNormals (1, const_cast <GLfloat *> (&normal[0]));
1151
1152 if (withTexture)
1153 streamingBuffer->addTexCoords (0, 2, priv->mTc);
1154
1155 streamingBuffer->end ();
1156 streamingBuffer->render (sTransform);
1157
1158 if (withTexture)
1137 priv->mTexture[0]->disable ();1159 priv->mTexture[0]->disable ();
1138 glDisableClientState (GL_TEXTURE_COORD_ARRAY);
1139 }
1140 else
1141 {
1142 glDisableClientState (GL_TEXTURE_COORD_ARRAY);
1143 glDrawArrays (GL_TRIANGLE_FAN, 0, priv->mNVertices >> 1);
1144 }
1145
1146 glPopMatrix ();
1147
1148 glColor4usv (defaultColor);
1149 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
11501160
1151 priv->gScreen->setTexEnvMode (GL_REPLACE);1161 priv->gScreen->setTexEnvMode (GL_REPLACE);
1152 glDisable (GL_BLEND);
1153 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);1162 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1154}1163}
11551164
@@ -1157,9 +1166,10 @@
1157CubeScreen::cubePaintBottom (const GLScreenPaintAttrib &sAttrib,1166CubeScreen::cubePaintBottom (const GLScreenPaintAttrib &sAttrib,
1158 const GLMatrix &transform,1167 const GLMatrix &transform,
1159 CompOutput *output,1168 CompOutput *output,
1160 int size)1169 int size,
1170 const GLVector &normal)
1161{1171{
1162 WRAPABLE_HND_FUNCTN (cubePaintBottom, sAttrib, transform, output, size)1172 WRAPABLE_HND_FUNCTN (cubePaintBottom, sAttrib, transform, output, size, normal)
11631173
1164 GLScreenPaintAttrib sa = sAttrib;1174 GLScreenPaintAttrib sa = sAttrib;
1165 GLMatrix sTransform = transform;1175 GLMatrix sTransform = transform;
@@ -1172,41 +1182,40 @@
1172 color = priv->optionGetBottomColor ();1182 color = priv->optionGetBottomColor ();
1173 opacity = priv->mDesktopOpacity * color[3] / 0xffff;1183 opacity = priv->mDesktopOpacity * color[3] / 0xffff;
11741184
1175 glColor4us (color[0] * opacity / 0xffff,1185 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
1176 color[1] * opacity / 0xffff,1186 std::vector <GLushort> colorData;
1177 color[2] * opacity / 0xffff,
1178 opacity);
11791187
1180 glPushMatrix ();1188 colorData.push_back (color[0] * opacity / 0xffff);
1189 colorData.push_back (color[1] * opacity / 0xffff);
1190 colorData.push_back (color[2] * opacity / 0xffff);
1191 colorData.push_back (opacity);
11811192
1182 sa.yRotate += (360.0f / size) * (priv->mXRotations + 1);1193 sa.yRotate += (360.0f / size) * (priv->mXRotations + 1);
11831194
1184 priv->gScreen->glApplyTransform (sa, output, &sTransform);1195 priv->gScreen->glApplyTransform (sa, output, &sTransform);
11851196
1186 glLoadMatrixf (sTransform.getMatrix ());1197 sTransform.translate (priv->mOutputXOffset, -priv->mOutputYOffset, 0.0f);
1187 glTranslatef (priv->mOutputXOffset, -priv->mOutputYOffset, 0.0f);1198 sTransform.scale (priv->mOutputXScale, priv->mOutputYScale, 1.0f);
1188 glScalef (priv->mOutputXScale, priv->mOutputYScale, 1.0f);
11891199
1190 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))1200 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))
1191 {1201 {
1202#ifndef USE_GLES
1192 priv->gScreen->setTexEnvMode (GL_MODULATE);1203 priv->gScreen->setTexEnvMode (GL_MODULATE);
1193 glEnable (GL_BLEND);1204#endif
1194 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);1205 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1195 }1206 }
11961207
1197 glVertexPointer (3, GL_FLOAT, 0, priv->mVertices);1208 streamingBuffer->begin (GL_TRIANGLE_FAN);
11981209 streamingBuffer->addColors (1, &(colorData[0]));
11991210 streamingBuffer->addVertices (priv->mNVertices, priv->mVertices);
1200 glDisableClientState (GL_TEXTURE_COORD_ARRAY);1211 streamingBuffer->addNormals (1, const_cast <GLfloat *> (&normal[0]));
1201 glDrawArrays (GL_TRIANGLE_FAN, priv->mNVertices >> 1, priv->mNVertices >> 1);1212 streamingBuffer->setVertexOffset (priv->mNVertices >> 1);
12021213 streamingBuffer->setMaxVertices (priv->mNVertices >> 1);
1203 glPopMatrix ();1214
12041215 streamingBuffer->end ();
1205 glColor4usv (defaultColor);1216 streamingBuffer->render (sTransform);
1206 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
12071217
1208 priv->gScreen->setTexEnvMode (GL_REPLACE);1218 priv->gScreen->setTexEnvMode (GL_REPLACE);
1209 glDisable (GL_BLEND);
1210 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);1219 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1211}1220}
12121221
@@ -1214,9 +1223,10 @@
1214CubeScreen::cubePaintInside (const GLScreenPaintAttrib &sAttrib,1223CubeScreen::cubePaintInside (const GLScreenPaintAttrib &sAttrib,
1215 const GLMatrix &transform,1224 const GLMatrix &transform,
1216 CompOutput *output,1225 CompOutput *output,
1217 int size)1226 int size,
1227 const GLVector &normal)
1218{1228{
1219 WRAPABLE_HND_FUNCTN (cubePaintInside, sAttrib, transform, output, size)1229 WRAPABLE_HND_FUNCTN (cubePaintInside, sAttrib, transform, output, size, normal)
1220}1230}
12211231
1222void 1232void
@@ -1226,6 +1236,8 @@
1226{1236{
1227 if (mRotationState != CubeScreen::RotationNone)1237 if (mRotationState != CubeScreen::RotationNone)
1228 {1238 {
1239 /* FIXME: No output clipping in OpenGL|ES yet */
1240 #ifndef USE_GLES
1229 glPushMatrix ();1241 glPushMatrix ();
1230 glLoadMatrixf (transform.getMatrix ());1242 glLoadMatrixf (transform.getMatrix ());
1231 glTranslatef (mOutputXOffset, -mOutputYOffset, 0.0f);1243 glTranslatef (mOutputXOffset, -mOutputYOffset, 0.0f);
@@ -1260,6 +1272,7 @@
1260 glEnable (GL_CLIP_PLANE3);1272 glEnable (GL_CLIP_PLANE3);
12611273
1262 glPopMatrix ();1274 glPopMatrix ();
1275 #endif
1263 }1276 }
1264 else1277 else
1265 gScreen->glEnableOutputClipping (transform, region, output);1278 gScreen->glEnableOutputClipping (transform, region, output);
@@ -1447,38 +1460,28 @@
14471460
1448 if (topDir && bottomDir)1461 if (topDir && bottomDir)
1449 {1462 {
1450 glNormal3f (0.0f, -1.0f, 0.0f);
1451 if (allCaps)1463 if (allCaps)
1452 {1464 {
1453 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize);1465 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize, GLVector (0.0f, -1.0f, 0.0f, 1.0f));
1454 glNormal3f (0.0f, 0.0f, -1.0f);1466 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize, GLVector (0.0f, 0.0f, -1.0f, 1.0f));
1455 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize);
1456 glNormal3f (0.0f, -1.0f, 0.0f);
1457 }1467 }
1458 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize);1468 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize, GLVector (0.0f, -1.0f, 0.0f, 1.0f));
1459 }1469 }
1460 else if (!topDir && !bottomDir)1470 else if (!topDir && !bottomDir)
1461 {1471 {
1462 glNormal3f (0.0f, 1.0f, 0.0f);
1463 if (allCaps)1472 if (allCaps)
1464 {1473 {
1465 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize);1474 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize, GLVector (0.0f, 1.0f, 0.0f, 1.0f));
1466 glNormal3f (0.0f, 0.0f, -1.0f);1475 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize, GLVector (0.0f, 0.0f, -1.0f, 1.0f));
1467 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize);
1468 glNormal3f (0.0f, 1.0f, 0.0f);
1469 }1476 }
1470 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize);1477 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize, GLVector (0.0f, -1.0f, 0.0f, 1.0f));
1471 }1478 }
1472 else if (allCaps)1479 else if (allCaps)
1473 {1480 {
1474 glNormal3f (0.0f, 1.0f, 0.0f);1481 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize, GLVector (0.0f, 1.0f, 0.0f, 1.0f));
1475 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize);1482 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize, GLVector (0.0f, -1.0f, 0.0f, 1.0f));
1476 glNormal3f (0.0f, -1.0f, 0.0f);1483 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize, GLVector (0.0f, 0.0f, -1.0f, 1.0f));
1477 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize);
1478 glNormal3f (0.0f, 0.0f, -1.0f);
1479 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize);
1480 }1484 }
1481 glNormal3f (0.0f, 0.0f, -1.0f);
1482 }1485 }
14831486
1484 if (wasCulled)1487 if (wasCulled)
@@ -1705,8 +1708,10 @@
1705 if (mVertices)1708 if (mVertices)
1706 free (mVertices);1709 free (mVertices);
17071710
1711#ifndef USE_GLES
1708 if (mSkyListId)1712 if (mSkyListId)
1709 glDeleteLists (mSkyListId, 1);1713 glDeleteLists (mSkyListId, 1);
1714#endif
1710}1715}
17111716
17121717
17131718
=== modified file 'plugins/decor/src/decor.cpp'
--- plugins/decor/src/decor.cpp 2012-08-03 10:12:25 +0000
+++ plugins/decor/src/decor.cpp 2012-08-22 06:16:22 +0000
@@ -153,14 +153,12 @@
153153
154bool154bool
155DecorWindow::glDraw (const GLMatrix &transform,155DecorWindow::glDraw (const GLMatrix &transform,
156 GLFragment::Attrib &attrib,156 const GLWindowPaintAttrib &attrib,
157 const CompRegion &region,157 const CompRegion &region,
158 unsigned int mask)158 unsigned int mask)
159{159{
160 bool status;160 bool status;
161161
162 status = gWindow->glDraw (transform, attrib, region, mask);
163
164 /* Don't render dock decorations (shadows) on just any old window */162 /* Don't render dock decorations (shadows) on just any old window */
165 if (!(window->type () & CompWindowTypeDockMask))163 if (!(window->type () & CompWindowTypeDockMask))
166 {164 {
@@ -188,25 +186,26 @@
188 */186 */
189 pmask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;187 pmask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;
190188
191 if (d->gWindow->glPaint (d->gWindow->paintAttrib (),189 const GLWindowPaintAttrib &pAttrib (d->gWindow->paintAttrib ());
190
191 if (d->gWindow->glPaint (pAttrib,
192 transform,192 transform,
193 region,193 region,
194 pmask))194 pmask))
195 {195 d->glDecorate (transform, pAttrib, region, mask);
196 GLFragment::Attrib fa (d->gWindow->paintAttrib ());
197 d->glDecorate (transform, fa, region, mask);
198 }
199 }196 }
200 }197 }
201 }198 }
202 }199 }
203200
201 status = gWindow->glDraw (transform, attrib, region, mask);
202
204 return status;203 return status;
205}204}
206205
207void206void
208DecorWindow::glDecorate (const GLMatrix &transform,207DecorWindow::glDecorate (const GLMatrix &transform,
209 GLFragment::Attrib &attrib,208 const GLWindowPaintAttrib &attrib,
210 const CompRegion &region,209 const CompRegion &region,
211 unsigned int mask)210 unsigned int mask)
212{211{
@@ -217,6 +216,7 @@
217 GLTexture::MatrixList ml (1);216 GLTexture::MatrixList ml (1);
218 mask |= PAINT_WINDOW_BLEND_MASK;217 mask |= PAINT_WINDOW_BLEND_MASK;
219218
219 gWindow->vertexBuffer ()->begin ();
220 const CompRegion *preg = NULL;220 const CompRegion *preg = NULL;
221221
222 if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |222 if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |
@@ -228,11 +228,8 @@
228 {228 {
229 tmpRegion = mOutputRegion;229 tmpRegion = mOutputRegion;
230 tmpRegion &= region;230 tmpRegion &= region;
231231 tmpRegion &= shadowRegion;
232 if (tmpRegion.isEmpty ())232 preg = &tmpRegion;
233 preg = &region;
234 else
235 preg = &shadowRegion;
236 }233 }
237 else234 else
238 preg = &region;235 preg = &region;
@@ -243,8 +240,6 @@
243240
244 const CompRegion &reg (*preg);241 const CompRegion &reg (*preg);
245242
246 gWindow->geometry ().reset ();
247
248 if (updateMatrix)243 if (updateMatrix)
249 updateDecorationScale ();244 updateDecorationScale ();
250245
@@ -263,9 +258,13 @@
263 }258 }
264 }259 }
265260
266 if (gWindow->geometry ().vCount)261 if (gWindow->vertexBuffer ()->end ())
267 gWindow->glDrawTexture (wd->decor->texture->textures[0],262 {
263 glEnable (GL_BLEND);
264 gWindow->glDrawTexture (wd->decor->texture->textures[0], transform,
268 attrib, mask);265 attrib, mask);
266 glDisable (GL_BLEND);
267 }
269 }268 }
270 else if (wd && wd->decor->type == WINDOW_DECORATION_TYPE_WINDOW)269 else if (wd && wd->decor->type == WINDOW_DECORATION_TYPE_WINDOW)
271 {270 {
@@ -279,14 +278,16 @@
279 if (updateMatrix)278 if (updateMatrix)
280 updateDecorationScale ();279 updateDecorationScale ();
281280
281 glEnable (GL_BLEND);
282
282 if (gWindow->textures ().size () == 1)283 if (gWindow->textures ().size () == 1)
283 {284 {
284 ml[0] = gWindow->matrices ()[0];285 ml[0] = gWindow->matrices ()[0];
285 gWindow->geometry ().reset ();286 gWindow->vertexBuffer ()->begin ();
286 gWindow->glAddGeometry (ml, window->frameRegion (), region);287 gWindow->glAddGeometry (ml, window->frameRegion (), region);
287288 if (gWindow->vertexBuffer ()->end ())
288 if (gWindow->geometry ().vCount)289 gWindow->glDrawTexture (gWindow->textures ()[0], transform,
289 gWindow->glDrawTexture (gWindow->textures ()[0], attrib, mask);290 attrib, mask);
290 }291 }
291 else292 else
292 {293 {
@@ -295,14 +296,15 @@
295 for (unsigned int i = 0; i < gWindow->textures ().size (); i++)296 for (unsigned int i = 0; i < gWindow->textures ().size (); i++)
296 {297 {
297 ml[0] = gWindow->matrices ()[i];298 ml[0] = gWindow->matrices ()[i];
298 gWindow->geometry ().reset ();299 gWindow->vertexBuffer ()->begin ();
299 gWindow->glAddGeometry (ml, regions[i], region);300 gWindow->glAddGeometry (ml, regions[i], region);
300301 if (gWindow->vertexBuffer ()->end ())
301 if (gWindow->geometry ().vCount)302 gWindow->glDrawTexture (gWindow->textures ()[i], transform,
302 gWindow->glDrawTexture (gWindow->textures ()[i], attrib,303 attrib, mask);
303 mask);
304 }304 }
305 }305 }
306
307 glDisable (GL_BLEND);
306 }308 }
307}309}
308310
309311
=== modified file 'plugins/decor/src/decor.h'
--- plugins/decor/src/decor.h 2012-05-10 15:40:25 +0000
+++ plugins/decor/src/decor.h 2012-08-22 06:16:22 +0000
@@ -276,9 +276,9 @@
276276
277 bool damageRect (bool, const CompRect &);277 bool damageRect (bool, const CompRect &);
278278
279 bool glDraw (const GLMatrix &, GLFragment::Attrib &,279 bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
280 const CompRegion &, unsigned int);280 const CompRegion &, unsigned int);
281 void glDecorate (const GLMatrix &, GLFragment::Attrib &,281 void glDecorate (const GLMatrix &, const GLWindowPaintAttrib &,
282 const CompRegion &, unsigned int);282 const CompRegion &, unsigned int);
283283
284 void windowNotify (CompWindowNotify n);284 void windowNotify (CompWindowNotify n);
285285
=== modified file 'plugins/expo/CMakeLists.txt'
--- plugins/expo/CMakeLists.txt 2012-08-09 20:14:36 +0000
+++ plugins/expo/CMakeLists.txt 2012-08-22 06:16:22 +0000
@@ -1,11 +1,7 @@
1find_package (Compiz REQUIRED)1find_package (Compiz REQUIRED)
2include (FindOpenGL)
3include (CompizPlugin)2include (CompizPlugin)
43
5if (OPENGL_GLU_FOUND)4add_subdirectory (src/click_threshold)
6 add_subdirectory (src/click_threshold)5include_directories (src/click_threshold/include)
7 include_directories (src/click_threshold/include)6
87compiz_plugin (expo PLUGINDEPS composite opengl LIBRARIES compiz_expo_click_threshold)
9 compiz_plugin (expo PLUGINDEPS composite opengl LIBRARIES ${OPENGL_glu_LIBRARY} compiz_expo_click_threshold INCDIRS ${OPENGL_INCLUDE_DIR})
10endif (OPENGL_GLU_FOUND)
11
128
=== modified file 'plugins/expo/src/expo.cpp'
--- plugins/expo/src/expo.cpp 2012-08-16 17:00:05 +0000
+++ plugins/expo/src/expo.cpp 2012-08-22 06:16:22 +0000
@@ -4,12 +4,14 @@
4 *4 *
5 * expo.c5 * expo.c
6 *6 *
7 * Copyright (c) 2011 Linaro Limited
7 * Copyright (c) 2008 Dennis Kasprzyk <racarr@opencompositing.org>8 * Copyright (c) 2008 Dennis Kasprzyk <racarr@opencompositing.org>
8 * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>9 * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
9 *10 *
10 * Authors:11 * Authors:
11 * Robert Carr <racarr@beryl-project.org>12 * Robert Carr <racarr@beryl-project.org>
12 * Dennis Kasprzyk <onestone@opencompositing.org>13 * Dennis Kasprzyk <onestone@opencompositing.org>
14 * Travis Watkins <travis.watkins@linaro.org>
13 *15 *
14 * This program is free software; you can redistribute it and/or16 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License17 * modify it under the terms of the GNU General Public License
@@ -26,7 +28,9 @@
26#include "expo.h"28#include "expo.h"
27#include "click-threshold.h"29#include "click-threshold.h"
28#include <math.h>30#include <math.h>
31#ifndef USE_GLES
29#include <GL/glu.h>32#include <GL/glu.h>
33#endif
30#include <X11/cursorfont.h>34#include <X11/cursorfont.h>
3135
32COMPIZ_PLUGIN_20090315 (expo, ExpoPluginVTable);36COMPIZ_PLUGIN_20090315 (expo, ExpoPluginVTable);
@@ -641,6 +645,55 @@
641 }645 }
642}646}
643647
648static bool
649unproject (float winx, float winy, float winz,
650 const GLMatrix &modelview,
651 const GLMatrix &projection,
652 const GLint viewport[4],
653 float *objx, float *objy, float *objz)
654{
655 GLMatrix finalMatrix = projection * modelview;
656 float in[4], out[4];
657
658 if (!finalMatrix.invert ())
659 return false;
660
661 in[0] = winx;
662 in[1] = winy;
663 in[2] = winz;
664 in[3] = 1.0;
665
666 /* Map x and y from window coordinates */
667 in[0] = (in[0] - viewport[0]) / viewport[2];
668 in[1] = (in[1] - viewport[1]) / viewport[3];
669
670 /* Map to range -1 to 1 */
671 in[0] = in[0] * 2 - 1;
672 in[1] = in[1] * 2 - 1;
673 in[2] = in[2] * 2 - 1;
674
675 for (int i = 0; i < 4; i++)
676 {
677 out[i] = in[0] * finalMatrix[i] +
678 in[1] * finalMatrix[4 + i] +
679 in[2] * finalMatrix[8 + i] +
680 in[3] * finalMatrix[12 + i];
681 }
682
683 if (out[3] == 0.0)
684 return false;
685
686 out[0] /= out[3];
687 out[1] /= out[3];
688 out[2] /= out[3];
689
690 *objx = out[0];
691 *objy = out[1];
692 *objz = out[2];
693
694 return true;
695}
696
644void697void
645ExpoScreen::invertTransformedVertex (const GLScreenPaintAttrib& attrib,698ExpoScreen::invertTransformedVertex (const GLScreenPaintAttrib& attrib,
646 const GLMatrix& transform,699 const GLMatrix& transform,
@@ -648,8 +701,7 @@
648 int vertex[2])701 int vertex[2])
649{702{
650 GLMatrix sTransform (transform);703 GLMatrix sTransform (transform);
651 GLdouble p1[3], p2[3], v[3], alpha;704 float p1[3], p2[3], v[3], alpha;
652 GLdouble mvm[16], pm[16];
653 GLint viewport[4];705 GLint viewport[4];
654 int i;706 int i;
655707
@@ -657,16 +709,13 @@
657 sTransform.toScreenSpace (output, -attrib.zTranslate);709 sTransform.toScreenSpace (output, -attrib.zTranslate);
658710
659 glGetIntegerv (GL_VIEWPORT, viewport);711 glGetIntegerv (GL_VIEWPORT, viewport);
660 for (i = 0; i < 16; i++)
661 {
662 mvm[i] = sTransform[i];
663 pm[i] = gScreen->projectionMatrix ()[i];
664 }
665712
666 gluUnProject (vertex[0], screen->height () - vertex[1], 0, mvm, pm,713 unproject (vertex[0], screen->height () - vertex[1], 0,
667 viewport, &p1[0], &p1[1], &p1[2]);714 sTransform, *gScreen->projectionMatrix (), viewport,
668 gluUnProject (vertex[0], screen->height () - vertex[1], -1.0, mvm, pm,715 &p1[0], &p1[1], &p1[2]);
669 viewport, &p2[0], &p2[1], &p2[2]);716 unproject (vertex[0], screen->height () - vertex[1], -1.0,
717 sTransform, *gScreen->projectionMatrix (), viewport,
718 &p2[0], &p2[1], &p2[2]);
670719
671 for (i = 0; i < 3; i++)720 for (i = 0; i < 3; i++)
672 v[i] = p1[i] - p2[i];721 v[i] = p1[i] - p2[i];
@@ -720,6 +769,8 @@
720 unsigned int mask,769 unsigned int mask,
721 bool reflection)770 bool reflection)
722{771{
772 GLfloat vertexData[12];
773 GLushort colorData[16];
723 GLMatrix sTransformW, sTransform (transform);774 GLMatrix sTransformW, sTransform (transform);
724 int i, j, vp;775 int i, j, vp;
725 GLenum oldFilter = gScreen->textureFilter ();776 GLenum oldFilter = gScreen->textureFilter ();
@@ -740,6 +791,8 @@
740 int glPaintTransformedOutputIndex =791 int glPaintTransformedOutputIndex =
741 gScreen->glPaintTransformedOutputGetCurrentIndex ();792 gScreen->glPaintTransformedOutputGetCurrentIndex ();
742793
794 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
795
743 // Make sure that the base glPaintTransformedOutput function is called796 // Make sure that the base glPaintTransformedOutput function is called
744 gScreen->glPaintTransformedOutputSetCurrentIndex (MAXSHORT);797 gScreen->glPaintTransformedOutputSetCurrentIndex (MAXSHORT);
745798
@@ -832,7 +885,7 @@
832 /* zoom out */885 /* zoom out */
833 oScale = DEFAULT_Z_CAMERA / (cam[GLVector::z] + DEFAULT_Z_CAMERA);886 oScale = DEFAULT_Z_CAMERA / (cam[GLVector::z] + DEFAULT_Z_CAMERA);
834 sTransform.scale (oScale, oScale, oScale);887 sTransform.scale (oScale, oScale, oScale);
835 glNormal3f (0.0, 0.0, -oScale);888// glNormal3f (0.0, 0.0, -oScale);
836 sTransform.translate (-cam[GLVector::x], -cam[GLVector::y],889 sTransform.translate (-cam[GLVector::x], -cam[GLVector::y],
837 -cam[GLVector::z] - DEFAULT_Z_CAMERA);890 -cam[GLVector::z] - DEFAULT_Z_CAMERA);
838891
@@ -967,73 +1020,169 @@
967 sTransform.translate (0.0, -(sy + gapY), 0.0f);1020 sTransform.translate (0.0, -(sy + gapY), 0.0f);
968 }1021 }
9691022
970 glNormal3f (0.0, 0.0, -1.0);1023// glNormal3f (0.0, 0.0, -1.0);
9711024
972 if (reflection)1025 if (reflection)
973 {1026 {
974 glEnable (GL_BLEND);1027 glEnable (GL_BLEND);
975 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);1028 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
9761029
977 glPushMatrix ();
978
979 if (optionGetDeform () != DeformCurve)1030 if (optionGetDeform () != DeformCurve)
980 {1031 {
981 glLoadMatrixf (sTransformW.getMatrix ());1032 streamingBuffer->begin (GL_TRIANGLE_STRIP);
9821033
983 glBegin (GL_QUADS);1034 colorData[0] = 0;
984 glColor4f (0.0, 0.0, 0.0, 1.0);1035 colorData[1] = 0;
985 glVertex2f (0.0, 0.0);1036 colorData[2] = 0;
986 glColor4f (0.0, 0.0, 0.0, 0.5);1037 colorData[3] = 65535;
987 glVertex2f (0.0, -vpSize.y () * (sy + gapY));1038 colorData[4] = 0;
988 glVertex2f (vpSize.x () * sx * (1.0 + gapX),1039 colorData[5] = 0;
989 -vpSize.y () * sy * (1.0 + gapY));1040 colorData[6] = 0;
990 glColor4f (0.0, 0.0, 0.0, 1.0);1041 colorData[7] = 32768;
991 glVertex2f (vpSize.x () * sx * (1.0 + gapX), 0.0);1042 colorData[8] = 0;
992 glEnd ();1043 colorData[9] = 0;
1044 colorData[10] = 0;
1045 colorData[11] = 65535;
1046 colorData[12] = 0;
1047 colorData[13] = 0;
1048 colorData[14] = 0;
1049 colorData[15] = 32768;
1050
1051 vertexData[0] = 0;
1052 vertexData[1] = 0;
1053 vertexData[2] = 0;
1054 vertexData[3] = 0;
1055 vertexData[4] = -vpSize.y () * (sy + gapY);
1056 vertexData[5] = 0;
1057 vertexData[6] = vpSize.x () * sx * (1.0 + gapX);
1058 vertexData[7] = 0;
1059 vertexData[8] = 0;
1060 vertexData[9] = vpSize.x () * sx * (1.0 + gapX);
1061 vertexData[10] = -vpSize.y () * sy * (1.0 + gapY);
1062 vertexData[11] = 0;
1063
1064 streamingBuffer->addColors (4, colorData);
1065 streamingBuffer->addVertices (4, vertexData);
1066
1067 streamingBuffer->end ();
1068 streamingBuffer->render (sTransformW);
993 }1069 }
994 else1070 else
995 {1071 {
1072 GLMatrix cTransform;
1073 cTransform.translate (0.0, 0.0, -DEFAULT_Z_CAMERA);
1074
996 glCullFace (GL_BACK);1075 glCullFace (GL_BACK);
997 glLoadIdentity ();1076
998 glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA);1077 streamingBuffer->begin (GL_TRIANGLE_STRIP);
9991078
1000 glBegin (GL_QUADS);1079 colorData[0] = 0;
1001 glColor4f (0.0, 0.0, 0.0, 1.0 * expoCam);1080 colorData[1] = 0;
1002 glVertex2f (-0.5, -0.5);1081 colorData[2] = 0;
1003 glVertex2f (0.5, -0.5);1082 colorData[3] = (1.0 * expoCam) * 65535;
1004 glColor4f (0.0, 0.0, 0.0, 0.5 * expoCam);1083 colorData[4] = 0;
1005 glVertex2f (0.5, 0.0);1084 colorData[5] = 0;
1006 glVertex2f (-0.5, 0.0);1085 colorData[6] = 0;
1007 glColor4f (0.0, 0.0, 0.0, 0.5 * expoCam);1086 colorData[7] = (1.0 * expoCam) * 65535;
1008 glVertex2f (-0.5, 0.0);1087 colorData[8] = 0;
1009 glVertex2f (0.5, 0.0);1088 colorData[9] = 0;
1010 glColor4f (0.0, 0.0, 0.0, 0.0);1089 colorData[10] = 0;
1011 glVertex2f (0.5, 0.5);1090 colorData[11] = (0.5 * expoCam) * 65535;
1012 glVertex2f (-0.5, 0.5);1091 colorData[12] = 0;
1013 glEnd ();1092 colorData[13] = 0;
1093 colorData[14] = 0;
1094 colorData[15] = (0.5 * expoCam) * 65535;
1095
1096 vertexData[0] = -0.5;
1097 vertexData[1] = -0.5;
1098 vertexData[2] = 0;
1099 vertexData[3] = 0.5;
1100 vertexData[4] = -0.5;
1101 vertexData[5] = 0;
1102 vertexData[6] = -0.5;
1103 vertexData[7] = 0;
1104 vertexData[8] = 0;
1105 vertexData[9] = 0.5;
1106 vertexData[10] = 0;
1107 vertexData[11] = 0;
1108
1109 streamingBuffer->addColors (4, colorData);
1110 streamingBuffer->addVertices (4, vertexData);
1111
1112 streamingBuffer->end ();
1113 streamingBuffer->render (cTransform);
1114
1115 streamingBuffer->begin (GL_TRIANGLE_STRIP);
1116
1117 colorData[0] = 0;
1118 colorData[1] = 0;
1119 colorData[2] = 0;
1120 colorData[3] = (0.5 * expoCam) * 65535;
1121 colorData[4] = 0;
1122 colorData[5] = 0;
1123 colorData[6] = 0;
1124 colorData[7] = (0.5 * expoCam) * 65535;
1125 colorData[8] = 0;
1126 colorData[9] = 0;
1127 colorData[10] = 0;
1128 colorData[11] = 0;
1129 colorData[12] = 0;
1130 colorData[13] = 0;
1131 colorData[14] = 0;
1132 colorData[15] = 0;
1133
1134 vertexData[0] = -0.5;
1135 vertexData[1] = 0;
1136 vertexData[2] = 0;
1137 vertexData[3] = 0.5;
1138 vertexData[4] = 0;
1139 vertexData[5] = 0;
1140 vertexData[6] = -0.5;
1141 vertexData[7] = 0.5;
1142 vertexData[8] = 0;
1143 vertexData[9] = 0.5;
1144 vertexData[10] = 0.5;
1145 vertexData[11] = 0;
1146
1147 streamingBuffer->addColors (4, colorData);
1148 streamingBuffer->addVertices (4, vertexData);
1149
1150 streamingBuffer->end ();
1151 streamingBuffer->render (cTransform);
1014 }1152 }
1015 glCullFace (GL_BACK);1153 glCullFace (GL_BACK);
10161154
1017 glLoadIdentity ();
1018 glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA);
1019
1020 if (optionGetGroundSize () > 0.0)1155 if (optionGetGroundSize () > 0.0)
1021 {1156 {
1022 glBegin (GL_QUADS);1157 GLMatrix gTransform;
1023 glColor4usv (optionGetGroundColor1 ());1158 gTransform.translate (0.0, 0.0, -DEFAULT_Z_CAMERA);
1024 glVertex2f (-0.5, -0.5);1159
1025 glVertex2f (0.5, -0.5);1160 streamingBuffer->begin (GL_TRIANGLE_STRIP);
1026 glColor4usv (optionGetGroundColor2 ());1161
1027 glVertex2f (0.5, -0.5 + optionGetGroundSize ());1162 vertexData[0] = -0.5;
1028 glVertex2f (-0.5, -0.5 + optionGetGroundSize ());1163 vertexData[1] = -0.5;
1029 glEnd ();1164 vertexData[2] = 0;
1165 vertexData[3] = 0.5;
1166 vertexData[4] = -0.5;
1167 vertexData[5] = 0;
1168 vertexData[6] = -0.5;
1169 vertexData[7] = -0.5 + optionGetGroundSize ();
1170 vertexData[8] = 0;
1171 vertexData[9] = 0.5;
1172 vertexData[10] = -0.5 + optionGetGroundSize ();
1173 vertexData[11] = 0;
1174
1175 streamingBuffer->addColors (1, optionGetGroundColor1 ());
1176 streamingBuffer->addColors (1, optionGetGroundColor1 ());
1177 streamingBuffer->addColors (1, optionGetGroundColor2 ());
1178 streamingBuffer->addColors (1, optionGetGroundColor2 ());
1179 streamingBuffer->addVertices (4, vertexData);
1180
1181 streamingBuffer->end ();
1182 streamingBuffer->render (gTransform);
1030 }1183 }
1031
1032 glColor4usv (defaultColor);
1033
1034 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);1184 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1035 glDisable (GL_BLEND);1185 glDisable (GL_BLEND);
1036 glPopMatrix ();
1037 }1186 }
10381187
1039 expoActive = false;1188 expoActive = false;
@@ -1094,14 +1243,14 @@
10941243
1095bool1244bool
1096ExpoWindow::glDraw (const GLMatrix& transform,1245ExpoWindow::glDraw (const GLMatrix& transform,
1097 GLFragment::Attrib& fragment,1246 const GLWindowPaintAttrib &attrib,
1098 const CompRegion& region,1247 const CompRegion& region,
1099 unsigned int mask)1248 unsigned int mask)
1100{1249{
1101 if (eScreen->expoCam == 0.0f)1250 if (eScreen->expoCam == 0.0f)
1102 return gWindow->glDraw (transform, fragment, region, mask);1251 return gWindow->glDraw (transform, attrib, region, mask);
11031252
1104 GLFragment::Attrib fA (fragment);1253 GLWindowPaintAttrib eAttrib (attrib);
1105 int expoAnimation;1254 int expoAnimation;
11061255
1107 expoAnimation = eScreen->optionGetExpoAnimation ();1256 expoAnimation = eScreen->optionGetExpoAnimation ();
@@ -1109,7 +1258,7 @@
1109 if (eScreen->expoActive)1258 if (eScreen->expoActive)
1110 {1259 {
1111 if (expoAnimation != ExpoScreen::ExpoAnimationZoom)1260 if (expoAnimation != ExpoScreen::ExpoAnimationZoom)
1112 fA.setOpacity (fragment.getOpacity () * eScreen->expoCam);1261 eAttrib.opacity = attrib.opacity * eScreen->expoCam;
11131262
1114 if (window->wmType () & CompWindowTypeDockMask &&1263 if (window->wmType () & CompWindowTypeDockMask &&
1115 eScreen->optionGetHideDocks ())1264 eScreen->optionGetHideDocks ())
@@ -1117,28 +1266,28 @@
1117 if (expoAnimation == ExpoScreen::ExpoAnimationZoom &&1266 if (expoAnimation == ExpoScreen::ExpoAnimationZoom &&
1118 eScreen->paintingVp == eScreen->selectedVp)1267 eScreen->paintingVp == eScreen->selectedVp)
1119 {1268 {
1120 fA.setOpacity (fragment.getOpacity () *1269 eAttrib.opacity = attrib.opacity *
1121 (1 - sigmoidProgress (eScreen->expoCam)));1270 (1 - sigmoidProgress (eScreen->expoCam));
1122 }1271 }
1123 else1272 else
1124 {1273 {
1125 fA.setOpacity (0);1274 eAttrib.opacity = 0;
1126 }1275 }
1127 }1276 }
11281277
1129 fA.setBrightness (fragment.getBrightness () * eScreen->vpBrightness);1278 eAttrib.brightness = attrib.brightness * eScreen->vpBrightness;
1130 fA.setSaturation (fragment.getSaturation () * eScreen->vpSaturation);1279 eAttrib.saturation = attrib.saturation * eScreen->vpSaturation;
1131 }1280 }
1132 else1281 else
1133 {1282 {
1134 if (expoAnimation == ExpoScreen::ExpoAnimationZoom)1283 if (expoAnimation == ExpoScreen::ExpoAnimationZoom)
1135 fA.setBrightness (0);1284 eAttrib.brightness = 0;
1136 else1285 else
1137 fA.setBrightness (fragment.getBrightness () *1286 eAttrib.brightness = attrib.brightness *
1138 (1 - sigmoidProgress (eScreen->expoCam)));1287 (1 - sigmoidProgress (eScreen->expoCam));
1139 }1288 }
11401289
1141 return gWindow->glDraw (transform, fA, region, mask);1290 return gWindow->glDraw (transform, eAttrib, region, mask);
1142}1291}
11431292
1144#define EXPO_GRID_SIZE 1001293#define EXPO_GRID_SIZE 100
@@ -1154,7 +1303,7 @@
1154 screen->desktopWindowCount () &&1303 screen->desktopWindowCount () &&
1155 eScreen->optionGetDeform () == ExpoScreen::DeformCurve)1304 eScreen->optionGetDeform () == ExpoScreen::DeformCurve)
1156 {1305 {
1157 int i, oldVCount = gWindow->geometry ().vCount;1306 int i, oldVCount = gWindow->vertexBuffer ()->countVertices ();
1158 GLfloat *v;1307 GLfloat *v;
1159 CompPoint offset;1308 CompPoint offset;
1160 float lastX, lastZ = 0.0;1309 float lastX, lastZ = 0.0;
@@ -1165,9 +1314,10 @@
1165 MIN(maxGridWidth , EXPO_GRID_SIZE),1314 MIN(maxGridWidth , EXPO_GRID_SIZE),
1166 maxGridHeight);1315 maxGridHeight);
11671316
1168 v = gWindow->geometry ().vertices;1317 int stride = gWindow->vertexBuffer ()->getVertexStride ();
1169 v += gWindow->geometry ().vertexStride - 3;1318 v = gWindow->vertexBuffer ()->getVertices ();
1170 v += gWindow->geometry ().vertexStride * oldVCount;1319 v += stride - 3;
1320 v += stride * oldVCount;
11711321
1172 if (!window->onAllViewports ())1322 if (!window->onAllViewports ())
1173 {1323 {
@@ -1177,7 +1327,7 @@
11771327
1178 lastX = -1000000000.0;1328 lastX = -1000000000.0;
11791329
1180 for (i = oldVCount; i < gWindow->geometry ().vCount; i++)1330 for (i = oldVCount; i < gWindow->vertexBuffer ()->countVertices (); i++)
1181 {1331 {
1182 if (v[0] == lastX)1332 if (v[0] == lastX)
1183 {1333 {
@@ -1198,7 +1348,7 @@
1198 lastX = v[0];1348 lastX = v[0];
1199 lastZ = v[2];1349 lastZ = v[2];
12001350
1201 v += gWindow->geometry ().vertexStride;1351 v += stride;
1202 }1352 }
1203 }1353 }
1204 else1354 else
@@ -1209,7 +1359,8 @@
12091359
1210void1360void
1211ExpoWindow::glDrawTexture (GLTexture *texture,1361ExpoWindow::glDrawTexture (GLTexture *texture,
1212 GLFragment::Attrib& attrib,1362 const GLMatrix &transform,
1363 const GLWindowPaintAttrib &attrib,
1213 unsigned int mask)1364 unsigned int mask)
1214{1365{
1215 if (eScreen->expoCam > 0.0 &&1366 if (eScreen->expoCam > 0.0 &&
@@ -1217,15 +1368,9 @@
1217 eScreen->gScreen->lighting () &&1368 eScreen->gScreen->lighting () &&
1218 screen->desktopWindowCount ())1369 screen->desktopWindowCount ())
1219 {1370 {
1220 unsigned int i, idx, vCount;
1221 CompPoint offset;1371 CompPoint offset;
1222 float x;
1223 GLfloat *v;1372 GLfloat *v;
12241373 GLVertexBuffer *vb = gWindow->vertexBuffer ();
1225 vCount = gWindow->geometry ().vCount;
1226
1227 if (eScreen->winNormals.size () < vCount * 3)
1228 eScreen->winNormals.resize (vCount * 3);
12291374
1230 if (!window->onAllViewports ())1375 if (!window->onAllViewports ())
1231 {1376 {
@@ -1233,44 +1378,44 @@
1233 offset = window->getMovementForOffset (offset);1378 offset = window->getMovementForOffset (offset);
1234 }1379 }
12351380
1236 v = gWindow->geometry ().vertices +1381 int stride = vb->getVertexStride ();
1237 (gWindow->geometry ().vertexStride - 3);1382 v = vb->getVertices () + stride - 3;
12381383
1239 for (i = 0; i < vCount; i++)1384 for (int i = 0; i < vb->countVertices (); i++)
1240 {1385 {
1241 x = (float) (v[0] + offset.x () - screen->width () / 2) *1386 float x = (v[0] + offset.x () - screen->width () / 2) *
1242 eScreen->curveAngle / screen->width ();1387 eScreen->curveAngle / screen->width ();
12431388
1244 while (x < 0)1389 while (x < 0)
1245 x += 360.0;1390 x += 360.0;
12461391
1247 idx = floor (x);1392 int idx = floor (x);
12481393
1249 eScreen->winNormals[i * 3] = -eScreen->vpNormals[idx * 3];1394 GLfloat normal[3];
1250 eScreen->winNormals[(i * 3) + 1] =1395 normal[0] = -eScreen->vpNormals[idx * 3];
1251 eScreen->vpNormals[(idx * 3) + 1];1396 normal[1] = eScreen->vpNormals[(idx * 3) + 1];
1252 eScreen->winNormals[(i * 3) + 2] =1397 normal[2] = eScreen->vpNormals[(idx * 3) + 2];
1253 eScreen->vpNormals[(idx * 3) + 2];1398 vb->addNormals (1, normal);
12541399
1255 v += gWindow->geometry ().vertexStride;1400 v += stride;
1256 }1401 }
12571402
1403/* I am not entirely certain if these ifdefs are necessary
1404 * since we should be doing normalization in the shader,
1405 * however I have them here for now */
1406#ifndef USE_GLES
1258 glEnable (GL_NORMALIZE);1407 glEnable (GL_NORMALIZE);
1259 glNormalPointer (GL_FLOAT,0, &eScreen->winNormals.at (0));1408#endif
12601409 gWindow->glDrawTexture (texture, transform, attrib, mask);
1261 glEnableClientState (GL_NORMAL_ARRAY);1410#ifndef USE_GLES
1262
1263 gWindow->glDrawTexture (texture, attrib, mask);
1264
1265 glDisable (GL_NORMALIZE);1411 glDisable (GL_NORMALIZE);
1266 glDisableClientState (GL_NORMAL_ARRAY);1412#endif
1267 glNormal3f (0.0, 0.0, -1.0);
1268 }1413 }
1269 else1414 else
1270 {1415 {
1271 glEnable (GL_NORMALIZE);1416// glEnable (GL_NORMALIZE);
1272 gWindow->glDrawTexture (texture, attrib, mask);1417 gWindow->glDrawTexture (texture, transform, attrib, mask);
1273 glDisable (GL_NORMALIZE);1418// glDisable (GL_NORMALIZE);
1274 }1419 }
1275}1420}
12761421
12771422
=== modified file 'plugins/expo/src/expo.h'
--- plugins/expo/src/expo.h 2012-08-09 14:42:56 +0000
+++ plugins/expo/src/expo.h 2012-08-22 06:16:22 +0000
@@ -110,7 +110,6 @@
110 float curveRadius;110 float curveRadius;
111111
112 std::vector<GLfloat> vpNormals;112 std::vector<GLfloat> vpNormals;
113 std::vector<GLfloat> winNormals;
114113
115 CompScreen::GrabHandle grabIndex;114 CompScreen::GrabHandle grabIndex;
116115
@@ -142,15 +141,15 @@
142141
143 bool damageRect (bool, const CompRect&);142 bool damageRect (bool, const CompRect&);
144143
145 bool glDraw (const GLMatrix&, GLFragment::Attrib&,144 bool glDraw (const GLMatrix&, const GLWindowPaintAttrib&,
146 const CompRegion&, unsigned int);145 const CompRegion&, unsigned int);
147 bool glPaint (const GLWindowPaintAttrib&, const GLMatrix&,146 bool glPaint (const GLWindowPaintAttrib&, const GLMatrix&,
148 const CompRegion&, unsigned int);147 const CompRegion&, unsigned int);
149 void glAddGeometry (const GLTexture::MatrixList&,148 void glAddGeometry (const GLTexture::MatrixList&,
150 const CompRegion&, const CompRegion&,149 const CompRegion&, const CompRegion&,
151 unsigned int, unsigned int);150 unsigned int, unsigned int);
152 void glDrawTexture (GLTexture *, GLFragment::Attrib& attrib,151 void glDrawTexture (GLTexture*, const GLMatrix&,
153 unsigned int);152 const GLWindowPaintAttrib&, unsigned int);
154153
155 CompWindow *window;154 CompWindow *window;
156 CompositeWindow *cWindow;155 CompositeWindow *cWindow;
157156
=== modified file 'plugins/ezoom/src/ezoom.cpp'
--- plugins/ezoom/src/ezoom.cpp 2012-07-29 19:54:31 +0000
+++ plugins/ezoom/src/ezoom.cpp 2012-08-22 06:16:22 +0000
@@ -381,10 +381,13 @@
381 CompOutput *output,381 CompOutput *output,
382 CompRect box)382 CompRect box)
383{383{
384 GLMatrix zTransform = transform;384 GLMatrix zTransform (transform);
385 int x1,x2,y1,y2;385 int x1,x2,y1,y2;
386 int inx1, inx2, iny1, iny2;386 int inx1, inx2, iny1, iny2;
387 int out = output->id ();387 int out = output->id ();
388 GLushort colorData[4];
389 GLfloat vertexData[12];
390 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
388391
389 zTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);392 zTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
390 convertToZoomed (out, box.x1 (), box.y1 (), &inx1, &iny1);393 convertToZoomed (out, box.x1 (), box.y1 (), &inx1, &iny1);
@@ -394,23 +397,61 @@
394 y1 = MIN (iny1, iny2);397 y1 = MIN (iny1, iny2);
395 x2 = MAX (inx1, inx2);398 x2 = MAX (inx1, inx2);
396 y2 = MAX (iny1, iny2);399 y2 = MAX (iny1, iny2);
397 glPushMatrix ();400
398 glLoadMatrixf (zTransform.getMatrix ());401 streamingBuffer->begin (GL_TRIANGLE_STRIP);
399 glDisableClientState (GL_TEXTURE_COORD_ARRAY);402
400 glEnable (GL_BLEND);403 colorData[0] = 0x2fff;
401 glColor4us (0x2fff, 0x2fff, 0x4fff, 0x4fff);404 colorData[1] = 0x2fff;
402 glRecti (x1,y2,x2,y1);405 colorData[2] = 0x2fff;
403 glColor4us (0x2fff, 0x2fff, 0x4fff, 0x9fff);406 colorData[3] = 0x4fff;
404 glBegin (GL_LINE_LOOP);407
405 glVertex2i (x1, y1);408 streamingBuffer->addColors (1, colorData);
406 glVertex2i (x2, y1);409
407 glVertex2i (x2, y2);410 vertexData[0] = x1;
408 glVertex2i (x1, y2);411 vertexData[1] = y1;
409 glEnd ();412 vertexData[2] = 0.0f;
410 glColor4usv (defaultColor);413 vertexData[3] = x1;
411 glDisable (GL_BLEND);414 vertexData[4] = y2;
412 glEnableClientState (GL_TEXTURE_COORD_ARRAY);415 vertexData[5] = 0.0f;
413 glPopMatrix ();416 vertexData[6] = x2;
417 vertexData[7] = y1;
418 vertexData[8] = 0.0f;
419 vertexData[9] = x2;
420 vertexData[10] = y2;
421 vertexData[11] = 0.0f;
422
423 streamingBuffer->addVertices (4, vertexData);
424
425 streamingBuffer->end ();
426 streamingBuffer->render (zTransform);
427
428
429 streamingBuffer->begin (GL_LINE_LOOP);
430
431 colorData[0] = 0x2fff;
432 colorData[1] = 0x2fff;
433 colorData[2] = 0x4fff;
434 colorData[3] = 0x9fff;
435
436 streamingBuffer->addColors (1, colorData);
437
438 vertexData[0] = x1;
439 vertexData[1] = y1;
440 vertexData[2] = 0.0f;
441 vertexData[3] = x2;
442 vertexData[4] = y1;
443 vertexData[5] = 0.0f;
444 vertexData[6] = x2;
445 vertexData[7] = y2;
446 vertexData[8] = 0.0f;
447 vertexData[9] = x1;
448 vertexData[10] = y2;
449 vertexData[11] = 0.0f;
450
451 streamingBuffer->addVertices (4, vertexData);
452
453 streamingBuffer->end ();
454 streamingBuffer->render (zTransform);
414}455}
415/* Apply the zoom if we are grabbed.456/* Apply the zoom if we are grabbed.
416 * Make sure to use the correct filter.457 * Make sure to use the correct filter.
@@ -1060,6 +1101,9 @@
1060 GLMatrix sTransform = transform;1101 GLMatrix sTransform = transform;
1061 float scaleFactor;1102 float scaleFactor;
1062 int ax, ay, x, y;1103 int ax, ay, x, y;
1104 GLfloat textureData[8];
1105 GLfloat vertexData[12];
1106 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
10631107
1064 /*1108 /*
1065 * XXX: expo knows how to handle mouse when zoomed, so we back off1109 * XXX: expo knows how to handle mouse when zoomed, so we back off
@@ -1073,37 +1117,55 @@
10731117
1074 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);1118 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
1075 convertToZoomed (out, mouse.x (), mouse.y (), &ax, &ay);1119 convertToZoomed (out, mouse.x (), mouse.y (), &ax, &ay);
1076 glPushMatrix ();1120 sTransform.translate ((float) ax, (float) ay, 0.0f);
1077 glLoadMatrixf (sTransform.getMatrix ());1121
1078 glTranslatef ((float) ax, (float) ay, 0.0f);
1079 if (optionGetScaleMouseDynamic ())1122 if (optionGetScaleMouseDynamic ())
1080 scaleFactor = 1.0f / zooms.at (out).currentZoom;1123 scaleFactor = 1.0f / zooms.at (out).currentZoom;
1081 else1124 else
1082 scaleFactor = 1.0f / optionGetScaleMouseStatic ();1125 scaleFactor = 1.0f / optionGetScaleMouseStatic ();
1083 glScalef (scaleFactor,1126
1084 scaleFactor,1127 sTransform.scale (scaleFactor, scaleFactor, 1.0f);
1085 1.0f);
1086 x = -cursor.hotX;1128 x = -cursor.hotX;
1087 y = -cursor.hotY;1129 y = -cursor.hotY;
10881130
1089 glEnable (GL_BLEND);1131 glEnable (GL_BLEND);
1090 glBindTexture (GL_TEXTURE_RECTANGLE_ARB, cursor.texture);1132 glEnable (GL_TEXTURE_2D);
1091 glEnable (GL_TEXTURE_RECTANGLE_ARB);1133 glBindTexture (GL_TEXTURE_2D, cursor.texture);
10921134
1093 glBegin (GL_QUADS);1135 streamingBuffer->begin (GL_TRIANGLE_STRIP);
1094 glTexCoord2d (0, 0);1136
1095 glVertex2f (x, y);1137 vertexData[0] = x;
1096 glTexCoord2d (0, cursor.height);1138 vertexData[1] = y;
1097 glVertex2f (x, y + cursor.height);1139 vertexData[2] = 0.0f;
1098 glTexCoord2d (cursor.width, cursor.height);1140 vertexData[3] = x;
1099 glVertex2f (x + cursor.width, y + cursor.height);1141 vertexData[4] = y + cursor.height;
1100 glTexCoord2d (cursor.width, 0);1142 vertexData[5] = 0.0f;
1101 glVertex2f (x + cursor.width, y);1143 vertexData[6] = x + cursor.width;
1102 glEnd ();1144 vertexData[7] = y;
1145 vertexData[8] = 0.0f;
1146 vertexData[9] = x + cursor.width;
1147 vertexData[10] = y + cursor.height;
1148 vertexData[11] = 0.0f;
1149
1150 streamingBuffer->addVertices (4, vertexData);
1151
1152 textureData[0] = 0;
1153 textureData[1] = 0;
1154 textureData[2] = 0;
1155 textureData[3] = 1;
1156 textureData[4] = 1;
1157 textureData[5] = 0;
1158 textureData[6] = 1;
1159 textureData[7] = 1;
1160
1161 streamingBuffer->addTexCoords (0, 4, textureData);
1162
1163 streamingBuffer->end ();
1164 streamingBuffer->render (sTransform);
1165
1166 glBindTexture (GL_TEXTURE_2D, 0);
1167 glDisable (GL_TEXTURE_2D);
1103 glDisable (GL_BLEND);1168 glDisable (GL_BLEND);
1104 glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
1105 glDisable (GL_TEXTURE_RECTANGLE_ARB);
1106 glPopMatrix ();
1107 }1169 }
1108}1170}
11091171
@@ -1120,16 +1182,20 @@
1120 {1182 {
1121 cursor->isSet = true;1183 cursor->isSet = true;
1122 cursor->screen = screen;1184 cursor->screen = screen;
1123 glEnable (GL_TEXTURE_RECTANGLE_ARB);1185
1186 glEnable (GL_TEXTURE_2D);
1124 glGenTextures (1, &cursor->texture);1187 glGenTextures (1, &cursor->texture);
1125 glBindTexture (GL_TEXTURE_RECTANGLE_ARB, cursor->texture);1188 glBindTexture (GL_TEXTURE_2D, cursor->texture);
11261189
1127 glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,1190 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1128 GL_TEXTURE_WRAP_S, GL_CLAMP);1191 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1129 glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,1192 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
1130 GL_TEXTURE_WRAP_T, GL_CLAMP);1193 gScreen->textureFilter ());
1131 } else {1194 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
1132 glEnable (GL_TEXTURE_RECTANGLE_ARB);1195 gScreen->textureFilter ());
1196 }
1197 else {
1198 glEnable (GL_TEXTURE_2D);
1133 }1199 }
11341200
1135 XFixesCursorImage *ci = XFixesGetCursorImage (dpy);1201 XFixesCursorImage *ci = XFixesGetCursorImage (dpy);
@@ -1185,11 +1251,11 @@
1185 compLogMessage ("ezoom", CompLogLevelWarn, "unable to get system cursor image!");1251 compLogMessage ("ezoom", CompLogLevelWarn, "unable to get system cursor image!");
1186 }1252 }
11871253
1188 glBindTexture (GL_TEXTURE_RECTANGLE_ARB, cursor->texture);1254 glBindTexture (GL_TEXTURE_2D, cursor->texture);
1189 glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, cursor->width,1255 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, cursor->width,
1190 cursor->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);1256 cursor->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
1191 glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);1257 glBindTexture (GL_TEXTURE_2D, 0);
1192 glDisable (GL_TEXTURE_RECTANGLE_ARB);1258 glDisable (GL_TEXTURE_2D);
1193 1259
1194 free (pixels);1260 free (pixels);
1195}1261}
11961262
=== modified file 'plugins/grid/src/grid.cpp'
--- plugins/grid/src/grid.cpp 2012-08-03 10:12:25 +0000
+++ plugins/grid/src/grid.cpp 2012-08-22 06:16:22 +0000
@@ -432,35 +432,52 @@
432 CompRect rect;432 CompRect rect;
433 GLMatrix sTransform (transform);433 GLMatrix sTransform (transform);
434 std::vector<Animation>::iterator iter;434 std::vector<Animation>::iterator iter;
435 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
436 GLfloat vertexData[12];
437 GLushort colorData[4];
438 GLushort *color;
439 GLboolean isBlendingEnabled;
435440
436 getPaintRectangle (rect);441 getPaintRectangle (rect);
437442
438 for (unsigned int i = 0; i < animations.size (); i++)443 for (unsigned int i = 0; i < animations.size (); i++)
439 setCurrentRect (animations.at (i));444 setCurrentRect (animations.at (i));
440445
441 glPushMatrix ();
442
443 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);446 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
444447
445 glLoadMatrixf (sTransform.getMatrix ());448 glGetBooleanv (GL_BLEND, &isBlendingEnabled);
446
447 glDisableClientState (GL_TEXTURE_COORD_ARRAY);
448 glEnable (GL_BLEND);449 glEnable (GL_BLEND);
449450
450 for (iter = animations.begin (); iter != animations.end () && animating; ++iter)451 for (iter = animations.begin (); iter != animations.end () && animating; ++iter)
451 {452 {
452 Animation& anim = *iter;453 Animation& anim = *iter;
453 float alpha = ((float) optionGetFillColorAlpha () / 65535.0f) * anim.opacity;454 float alpha = ((float) optionGetFillColorAlpha () / 65535.0f) * anim.opacity;
454455 color = optionGetFillColor ();
455 /* fill rectangle */456
456 glColor4f (((float) optionGetFillColorRed () / 65535.0f) * alpha,457 colorData[0] = alpha * color[0];
457 ((float) optionGetFillColorGreen () / 65535.0f) * alpha,458 colorData[1] = alpha * color[1];
458 ((float) optionGetFillColorBlue () / 65535.0f) * alpha,459 colorData[2] = alpha * color[2];
459 alpha);460 colorData[3] = alpha * 65535.0f;
460461
461 /* fill rectangle */462 vertexData[0] = anim.currentRect.x1 ();
462 glRecti (anim.currentRect.x1 (), anim.currentRect.y2 (),463 vertexData[1] = anim.currentRect.y1 ();
463 anim.currentRect.x2 (), anim.currentRect.y1 ());464 vertexData[2] = 0.0f;
465 vertexData[3] = anim.currentRect.x1 ();
466 vertexData[4] = anim.currentRect.y2 ();
467 vertexData[5] = 0.0f;
468 vertexData[6] = anim.currentRect.x2 ();
469 vertexData[7] = anim.currentRect.y1 ();
470 vertexData[8] = 0.0f;
471 vertexData[9] = anim.currentRect.x2 ();
472 vertexData[10] = anim.currentRect.y2 ();
473 vertexData[11] = 0.0f;
474
475 streamingBuffer->begin (GL_TRIANGLE_STRIP);
476 streamingBuffer->addColors (1, colorData);
477 streamingBuffer->addVertices (4, vertexData);
478
479 streamingBuffer->end ();
480 streamingBuffer->render (sTransform);
464481
465 /* Set outline rect smaller to avoid damage issues */482 /* Set outline rect smaller to avoid damage issues */
466 anim.currentRect.setGeometry (anim.currentRect.x () + 1,483 anim.currentRect.setGeometry (anim.currentRect.x () + 1,
@@ -468,63 +485,101 @@
468 anim.currentRect.width () - 2,485 anim.currentRect.width () - 2,
469 anim.currentRect.height () - 2);486 anim.currentRect.height () - 2);
470487
471 alpha = (float) (optionGetOutlineColorAlpha () / 65535.0f) * anim.opacity;
472
473 /* draw outline */488 /* draw outline */
474 glColor4f (((float) optionGetOutlineColorRed () / 65535.0f) * alpha,489 alpha = ((float) optionGetOutlineColorAlpha () / 65535.0f) * anim.opacity;
475 ((float) optionGetOutlineColorGreen () / 65535.0f) * alpha,490 color = optionGetOutlineColor ();
476 ((float) optionGetOutlineColorBlue () / 65535.0f) * alpha,491
477 alpha);492 colorData[0] = alpha * color[0];
493 colorData[1] = alpha * color[1];
494 colorData[2] = alpha * color[2];
495 colorData[3] = alpha * 65535.0f;
496
497 vertexData[0] = anim.currentRect.x1 ();
498 vertexData[1] = anim.currentRect.y1 ();
499 vertexData[3] = anim.currentRect.x1 ();
500 vertexData[4] = anim.currentRect.y2 ();
501 vertexData[6] = anim.currentRect.x2 ();
502 vertexData[7] = anim.currentRect.y2 ();
503 vertexData[9] = anim.currentRect.x2 ();
504 vertexData[10] = anim.currentRect.y1 ();
478505
479 glLineWidth (2.0);506 glLineWidth (2.0);
480507
481 glBegin (GL_LINE_LOOP);508 streamingBuffer->begin (GL_LINE_LOOP);
482 glVertex2i (anim.currentRect.x1 (), anim.currentRect.y1 ());509 streamingBuffer->addColors (1, colorData);
483 glVertex2i (anim.currentRect.x2 (), anim.currentRect.y1 ());510 streamingBuffer->addVertices (4, vertexData);
484 glVertex2i (anim.currentRect.x2 (), anim.currentRect.y2 ());511
485 glVertex2i (anim.currentRect.x1 (), anim.currentRect.y2 ());512 streamingBuffer->end ();
486 glEnd ();513 streamingBuffer->render (sTransform);
487 }514 }
488515
489 if (!animating)516 if (!animating)
490 {517 {
491 /* fill rectangle */518 /* draw filled rectangle */
492 float alpha = (float) optionGetFillColorAlpha () / 65535.0f;519 float alpha = (float) optionGetFillColorAlpha () / 65535.0f;
493520 color = optionGetFillColor ();
494 /* fill rectangle */521
495 glColor4f (((float) optionGetFillColorRed () / 65535.0f) * alpha,522 colorData[0] = alpha * color[0];
496 ((float) optionGetFillColorGreen () / 65535.0f) * alpha,523 colorData[1] = alpha * color[1];
497 ((float) optionGetFillColorBlue () / 65535.0f) * alpha,524 colorData[2] = alpha * color[2];
498 alpha);525 colorData[3] = alpha * 65535.0f;
499 glRecti (rect.x1 (), rect.y2 (), rect.x2 (), rect.y1 ());526
527 vertexData[0] = rect.x1 ();
528 vertexData[1] = rect.y1 ();
529 vertexData[2] = 0.0f;
530 vertexData[3] = rect.x1 ();
531 vertexData[4] = rect.y2 ();
532 vertexData[5] = 0.0f;
533 vertexData[6] = rect.x2 ();
534 vertexData[7] = rect.y1 ();
535 vertexData[8] = 0.0f;
536 vertexData[9] = rect.x2 ();
537 vertexData[10] = rect.y2 ();
538 vertexData[11] = 0.0f;
539
540 streamingBuffer->begin (GL_TRIANGLE_STRIP);
541 streamingBuffer->addColors (1, colorData);
542 streamingBuffer->addVertices (4, vertexData);
543
544 streamingBuffer->end ();
545 streamingBuffer->render (sTransform);
500546
501 /* Set outline rect smaller to avoid damage issues */547 /* Set outline rect smaller to avoid damage issues */
502 rect.setGeometry (rect.x () + 1, rect.y () + 1,548 rect.setGeometry (rect.x () + 1,
503 rect.width () - 2, rect.height () - 2);549 rect.y () + 1,
550 rect.width () - 2,
551 rect.height () - 2);
504552
505 /* draw outline */553 /* draw outline */
506 alpha = (float) optionGetOutlineColorAlpha () / 65535.0f;554 alpha = (float) optionGetOutlineColorAlpha () / 65535.0f;
507555 color = optionGetOutlineColor ();
508 /* draw outline */556
509 glColor4f (((float) optionGetOutlineColorRed () / 65535.0f) * alpha,557 colorData[0] = alpha * color[0];
510 ((float) optionGetOutlineColorGreen () / 65535.0f) * alpha,558 colorData[1] = alpha * color[1];
511 ((float) optionGetOutlineColorBlue () / 65535.0f) * alpha,559 colorData[2] = alpha * color[2];
512 alpha);560 colorData[3] = alpha * 65535.0f;
561
562 vertexData[0] = rect.x1 ();
563 vertexData[1] = rect.y1 ();
564 vertexData[3] = rect.x1 ();
565 vertexData[4] = rect.y2 ();
566 vertexData[6] = rect.x2 ();
567 vertexData[7] = rect.y2 ();
568 vertexData[9] = rect.x2 ();
569 vertexData[10] = rect.y1 ();
513570
514 glLineWidth (2.0);571 glLineWidth (2.0);
515 glBegin (GL_LINE_LOOP);572
516 glVertex2i (rect.x1 (), rect.y1 ());573 streamingBuffer->begin (GL_LINE_LOOP);
517 glVertex2i (rect.x2 (), rect.y1 ());574 streamingBuffer->addColors (1, colorData);
518 glVertex2i (rect.x2 (), rect.y2 ());575 streamingBuffer->addVertices (4, vertexData);
519 glVertex2i (rect.x1 (), rect.y2 ());576
520 glEnd ();577 streamingBuffer->end ();
578 streamingBuffer->render (sTransform);
521 }579 }
522580
523 /* clean up */581 if (!isBlendingEnabled)
524 glColor4usv (defaultColor);
525 glDisable (GL_BLEND);582 glDisable (GL_BLEND);
526 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
527 glPopMatrix ();
528}583}
529584
530bool585bool
531586
=== modified file 'plugins/imgsvg/src/imgsvg.cpp'
--- plugins/imgsvg/src/imgsvg.cpp 2012-01-18 16:26:45 +0000
+++ plugins/imgsvg/src/imgsvg.cpp 2012-08-22 06:16:22 +0000
@@ -221,11 +221,11 @@
221221
222bool222bool
223SvgWindow::glDraw (const GLMatrix &transform,223SvgWindow::glDraw (const GLMatrix &transform,
224 GLFragment::Attrib &fragment,224 const GLWindowPaintAttrib &attrib,
225 const CompRegion &region,225 const CompRegion &region,
226 unsigned int mask)226 unsigned int mask)
227{227{
228 bool status = gWindow->glDraw (transform, fragment, region, mask);228 bool status = gWindow->glDraw (transform, attrib, region, mask);
229229
230 if (!status)230 if (!status)
231 return status;231 return status;
@@ -251,13 +251,15 @@
251 {251 {
252 matrix[0] = context->texture[0].matrices[i];252 matrix[0] = context->texture[0].matrices[i];
253253
254 gWindow->geometry ().reset ();254 gWindow->vertexBuffer ()->begin ();
255 gWindow->glAddGeometry (matrix, context->box, reg);255 gWindow->glAddGeometry (matrix, context->box, reg);
256 gWindow->vertexBuffer ()->end ();
256257
257 if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)258 if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
258 mask |= PAINT_WINDOW_BLEND_MASK;259 mask |= PAINT_WINDOW_BLEND_MASK;
259260
260 gWindow->glDrawTexture (context->texture[0].textures[i], fragment, mask);261 gWindow->glDrawTexture (context->texture[0].textures[i], transform,
262 attrib, mask);
261263
262 if (rect.width () > 0 && rect.height () > 0)264 if (rect.width () > 0 && rect.height () > 0)
263 {265 {
@@ -321,11 +323,12 @@
321 saveFilter = gScreen->filter (SCREEN_TRANS_FILTER);323 saveFilter = gScreen->filter (SCREEN_TRANS_FILTER);
322 gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good);324 gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good);
323325
324 gWindow->geometry ().reset ();326 gWindow->vertexBuffer ()->begin ();
325 gWindow->glAddGeometry (matrix, r, reg);327 gWindow->glAddGeometry (matrix, r, reg);
328 gWindow->vertexBuffer ()->end ();
326329
327 gWindow->glDrawTexture (context->texture[1].textures[j],330 gWindow->glDrawTexture (context->texture[1].textures[j],
328 fragment, mask);331 transform, attrib, mask);
329332
330 gScreen->setFilter (SCREEN_TRANS_FILTER, saveFilter);333 gScreen->setFilter (SCREEN_TRANS_FILTER, saveFilter);
331 }334 }
332335
=== modified file 'plugins/imgsvg/src/imgsvg.h'
--- plugins/imgsvg/src/imgsvg.h 2012-08-22 05:05:13 +0000
+++ plugins/imgsvg/src/imgsvg.h 2012-08-22 06:16:22 +0000
@@ -81,7 +81,8 @@
81 SvgWindow (CompWindow *window);81 SvgWindow (CompWindow *window);
82 ~SvgWindow ();82 ~SvgWindow ();
8383
84 bool glDraw (const GLMatrix &transform, GLFragment::Attrib &fragment,84 bool glDraw (const GLMatrix &transform,
85 const GLWindowPaintAttrib &attrib,
85 const CompRegion &region, unsigned int mask);86 const CompRegion &region, unsigned int mask);
86 void moveNotify (int dx, int dy, bool immediate);87 void moveNotify (int dx, int dy, bool immediate);
87 void resizeNotify (int dx, int dy, int dwidth, int dheight);88 void resizeNotify (int dx, int dy, int dwidth, int dheight);
8889
=== modified file 'plugins/kdecompat/src/kdecompat.cpp'
--- plugins/kdecompat/src/kdecompat.cpp 2012-05-27 04:32:55 +0000
+++ plugins/kdecompat/src/kdecompat.cpp 2012-08-22 06:16:22 +0000
@@ -204,7 +204,6 @@
204204
205 if (mSlideData && mSlideData->remaining)205 if (mSlideData && mSlideData->remaining)
206 {206 {
207 GLFragment::Attrib fragment (gWindow->paintAttrib ());
208 GLMatrix wTransform = transform;207 GLMatrix wTransform = transform;
209 SlideData *data = mSlideData;208 SlideData *data = mSlideData;
210 float xTranslate = 0, yTranslate = 0, remainder;209 float xTranslate = 0, yTranslate = 0, remainder;
@@ -241,26 +240,20 @@
241 status = gWindow->glPaint (attrib, transform, region, mask |240 status = gWindow->glPaint (attrib, transform, region, mask |
242 PAINT_WINDOW_NO_CORE_INSTANCE_MASK);241 PAINT_WINDOW_NO_CORE_INSTANCE_MASK);
243242
244 if (window->alpha () || fragment.getOpacity () != OPAQUE)243 if (window->alpha () || attrib.opacity != OPAQUE)
245 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;244 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
246245
247 wTransform.translate (xTranslate, yTranslate, 0.0f);246 wTransform.translate (xTranslate, yTranslate, 0.0f);
248247
249 glPushMatrix ();
250 glLoadMatrixf (wTransform.getMatrix ());
251
252 glPushAttrib (GL_SCISSOR_BIT);
253 glEnable (GL_SCISSOR_TEST);248 glEnable (GL_SCISSOR_TEST);
254249
255 glScissor (clipBox.x1 (), screen->height () - clipBox.y2 (),250 glScissor (clipBox.x1 (), screen->height () - clipBox.y2 (),
256 clipBox.width (), clipBox.height ());251 clipBox.width (), clipBox.height ());
257252
258 status = gWindow->glDraw (wTransform, fragment, region,253 status = gWindow->glDraw (wTransform, attrib, region,
259 mask | PAINT_WINDOW_TRANSFORMED_MASK);254 mask | PAINT_WINDOW_TRANSFORMED_MASK);
260255
261 glDisable (GL_SCISSOR_TEST);256 glDisable (GL_SCISSOR_TEST);
262 glPopAttrib ();
263 glPopMatrix ();
264 }257 }
265258
266 foreach (const Thumb& thumb, mPreviews)259 foreach (const Thumb& thumb, mPreviews)
@@ -329,20 +322,17 @@
329 matrices[0].x0 -= (tw->x () * icon->matrix ().xx);322 matrices[0].x0 -= (tw->x () * icon->matrix ().xx);
330 matrices[0].y0 -= (tw->y () * icon->matrix ().yy);323 matrices[0].y0 -= (tw->y () * icon->matrix ().yy);
331324
332 gtw->geometry ().reset ();325 gtw->vertexBuffer ()->begin ();
333 gtw->glAddGeometry (matrices, tw->geometry (), infiniteRegion);326 gtw->glAddGeometry (matrices, tw->geometry (), infiniteRegion);
334327 gtw->vertexBuffer ()->end ();
335 if (!gtw->geometry ().vertices)
336 icon = NULL;
337 }328 }
338 }329 }
339330
340 if (!gtw->textures ().empty () || icon)331 if (!gtw->textures ().empty () || icon)
341 {332 {
342 GLFragment::Attrib fragment (attrib);
343 GLMatrix wTransform (transform);333 GLMatrix wTransform (transform);
344334
345 if (tw->alpha () || fragment.getOpacity () != OPAQUE)335 if (tw->alpha () || attrib.opacity != OPAQUE)
346 paintMask |= PAINT_WINDOW_TRANSLUCENT_MASK;336 paintMask |= PAINT_WINDOW_TRANSLUCENT_MASK;
347337
348 wTransform.translate (tw->x (), tw->y (), 0.0f);338 wTransform.translate (tw->x (), tw->y (), 0.0f);
@@ -351,16 +341,11 @@
351 yTranslate / yScale - tw->y (),341 yTranslate / yScale - tw->y (),
352 0.0f);342 0.0f);
353343
354 glPushMatrix ();
355 glLoadMatrixf (wTransform.getMatrix ());
356
357 if (!gtw->textures ().empty ())344 if (!gtw->textures ().empty ())
358 gtw->glDraw (wTransform, fragment,345 gtw->glDraw (wTransform, attrib,
359 infiniteRegion, paintMask);346 infiniteRegion, paintMask);
360 else if (icon)347 else if (icon)
361 gtw->glDrawTexture (icon, fragment, paintMask);348 gtw->glDrawTexture (icon, wTransform, attrib, paintMask);
362
363 glPopMatrix ();
364 }349 }
365 }350 }
366 351
367352
=== modified file 'plugins/mag/src/mag.cpp'
--- plugins/mag/src/mag.cpp 2012-05-27 04:32:55 +0000
+++ plugins/mag/src/mag.cpp 2012-08-22 06:16:22 +0000
@@ -38,7 +38,9 @@
3838
39 if (program)39 if (program)
40 {40 {
41#if 0
41 GL::deletePrograms (1, &program);42 GL::deletePrograms (1, &program);
43#endif
42 program = 0;44 program = 0;
43 }45 }
44}46}
@@ -46,6 +48,7 @@
46bool48bool
47MagScreen::loadFragmentProgram ()49MagScreen::loadFragmentProgram ()
48{50{
51#if 0
49 char buffer[1024];52 char buffer[1024];
50 GLsizei bufSize;53 GLsizei bufSize;
51 GLint errorPos;54 GLint errorPos;
@@ -85,11 +88,14 @@
85 GL::bindProgram (GL_FRAGMENT_PROGRAM_ARB, 0);88 GL::bindProgram (GL_FRAGMENT_PROGRAM_ARB, 0);
8689
87 return true;90 return true;
91#endif
92 return false;
88}93}
8994
90bool95bool
91MagScreen::loadImages ()96MagScreen::loadImages ()
92{97{
98#if 0
93 CompString overlay_s = optionGetOverlay ();99 CompString overlay_s = optionGetOverlay ();
94 CompString mask_s = optionGetMask ();100 CompString mask_s = optionGetMask ();
95 CompString pname ("mag");101 CompString pname ("mag");
@@ -130,6 +136,8 @@
130 }136 }
131137
132 return true;138 return true;
139#endif
140 return false;
133}141}
134142
135void143void
@@ -317,8 +325,6 @@
317325
318 if (!adjust && zoom == 1.0 && (width || height))326 if (!adjust && zoom == 1.0 && (width || height))
319 {327 {
320 glEnable (target);
321
322 glBindTexture (target, texture);328 glBindTexture (target, texture);
323329
324 glTexImage2D (target, 0, GL_RGB, 0, 0, 0,330 glTexImage2D (target, 0, GL_RGB, 0, 0, 0,
@@ -328,8 +334,6 @@
328 height = 0;334 height = 0;
329 335
330 glBindTexture (target, 0);336 glBindTexture (target, 0);
331
332 glDisable (target);
333 }337 }
334338
335 if (zoom == 1.0 && !adjust)339 if (zoom == 1.0 && !adjust)
@@ -357,6 +361,10 @@
357 bool kScreen;361 bool kScreen;
358 unsigned short *color;362 unsigned short *color;
359 float tmp;363 float tmp;
364 GLMatrix projection;
365 GLMatrix modelview;
366 GLVertexBuffer *vb = GLVertexBuffer::streamingBuffer ();
367 const GLWindowPaintAttrib attrib = { OPAQUE, BRIGHT, COLOR, 0, 0, 0, 0 };
360368
361 w = optionGetBoxWidth ();369 w = optionGetBoxWidth ();
362 h = optionGetBoxHeight ();370 h = optionGetBoxHeight ();
@@ -393,8 +401,6 @@
393 ch = h;401 ch = h;
394 }402 }
395403
396 glEnable (target);
397
398 glBindTexture (target, texture);404 glBindTexture (target, texture);
399405
400 if (width != w || height != h)406 if (width != w || height != h)
@@ -419,13 +425,6 @@
419 ph = 1.0;425 ph = 1.0;
420 }426 }
421427
422 glMatrixMode (GL_PROJECTION);
423 glPushMatrix ();
424 glLoadIdentity ();
425 glMatrixMode (GL_MODELVIEW);
426 glPushMatrix ();
427 glLoadIdentity ();
428
429 vc[0] = ((x1 * 2.0) / screen->width ()) - 1.0;428 vc[0] = ((x1 * 2.0) / screen->width ()) - 1.0;
430 vc[1] = ((x2 * 2.0) / screen->width ()) - 1.0;429 vc[1] = ((x2 * 2.0) / screen->width ()) - 1.0;
431 vc[2] = ((y1 * -2.0) / screen->height ()) + 1.0;430 vc[2] = ((y1 * -2.0) / screen->height ()) + 1.0;
@@ -436,41 +435,63 @@
436 tc[2] = h * ph;435 tc[2] = h * ph;
437 tc[3] = 0.0;436 tc[3] = 0.0;
438437
439 glColor4usv (defaultColor);438 /* Draw zoom box contents */
440439 glScissor (x1, screen->height () - y2, w, h);
441 glPushMatrix ();440
442441 glEnable (GL_SCISSOR_TEST);
443 glTranslatef ((float)(posX - (screen->width () / 2)) * 2 / screen->width (),442
443 modelview.translate ((float)(posX - (screen->width () / 2)) * 2 / screen->width (),
444 (float)(posY - (screen->height () / 2)) * 2 / -screen->height (), 0.0);444 (float)(posY - (screen->height () / 2)) * 2 / -screen->height (), 0.0);
445445
446 glScalef (zoom, zoom, 1.0);446 modelview.scale (zoom, zoom, 1.0);
447447
448 glTranslatef ((float)((screen->width () / 2) - posX) * 2 / screen->width (),448 modelview.translate ((float)((screen->width () / 2) - posX) * 2 / screen->width (),
449 (float)((screen->height () / 2) - posY) * 2 / -screen->height (), 0.0);449 (float)((screen->height () / 2) - posY) * 2 / -screen->height (), 0.0);
450450
451 glScissor (x1, screen->height () - y2, w, h);451 GLfloat vertices[] = {
452452 vc[0], vc[2], 0,
453 glEnable (GL_SCISSOR_TEST);453 vc[0], vc[3], 0,
454454 vc[1], vc[2], 0,
455 glBegin (GL_QUADS);455 vc[1], vc[3], 0,
456 glTexCoord2f (tc[0], tc[2]);456 };
457 glVertex2f (vc[0], vc[2]);457
458 glTexCoord2f (tc[0], tc[3]);458 GLfloat texcoords[] = {
459 glVertex2f (vc[0], vc[3]);459 tc[0], tc[2],
460 glTexCoord2f (tc[1], tc[3]);460 tc[0], tc[3],
461 glVertex2f (vc[1], vc[3]);461 tc[1], tc[2],
462 glTexCoord2f (tc[1], tc[2]);462 tc[1], tc[3],
463 glVertex2f (vc[1], vc[2]);463 };
464 glEnd ();464
465 vb->begin (GL_TRIANGLE_STRIP);
466 vb->colorDefault ();
467 vb->addVertices (4, vertices);
468 vb->addTexCoords (0, 4, texcoords);
469 vb->end ();
470
471 vb->render (projection, modelview, attrib);
465472
466 glDisable (GL_SCISSOR_TEST);473 glDisable (GL_SCISSOR_TEST);
467474 modelview.reset ();
468 glPopMatrix ();
469
470 glBindTexture (target, 0);475 glBindTexture (target, 0);
471476
472 glDisable (target);477 /* Save blending state */
473478#if USE_GLES
479 GLboolean isBlendingEnabled = GL_TRUE;
480 GLint blendSrcRGB = GL_ONE;
481 GLint blendSrcAlpha = GL_ONE;
482 GLint blendDstRGB = GL_ZERO;
483 GLint blendDstAlpha = GL_ZERO;
484
485 glGetBooleanv (GL_BLEND, &isBlendingEnabled);
486 glGetIntegerv (GL_BLEND_SRC_RGB, &blendSrcRGB);
487 glGetIntegerv (GL_BLEND_DST_RGB, &blendDstRGB);
488 glGetIntegerv (GL_BLEND_SRC_ALPHA, &blendSrcAlpha);
489 glGetIntegerv (GL_BLEND_DST_ALPHA, &blendDstAlpha);
490#else
491 glPushAttrib (GL_COLOR_BUFFER_BIT);
492#endif
493
494 /* Draw zoom box border */
474 glEnable (GL_BLEND);495 glEnable (GL_BLEND);
475 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);496 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
476497
@@ -488,40 +509,43 @@
488509
489 color = optionGetBoxColor ();510 color = optionGetBoxColor ();
490511
491 glColor4us (color[0], color[1], color[2], color[3] * tmp);512 GLfloat verticesBorder[] = {
492513 vc[0] - bw, vc[2] + bh, 0,
493 glBegin (GL_QUADS);514 vc[0], vc[2], 0,
494 glVertex2f (vc[0] - bw, vc[2] + bh);515 vc[1] + bw, vc[2] + bh, 0,
495 glVertex2f (vc[0] - bw, vc[2]);516 vc[1], vc[2], 0,
496 glVertex2f (vc[1] + bw, vc[2]);517 vc[1] + bw, vc[3] - bh, 0,
497 glVertex2f (vc[1] + bw, vc[2] + bh);518 vc[1], vc[3], 0,
498 glVertex2f (vc[0] - bw, vc[3]);519 vc[0] - bw, vc[3] - bh, 0,
499 glVertex2f (vc[0] - bw, vc[3] - bh);520 vc[0], vc[3], 0,
500 glVertex2f (vc[1] + bw, vc[3] - bh);521 vc[0] - bw, vc[2] + bh, 0,
501 glVertex2f (vc[1] + bw, vc[3]);522 vc[0], vc[2], 0,
502 glVertex2f (vc[0] - bw, vc[2]);523 };
503 glVertex2f (vc[0] - bw, vc[3]);524
504 glVertex2f (vc[0], vc[3]);525 vb->begin (GL_TRIANGLE_STRIP);
505 glVertex2f (vc[0], vc[2]);526 vb->color4f (color[0] / 65535.0, color[1] / 65535.0,
506 glVertex2f (vc[1], vc[2]);527 color[2] / 65535.0, color[3] * tmp / 65535.0);
507 glVertex2f (vc[1], vc[3]);528 vb->addVertices (10, verticesBorder);
508 glVertex2f (vc[1] + bw, vc[3]);529 vb->end ();
509 glVertex2f (vc[1] + bw, vc[2]);530
510 glEnd();531 vb->render (projection, modelview, attrib);
511532
512 glColor4usv (defaultColor);533 vb->colorDefault ();
534
535 /* Restore blending state */
536#if USE_GLES
537 if (!isBlendingEnabled)
513 glDisable (GL_BLEND);538 glDisable (GL_BLEND);
514 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);539 glBlendFuncSeparate (blendSrcRGB, blendDstRGB, blendSrcAlpha, blendDstAlpha);
515540#else
516 glPopMatrix();541 glPopAttrib ();
517 glMatrixMode (GL_PROJECTION);542#endif
518 glPopMatrix ();
519 glMatrixMode (GL_MODELVIEW);
520}543}
521544
522void545void
523MagScreen::paintImage ()546MagScreen::paintImage ()
524{547{
548#if 0
525 float pw, ph;549 float pw, ph;
526 int x1, x2, y1, y2;550 int x1, x2, y1, y2;
527 float vc[4];551 float vc[4];
@@ -680,12 +704,14 @@
680 glMatrixMode (GL_MODELVIEW);704 glMatrixMode (GL_MODELVIEW);
681705
682 glPopAttrib ();706 glPopAttrib ();
707#endif
683708
684}709}
685710
686void711void
687MagScreen::paintFisheye ()712MagScreen::paintFisheye ()
688{713{
714#if 0
689 float pw, ph;715 float pw, ph;
690 float radius, fZoom, base; // fZoom is the local zoom variable716 float radius, fZoom, base; // fZoom is the local zoom variable
691 int x1, x2, y1, y2;717 int x1, x2, y1, y2;
@@ -786,6 +812,7 @@
786 glBindTexture (target, 0);812 glBindTexture (target, 0);
787813
788 glDisable (target);814 glDisable (target);
815#endif
789}816}
790817
791818
@@ -939,12 +966,14 @@
939966
940 glGenTextures (1, &texture);967 glGenTextures (1, &texture);
941968
969#ifdef USE_GLES
970 target = GL_TEXTURE_2D;
971#else
942 if (GL::textureNonPowerOfTwo)972 if (GL::textureNonPowerOfTwo)
943 target = GL_TEXTURE_2D;973 target = GL_TEXTURE_2D;
944 else974 else
945 target = GL_TEXTURE_RECTANGLE_ARB;975 target = GL_TEXTURE_RECTANGLE_ARB;
946976#endif
947 glEnable (target);
948977
949 /* Bind the texture */978 /* Bind the texture */
950 glBindTexture (target, texture);979 glBindTexture (target, texture);
@@ -952,8 +981,8 @@
952 /* Load the parameters */981 /* Load the parameters */
953 glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);982 glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
954 glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);983 glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
955 glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP);984 glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
956 glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP);985 glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
957986
958 glTexImage2D (target, 0, GL_RGB, 0, 0, 0,987 glTexImage2D (target, 0, GL_RGB, 0, 0, 0,
959 GL_RGB, GL_UNSIGNED_BYTE, NULL);988 GL_RGB, GL_UNSIGNED_BYTE, NULL);
@@ -963,8 +992,6 @@
963992
964 glBindTexture (target, 0);993 glBindTexture (target, 0);
965994
966 glDisable (target);
967
968#define optionNotify(name) \995#define optionNotify(name) \
969 optionSet##name##Notify (boost::bind (&MagScreen::optionChanged, \996 optionSet##name##Notify (boost::bind (&MagScreen::optionChanged, \
970 this, _1, _2))997 this, _1, _2))
@@ -1004,10 +1031,12 @@
1004 mode = MagOptions::ModeSimple;1031 mode = MagOptions::ModeSimple;
1005 }1032 }
10061033
1034#if 0
1007 if (!GL::fragmentProgram)1035 if (!GL::fragmentProgram)
1008 compLogMessage ("mag", CompLogLevelWarn,1036 compLogMessage ("mag", CompLogLevelWarn,
1009 "GL_ARB_fragment_program not supported. "1037 "GL_ARB_fragment_program not supported. "
1010 "Fisheye mode will not work.");1038 "Fisheye mode will not work.");
1039#endif
1011}1040}
10121041
1013MagScreen::~MagScreen ()1042MagScreen::~MagScreen ()
10141043
=== modified file 'plugins/mag/src/mag.h'
--- plugins/mag/src/mag.h 2012-05-27 04:32:55 +0000
+++ plugins/mag/src/mag.h 2012-08-22 06:16:22 +0000
@@ -161,6 +161,7 @@
161 bool init ();161 bool init ();
162};162};
163163
164#if 0
164static const char *fisheyeFpString =165static const char *fisheyeFpString =
165 "!!ARBfp1.0"166 "!!ARBfp1.0"
166167
@@ -190,3 +191,4 @@
190 "TEX result.color, t1, texture[0], %s;"191 "TEX result.color, t1, texture[0], %s;"
191192
192 "END";193 "END";
194#endif
193195
=== modified file 'plugins/neg/src/neg.cpp'
--- plugins/neg/src/neg.cpp 2011-05-18 01:06:37 +0000
+++ plugins/neg/src/neg.cpp 2012-08-22 06:16:22 +0000
@@ -22,7 +22,12 @@
2222
23#include "neg.h"23#include "neg.h"
2424
25using namespace GLFragment;25static std::string fragment_function = " \n\
26void neg_fragment () { \n\
27 vec3 color = vec3(1.0, 1.0, 1.0) - gl_FragColor.rgb; \n\
28 gl_FragColor = vec4(color, gl_FragColor.a); \n\
29} \n\
30";
2631
27COMPIZ_PLUGIN_20090315 (neg, NegPluginVTable);32COMPIZ_PLUGIN_20090315 (neg, NegPluginVTable);
2833
@@ -74,65 +79,12 @@
74 return true;79 return true;
75}80}
7681
77int
78NegScreen::getFragmentFunction (GLTexture *texture,
79 bool alpha)
80{
81 int handle = 0;
82
83 if (alpha && negAlphaFunction)
84 handle = negAlphaFunction;
85 else if (!alpha && negFunction)
86 handle = negFunction;
87
88 if (!handle)
89 {
90 FunctionData data;
91 int target;
92
93 if (alpha)
94 data.addTempHeaderOp ("neg");
95
96 if (texture->target () == GL_TEXTURE_2D)
97 target = COMP_FETCH_TARGET_2D;
98 else
99 target = COMP_FETCH_TARGET_RECT;
100
101 data.addFetchOp ("output", NULL, target);
102
103 if (alpha)
104 {
105 data.addDataOp ("RCP neg.a, output.a;");
106 data.addDataOp ("MAD output.rgb, -neg.a, output, 1.0;");
107 }
108 else
109 data.addDataOp ("SUB output.rgb, 1.0, output;");
110
111 if (alpha)
112 data.addDataOp ("MUL output.rgb, output.a, output;");
113
114 data.addColorOp ("output", "output");
115
116 if (!data.status ())
117 return 0;
118
119 handle = data.createFragmentFunction ("neg");
120
121 if (alpha)
122 negAlphaFunction = handle;
123 else
124 negFunction = handle;
125 }
126
127 return handle;
128}
129
130void82void
131NegWindow::glDrawTexture (GLTexture *texture,83NegWindow::glDrawTexture (GLTexture *texture,
132 GLFragment::Attrib &attrib,84 const GLMatrix &transform,
85 const GLWindowPaintAttrib &attrib,
133 unsigned int mask)86 unsigned int mask)
134{87{
135 GLTexture::Filter filter;
136 bool doNeg = false;88 bool doNeg = false;
137 GLTexture *tex = NULL;89 GLTexture *tex = NULL;
13890
@@ -160,24 +112,16 @@
160112
161 if (doNeg && tex)113 if (doNeg && tex)
162 {114 {
163 /* Fragment program negation */115 /* shader program negation */
164 if (GL::fragmentProgram)116 if (true)
165 {117 {
166 GLFragment::Attrib fa = attrib;118 gWindow->addShaders ("neg", "", fragment_function);
167 int function;119 gWindow->glDrawTexture (texture, transform, attrib, mask);
168 bool alpha = true;
169
170 if (texture->name () == tex->name ()) /* Not a decoration */
171 alpha = window->alpha ();
172
173 function = ns->getFragmentFunction (texture, alpha);
174 if (function)
175 fa.addFunction (function);
176
177 gWindow->glDrawTexture (texture, fa, mask);
178 }120 }
179 else /* Texture manipulation negation */121 else /* Texture manipulation negation */
180 {122 {
123#ifndef USE_GLES
124 GLTexture::Filter filter;
181 /* this is for the most part taken from paint.c */125 /* this is for the most part taken from paint.c */
182126
183 if (mask & PAINT_WINDOW_TRANSFORMED_MASK)127 if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
@@ -188,14 +132,10 @@
188 filter = ns->gScreen->filter (NOTHING_TRANS_FILTER);132 filter = ns->gScreen->filter (NOTHING_TRANS_FILTER);
189133
190 /* if we can adjust saturation, even if it's just on and off */134 /* if we can adjust saturation, even if it's just on and off */
191 if (GL::canDoSaturated && attrib.getSaturation () != COLOR)135 if (GL::canDoSaturated && attrib.saturation != COLOR)
192 {136 {
193 GLfloat constant[4];137 GLfloat constant[4];
194138
195 /* if the paint mask has this set we want to blend */
196 if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
197 glEnable (GL_BLEND);
198
199 /* enable the texture */139 /* enable the texture */
200 texture->enable (filter);140 texture->enable (filter);
201141
@@ -233,7 +173,7 @@
233 glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);173 glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
234174
235 /* if we can do saturation that is in between min and max */175 /* if we can do saturation that is in between min and max */
236 if (GL::canDoSlightlySaturated && attrib.getSaturation () > 0)176 if (GL::canDoSlightlySaturated && attrib.saturation > 0)
237 {177 {
238 glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);178 glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
239 glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);179 glTexEnvf (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
@@ -270,13 +210,13 @@
270 glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);210 glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
271211
272 /* color constant */212 /* color constant */
273 constant[3] = attrib.getSaturation () / 65535.0f;213 constant[3] = attrib.saturation / 65535.0f;
274214
275 glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);215 glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
276216
277 /* if we are not opaque or not fully bright */217 /* if we are not opaque or not fully bright */
278 if (attrib.getOpacity () < OPAQUE ||218 if (attrib.opacity < OPAQUE ||
279 attrib.getBrightness () != BRIGHT)219 attrib.brightness != BRIGHT)
280 {220 {
281 /* make another texture active */221 /* make another texture active */
282 GL::activeTexture (GL_TEXTURE3_ARB);222 GL::activeTexture (GL_TEXTURE3_ARB);
@@ -285,9 +225,9 @@
285 texture->enable (filter);225 texture->enable (filter);
286226
287 /* color constant */227 /* color constant */
288 constant[3] = attrib.getOpacity () / 65535.0f;228 constant[3] = attrib.opacity / 65535.0f;
289 constant[0] = constant[1] = constant[2] =229 constant[0] = constant[1] = constant[2] =
290 constant[3] * attrib.getBrightness () / 65535.0f;230 constant[3] * attrib.brightness / 65535.0f;
291231
292 glTexEnvfv(GL_TEXTURE_ENV,232 glTexEnvfv(GL_TEXTURE_ENV,
293 GL_TEXTURE_ENV_COLOR, constant);233 GL_TEXTURE_ENV_COLOR, constant);
@@ -314,8 +254,7 @@
314 glTexEnvf(GL_TEXTURE_ENV,254 glTexEnvf(GL_TEXTURE_ENV,
315 GL_OPERAND1_ALPHA, GL_SRC_ALPHA);255 GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
316256
317 /* draw the window geometry */257 gWindow->glDrawTexture (texture, transform, attrib, mask);
318 gWindow->glDrawGeometry ();
319258
320 /* disable the current texture */259 /* disable the current texture */
321 texture->disable ();260 texture->disable ();
@@ -331,8 +270,7 @@
331 {270 {
332 /* fully opaque and bright */271 /* fully opaque and bright */
333272
334 /* draw the window geometry */273 gWindow->glDrawTexture (texture, transform, attrib, mask);
335 gWindow->glDrawGeometry ();
336 }274 }
337275
338 /* disable the current texture */276 /* disable the current texture */
@@ -355,9 +293,9 @@
355 glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);293 glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
356294
357 /* color constant */295 /* color constant */
358 constant[3] = attrib.getOpacity () / 65535.0f;296 constant[3] = attrib.opacity / 65535.0f;
359 constant[0] = constant[1] = constant[2] =297 constant[0] = constant[1] = constant[2] =
360 constant[3] * attrib.getBrightness () / 65535.0f;298 constant[3] * attrib.brightness / 65535.0f;
361299
362 constant[0] =300 constant[0] =
363 0.5f + 0.5f * RED_SATURATION_WEIGHT * constant[0];301 0.5f + 0.5f * RED_SATURATION_WEIGHT * constant[0];
@@ -368,8 +306,7 @@
368306
369 glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);307 glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
370308
371 /* draw the window geometry */309 gWindow->glDrawTexture (texture, transform, attrib, mask);
372 gWindow->glDrawGeometry ();
373 }310 }
374311
375 /* disable the current texture */312 /* disable the current texture */
@@ -390,9 +327,6 @@
390 /* set screens texture mode back to replace */327 /* set screens texture mode back to replace */
391 ns->gScreen->setTexEnvMode (GL_REPLACE);328 ns->gScreen->setTexEnvMode (GL_REPLACE);
392329
393 /* if it's a translucent window, disable blending */
394 if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
395 glDisable (GL_BLEND);
396 }330 }
397 else331 else
398 {332 {
@@ -411,17 +345,14 @@
411345
412 /* we are not opaque or fully bright */346 /* we are not opaque or fully bright */
413 if ((mask & PAINT_WINDOW_TRANSLUCENT_MASK) ||347 if ((mask & PAINT_WINDOW_TRANSLUCENT_MASK) ||
414 attrib.getBrightness () != BRIGHT)348 attrib.brightness != BRIGHT)
415 {349 {
416 GLfloat constant[4];350 GLfloat constant[4];
417351
418 /* enable blending */
419 glEnable (GL_BLEND);
420
421 /* color constant */352 /* color constant */
422 constant[3] = attrib.getOpacity () / 65535.0f;353 constant[3] = attrib.opacity / 65535.0f;
423 constant[0] = constant[1] = constant[2] =354 constant[0] = constant[1] = constant[2] =
424 constant[3] * attrib.getBrightness () / 65535.0f;355 constant[3] * attrib.brightness / 65535.0f;
425356
426 glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);357 glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
427 glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);358 glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
@@ -441,18 +372,13 @@
441 glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);372 glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
442 glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);373 glTexEnvf (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
443374
444 /* draw the window geometry */375 gWindow->glDrawTexture (texture, transform, attrib, mask);
445 gWindow->glDrawGeometry ();
446
447 /* disable blending */
448 glDisable (GL_BLEND);
449 }376 }
450 else377 else
451 {378 {
452 /* no adjustments to saturation, brightness or opacity */379 /* no adjustments to saturation, brightness or opacity */
453380
454 /* draw the window geometry */381 gWindow->glDrawTexture (texture, transform, attrib, mask);
455 gWindow->glDrawGeometry ();
456 }382 }
457383
458 /* disable the current texture */384 /* disable the current texture */
@@ -461,12 +387,13 @@
461 /* set the screens texture mode back to replace */387 /* set the screens texture mode back to replace */
462 ns->gScreen->setTexEnvMode (GL_REPLACE);388 ns->gScreen->setTexEnvMode (GL_REPLACE);
463 }389 }
390#endif
464 }391 }
465 }392 }
466 else393 else
467 {394 {
468 /* not negative */395 /* not negative */
469 gWindow->glDrawTexture (texture, attrib, mask);396 gWindow->glDrawTexture (texture, transform, attrib, mask);
470 }397 }
471}398}
472399
473400
=== modified file 'plugins/neg/src/neg.h'
--- plugins/neg/src/neg.h 2011-05-27 08:32:06 +0000
+++ plugins/neg/src/neg.h 2012-08-22 06:16:22 +0000
@@ -57,10 +57,6 @@
57 CompOption::Vector opt,57 CompOption::Vector opt,
58 bool all);58 bool all);
5959
60 int
61 getFragmentFunction (GLTexture *texture,
62 bool alpha);
63
64 GLScreen *gScreen;60 GLScreen *gScreen;
65};61};
6662
@@ -89,8 +85,9 @@
89 bool isNeg;85 bool isNeg;
9086
91 void87 void
92 glDrawTexture(GLTexture *texture,88 glDrawTexture (GLTexture *texture,
93 GLFragment::Attrib &attrib,89 const GLMatrix &transform,
90 const GLWindowPaintAttrib &attrib,
94 unsigned int mask);91 unsigned int mask);
9592
96 void toggle ();93 void toggle ();
9794
=== modified file 'plugins/obs/src/obs.cpp'
--- plugins/obs/src/obs.cpp 2010-07-02 02:49:24 +0000
+++ plugins/obs/src/obs.cpp 2012-08-22 06:16:22 +0000
@@ -151,29 +151,30 @@
151 we wrap into glDrawWindow here */151 we wrap into glDrawWindow here */
152152
153bool153bool
154ObsWindow::glDraw (const GLMatrix& transform,154ObsWindow::glDraw (const GLMatrix &transform,
155 GLFragment::Attrib& attrib,155 const GLWindowPaintAttrib &attrib,
156 const CompRegion& region,156 const CompRegion &region,
157 unsigned int mask)157 unsigned int mask)
158{158{
159 GLWindowPaintAttrib wAttrib (attrib);
159 int factor;160 int factor;
160161
161 factor = customFactor[MODIFIER_OPACITY];162 factor = customFactor[MODIFIER_OPACITY];
162 if (factor != 100)163 if (factor != 100)
163 {164 {
164 attrib.setOpacity (factor * attrib.getOpacity () / 100);165 wAttrib.opacity = factor * wAttrib.opacity / 100;
165 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;166 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
166 }167 }
167168
168 factor = customFactor[MODIFIER_BRIGHTNESS];169 factor = customFactor[MODIFIER_BRIGHTNESS];
169 if (factor != 100)170 if (factor != 100)
170 attrib.setBrightness (factor * attrib.getBrightness () / 100);171 wAttrib.brightness = factor * wAttrib.brightness / 100;
171172
172 factor = customFactor[MODIFIER_SATURATION];173 factor = customFactor[MODIFIER_SATURATION];
173 if (factor != 100)174 if (factor != 100)
174 attrib.setSaturation (factor * attrib.getSaturation () / 100);175 wAttrib.saturation = factor * wAttrib.saturation / 100;
175176
176 return gWindow->glDraw (transform, attrib, region, mask);177 return gWindow->glDraw (transform, wAttrib, region, mask);
177}178}
178179
179void180void
180181
=== modified file 'plugins/obs/src/obs.h'
--- plugins/obs/src/obs.h 2012-01-18 16:26:45 +0000
+++ plugins/obs/src/obs.h 2012-08-22 06:16:22 +0000
@@ -66,7 +66,7 @@
6666
67 bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,67 bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
68 const CompRegion &, unsigned int);68 const CompRegion &, unsigned int);
69 bool glDraw (const GLMatrix &, GLFragment::Attrib &,69 bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
70 const CompRegion &, unsigned int);70 const CompRegion &, unsigned int);
7171
72 void changePaintModifier (unsigned int, int);72 void changePaintModifier (unsigned int, int);
7373
=== modified file 'plugins/opengl/CMakeLists.txt'
--- plugins/opengl/CMakeLists.txt 2009-03-15 05:09:18 +0000
+++ plugins/opengl/CMakeLists.txt 2012-08-22 06:16:22 +0000
@@ -2,7 +2,17 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5find_package (OpenGL)
6if (OPENGL_FOUND)
7 compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
8endif ()
9\ No newline at end of file5\ No newline at end of file
6set (INTERNAL_LIBRARIES
7 compiz_opengl_double_buffer)
8
9add_subdirectory (src/doublebuffer)
10
11if (USE_GLES)
12 compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD "-DUSE_GLES -std=c++0x" LIBRARIES ${OPENGLES2_LIBRARIES} ${INTERNAL_LIBRARIES} INCDIRS ${OPENGLES2_INCLUDE_DIR})
13else (USE_GLES)
14 find_package (OpenGL)
15 if (OPENGL_FOUND)
16 compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD -std=c++0x LIBRARIES ${OPENGL_gl_LIBRARY} ${INTERNAL_LIBRARIES} INCDIRS ${OPENGL_INCLUDE_DIR})
17 endif (OPENGL_FOUND)
18endif (USE_GLES)
19
1020
=== modified file 'plugins/opengl/compiz-opengl.pc.in'
--- plugins/opengl/compiz-opengl.pc.in 2009-03-15 05:09:18 +0000
+++ plugins/opengl/compiz-opengl.pc.in 2012-08-22 06:16:22 +0000
@@ -8,5 +8,5 @@
8Version: @VERSION@8Version: @VERSION@
99
10Requires: compiz compiz-composite10Requires: compiz compiz-composite
11Libs: -lGL -L${libdir} -lopengl11Libs: @PKGCONFIG_LIBS@ -L${libdir} -lopengl
12Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz12Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz
13\ No newline at end of file13\ No newline at end of file
1414
=== added file 'plugins/opengl/include/opengl/doublebuffer.h'
--- plugins/opengl/include/opengl/doublebuffer.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/doublebuffer.h 2012-08-22 06:16:22 +0000
@@ -0,0 +1,39 @@
1#ifndef _COMPIZ_OPENGL_BUFFERBLIT_H
2#define _COMPIZ_OPENGL_BUFFERBLIT_H
3
4#include <core/region.h>
5
6namespace compiz
7{
8namespace opengl
9{
10
11class DoubleBuffer
12{
13 public:
14 DoubleBuffer ();
15 virtual ~DoubleBuffer ();
16
17 virtual void swap () const = 0;
18 virtual bool blitAvailable () const = 0;
19 virtual void blit (const CompRegion &region) const = 0;
20 virtual bool fallbackBlitAvailable () const = 0;
21 virtual void fallbackBlit (const CompRegion &region) const = 0;
22
23 typedef enum
24 {
25 VSYNC,
26 PERSISTENT_BACK_BUFFER,
27 _NSETTINGS
28 } Setting;
29
30 void set (Setting name, bool value);
31 void render (const CompRegion &region, bool fullscreen);
32
33 protected:
34 bool setting[_NSETTINGS];
35};
36
37}
38}
39#endif
040
=== removed file 'plugins/opengl/include/opengl/fragment.h'
--- plugins/opengl/include/opengl/fragment.h 2012-01-18 16:26:45 +0000
+++ plugins/opengl/include/opengl/fragment.h 1970-01-01 00:00:00 +0000
@@ -1,125 +0,0 @@
1/*
2 * Copyright © 2008 Dennis Kasprzyk
3 * Copyright © 2007 Novell, Inc.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software
6 * and its documentation for any purpose is hereby granted without
7 * fee, provided that the above copyright notice appear in all copies
8 * and that both that copyright notice and this permission notice
9 * appear in supporting documentation, and that the name of
10 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior permission.
12 * Dennis Kasprzyk makes no representations about the suitability of this
13 * software for any purpose. It is provided "as is" without express or
14 * implied warranty.
15 *
16 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
22 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 *
24 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
25 * David Reveman <davidr@novell.com>
26 */
27
28#ifndef _GLFRAGMENT_H
29#define _GLFRAGMENT_H
30
31#define MAX_FRAGMENT_FUNCTIONS 16
32
33#define COMP_FETCH_TARGET_2D 0
34#define COMP_FETCH_TARGET_RECT 1
35#define COMP_FETCH_TARGET_NUM 2
36
37struct GLWindowPaintAttrib;
38class GLScreen;
39class GLTexture;
40
41/**
42 * Describes a texture modification fragment program
43 * for a texture
44 */
45namespace GLFragment {
46
47 class Storage;
48
49 typedef unsigned int FunctionId;
50
51 class PrivateFunctionData;
52 class PrivateAttrib;
53
54 class FunctionData {
55 public:
56 FunctionData ();
57 ~FunctionData ();
58
59 /**
60 * Returns the status of this fragment program
61 * (valid or invalid)
62 */
63 bool status ();
64
65 void addTempHeaderOp (const char *name);
66
67 void addParamHeaderOp (const char *name);
68
69 void addAttribHeaderOp (const char *name);
70
71
72 void addFetchOp (const char *dst, const char *offset, int target);
73
74 void addColorOp (const char *dst, const char *src);
75
76 void addDataOp (const char *str, ...);
77
78 void addBlendOp (const char *str, ...);
79
80 FunctionId createFragmentFunction (const char *name);
81
82 private:
83 PrivateFunctionData *priv;
84 };
85
86 class Attrib {
87 public:
88 Attrib (const GLWindowPaintAttrib &paint);
89 Attrib (const Attrib&);
90 ~Attrib ();
91
92 Attrib &operator= (const Attrib &rhs);
93
94 unsigned int allocTextureUnits (unsigned int nTexture);
95
96 unsigned int allocParameters (unsigned int nParam);
97
98 void addFunction (FunctionId function);
99
100 bool enable (bool *blending);
101 void disable ();
102
103 unsigned short getSaturation ();
104 unsigned short getBrightness ();
105 unsigned short getOpacity ();
106
107 void setSaturation (unsigned short);
108 void setBrightness (unsigned short);
109 void setOpacity (unsigned short);
110
111 bool hasFunctions ();
112
113 private:
114 PrivateAttrib *priv;
115 };
116
117 void destroyFragmentFunction (FunctionId id);
118
119 FunctionId getSaturateFragmentFunction (GLTexture *texture,
120 int param);
121};
122
123
124
125#endif
1260
=== added file 'plugins/opengl/include/opengl/framebufferobject.h'
--- plugins/opengl/include/opengl/framebufferobject.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/framebufferobject.h 2012-08-22 06:16:22 +0000
@@ -0,0 +1,104 @@
1/*
2 * Copyright (c) 2011 Collabora, Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Collabora Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Collabora Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * COLLABORA LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL COLLABORA LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Pekka Paalanen <ppaalanen@gmail.com>
24 */
25
26#ifndef _COMPIZ_GLFRAMEBUFFEROBJECT_H
27#define _COMPIZ_GLFRAMEBUFFEROBJECT_H
28
29#include <opengl/opengl.h>
30
31struct PrivateGLFramebufferObject;
32
33/**
34 * Class representing a framebuffer object in GL, supporting only one
35 * color attachment as per GLES 2 spec. The color attachment is referred
36 * to as the texture (of the FBO).
37 *
38 * Usage:
39 * 1. create a GLFramebufferObject (requires a GL context)
40 * 2. call allocate (size), and check status ()
41 * 3. old = bind ()
42 * 4. do your rendering
43 * 5. rebind (old)
44 * 6. use the rendered texture via tex ()
45 * 7. go to 2 or 3, or delete to quit (requires a GL context)
46 */
47class GLFramebufferObject
48{
49 public:
50 GLFramebufferObject ();
51 ~GLFramebufferObject ();
52
53 /**
54 * Ensure the texture is of the given size, recreating it if needed,
55 * and replace the FBO color attachment with it. The texture contents
56 * become undefined, unless specified in the 'image' argument.
57 * When specifying 'image', it's also possible to pass-in the
58 * desired image's 'format' and 'type'.
59 *
60 * Returns true on success, and false on texture allocation failure.
61 */
62 bool allocate (const CompSize &size,
63 const char *image = NULL,
64 GLenum format = GL_RGBA,
65 GLenum type = GL_UNSIGNED_BYTE);
66
67 /**
68 * Bind this as the current FBO, previous binding in GL context is
69 * undone. GL rendering is now targeted to this FBO.
70 * Returns a pointer to the previously bound FBO, or NULL if
71 * the previous binding was zero (the window system provided
72 * framebuffer).
73 *
74 * The previous FBO is no longer bound, so you can use its
75 * texture. To restore the previous FBO, call rebind (FBO) with
76 * the returned pointer as the argument.
77 */
78 GLFramebufferObject *bind ();
79
80 /**
81 * Bind the given FBO as the current FBO, without looking up the
82 * previous binding. The argument can be NULL, in which case the
83 * window system provided framebuffer gets bound (FBO is unbound).
84 */
85 static void rebind (GLFramebufferObject *fbo);
86
87 /**
88 * Check the FBO completeness. Returns true on complete.
89 * Otherwise returns false and reports the error to log.
90 */
91 bool checkStatus ();
92
93 /**
94 * Return a pointer to the texture that is the color attachment.
95 * This will return NULL, if allocate () has not been called, or
96 * the last allocate () call failed.
97 */
98 GLTexture *tex ();
99
100 private:
101 PrivateGLFramebufferObject *priv;
102};
103
104#endif // _COMPIZ_GLFRAMEBUFFEROBJECT_H
0105
=== modified file 'plugins/opengl/include/opengl/matrix.h'
--- plugins/opengl/include/opengl/matrix.h 2009-03-15 05:09:18 +0000
+++ plugins/opengl/include/opengl/matrix.h 2012-08-22 06:16:22 +0000
@@ -44,6 +44,8 @@
44 void reset ();44 void reset ();
45 void toScreenSpace (const CompOutput *output, float z);45 void toScreenSpace (const CompOutput *output, float z);
4646
47 bool invert ();
48
47 void rotate (const float angle, const float x,49 void rotate (const float angle, const float x,
48 const float y, const float z);50 const float y, const float z);
49 void rotate (const float angle, const GLVector& vector);51 void rotate (const float angle, const GLVector& vector);
5052
=== modified file 'plugins/opengl/include/opengl/opengl.h'
--- plugins/opengl/include/opengl/opengl.h 2012-01-20 09:05:56 +0000
+++ plugins/opengl/include/opengl/opengl.h 2012-08-22 06:16:22 +0000
@@ -28,16 +28,52 @@
28#ifndef _COMPIZ_OPENGL_H28#ifndef _COMPIZ_OPENGL_H
29#define _COMPIZ_OPENGL_H29#define _COMPIZ_OPENGL_H
3030
31#ifdef USE_GLES
32#define SUPPORT_X11
33#include <GLES2/gl2.h>
34#include <GLES2/gl2ext.h>
35#include <EGL/egl.h>
36#include <EGL/eglext.h>
37#else
31#include <GL/gl.h>38#include <GL/gl.h>
32#include <GL/glx.h>39#include <GL/glx.h>
40#endif
41
42#include <core/size.h>
43#include <core/pluginclasshandler.h>
3344
34#include <opengl/matrix.h>45#include <opengl/matrix.h>
35#include <opengl/texture.h>46#include <opengl/texture.h>
36#include <opengl/fragment.h>47#include <opengl/framebufferobject.h>
3748#include <opengl/vertexbuffer.h>
38#define COMPIZ_OPENGL_ABI 449#include <opengl/program.h>
3950#include <opengl/programcache.h>
40#include <core/pluginclasshandler.h>51#include <opengl/shadercache.h>
52
53#define COMPIZ_OPENGL_ABI 5
54
55/*
56 * Some plugins check for #ifdef USE_MODERN_COMPIZ_GL. Support it for now, but
57 * but the offending code should be changed to: #if COMPIZ_OPENGL_ABI >= 5
58 * Or the preprocessor checks should be removed altogether.
59 */
60#define USE_MODERN_COMPIZ_GL 1
61
62#if !defined(GL_BGRA)
63 #if !defined(GL_BGRA_EXT)
64 #error GL_BGRA support is required
65 #else
66 #define GL_BGRA GL_BGRA_EXT
67 #endif
68#endif
69
70#if !defined(GL_BGRA)
71 #if !defined(GL_BGRA_EXT)
72 #error GL_BGRA support is required
73 #else
74 #define GL_BGRA GL_BGRA_EXT
75 #endif
76#endif
4177
42/**78/**
43 * camera distance from screen, 0.5 * tan (FOV)79 * camera distance from screen, 0.5 * tan (FOV)
@@ -75,8 +111,26 @@
75#endif111#endif
76112
77namespace GL {113namespace GL {
78114 #ifdef USE_GLES
115 typedef EGLImageKHR (*EGLCreateImageKHRProc) (EGLDisplay dpy,
116 EGLContext ctx,
117 EGLenum target,
118 EGLClientBuffer buffer,
119 const EGLint *attrib_list);
120 typedef EGLBoolean (*EGLDestroyImageKHRProc) (EGLDisplay dpy,
121 EGLImageKHR image);
122
123 typedef void (*GLEGLImageTargetTexture2DOESProc) (GLenum target,
124 GLeglImageOES image);
125
126 typedef EGLBoolean (*EGLPostSubBufferNVProc) (EGLDisplay dpy,
127 EGLSurface surface,
128 EGLint x, EGLint y,
129 EGLint width, EGLint height);
130
131 #else
79 typedef void (*FuncPtr) (void);132 typedef void (*FuncPtr) (void);
133
80 typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);134 typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
81135
82 typedef void (*GLXBindTexImageProc) (Display *display,136 typedef void (*GLXBindTexImageProc) (Display *display,
@@ -122,11 +176,6 @@
122 const int *attribList);176 const int *attribList);
123 typedef void (*GLXDestroyPixmapProc) (Display *display,177 typedef void (*GLXDestroyPixmapProc) (Display *display,
124 GLXPixmap pixmap);178 GLXPixmap pixmap);
125
126 typedef void (*GLActiveTextureProc) (GLenum texture);
127 typedef void (*GLClientActiveTextureProc) (GLenum texture);
128 typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
129
130 typedef void (*GLGenProgramsProc) (GLsizei n,179 typedef void (*GLGenProgramsProc) (GLsizei n,
131 GLuint *programs);180 GLuint *programs);
132 typedef void (*GLDeleteProgramsProc) (GLsizei n,181 typedef void (*GLDeleteProgramsProc) (GLsizei n,
@@ -146,11 +195,16 @@
146 typedef void (*GLGetProgramivProc) (GLenum target,195 typedef void (*GLGetProgramivProc) (GLenum target,
147 GLenum pname,196 GLenum pname,
148 int *params);197 int *params);
198 #endif
199
200 typedef void (*GLActiveTextureProc) (GLenum texture);
201 typedef void (*GLClientActiveTextureProc) (GLenum texture);
202 typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
149203
150 typedef void (*GLGenFramebuffersProc) (GLsizei n,204 typedef void (*GLGenFramebuffersProc) (GLsizei n,
151 GLuint *framebuffers);205 GLuint *framebuffers);
152 typedef void (*GLDeleteFramebuffersProc) (GLsizei n,206 typedef void (*GLDeleteFramebuffersProc) (GLsizei n,
153 GLuint *framebuffers);207 const GLuint *framebuffers);
154 typedef void (*GLBindFramebufferProc) (GLenum target,208 typedef void (*GLBindFramebufferProc) (GLenum target,
155 GLuint framebuffer);209 GLuint framebuffer);
156 typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target);210 typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target);
@@ -161,6 +215,136 @@
161 GLint level);215 GLint level);
162 typedef void (*GLGenerateMipmapProc) (GLenum target);216 typedef void (*GLGenerateMipmapProc) (GLenum target);
163217
218 typedef void (*GLBindBufferProc) (GLenum target,
219 GLuint buffer);
220 typedef void (*GLDeleteBuffersProc) (GLsizei n,
221 const GLuint *buffers);
222 typedef void (*GLGenBuffersProc) (GLsizei n,
223 GLuint *buffers);
224 typedef void (*GLBufferDataProc) (GLenum target,
225 GLsizeiptr size,
226 const GLvoid *data,
227 GLenum usage);
228 typedef void (*GLBufferSubDataProc) (GLenum target,
229 GLintptr offset,
230 GLsizeiptr size,
231 const GLvoid *data);
232
233 typedef void (*GLGetShaderivProc) (GLuint shader,
234 GLenum pname,
235 GLint *params);
236 typedef void (*GLGetShaderInfoLogProc) (GLuint shader,
237 GLsizei bufsize,
238 GLsizei *length,
239 GLchar *infoLog);
240 typedef void (*GLGetProgramivProc) (GLuint program,
241 GLenum pname,
242 GLint* params);
243 typedef void (*GLGetProgramInfoLogProc) (GLuint program,
244 GLsizei bufsize,
245 GLsizei *length,
246 GLchar *infoLog);
247 typedef GLuint (*GLCreateShaderProc) (GLenum type);
248 typedef void (*GLShaderSourceProc) (GLuint shader,
249 GLsizei count,
250 const GLchar **string,
251 const GLint* length);
252 typedef void (*GLCompileShaderProc) (GLuint shader);
253 typedef GLuint (*GLCreateProgramProc) ();
254 typedef void (*GLAttachShaderProc) (GLuint program,
255 GLuint shader);
256 typedef void (*GLLinkProgramProc) (GLuint program);
257 typedef void (*GLValidateProgramProc) (GLuint program);
258 typedef void (*GLDeleteShaderProc) (GLuint shader);
259 typedef void (*GLDeleteProgramProc) (GLuint program);
260 typedef void (*GLUseProgramProc) (GLuint program);
261 typedef int (*GLGetUniformLocationProc) (GLuint program,
262 const GLchar* name);
263 typedef void (*GLUniform1fProc) (GLint location, GLfloat x);
264 typedef void (*GLUniform1iProc) (GLint location, GLint x);
265 typedef void (*GLUniform2fProc) (GLint location, GLfloat x, GLfloat y);
266 typedef void (*GLUniform3fProc) (GLint location,
267 GLfloat x,
268 GLfloat y,
269 GLfloat z);
270 typedef void (*GLUniform4fProc) (GLint location,
271 GLfloat x,
272 GLfloat y,
273 GLfloat z,
274 GLfloat w);
275 typedef void (*GLUniform2iProc) (GLint location, GLint x, GLint y);
276 typedef void (*GLUniform3iProc) (GLint location,
277 GLint x,
278 GLint y,
279 GLint z);
280 typedef void (*GLUniform4iProc) (GLint location,
281 GLint x,
282 GLint y,
283 GLint z,
284 GLint w);
285 typedef void (*GLUniformMatrix4fvProc) (GLint location,
286 GLsizei count,
287 GLboolean transpose,
288 const GLfloat *value);
289 typedef int (*GLGetAttribLocationProc) (GLuint program,
290 const GLchar *name);
291
292 typedef void (*GLEnableVertexAttribArrayProc) (GLuint index);
293 typedef void (*GLDisableVertexAttribArrayProc) (GLuint index);
294 typedef void (*GLVertexAttribPointerProc) (GLuint index,
295 GLint size,
296 GLenum type,
297 GLboolean normalized,
298 GLsizei stride,
299 const GLvoid *ptr);
300
301 typedef void (*GLGenRenderbuffersProc) (GLsizei n,
302 GLuint *rb);
303 typedef void (*GLDeleteRenderbuffersProc) (GLsizei n,
304 const GLuint *rb);
305 typedef void (*GLBindRenderbufferProc) (GLenum target,
306 GLuint renderbuffer);
307 typedef void (*GLFramebufferRenderbufferProc) (GLenum target,
308 GLenum attachment,
309 GLenum renderbuffertarget,
310 GLuint renderbuffer);
311 typedef void (*GLRenderbufferStorageProc) (GLenum target,
312 GLenum internalformat,
313 GLsizei width,
314 GLsizei height);
315
316
317 /* GL_ARB_shader_objects */
318 #ifndef USE_GLES
319 typedef GLhandleARB (*GLCreateShaderObjectARBProc) (GLenum type);
320 typedef GLhandleARB (*GLCreateProgramObjectARBProc) ();
321 typedef void (*GLShaderSourceARBProc) (GLhandleARB shader,
322 GLsizei count,
323 const GLchar **string,
324 const GLint* length);
325 typedef void (*GLCompileShaderARBProc) (GLhandleARB shader);
326 typedef void (*GLValidateProgramARBProc) (GLhandleARB program);
327 typedef void (*GLDeleteObjectARBProc) (GLhandleARB object);
328 typedef void (*GLAttachObjectARBProc) (GLhandleARB program,
329 GLhandleARB shader);
330 typedef void (*GLLinkProgramARBProc) (GLhandleARB program);
331 typedef void (*GLUseProgramObjectARBProc) (GLhandleARB program);
332 typedef int (*GLGetUniformLocationARBProc) (GLhandleARB program,
333 const GLchar* name);
334 typedef int (*GLGetAttribLocationARBProc) (GLhandleARB program,
335 const GLchar *name);
336
337 typedef void (*GLGetObjectParameterivProc) (GLhandleARB object, GLenum type, int *param);
338 typedef void (*GLGetInfoLogProc) (GLhandleARB object, int maxLen, int *len, char *log);
339 #endif
340
341 #ifdef USE_GLES
342 extern EGLCreateImageKHRProc createImage;
343 extern EGLDestroyImageKHRProc destroyImage;
344
345 extern GLEGLImageTargetTexture2DOESProc eglImageTargetTexture;
346
347 #else
164 extern GLXBindTexImageProc bindTexImage;348 extern GLXBindTexImageProc bindTexImage;
165 extern GLXReleaseTexImageProc releaseTexImage;349 extern GLXReleaseTexImageProc releaseTexImage;
166 extern GLXQueryDrawableProc queryDrawable;350 extern GLXQueryDrawableProc queryDrawable;
@@ -172,11 +356,6 @@
172 extern GLXGetFBConfigAttribProc getFBConfigAttrib;356 extern GLXGetFBConfigAttribProc getFBConfigAttrib;
173 extern GLXCreatePixmapProc createPixmap;357 extern GLXCreatePixmapProc createPixmap;
174 extern GLXDestroyPixmapProc destroyPixmap;358 extern GLXDestroyPixmapProc destroyPixmap;
175
176 extern GLActiveTextureProc activeTexture;
177 extern GLClientActiveTextureProc clientActiveTexture;
178 extern GLMultiTexCoord2fProc multiTexCoord2f;
179
180 extern GLGenProgramsProc genPrograms;359 extern GLGenProgramsProc genPrograms;
181 extern GLDeleteProgramsProc deletePrograms;360 extern GLDeleteProgramsProc deletePrograms;
182 extern GLBindProgramProc bindProgram;361 extern GLBindProgramProc bindProgram;
@@ -184,6 +363,11 @@
184 extern GLProgramParameter4fProc programEnvParameter4f;363 extern GLProgramParameter4fProc programEnvParameter4f;
185 extern GLProgramParameter4fProc programLocalParameter4f;364 extern GLProgramParameter4fProc programLocalParameter4f;
186 extern GLGetProgramivProc getProgramiv;365 extern GLGetProgramivProc getProgramiv;
366 #endif
367
368 extern GLActiveTextureProc activeTexture;
369 extern GLClientActiveTextureProc clientActiveTexture;
370 extern GLMultiTexCoord2fProc multiTexCoord2f;
187371
188 extern GLGenFramebuffersProc genFramebuffers;372 extern GLGenFramebuffersProc genFramebuffers;
189 extern GLDeleteFramebuffersProc deleteFramebuffers;373 extern GLDeleteFramebuffersProc deleteFramebuffers;
@@ -192,20 +376,177 @@
192 extern GLFramebufferTexture2DProc framebufferTexture2D;376 extern GLFramebufferTexture2DProc framebufferTexture2D;
193 extern GLGenerateMipmapProc generateMipmap;377 extern GLGenerateMipmapProc generateMipmap;
194378
379 extern GLBindBufferProc bindBuffer;
380 extern GLDeleteBuffersProc deleteBuffers;
381 extern GLGenBuffersProc genBuffers;
382 extern GLBufferDataProc bufferData;
383 extern GLBufferSubDataProc bufferSubData;
384
385
386 extern GLGetShaderivProc getShaderiv;
387 extern GLGetShaderInfoLogProc getShaderInfoLog;
388 extern GLGetProgramivProc getProgramiv;
389 extern GLGetProgramInfoLogProc getProgramInfoLog;
390 extern GLCreateShaderProc createShader;
391 extern GLShaderSourceProc shaderSource;
392 extern GLCompileShaderProc compileShader;
393 extern GLCreateProgramProc createProgram;
394 extern GLAttachShaderProc attachShader;
395 extern GLLinkProgramProc linkProgram;
396 extern GLValidateProgramProc validateProgram;
397 extern GLDeleteShaderProc deleteShader;
398 extern GLDeleteProgramProc deleteProgram;
399 extern GLUseProgramProc useProgram;
400 extern GLGetUniformLocationProc getUniformLocation;
401 extern GLUniform1fProc uniform1f;
402 extern GLUniform1iProc uniform1i;
403 extern GLUniform2fProc uniform2f;
404 extern GLUniform2iProc uniform2i;
405 extern GLUniform3fProc uniform3f;
406 extern GLUniform3iProc uniform3i;
407 extern GLUniform4fProc uniform4f;
408 extern GLUniform4iProc uniform4i;
409 extern GLUniformMatrix4fvProc uniformMatrix4fv;
410 extern GLGetAttribLocationProc getAttribLocation;
411
412 extern GLEnableVertexAttribArrayProc enableVertexAttribArray;
413 extern GLDisableVertexAttribArrayProc disableVertexAttribArray;
414 extern GLVertexAttribPointerProc vertexAttribPointer;
415
416 extern GLGenRenderbuffersProc genRenderbuffers;
417 extern GLDeleteRenderbuffersProc deleteRenderbuffers;
418 extern GLBindRenderbufferProc bindRenderbuffer;
419 extern GLFramebufferRenderbufferProc framebufferRenderbuffer;
420 extern GLRenderbufferStorageProc renderbufferStorage;
421
422 #ifndef USE_GLES
423 extern GLCreateShaderObjectARBProc createShaderObjectARB;
424 extern GLCreateProgramObjectARBProc createProgramObjectARB;
425 extern GLShaderSourceARBProc shaderSourceARB;
426 extern GLCompileShaderARBProc compileShaderARB;
427 extern GLValidateProgramARBProc validateProgramARB;
428 extern GLDeleteObjectARBProc deleteObjectARB;
429 extern GLAttachObjectARBProc attachObjectARB;
430 extern GLLinkProgramARBProc linkProgramARB;
431 extern GLUseProgramObjectARBProc useProgramObjectARB;
432 extern GLGetUniformLocationARBProc getUniformLocationARB;
433 extern GLGetAttribLocationARBProc getAttribLocationARB;
434
435 extern GLGetObjectParameterivProc getObjectParameteriv;
436 extern GLGetInfoLogProc getInfoLog;
437 #endif
438
439#ifdef USE_GLES
440
441 static const GLenum FRAMEBUFFER_BINDING = GL_FRAMEBUFFER_BINDING;
442 static const GLenum FRAMEBUFFER = GL_FRAMEBUFFER;
443 static const GLenum RENDERBUFFER = GL_RENDERBUFFER;
444 static const GLenum COLOR_ATTACHMENT0 = GL_COLOR_ATTACHMENT0;
445 static const GLenum DEPTH_ATTACHMENT = GL_DEPTH_ATTACHMENT;
446 static const GLenum STENCIL_ATTACHMENT = GL_STENCIL_ATTACHMENT;
447 static const GLenum DEPTH24_STENCIL8 = GL_DEPTH24_STENCIL8_OES;
448
449 /* OpenGL|ES does not support different draw/read framebuffers */
450 static const GLenum DRAW_FRAMEBUFFER = GL_FRAMEBUFFER;
451 static const GLenum READ_FRAMEBUFFER = GL_FRAMEBUFFER;
452
453 static const GLenum FRAMEBUFFER_COMPLETE = GL_FRAMEBUFFER_COMPLETE;
454 static const GLenum FRAMEBUFFER_UNDEFINED = 0;
455 static const GLenum FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
456 static const GLenum FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
457 static const GLenum FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = 0;
458 static const GLenum FRAMEBUFFER_INCOMPLETE_READ_BUFFER = 0;
459 static const GLenum FRAMEBUFFER_UNSUPPORTED = GL_FRAMEBUFFER_UNSUPPORTED;
460 static const GLenum FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0;
461 static const GLenum FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = 0;
462 static const GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
463
464 static const GLenum ARRAY_BUFFER = GL_ARRAY_BUFFER;
465 static const GLenum STATIC_DRAW = GL_STATIC_DRAW;
466 static const GLenum STREAM_DRAW = GL_STREAM_DRAW;
467 static const GLenum DYNAMIC_DRAW = GL_DYNAMIC_DRAW;
468
469 static const GLenum INFO_LOG_LENGTH = GL_INFO_LOG_LENGTH;
470 static const GLenum COMPILE_STATUS = GL_COMPILE_STATUS;
471 static const GLenum LINK_STATUS = GL_LINK_STATUS;
472 static const GLenum FRAGMENT_SHADER = GL_FRAGMENT_SHADER;
473 static const GLenum VERTEX_SHADER = GL_VERTEX_SHADER;
474
475#else
476
477 static const GLenum FRAMEBUFFER_BINDING = GL_FRAMEBUFFER_BINDING_EXT;
478 static const GLenum FRAMEBUFFER = GL_FRAMEBUFFER_EXT;
479 static const GLenum RENDERBUFFER = GL_RENDERBUFFER;
480 static const GLenum COLOR_ATTACHMENT0 = GL_COLOR_ATTACHMENT0_EXT;
481 static const GLenum DEPTH_ATTACHMENT = GL_DEPTH_ATTACHMENT_EXT;
482 static const GLenum STENCIL_ATTACHMENT = GL_STENCIL_ATTACHMENT_EXT;
483 static const GLenum DEPTH24_STENCIL8 = GL_DEPTH24_STENCIL8_EXT;
484
485 static const GLenum DRAW_FRAMEBUFFER = GL_DRAW_FRAMEBUFFER_EXT;
486 static const GLenum READ_FRAMEBUFFER = GL_READ_FRAMEBUFFER_EXT;
487 static const GLenum FRAMEBUFFER_COMPLETE = GL_FRAMEBUFFER_COMPLETE_EXT;
488 static const GLenum FRAMEBUFFER_UNDEFINED = GL_FRAMEBUFFER_UNDEFINED;
489 static const GLenum FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
490 static const GLenum FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
491 static const GLenum FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT;
492 static const GLenum FRAMEBUFFER_INCOMPLETE_READ_BUFFER = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT;
493 static const GLenum FRAMEBUFFER_UNSUPPORTED = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
494 static const GLenum FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT;
495 static const GLenum FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT;
496 static const GLenum FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0;
497
498 static const GLenum ARRAY_BUFFER = GL_ARRAY_BUFFER_ARB;
499 static const GLenum STATIC_DRAW = GL_STATIC_DRAW_ARB;
500 static const GLenum STREAM_DRAW = GL_STREAM_DRAW_ARB;
501 static const GLenum DYNAMIC_DRAW = GL_DYNAMIC_DRAW_ARB;
502
503 static const GLenum INFO_LOG_LENGTH = GL_OBJECT_INFO_LOG_LENGTH_ARB;
504 static const GLenum COMPILE_STATUS = GL_OBJECT_COMPILE_STATUS_ARB;
505 static const GLenum LINK_STATUS = GL_OBJECT_LINK_STATUS_ARB;
506 static const GLenum FRAGMENT_SHADER = GL_FRAGMENT_SHADER_ARB;
507 static const GLenum VERTEX_SHADER = GL_VERTEX_SHADER_ARB;
508
509#endif
510
195 extern bool textureFromPixmap;511 extern bool textureFromPixmap;
196 extern bool textureRectangle;512 extern bool textureRectangle;
197 extern bool textureNonPowerOfTwo;513 extern bool textureNonPowerOfTwo;
514 extern bool textureNonPowerOfTwoMipmap;
198 extern bool textureEnvCombine;515 extern bool textureEnvCombine;
199 extern bool textureEnvCrossbar;516 extern bool textureEnvCrossbar;
200 extern bool textureBorderClamp;517 extern bool textureBorderClamp;
201 extern bool textureCompression;518 extern bool textureCompression;
202 extern GLint maxTextureSize;519 extern GLint maxTextureSize;
203 extern bool fbo;520 extern bool fboSupported;
204 extern bool fragmentProgram;521 extern bool fboStencilSupported;
522 extern bool fboEnabled;
523 extern bool vboSupported;
524 extern bool vboEnabled;
525 extern bool shaders;
526 extern bool stencilBuffer;
205 extern GLint maxTextureUnits;527 extern GLint maxTextureUnits;
206528
207 extern bool canDoSaturated;529 extern bool canDoSaturated;
208 extern bool canDoSlightlySaturated;530 extern bool canDoSlightlySaturated;
531
532#ifndef USE_GLES
533 void getProgramInfoLogARBWrapper (GLuint object, int maxLen, int *len, char *log);
534 void getShaderInfoLogARBWrapper (GLuint object, int maxLen, int *len, char *log);
535 void getShaderivARBWrapper (GLuint object, GLenum type, int *param);
536 void getProgramivARBWrapper (GLuint object, GLenum type, int *param);
537 GLuint createShaderARBWrapper (GLenum type);
538 GLuint createProgramARBWrapper (GLenum type);
539 void shaderSourceARBWrapper (GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
540 void compileShaderARBWrapper (GLuint shader);
541 void validateProgramARBWrapper (GLuint program);
542 void deleteShaderARBWrapper (GLuint shader);
543 void deleteProgramARBWrapper (GLuint program);
544 void attachShaderARBWrapper (GLuint program, GLuint shader);
545 void linkProgramARBWrapper (GLuint program);
546 void useProgramARBWrapper (GLuint program);
547 int getUniformLocationARBWrapper (GLuint program, const GLchar *name);
548 int getAttribLocationARBWrapper (GLuint program, const GLchar *name);
549#endif
209};550};
210551
211struct GLScreenPaintAttrib {552struct GLScreenPaintAttrib {
@@ -220,6 +561,7 @@
220561
221#define MAX_DEPTH 32562#define MAX_DEPTH 32
222563
564#ifndef USE_GLES
223struct GLFBConfig {565struct GLFBConfig {
224 GLXFBConfig fbConfig;566 GLXFBConfig fbConfig;
225 int yInverted;567 int yInverted;
@@ -227,6 +569,7 @@
227 int textureFormat;569 int textureFormat;
228 int textureTargets;570 int textureTargets;
229};571};
572#endif
230573
231#define NOTHING_TRANS_FILTER 0574#define NOTHING_TRANS_FILTER 0
232#define SCREEN_TRANS_FILTER 1575#define SCREEN_TRANS_FILTER 1
@@ -236,6 +579,7 @@
236extern GLScreenPaintAttrib defaultScreenPaintAttrib;579extern GLScreenPaintAttrib defaultScreenPaintAttrib;
237580
238class GLScreen;581class GLScreen;
582class GLFramebufferObject;
239583
240class GLScreenInterface :584class GLScreenInterface :
241 public WrapableInterface<GLScreen, GLScreenInterface>585 public WrapableInterface<GLScreen, GLScreenInterface>
@@ -302,11 +646,32 @@
302 CompOutput *);646 CompOutput *);
303 virtual void glDisableOutputClipping ();647 virtual void glDisableOutputClipping ();
304648
649 virtual GLMatrix *projectionMatrix ();
650
651 /**
652 * Hookable function used by plugins to shade the final composited
653 * Output.
654 *
655 * @param tmpRegion Describes the final composited output region
656 * @param scratchFbo Describes the final composited FBO that is
657 * to be rendered.
658 */
659 virtual void glPaintCompositedOutput (const CompRegion &region,
660 GLFramebufferObject *fbo,
661 unsigned int mask);
662
663 /**
664 * Hookable function used by plugins to determine stenciling mask
665 */
666 virtual void glBufferStencil (const GLMatrix &matrix,
667 GLVertexBuffer &vertexBuffer,
668 CompOutput *output);
669
305};670};
306671
307672
308class GLScreen :673class GLScreen :
309 public WrapableHandler<GLScreenInterface, 6>,674 public WrapableHandler<GLScreenInterface, 8>,
310 public PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI>,675 public PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI>,
311 public CompOption::Class676 public CompOption::Class
312{677{
@@ -332,7 +697,9 @@
332 /**697 /**
333 * Gets the libGL address of a particular openGL functor698 * Gets the libGL address of a particular openGL functor
334 */699 */
700 #ifndef USE_GLES
335 GL::FuncPtr getProcAddress (const char *name);701 GL::FuncPtr getProcAddress (const char *name);
702 #endif
336703
337 void updateBackground ();704 void updateBackground ();
338705
@@ -346,8 +713,6 @@
346 */713 */
347 void setFilter (int, GLTexture::Filter);714 void setFilter (int, GLTexture::Filter);
348715
349 GLFragment::Storage * fragmentStorage ();
350
351 /**716 /**
352 * Sets a new compiz-wid openGL texture environment mode717 * Sets a new compiz-wid openGL texture environment mode
353 */718 */
@@ -356,7 +721,6 @@
356 /**721 /**
357 * Turns lighting on and off722 * Turns lighting on and off
358 */723 */
359
360 void setLighting (bool lighting);724 void setLighting (bool lighting);
361725
362 /**726 /**
@@ -371,7 +735,28 @@
371 GLTexture::BindPixmapHandle registerBindPixmap (GLTexture::BindPixmapProc);735 GLTexture::BindPixmapHandle registerBindPixmap (GLTexture::BindPixmapProc);
372 void unregisterBindPixmap (GLTexture::BindPixmapHandle);736 void unregisterBindPixmap (GLTexture::BindPixmapHandle);
373737
738 #ifndef USE_GLES
374 GLFBConfig * glxPixmapFBConfig (unsigned int depth);739 GLFBConfig * glxPixmapFBConfig (unsigned int depth);
740 #endif
741
742 #ifdef USE_GLES
743 EGLContext getEGLContext ();
744 #endif
745
746 /**
747 * Returns a GLProgram from the cache or creates one and caches it
748 */
749 GLProgram *getProgram (std::list<const GLShaderData*>);
750
751 /**
752 * Returns a GLShaderData from the cache or creates one and caches it
753 */
754 const GLShaderData *getShaderData (GLShaderParameters &params);
755
756 /**
757 * Returns the FBO compiz is using for the screen
758 */
759 GLFramebufferObject *fbo ();
375760
376 /**761 /**
377 * Returns a default icon texture762 * Returns a default icon texture
@@ -380,12 +765,6 @@
380765
381 void resetRasterPos ();766 void resetRasterPos ();
382767
383 /**
384 * Returns a 4x4 const float array which
385 * represents the current projection matrix
386 */
387 const float * projectionMatrix ();
388
389 bool glInitContext (XVisualInfo *);768 bool glInitContext (XVisualInfo *);
390769
391 WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput,770 WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput,
@@ -402,7 +781,16 @@
402 const GLMatrix &, const CompRegion &, CompOutput *);781 const GLMatrix &, const CompRegion &, CompOutput *);
403 WRAPABLE_HND (4, GLScreenInterface, void, glDisableOutputClipping);782 WRAPABLE_HND (4, GLScreenInterface, void, glDisableOutputClipping);
404783
784 WRAPABLE_HND (5, GLScreenInterface, GLMatrix *, projectionMatrix);
785 WRAPABLE_HND (6, GLScreenInterface, void, glPaintCompositedOutput,
786 const CompRegion &, GLFramebufferObject *, unsigned int);
787
788 WRAPABLE_HND (7, GLScreenInterface, void, glBufferStencil, const GLMatrix &,
789 GLVertexBuffer &,
790 CompOutput *);
791
405 friend class GLTexture;792 friend class GLTexture;
793 friend class GLWindow;
406794
407 private:795 private:
408 PrivateGLScreen *priv;796 PrivateGLScreen *priv;
@@ -454,7 +842,7 @@
454 * @param mask Bitmask which describes how this window is drawn842 * @param mask Bitmask which describes how this window is drawn
455 */843 */
456 virtual bool glDraw (const GLMatrix &matrix,844 virtual bool glDraw (const GLMatrix &matrix,
457 GLFragment::Attrib &attrib,845 const GLWindowPaintAttrib &attrib,
458 const CompRegion &region,846 const CompRegion &region,
459 unsigned int mask);847 unsigned int mask);
460848
@@ -479,51 +867,18 @@
479 const CompRegion &clipRegion,867 const CompRegion &clipRegion,
480 unsigned int min = MAXSHORT,868 unsigned int min = MAXSHORT,
481 unsigned int max = MAXSHORT);869 unsigned int max = MAXSHORT);
482 virtual void glDrawTexture (GLTexture *texture, GLFragment::Attrib &,870 virtual void glDrawTexture (GLTexture *texture, const GLMatrix &,
483 unsigned int);871 const GLWindowPaintAttrib &, unsigned int);
484 virtual void glDrawGeometry ();
485};872};
486873
487class GLWindow :874class GLWindow :
488 public WrapableHandler<GLWindowInterface, 5>,875 public WrapableHandler<GLWindowInterface, 4>,
489 public PluginClassHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI>876 public PluginClassHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI>
490{877{
491 public:878 public:
492879
493 /**
494 * Class which describes the texture geometry and transformation points
495 * of a window
496 */
497 class Geometry {
498 public:
499 Geometry ();
500 ~Geometry ();
501
502 void reset ();
503
504 /**
505 * Set the number of vertices in the texture geometry
506 */
507 bool moreVertices (int newSize);
508
509 /**
510 * Set the number of indices in the texture geometry
511 */
512 bool moreIndices (int newSize);
513
514 public:
515 GLfloat *vertices;
516 int vertexSize;
517 int vertexStride;
518 GLushort *indices;
519 int indexSize;
520 int vCount;
521 int texUnits;
522 int texCoordSize;
523 int indexCount;
524 };
525
526 static GLWindowPaintAttrib defaultPaintAttrib;880 static GLWindowPaintAttrib defaultPaintAttrib;
881
527 public:882 public:
528883
529 GLWindow (CompWindow *w);884 GLWindow (CompWindow *w);
@@ -566,9 +921,20 @@
566 void updatePaintAttribs ();921 void updatePaintAttribs ();
567922
568 /**923 /**
569 * Returns the window texture geometry924 * Returns the window vertex buffer object
570 */925 */
571 Geometry & geometry ();926 GLVertexBuffer * vertexBuffer ();
927
928 /**
929 * Add a vertex and/or fragment shader function to the pipeline.
930 *
931 * @param name Name of the plugin adding the functions
932 * @param vertex_shader Function to add to the vertex shader
933 * @param fragment_shader Function to add to the fragment shader
934 */
935 void addShaders (std::string name,
936 std::string vertex_shader,
937 std::string fragment_shader);
572938
573 GLTexture *getIcon (int width, int height);939 GLTexture *getIcon (int width, int height);
574940
@@ -576,14 +942,15 @@
576 const GLWindowPaintAttrib &, const GLMatrix &,942 const GLWindowPaintAttrib &, const GLMatrix &,
577 const CompRegion &, unsigned int);943 const CompRegion &, unsigned int);
578 WRAPABLE_HND (1, GLWindowInterface, bool, glDraw, const GLMatrix &,944 WRAPABLE_HND (1, GLWindowInterface, bool, glDraw, const GLMatrix &,
579 GLFragment::Attrib &, const CompRegion &, unsigned int);945 const GLWindowPaintAttrib &, const CompRegion &,
946 unsigned int);
580 WRAPABLE_HND (2, GLWindowInterface, void, glAddGeometry,947 WRAPABLE_HND (2, GLWindowInterface, void, glAddGeometry,
581 const GLTexture::MatrixList &, const CompRegion &,948 const GLTexture::MatrixList &, const CompRegion &,
582 const CompRegion &,949 const CompRegion &,
583 unsigned int = MAXSHORT, unsigned int = MAXSHORT);950 unsigned int = MAXSHORT, unsigned int = MAXSHORT);
584 WRAPABLE_HND (3, GLWindowInterface, void, glDrawTexture,951 WRAPABLE_HND (3, GLWindowInterface, void, glDrawTexture,
585 GLTexture *texture, GLFragment::Attrib &, unsigned int);952 GLTexture *texture, const GLMatrix &,
586 WRAPABLE_HND (4, GLWindowInterface, void, glDrawGeometry);953 const GLWindowPaintAttrib &, unsigned int);
587954
588 friend class GLScreen;955 friend class GLScreen;
589 friend class PrivateGLScreen;956 friend class PrivateGLScreen;
@@ -593,3 +960,4 @@
593};960};
594961
595#endif962#endif
963
596964
=== added file 'plugins/opengl/include/opengl/program.h'
--- plugins/opengl/include/opengl/program.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/program.h 2012-08-22 06:16:22 +0000
@@ -0,0 +1,75 @@
1/*
2 * Copyright © 2011 Linaro Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Linaro Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Linaro Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Travis Watkins <travis.watkins@linaro.org>
24 */
25
26#ifndef _COMPIZ_GLPROGRAM_H
27#define _COMPIZ_GLPROGRAM_H
28
29#ifdef USE_GLES
30#include <GLES2/gl2.h>
31#else
32#include <GL/gl.h>
33#endif
34
35#include <core/core.h>
36#include <opengl/matrix.h>
37
38class PrivateProgram;
39
40class GLProgram
41{
42 public:
43 GLProgram (CompString &vertexShader, CompString &fragmentShader);
44 ~GLProgram ();
45
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches