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