Merge lp:~linaro-graphics-wg/compiz-core/linaro-gles2 into lp:compiz-core

Proposed by Sam Spilsbury on 2012-02-21
Status: Rejected
Rejected by: Daniel van Vugt on 2012-04-19
Proposed branch: lp:~linaro-graphics-wg/compiz-core/linaro-gles2
Merge into: lp:compiz-core
Diff against target: 12057 lines (+4687/-4112)
66 files modified
CMakeLists.txt (+12/-0)
cmake/CMakeLists.txt (+2/-0)
cmake/CompizCommon.cmake (+12/-0)
cmake/CompizPlugin.cmake (+14/-10)
cmake/FindOpenGLES2.cmake (+51/-0)
cmake/base.cmake (+3/-1)
cmake/plugin_extensions/CompizOpenGLFixups.cmake (+22/-0)
gtk/config.h.gtk.in (+0/-25)
gtk/window-decorator/actionmenu.c (+0/-133)
gtk/window-decorator/blurprops.c (+0/-89)
gtk/window-decorator/forcequit.c (+0/-201)
gtk/window-decorator/gdk.c (+0/-106)
gtk/window-decorator/style.c (+0/-66)
gtk/window-decorator/util.c (+0/-299)
plugins/annotate/src/annotate.cpp (+151/-77)
plugins/blur/CMakeLists.txt (+12/-12)
plugins/clone/src/clone.cpp (+0/-5)
plugins/compiztoolbox/src/compiztoolbox.cpp (+14/-28)
plugins/copytex/src/copytex.cpp (+9/-0)
plugins/cube/CMakeLists.txt (+1/-1)
plugins/cube/src/cube.cpp (+0/-4)
plugins/decor/src/decor.cpp (+34/-21)
plugins/decor/src/decor.h (+3/-3)
plugins/imgsvg/src/imgsvg.cpp (+12/-9)
plugins/imgsvg/src/imgsvg.h (+2/-1)
plugins/obs/src/obs.cpp (+9/-8)
plugins/obs/src/obs.h (+1/-1)
plugins/opengl/CMakeLists.txt (+9/-4)
plugins/opengl/compiz-opengl.pc.in (+2/-2)
plugins/opengl/include/opengl/fragment.h (+0/-125)
plugins/opengl/include/opengl/framebufferobject.h (+107/-0)
plugins/opengl/include/opengl/matrix.h (+2/-0)
plugins/opengl/include/opengl/opengl.h (+266/-72)
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 (+1/-1)
plugins/opengl/include/opengl/vertexbuffer.h (+109/-0)
plugins/opengl/opengl.xml.in (+1/-1)
plugins/opengl/src/fragment.cpp (+0/-1146)
plugins/opengl/src/framebufferobject.cpp (+191/-0)
plugins/opengl/src/matrix.cpp (+54/-0)
plugins/opengl/src/paint.cpp (+414/-422)
plugins/opengl/src/privatefragment.h (+0/-54)
plugins/opengl/src/privates.h (+36/-11)
plugins/opengl/src/privatetexture.h (+32/-0)
plugins/opengl/src/privatevertexbuffer.h (+138/-0)
plugins/opengl/src/program.cpp (+262/-0)
plugins/opengl/src/programcache.cpp (+175/-0)
plugins/opengl/src/screen.cpp (+554/-70)
plugins/opengl/src/shadercache.cpp (+246/-0)
plugins/opengl/src/texture.cpp (+136/-11)
plugins/opengl/src/vertexbuffer.cpp (+550/-0)
plugins/opengl/src/window.cpp (+69/-84)
plugins/resize/src/resize.cpp (+95/-39)
plugins/rotate/CMakeLists.txt (+1/-1)
plugins/scale/src/scale.cpp (+12/-24)
plugins/screenshot/src/screenshot.cpp (+52/-25)
plugins/switcher/src/switcher.cpp (+49/-48)
plugins/water/CMakeLists.txt (+1/-1)
plugins/water/src/shaders.h (+201/-0)
plugins/water/src/water.cpp (+265/-803)
plugins/water/src/water.h (+37/-67)
plugins/water/water.xml.in (+24/-0)
plugins/wobbly/CMakeLists.txt (+1/-1)
To merge this branch: bzr merge lp:~linaro-graphics-wg/compiz-core/linaro-gles2
Reviewer Review Type Date Requested Status
Daniel van Vugt Disapprove on 2012-04-19
Sam Spilsbury Pending
Review via email: mp+94070@code.launchpad.net

This proposal supersedes a proposal from 2012-01-23.

Description of the change

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

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

Things left to do for a complete port:

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

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

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

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

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

--

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

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

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

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

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

Does this need to be off by default?

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

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

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

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

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

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

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

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

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

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

Read more...

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

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

Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

All these conflicts seem to be here due to the fact that bzr seems to think we've deleted and re-added every file in the tree *sigh*

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

No problem. Just make a new branch and copy these files into it and propose the new one. Then bzr should be happier.

Frederic Plourde (fredinfinite23) : Posted in a previous version of this proposal
Sam Spilsbury (smspillaz) wrote :

OK, it looks like trunk needs to be merged into this branch

2905. By Alexandros Frantzis on 2012-02-23

Sync with lp:compiz-core.

2906. By Alexandros Frantzis on 2012-02-23

Sync with lp:compiz-core.

2907. By Alexandros Frantzis on 2012-03-02

Sync with lp:compiz-core.

2908. By Alexandros Frantzis on 2012-03-05

Use new WRAPABLE_HND_* macros.

2909. By Alexandros Frantzis on 2012-03-05

Correct count of wrapable functions in GLScreen.

2910. By Alexandros Frantzis on 2012-03-05

Sync with lp:compiz-core

2911. By Frederic Plourde on 2012-03-09

Fix decoration mapping instabilities and texturing artefacts.

2912. By Alexandros Frantzis on 2012-03-13

Work around compile issue on ARM.

When compiling with -O2 on ARM, the original code leads to an array index out
of bounds compilation error. In that case, the compiler doesn't infer that
sizeof(a)/sizeof(T) is a constant, and tries to compile cases in the switch
statement that use array indices that are invalid for the particular template
instantiation.

To fix this we use the 'C' template variable, which is constant for each
template instantiation, directly in the switch statement.

2913. By Alexandros Frantzis on 2012-03-13

Sync with lp:compiz-core.

2914. By Alexandros Frantzis on 2012-03-21

Sync with lp:compiz-core.

2915. By Alexandros Frantzis on 2012-03-29

opengl: Ensure blending is enabled, when needed, when drawing window contents.

Daniel van Vugt (vanvugt) wrote :

I hope to test this and if all goes well then merge when 0.9.8 opens up.

2916. By Alexandros Frantzis on 2012-04-02

opengl: Refactor shader infrastructure to use small, performant programs.

This commit replaces the single complicated shader with minimal,
performant shaders, tailored to specific use cases. The new GLShaderCache
object is used for creating and caching the shader data for specific uses
cases (GLShaderParameters).

This commit also adds automatic creation of suitable GL programs in
GLVertexBuffers (see ::setAutoProgram) that don't have a program
explicitly set.

2917. By Alexandros Frantzis on 2012-04-03

Sync with lp:compiz-core.

2918. By Alexandros Frantzis on 2012-04-04

opengl: Disable blending by default when drawing the screen.

Each operation/plugin should enable it (and reset it) as needed
(as most operations are currently doing).

2919. By Alexandros Frantzis on 2012-04-06

Fix compilation with desktop GL.

2920. By Alexandros Frantzis on 2012-04-06

opengl: For OpenGL ES 2.0 ensure that format equals internalFormat when uploading texture data.

In OpenGL ES 2.0 no format conversion is allowed, i.e., format must equal internalFormat.

2921. By Alexandros Frantzis on 2012-04-10

Sync with lp:compiz-core.

Daniel van Vugt (vanvugt) wrote :

I will ask the linaro team to propose the branch to 0.9.8, since they're the ones who will be fixing anything that needs fixing...

review: Disapprove

Unmerged revisions

2922. By Alexandros Frantzis on 2012-04-19

Sync with lp:compiz-core.

2921. By Alexandros Frantzis on 2012-04-10

Sync with lp:compiz-core.

2920. By Alexandros Frantzis on 2012-04-06

opengl: For OpenGL ES 2.0 ensure that format equals internalFormat when uploading texture data.

In OpenGL ES 2.0 no format conversion is allowed, i.e., format must equal internalFormat.

2919. By Alexandros Frantzis on 2012-04-06

Fix compilation with desktop GL.

2918. By Alexandros Frantzis on 2012-04-04

opengl: Disable blending by default when drawing the screen.

Each operation/plugin should enable it (and reset it) as needed
(as most operations are currently doing).

2917. By Alexandros Frantzis on 2012-04-03

Sync with lp:compiz-core.

2916. By Alexandros Frantzis on 2012-04-02

opengl: Refactor shader infrastructure to use small, performant programs.

This commit replaces the single complicated shader with minimal,
performant shaders, tailored to specific use cases. The new GLShaderCache
object is used for creating and caching the shader data for specific uses
cases (GLShaderParameters).

This commit also adds automatic creation of suitable GL programs in
GLVertexBuffers (see ::setAutoProgram) that don't have a program
explicitly set.

2915. By Alexandros Frantzis on 2012-03-29

opengl: Ensure blending is enabled, when needed, when drawing window contents.

2914. By Alexandros Frantzis on 2012-03-21

Sync with lp:compiz-core.

2913. By Alexandros Frantzis on 2012-03-13

Sync with lp:compiz-core.

Preview Diff

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

Subscribers

People subscribed via source and target branches