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