Merge lp:~compiz-team/compiz/compiz.gles into lp:compiz/0.9.8

Proposed by Sam Spilsbury
Status: Rejected
Rejected by: Sam Spilsbury
Proposed branch: lp:~compiz-team/compiz/compiz.gles
Merge into: lp:compiz/0.9.8
Diff against target: 13017 lines (+5133/-4363)
68 files modified
CMakeLists.txt (+3/-0)
cmake/CMakeLists.txt (+2/-0)
cmake/CompizCommon.cmake (+12/-0)
cmake/CompizPlugin.cmake (+14/-10)
cmake/FindOpenGLES2.cmake (+51/-0)
cmake/base.cmake (+3/-1)
cmake/plugin_extensions/CompizOpenGLFixups.cmake (+22/-0)
gtk/config.h.gtk.in (+0/-25)
gtk/window-decorator/actionmenu.c (+0/-133)
gtk/window-decorator/blurprops.c (+0/-89)
gtk/window-decorator/forcequit.c (+0/-201)
gtk/window-decorator/gdk.c (+0/-106)
gtk/window-decorator/style.c (+0/-66)
gtk/window-decorator/util.c (+0/-299)
plugins/annotate/src/annotate.cpp (+151/-73)
plugins/blur/CMakeLists.txt (+12/-12)
plugins/clone/src/clone.cpp (+0/-5)
plugins/compiztoolbox/src/compiztoolbox.cpp (+14/-28)
plugins/copytex/src/copytex.cpp (+9/-0)
plugins/cube/CMakeLists.txt (+1/-1)
plugins/cube/include/cube/cube.h (+9/-6)
plugins/cube/src/cube.cpp (+85/-80)
plugins/decor/src/decor.cpp (+34/-22)
plugins/decor/src/decor.h (+3/-3)
plugins/imgsvg/src/imgsvg.cpp (+12/-9)
plugins/imgsvg/src/imgsvg.h (+2/-1)
plugins/obs/src/obs.cpp (+9/-8)
plugins/obs/src/obs.h (+1/-1)
plugins/opengl/CMakeLists.txt (+9/-4)
plugins/opengl/compiz-opengl.pc.in (+2/-2)
plugins/opengl/include/opengl/fragment.h (+0/-125)
plugins/opengl/include/opengl/framebufferobject.h (+107/-0)
plugins/opengl/include/opengl/matrix.h (+2/-0)
plugins/opengl/include/opengl/opengl.h (+264/-72)
plugins/opengl/include/opengl/program.h (+75/-0)
plugins/opengl/include/opengl/programcache.h (+51/-0)
plugins/opengl/include/opengl/shadercache.h (+100/-0)
plugins/opengl/include/opengl/texture.h (+5/-0)
plugins/opengl/include/opengl/vector.h (+3/-3)
plugins/opengl/include/opengl/vertexbuffer.h (+123/-0)
plugins/opengl/src/fragment.cpp (+0/-1146)
plugins/opengl/src/framebufferobject.cpp (+191/-0)
plugins/opengl/src/matrix.cpp (+54/-0)
plugins/opengl/src/paint.cpp (+410/-419)
plugins/opengl/src/privatefragment.h (+0/-54)
plugins/opengl/src/privates.h (+36/-11)
plugins/opengl/src/privatetexture.h (+32/-0)
plugins/opengl/src/privatevertexbuffer.h (+141/-0)
plugins/opengl/src/program.cpp (+262/-0)
plugins/opengl/src/programcache.cpp (+175/-0)
plugins/opengl/src/screen.cpp (+548/-69)
plugins/opengl/src/shadercache.cpp (+246/-0)
plugins/opengl/src/texture.cpp (+136/-11)
plugins/opengl/src/vector.cpp (+4/-4)
plugins/opengl/src/vertexbuffer.cpp (+567/-0)
plugins/opengl/src/window.cpp (+69/-84)
plugins/resize/src/resize.cpp (+95/-39)
plugins/rotate/CMakeLists.txt (+1/-1)
plugins/scale/src/scale.cpp (+12/-24)
plugins/screenshot/src/screenshot.cpp (+52/-25)
plugins/switcher/src/switcher.cpp (+49/-48)
plugins/water/CMakeLists.txt (+1/-1)
plugins/water/src/shaders.h (+200/-0)
plugins/water/src/water.cpp (+265/-803)
plugins/water/src/water.h (+37/-67)
plugins/water/water.xml.in (+26/-2)
plugins/wobbly/src/wobbly.cpp (+334/-169)
plugins/wobbly/src/wobbly.h (+0/-1)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.gles
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+106096@code.launchpad.net
To post a comment you must log in.
lp:~compiz-team/compiz/compiz.gles updated
3198. By Sam Spilsbury

Merged lp:compiz/0.9.8

3199. By Sam Spilsbury

Merge lp:compiz/0.9.8

3200. By Sam Spilsbury

Merge lp:compiz/0.9.8

3201. By Sam Spilsbury

Merge lp:compiz/0.9.8

Unmerged revisions

3201. By Sam Spilsbury

Merge lp:compiz/0.9.8

3200. By Sam Spilsbury

Merge lp:compiz/0.9.8

3199. By Sam Spilsbury

Merge lp:compiz/0.9.8

3198. By Sam Spilsbury

Merged lp:compiz/0.9.8

3197. By Sam Spilsbury

Merged branch gles into compiz-core

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2012-05-17 06:22:24 +0000
+++ CMakeLists.txt 2012-05-17 07:01:21 +0000
@@ -119,6 +119,9 @@
119 DESTINATION ${COMPIZ_DESTDIR}${libdir}/pkgconfig119 DESTINATION ${COMPIZ_DESTDIR}${libdir}/pkgconfig
120)120)
121121
122# temporarily disable plugins that aren't ported yed
123set (COMPIZ_DISABLE_PLUGIN_BLUR ON)
124
122# Build Google Test and make its headers known125# Build Google Test and make its headers known
123find_package (GTest)126find_package (GTest)
124127
125128
=== modified file 'cmake/CMakeLists.txt'
--- cmake/CMakeLists.txt 2011-07-27 16:13:28 +0000
+++ cmake/CMakeLists.txt 2012-05-17 07:01:21 +0000
@@ -15,6 +15,8 @@
15 plugin_extensions/CompizGenInstallData.cmake)15 plugin_extensions/CompizGenInstallData.cmake)
16list (APPEND _PluginExtensionFiles16list (APPEND _PluginExtensionFiles
17 plugin_extensions/CompizGenInstallImages.cmake)17 plugin_extensions/CompizGenInstallImages.cmake)
18list (APPEND _PluginExtensionFiles
19 plugin_extensions/CompizOpenGLFixups.cmake)
1820
19if (USE_GCONF)21if (USE_GCONF)
20 list (APPEND _files CompizGconf.cmake)22 list (APPEND _files CompizGconf.cmake)
2123
=== modified file 'cmake/CompizCommon.cmake'
--- cmake/CompizCommon.cmake 2012-05-17 05:09:25 +0000
+++ cmake/CompizCommon.cmake 2012-05-17 07:01:21 +0000
@@ -18,6 +18,7 @@
1818
19set (CMAKE_SKIP_RPATH FALSE)19set (CMAKE_SKIP_RPATH FALSE)
2020
21option (BUILD_GLES "Build against GLESv2 instead of GL" OFF)
21option (COMPIZ_BUILD_WITH_RPATH "Leave as ON unless building packages" ON)22option (COMPIZ_BUILD_WITH_RPATH "Leave as ON unless building packages" ON)
22option (COMPIZ_RUN_LDCONFIG "Leave OFF unless you need to run ldconfig after install")23option (COMPIZ_RUN_LDCONFIG "Leave OFF unless you need to run ldconfig after install")
23option (COMPIZ_PACKAGING_ENABLED "Enable to manually set prefix, exec_prefix, libdir, includedir, datadir" OFF)24option (COMPIZ_PACKAGING_ENABLED "Enable to manually set prefix, exec_prefix, libdir, includedir, datadir" OFF)
@@ -75,6 +76,17 @@
75 set(IS_BZR_REPO 0)76 set(IS_BZR_REPO 0)
76endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr)77endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr)
7778
79set (USE_GLES ${BUILD_GLES})
80
81if (USE_GLES)
82 find_package(OpenGLES2)
83
84 if (NOT OPENGLES2_FOUND)
85 set (USE_GLES 0)
86 message (SEND_ERROR "OpenGLESv2 not found")
87 endif (NOT OPENGLES2_FOUND)
88endif (USE_GLES)
89
78function (compiz_ensure_linkage)90function (compiz_ensure_linkage)
79 find_program (LDCONFIG_EXECUTABLE ldconfig)91 find_program (LDCONFIG_EXECUTABLE ldconfig)
80 mark_as_advanced (FORCE LDCONFIG_EXECUTABLE)92 mark_as_advanced (FORCE LDCONFIG_EXECUTABLE)
8193
=== modified file 'cmake/CompizPlugin.cmake'
--- cmake/CompizPlugin.cmake 2012-02-07 06:39:28 +0000
+++ cmake/CompizPlugin.cmake 2012-05-17 07:01:21 +0000
@@ -257,6 +257,16 @@
257 NO_DEFAULT_PATH257 NO_DEFAULT_PATH
258 )258 )
259259
260 set (COMPIZ_CURRENT_PLUGIN ${plugin})
261 set (COMPIZ_CURRENT_XML_FILE ${_translated_xml})
262
263 # find extension files
264 file (GLOB _extension_files "${COMPIZ_CMAKE_MODULE_PATH}/plugin_extensions/*.cmake")
265
266 foreach (_file ${_extension_files})
267 include (${_file})
268 endforeach ()
269
260 # generate pkgconfig file and install it and the plugin header file270 # generate pkgconfig file and install it and the plugin header file
261 if (_${plugin}_pkg AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin})271 if (_${plugin}_pkg AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin})
262 if ("${PLUGIN_BUILDTYPE}" STREQUAL "local")272 if ("${PLUGIN_BUILDTYPE}" STREQUAL "local")
@@ -269,11 +279,15 @@
269 set (VERSION 0.0.1-git)279 set (VERSION 0.0.1-git)
270 endif (NOT VERSION)280 endif (NOT VERSION)
271281
282 #add CFLAGSADD so pkg-config file has correct flags
283 set (COMPIZ_CFLAGS ${COMPIZ_CFLAGS} ${${_PLUGIN}_CFLAGSADD})
284
272 compiz_configure_file (285 compiz_configure_file (
273 ${_${plugin}_pkg}286 ${_${plugin}_pkg}
274 ${CMAKE_BINARY_DIR}/generated/compiz-${plugin}.pc287 ${CMAKE_BINARY_DIR}/generated/compiz-${plugin}.pc
275 COMPIZ_REQUIRES288 COMPIZ_REQUIRES
276 COMPIZ_CFLAGS289 COMPIZ_CFLAGS
290 PKGCONFIG_LIBS
277 )291 )
278292
279 install (293 install (
@@ -287,16 +301,6 @@
287 endif ()301 endif ()
288 endif ()302 endif ()
289303
290 set (COMPIZ_CURRENT_PLUGIN ${plugin})
291 set (COMPIZ_CURRENT_XML_FILE ${_translated_xml})
292
293 # find extension files
294 file (GLOB _extension_files "${COMPIZ_CMAKE_MODULE_PATH}/plugin_extensions/*.cmake")
295
296 foreach (_file ${_extension_files})
297 include (${_file})
298 endforeach ()
299
300 # find files for build304 # find files for build
301 file (GLOB _h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")305 file (GLOB _h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")
302 file (GLOB _h_ins_files "${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}/*.h")306 file (GLOB _h_ins_files "${CMAKE_CURRENT_SOURCE_DIR}/include/${plugin}/*.h")
303307
=== added file 'cmake/FindOpenGLES2.cmake'
--- cmake/FindOpenGLES2.cmake 1970-01-01 00:00:00 +0000
+++ cmake/FindOpenGLES2.cmake 2012-05-17 07:01:21 +0000
@@ -0,0 +1,51 @@
1# - Try to find OpenGLES
2# Once done this will define
3#
4# OPENGLES2_FOUND - system has OpenGLES
5# OPENGLES2_INCLUDE_DIR - the GLES include directory
6# OPENGLES2_LIBRARY - the GLES library
7# OPENGLES2_LIBRARIES - Link this to use OpenGLES
8#
9
10FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
11 /usr/openwin/share/include
12 /opt/graphics/OpenGL/include /usr/X11R6/include
13 /usr/include
14)
15
16FIND_LIBRARY(OPENGLES2_LIBRARY
17 NAMES GLESv2
18 PATHS /opt/graphics/OpenGL/lib
19 /usr/openwin/lib
20 /usr/shlib /usr/X11R6/lib
21 /usr/lib
22)
23
24FIND_LIBRARY(OPENGLES2_EGL_LIBRARY
25 NAMES EGL
26 PATHS /usr/shlib /usr/X11R6/lib
27 /usr/lib
28)
29
30# On Unix OpenGL most certainly always requires X11.
31# Feel free to tighten up these conditions if you don't
32# think this is always true.
33# It's not true on OSX.
34
35IF (OPENGLES2_LIBRARY)
36 IF(NOT X11_FOUND)
37 INCLUDE(FindX11)
38 ENDIF(NOT X11_FOUND)
39 IF (X11_FOUND)
40 IF (NOT APPLE)
41 SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES})
42 ENDIF (NOT APPLE)
43 ENDIF (X11_FOUND)
44ENDIF(OPENGLES2_LIBRARY)
45
46SET( OPENGLES2_FOUND "NO" )
47IF(OPENGLES2_LIBRARY AND OPENGLES2_EGL_LIBRARY)
48 SET( OPENGLES2_LIBRARIES ${OPENGLES2_LIBRARY} ${OPENGLES2_EGL_LIBRARY} ${OPENGLES2_LIBRARIES})
49 SET( OPENGLES2_FOUND "YES" )
50ENDIF(OPENGLES2_LIBRARY AND OPENGLES2_EGL_LIBRARY)
51
052
=== modified file 'cmake/base.cmake'
--- cmake/base.cmake 2011-07-27 16:13:28 +0000
+++ cmake/base.cmake 2012-05-17 07:01:21 +0000
@@ -24,6 +24,7 @@
24 compiz_print_configure_header ("Compiz")24 compiz_print_configure_header ("Compiz")
25 compiz_color_message ("\n${_escape}[4mOptional features:${_escape}[0m\n")25 compiz_color_message ("\n${_escape}[4mOptional features:${_escape}[0m\n")
2626
27 compiz_print_result_message ("GLESv2" USE_GLES)
27 compiz_print_result_message ("gtk window decorator" USE_GTK)28 compiz_print_result_message ("gtk window decorator" USE_GTK)
28 compiz_print_result_message ("metacity theme support" USE_METACITY)29 compiz_print_result_message ("metacity theme support" USE_METACITY)
29 compiz_print_result_message ("gconf schemas" USE_GCONF)30 compiz_print_result_message ("gconf schemas" USE_GCONF)
@@ -46,7 +47,8 @@
46 endif ()47 endif ()
47 add_custom_target (findcompiz_install48 add_custom_target (findcompiz_install
48 ${CMAKE_COMMAND} -E make_directory ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules &&49 ${CMAKE_COMMAND} -E make_directory ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules &&
49 ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindCompiz.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules50 ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindCompiz.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules &&
51 ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/cmake/FindOpenGLES2.cmake ${COMPIZ_DESTDIR}${CMAKE_ROOT}/Modules
50 )52 )
51endfunction ()53endfunction ()
5254
5355
=== added file 'cmake/plugin_extensions/CompizOpenGLFixups.cmake'
--- cmake/plugin_extensions/CompizOpenGLFixups.cmake 1970-01-01 00:00:00 +0000
+++ cmake/plugin_extensions/CompizOpenGLFixups.cmake 2012-05-17 07:01:21 +0000
@@ -0,0 +1,22 @@
1
2# modify pkg-config libs for opengl based on if we found GLES or not
3if (${COMPIZ_CURRENT_PLUGIN} STREQUAL "opengl")
4 if (USE_GLES)
5 set (PKGCONFIG_LIBS "-lGLESv2 -lEGL")
6 else (USE_GLES)
7 set (PKGCONFIG_LIBS "-lGL")
8 endif (USE_GLES)
9endif (${COMPIZ_CURRENT_PLUGIN} STREQUAL "opengl")
10
11# if plugin is using opengl plugin check for GLES library and set correct define
12if (NOT "${${_PLUGIN}_PLUGINDEPS}" STREQUAL "")
13 string (REGEX MATCH "opengl" opengl_found ${${_PLUGIN}_PLUGINDEPS})
14
15 if (opengl_found STREQUAL "opengl")
16 if (USE_GLES)
17 set (${_PLUGIN}_CFLAGSADD ${${_PLUGIN}_CFLAGSADD} " -DUSE_GLES")
18 string (REPLACE ";" " " ${_PLUGIN}_CFLAGSADD ${${_PLUGIN}_CFLAGSADD})
19 endif (USE_GLES)
20 endif (opengl_found STREQUAL "opengl")
21endif (NOT "${${_PLUGIN}_PLUGINDEPS}" STREQUAL "")
22
023
=== added file 'gtk/config.h.gtk.in'
--- gtk/config.h.gtk.in 1970-01-01 00:00:00 +0000
+++ gtk/config.h.gtk.in 2012-05-17 07:01:21 +0000
@@ -0,0 +1,25 @@
1/* Define to 1 if Metacity support is enabled */
2#cmakedefine USE_METACITY 1
3
4/* Define to 1 if Gconf support is enabled */
5#cmakedefine USE_GCONF 1
6
7/* Define to 1 if you have the `wnck_window_has_name' function. */
8#cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 1
9
10/* Define to 1 if libwnck version >= 2_18_1 */
11#cmakedefine HAVE_LIBWNCK_2_18_1 1
12
13/* Define to 1 if libwnck version >= 2_19_4 */
14#cmakedefine HAVE_LIBWNCK_2_19_4 1
15
16/* Define to 1 if metacity version >= 2.15.21 */
17#cmakedefine HAVE_METACITY_2_15_21 1
18
19/* Define to 1 if metacity version >= 2.17.0 */
20#cmakedefine HAVE_METACITY_2_17_0 1
21
22/* Define to 1 if metacity version >= 2.23.2 */
23#cmakedefine HAVE_METACITY_2_23_2 1
24
25#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"
026
=== removed file 'gtk/config.h.gtk.in'
--- gtk/config.h.gtk.in 2008-10-14 10:27:55 +0000
+++ gtk/config.h.gtk.in 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1/* Define to 1 if Metacity support is enabled */
2#cmakedefine USE_METACITY 1
3
4/* Define to 1 if Gconf support is enabled */
5#cmakedefine USE_GCONF 1
6
7/* Define to 1 if you have the `wnck_window_has_name' function. */
8#cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 1
9
10/* Define to 1 if libwnck version >= 2_18_1 */
11#cmakedefine HAVE_LIBWNCK_2_18_1 1
12
13/* Define to 1 if libwnck version >= 2_19_4 */
14#cmakedefine HAVE_LIBWNCK_2_19_4 1
15
16/* Define to 1 if metacity version >= 2.15.21 */
17#cmakedefine HAVE_METACITY_2_15_21 1
18
19/* Define to 1 if metacity version >= 2.17.0 */
20#cmakedefine HAVE_METACITY_2_17_0 1
21
22/* Define to 1 if metacity version >= 2.23.2 */
23#cmakedefine HAVE_METACITY_2_23_2 1
24
25#define GETTEXT_PACKAGE "${GETTEXT_PACKAGE}"
260
=== added file 'gtk/window-decorator/actionmenu.c'
--- gtk/window-decorator/actionmenu.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/actionmenu.c 2012-05-17 07:01:21 +0000
@@ -0,0 +1,133 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24static void
25action_menu_unmap (GObject *object)
26{
27 action_menu_mapped = FALSE;
28}
29
30static void
31position_action_menu (GtkMenu *menu,
32 gint *x,
33 gint *y,
34 gboolean *push_in,
35 gpointer user_data)
36{
37 WnckWindow *win = (WnckWindow *) user_data;
38 decor_frame_t *frame = gwd_get_decor_frame (get_frame_type (win));
39 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
40 gint bx, by, width, height;
41
42 wnck_window_get_client_window_geometry (win, x, y, &width, &height);
43
44 if ((*theme_get_button_position) (d, BUTTON_MENU, width, height,
45 &bx, &by, &width, &height))
46 *x = *x - frame->win_extents.left + bx;
47
48 gwd_decor_frame_unref (frame);
49
50 if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
51 {
52 GtkRequisition req;
53
54 gtk_widget_size_request (GTK_WIDGET (menu), &req);
55 *x = MAX (0, *x - req.width + width);
56 }
57
58 *push_in = TRUE;
59}
60
61void
62action_menu_map (WnckWindow *win,
63 long button,
64 Time time)
65{
66 GdkDisplay *gdkdisplay;
67 GdkScreen *screen;
68
69 gdkdisplay = gdk_display_get_default ();
70 screen = gdk_display_get_default_screen (gdkdisplay);
71
72 if (action_menu)
73 {
74 if (action_menu_mapped)
75 {
76 gtk_widget_destroy (action_menu);
77 action_menu_mapped = FALSE;
78 action_menu = NULL;
79 return;
80 }
81 else
82 gtk_widget_destroy (action_menu);
83 }
84
85 switch (wnck_window_get_window_type (win)) {
86 case WNCK_WINDOW_DESKTOP:
87 case WNCK_WINDOW_DOCK:
88 /* don't allow window action */
89 return;
90 case WNCK_WINDOW_NORMAL:
91 case WNCK_WINDOW_DIALOG:
92
93#ifndef HAVE_LIBWNCK_2_19_4
94 case WNCK_WINDOW_MODAL_DIALOG:
95#endif
96
97 case WNCK_WINDOW_TOOLBAR:
98 case WNCK_WINDOW_MENU:
99 case WNCK_WINDOW_UTILITY:
100 case WNCK_WINDOW_SPLASHSCREEN:
101 /* allow window action menu */
102 break;
103 }
104
105 action_menu = wnck_create_window_action_menu (win);
106
107 gtk_menu_set_screen (GTK_MENU (action_menu), screen);
108
109 g_signal_connect_object (G_OBJECT (action_menu), "unmap",
110 G_CALLBACK (action_menu_unmap),
111 0, 0);
112
113 gtk_widget_show (action_menu);
114
115 if (!button || button == 1)
116 {
117 gtk_menu_popup (GTK_MENU (action_menu),
118 NULL, NULL,
119 position_action_menu, (gpointer) win,
120 button,
121 time);
122 }
123 else
124 {
125 gtk_menu_popup (GTK_MENU (action_menu),
126 NULL, NULL,
127 NULL, NULL,
128 button,
129 time);
130 }
131
132 action_menu_mapped = TRUE;
133}
0134
=== removed file 'gtk/window-decorator/actionmenu.c'
--- gtk/window-decorator/actionmenu.c 2011-05-07 08:58:10 +0000
+++ gtk/window-decorator/actionmenu.c 1970-01-01 00:00:00 +0000
@@ -1,133 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24static void
25action_menu_unmap (GObject *object)
26{
27 action_menu_mapped = FALSE;
28}
29
30static void
31position_action_menu (GtkMenu *menu,
32 gint *x,
33 gint *y,
34 gboolean *push_in,
35 gpointer user_data)
36{
37 WnckWindow *win = (WnckWindow *) user_data;
38 decor_frame_t *frame = gwd_get_decor_frame (get_frame_type (win));
39 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
40 gint bx, by, width, height;
41
42 wnck_window_get_client_window_geometry (win, x, y, &width, &height);
43
44 if ((*theme_get_button_position) (d, BUTTON_MENU, width, height,
45 &bx, &by, &width, &height))
46 *x = *x - frame->win_extents.left + bx;
47
48 gwd_decor_frame_unref (frame);
49
50 if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
51 {
52 GtkRequisition req;
53
54 gtk_widget_size_request (GTK_WIDGET (menu), &req);
55 *x = MAX (0, *x - req.width + width);
56 }
57
58 *push_in = TRUE;
59}
60
61void
62action_menu_map (WnckWindow *win,
63 long button,
64 Time time)
65{
66 GdkDisplay *gdkdisplay;
67 GdkScreen *screen;
68
69 gdkdisplay = gdk_display_get_default ();
70 screen = gdk_display_get_default_screen (gdkdisplay);
71
72 if (action_menu)
73 {
74 if (action_menu_mapped)
75 {
76 gtk_widget_destroy (action_menu);
77 action_menu_mapped = FALSE;
78 action_menu = NULL;
79 return;
80 }
81 else
82 gtk_widget_destroy (action_menu);
83 }
84
85 switch (wnck_window_get_window_type (win)) {
86 case WNCK_WINDOW_DESKTOP:
87 case WNCK_WINDOW_DOCK:
88 /* don't allow window action */
89 return;
90 case WNCK_WINDOW_NORMAL:
91 case WNCK_WINDOW_DIALOG:
92
93#ifndef HAVE_LIBWNCK_2_19_4
94 case WNCK_WINDOW_MODAL_DIALOG:
95#endif
96
97 case WNCK_WINDOW_TOOLBAR:
98 case WNCK_WINDOW_MENU:
99 case WNCK_WINDOW_UTILITY:
100 case WNCK_WINDOW_SPLASHSCREEN:
101 /* allow window action menu */
102 break;
103 }
104
105 action_menu = wnck_create_window_action_menu (win);
106
107 gtk_menu_set_screen (GTK_MENU (action_menu), screen);
108
109 g_signal_connect_object (G_OBJECT (action_menu), "unmap",
110 G_CALLBACK (action_menu_unmap),
111 0, 0);
112
113 gtk_widget_show (action_menu);
114
115 if (!button || button == 1)
116 {
117 gtk_menu_popup (GTK_MENU (action_menu),
118 NULL, NULL,
119 position_action_menu, (gpointer) win,
120 button,
121 time);
122 }
123 else
124 {
125 gtk_menu_popup (GTK_MENU (action_menu),
126 NULL, NULL,
127 NULL, NULL,
128 button,
129 time);
130 }
131
132 action_menu_mapped = TRUE;
133}
1340
=== added file 'gtk/window-decorator/blurprops.c'
--- gtk/window-decorator/blurprops.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/blurprops.c 2012-05-17 07:01:21 +0000
@@ -0,0 +1,89 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24void
25decor_update_blur_property (decor_t *d,
26 int width,
27 int height,
28 Region top_region,
29 int top_offset,
30 Region bottom_region,
31 int bottom_offset,
32 Region left_region,
33 int left_offset,
34 Region right_region,
35 int right_offset)
36{
37 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
38 long *data = NULL;
39 int size = 0;
40
41 if (settings->blur_type != BLUR_TYPE_ALL)
42 {
43 bottom_region = NULL;
44 left_region = NULL;
45 right_region = NULL;
46
47 if (settings->blur_type != BLUR_TYPE_TITLEBAR)
48 top_region = NULL;
49 }
50
51 if (top_region)
52 size += top_region->numRects;
53 if (bottom_region)
54 size += bottom_region->numRects;
55 if (left_region)
56 size += left_region->numRects;
57 if (right_region)
58 size += right_region->numRects;
59
60 if (size)
61 data = (long *) malloc (sizeof (long) * (2 + size * 6));
62
63 if (data)
64 {
65 decor_region_to_blur_property (data, 4, 0, width, height,
66 top_region, top_offset,
67 bottom_region, bottom_offset,
68 left_region, left_offset,
69 right_region, right_offset);
70
71 gdk_error_trap_push ();
72 XChangeProperty (xdisplay, d->prop_xid,
73 win_blur_decor_atom,
74 XA_INTEGER,
75 32, PropModeReplace, (guchar *) data,
76 2 + size * 6);
77 gdk_display_sync (gdk_display_get_default ());
78 gdk_error_trap_pop ();
79
80 free (data);
81 }
82 else
83 {
84 gdk_error_trap_push ();
85 XDeleteProperty (xdisplay, d->prop_xid, win_blur_decor_atom);
86 gdk_display_sync (gdk_display_get_default ());
87 gdk_error_trap_pop ();
88 }
89}
090
=== removed file 'gtk/window-decorator/blurprops.c'
--- gtk/window-decorator/blurprops.c 2011-02-21 09:53:08 +0000
+++ gtk/window-decorator/blurprops.c 1970-01-01 00:00:00 +0000
@@ -1,89 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24void
25decor_update_blur_property (decor_t *d,
26 int width,
27 int height,
28 Region top_region,
29 int top_offset,
30 Region bottom_region,
31 int bottom_offset,
32 Region left_region,
33 int left_offset,
34 Region right_region,
35 int right_offset)
36{
37 Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
38 long *data = NULL;
39 int size = 0;
40
41 if (settings->blur_type != BLUR_TYPE_ALL)
42 {
43 bottom_region = NULL;
44 left_region = NULL;
45 right_region = NULL;
46
47 if (settings->blur_type != BLUR_TYPE_TITLEBAR)
48 top_region = NULL;
49 }
50
51 if (top_region)
52 size += top_region->numRects;
53 if (bottom_region)
54 size += bottom_region->numRects;
55 if (left_region)
56 size += left_region->numRects;
57 if (right_region)
58 size += right_region->numRects;
59
60 if (size)
61 data = (long *) malloc (sizeof (long) * (2 + size * 6));
62
63 if (data)
64 {
65 decor_region_to_blur_property (data, 4, 0, width, height,
66 top_region, top_offset,
67 bottom_region, bottom_offset,
68 left_region, left_offset,
69 right_region, right_offset);
70
71 gdk_error_trap_push ();
72 XChangeProperty (xdisplay, d->prop_xid,
73 win_blur_decor_atom,
74 XA_INTEGER,
75 32, PropModeReplace, (guchar *) data,
76 2 + size * 6);
77 gdk_display_sync (gdk_display_get_default ());
78 gdk_error_trap_pop ();
79
80 free (data);
81 }
82 else
83 {
84 gdk_error_trap_push ();
85 XDeleteProperty (xdisplay, d->prop_xid, win_blur_decor_atom);
86 gdk_display_sync (gdk_display_get_default ());
87 gdk_error_trap_pop ();
88 }
89}
900
=== added file 'gtk/window-decorator/forcequit.c'
--- gtk/window-decorator/forcequit.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/forcequit.c 2012-05-17 07:01:21 +0000
@@ -0,0 +1,201 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 *
21 * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com>
22 * Frames Management: Copright © 2011 Canonical Ltd.
23 * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */
25
26#include "gtk-window-decorator.h"
27
28static char *
29get_client_machine (Window xwindow)
30{
31 Atom atom, type;
32 gulong nitems, bytes_after;
33 guchar *str = NULL;
34 int format, result;
35 char *retval;
36
37 atom = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "WM_CLIENT_MACHINE", FALSE);
38
39 gdk_error_trap_push ();
40
41 result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
42 xwindow, atom,
43 0, G_MAXLONG,
44 FALSE, XA_STRING, &type, &format, &nitems,
45 &bytes_after, &str);
46
47 gdk_error_trap_pop ();
48
49 if (result != Success)
50 return NULL;
51
52 if (type != XA_STRING)
53 {
54 XFree (str);
55 return NULL;
56 }
57
58 retval = g_strdup ((gchar *) str);
59
60 XFree (str);
61
62 return retval;
63}
64
65static void
66kill_window (WnckWindow *win)
67{
68 WnckApplication *app;
69
70 app = wnck_window_get_application (win);
71 if (app)
72 {
73 gchar buf[257], *client_machine;
74 int pid;
75
76 pid = wnck_application_get_pid (app);
77 client_machine = get_client_machine (wnck_application_get_xid (app));
78
79 if (client_machine && pid > 0)
80 {
81 if (gethostname (buf, sizeof (buf) - 1) == 0)
82 {
83 if (strcmp (buf, client_machine) == 0)
84 kill (pid, 9);
85 }
86 }
87
88 if (client_machine)
89 g_free (client_machine);
90 }
91
92 gdk_error_trap_push ();
93 XKillClient (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wnck_window_get_xid (win));
94 gdk_display_sync (gdk_display_get_default ());
95 gdk_error_trap_pop ();
96}
97
98static void
99force_quit_dialog_realize (GtkWidget *dialog,
100 void *data)
101{
102 WnckWindow *win = data;
103
104 gdk_error_trap_push ();
105 XSetTransientForHint (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
106 GDK_WINDOW_XID (dialog->window),
107 wnck_window_get_xid (win));
108 gdk_display_sync (gdk_display_get_default ());
109 gdk_error_trap_pop ();
110}
111
112static void
113force_quit_dialog_response (GtkWidget *dialog,
114 gint response,
115 void *data)
116{
117 WnckWindow *win = data;
118 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
119
120 if (response == GTK_RESPONSE_ACCEPT)
121 kill_window (win);
122
123 if (d->force_quit_dialog)
124 {
125 d->force_quit_dialog = NULL;
126 gtk_widget_destroy (dialog);
127 }
128}
129
130void
131show_force_quit_dialog (WnckWindow *win,
132 Time timestamp)
133{
134 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
135 GtkWidget *dialog;
136 gchar *str, *tmp;
137
138 if (d->force_quit_dialog)
139 return;
140
141 tmp = g_markup_escape_text (wnck_window_get_name (win), -1);
142 str = g_strdup_printf (_("The window \"%s\" is not responding."), tmp);
143
144 g_free (tmp);
145
146 dialog = gtk_message_dialog_new (NULL, 0,
147 GTK_MESSAGE_WARNING,
148 GTK_BUTTONS_NONE,
149 "<b>%s</b>\n\n%s",
150 str,
151 _("Forcing this application to "
152 "quit will cause you to lose any "
153 "unsaved changes."));
154 g_free (str);
155
156 gtk_window_set_icon_name (GTK_WINDOW (dialog), "force-quit");
157
158 gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label),
159 TRUE);
160 gtk_label_set_line_wrap (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label),
161 TRUE);
162
163 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
164 GTK_STOCK_CANCEL,
165 GTK_RESPONSE_REJECT,
166 _("_Force Quit"),
167 GTK_RESPONSE_ACCEPT,
168 NULL);
169
170 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
171
172 g_signal_connect (G_OBJECT (dialog), "realize",
173 G_CALLBACK (force_quit_dialog_realize),
174 win);
175
176 g_signal_connect (G_OBJECT (dialog), "response",
177 G_CALLBACK (force_quit_dialog_response),
178 win);
179
180 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
181
182 gtk_widget_realize (dialog);
183
184 gdk_x11_window_set_user_time (dialog->window, timestamp);
185
186 gtk_widget_show (dialog);
187
188 d->force_quit_dialog = dialog;
189}
190
191void
192hide_force_quit_dialog (WnckWindow *win)
193{
194 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
195
196 if (d->force_quit_dialog)
197 {
198 gtk_widget_destroy (d->force_quit_dialog);
199 d->force_quit_dialog = NULL;
200 }
201}
0202
=== removed file 'gtk/window-decorator/forcequit.c'
--- gtk/window-decorator/forcequit.c 2011-02-21 09:53:08 +0000
+++ gtk/window-decorator/forcequit.c 1970-01-01 00:00:00 +0000
@@ -1,201 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 *
21 * 2D Mode: Copyright © 2010 Sam Spilsbury <smspillaz@gmail.com>
22 * Frames Management: Copright © 2011 Canonical Ltd.
23 * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */
25
26#include "gtk-window-decorator.h"
27
28static char *
29get_client_machine (Window xwindow)
30{
31 Atom atom, type;
32 gulong nitems, bytes_after;
33 guchar *str = NULL;
34 int format, result;
35 char *retval;
36
37 atom = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "WM_CLIENT_MACHINE", FALSE);
38
39 gdk_error_trap_push ();
40
41 result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
42 xwindow, atom,
43 0, G_MAXLONG,
44 FALSE, XA_STRING, &type, &format, &nitems,
45 &bytes_after, &str);
46
47 gdk_error_trap_pop ();
48
49 if (result != Success)
50 return NULL;
51
52 if (type != XA_STRING)
53 {
54 XFree (str);
55 return NULL;
56 }
57
58 retval = g_strdup ((gchar *) str);
59
60 XFree (str);
61
62 return retval;
63}
64
65static void
66kill_window (WnckWindow *win)
67{
68 WnckApplication *app;
69
70 app = wnck_window_get_application (win);
71 if (app)
72 {
73 gchar buf[257], *client_machine;
74 int pid;
75
76 pid = wnck_application_get_pid (app);
77 client_machine = get_client_machine (wnck_application_get_xid (app));
78
79 if (client_machine && pid > 0)
80 {
81 if (gethostname (buf, sizeof (buf) - 1) == 0)
82 {
83 if (strcmp (buf, client_machine) == 0)
84 kill (pid, 9);
85 }
86 }
87
88 if (client_machine)
89 g_free (client_machine);
90 }
91
92 gdk_error_trap_push ();
93 XKillClient (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wnck_window_get_xid (win));
94 gdk_display_sync (gdk_display_get_default ());
95 gdk_error_trap_pop ();
96}
97
98static void
99force_quit_dialog_realize (GtkWidget *dialog,
100 void *data)
101{
102 WnckWindow *win = data;
103
104 gdk_error_trap_push ();
105 XSetTransientForHint (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
106 GDK_WINDOW_XID (dialog->window),
107 wnck_window_get_xid (win));
108 gdk_display_sync (gdk_display_get_default ());
109 gdk_error_trap_pop ();
110}
111
112static void
113force_quit_dialog_response (GtkWidget *dialog,
114 gint response,
115 void *data)
116{
117 WnckWindow *win = data;
118 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
119
120 if (response == GTK_RESPONSE_ACCEPT)
121 kill_window (win);
122
123 if (d->force_quit_dialog)
124 {
125 d->force_quit_dialog = NULL;
126 gtk_widget_destroy (dialog);
127 }
128}
129
130void
131show_force_quit_dialog (WnckWindow *win,
132 Time timestamp)
133{
134 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
135 GtkWidget *dialog;
136 gchar *str, *tmp;
137
138 if (d->force_quit_dialog)
139 return;
140
141 tmp = g_markup_escape_text (wnck_window_get_name (win), -1);
142 str = g_strdup_printf (_("The window \"%s\" is not responding."), tmp);
143
144 g_free (tmp);
145
146 dialog = gtk_message_dialog_new (NULL, 0,
147 GTK_MESSAGE_WARNING,
148 GTK_BUTTONS_NONE,
149 "<b>%s</b>\n\n%s",
150 str,
151 _("Forcing this application to "
152 "quit will cause you to lose any "
153 "unsaved changes."));
154 g_free (str);
155
156 gtk_window_set_icon_name (GTK_WINDOW (dialog), "force-quit");
157
158 gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label),
159 TRUE);
160 gtk_label_set_line_wrap (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label),
161 TRUE);
162
163 gtk_dialog_add_buttons (GTK_DIALOG (dialog),
164 GTK_STOCK_CANCEL,
165 GTK_RESPONSE_REJECT,
166 _("_Force Quit"),
167 GTK_RESPONSE_ACCEPT,
168 NULL);
169
170 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_REJECT);
171
172 g_signal_connect (G_OBJECT (dialog), "realize",
173 G_CALLBACK (force_quit_dialog_realize),
174 win);
175
176 g_signal_connect (G_OBJECT (dialog), "response",
177 G_CALLBACK (force_quit_dialog_response),
178 win);
179
180 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
181
182 gtk_widget_realize (dialog);
183
184 gdk_x11_window_set_user_time (dialog->window, timestamp);
185
186 gtk_widget_show (dialog);
187
188 d->force_quit_dialog = dialog;
189}
190
191void
192hide_force_quit_dialog (WnckWindow *win)
193{
194 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
195
196 if (d->force_quit_dialog)
197 {
198 gtk_widget_destroy (d->force_quit_dialog);
199 d->force_quit_dialog = NULL;
200 }
201}
2020
=== added file 'gtk/window-decorator/gdk.c'
--- gtk/window-decorator/gdk.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/gdk.c 2012-05-17 07:01:21 +0000
@@ -0,0 +1,106 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24GdkPixmap *
25pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, GtkWidget *parent)
26{
27 GdkPixmap *pixmap;
28 guint width, height;
29 cairo_t *cr;
30
31 width = gdk_pixbuf_get_width (pixbuf);
32 height = gdk_pixbuf_get_height (pixbuf);
33
34 pixmap = create_pixmap (width, height, parent);
35 if (!pixmap)
36 return NULL;
37
38 cr = (cairo_t *) gdk_cairo_create (GDK_DRAWABLE (pixmap));
39 gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
40 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
41 cairo_paint (cr);
42 cairo_destroy (cr);
43
44 return pixmap;
45}
46
47
48void
49gdk_cairo_set_source_color_alpha (cairo_t *cr,
50 GdkColor *color,
51 double alpha)
52{
53 cairo_set_source_rgba (cr,
54 color->red / 65535.0,
55 color->green / 65535.0,
56 color->blue / 65535.0,
57 alpha);
58}
59
60inline GdkWindow *
61create_gdk_window (Window xframe)
62{
63 GdkDisplay *display = gdk_display_get_default ();
64 GdkScreen *screen = gdk_display_get_default_screen (display);
65 GdkWindow *window = create_foreign_window (xframe);
66 GdkColormap *cmap = gdk_screen_get_rgb_colormap (screen);
67
68 gdk_drawable_set_colormap (GDK_DRAWABLE (window), cmap);
69
70 return window;
71}
72
73GdkColormap *
74get_colormap_for_drawable (GdkDrawable *d)
75{
76 GdkDisplay *display = gdk_display_get_default ();
77 GdkScreen *screen = gdk_display_get_default_screen (display);
78
79 if (gdk_drawable_get_depth (d) == 32)
80 return gdk_screen_get_rgba_colormap (screen);
81
82 return gdk_screen_get_rgb_colormap (screen);
83}
84
85XRenderPictFormat *
86get_format_for_drawable (decor_t *d, GdkDrawable *drawable)
87{
88 if (!d->frame_window || gdk_drawable_get_depth (drawable) == 32)
89 return xformat_rgba;
90
91 return xformat_rgb;
92}
93
94GdkPixmap *
95create_pixmap (int w,
96 int h,
97 GtkWidget *parent_style_window)
98{
99 GdkWindow *window;
100
101 if (w == 0 || h == 0)
102 abort ();
103
104 window = gtk_widget_get_window (parent_style_window);
105 return gdk_pixmap_new (GDK_DRAWABLE (window), w, h, -1 /* CopyFromParent */);
106}
0107
=== removed file 'gtk/window-decorator/gdk.c'
--- gtk/window-decorator/gdk.c 2011-02-23 18:11:11 +0000
+++ gtk/window-decorator/gdk.c 1970-01-01 00:00:00 +0000
@@ -1,106 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24GdkPixmap *
25pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, GtkWidget *parent)
26{
27 GdkPixmap *pixmap;
28 guint width, height;
29 cairo_t *cr;
30
31 width = gdk_pixbuf_get_width (pixbuf);
32 height = gdk_pixbuf_get_height (pixbuf);
33
34 pixmap = create_pixmap (width, height, parent);
35 if (!pixmap)
36 return NULL;
37
38 cr = (cairo_t *) gdk_cairo_create (GDK_DRAWABLE (pixmap));
39 gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
40 cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
41 cairo_paint (cr);
42 cairo_destroy (cr);
43
44 return pixmap;
45}
46
47
48void
49gdk_cairo_set_source_color_alpha (cairo_t *cr,
50 GdkColor *color,
51 double alpha)
52{
53 cairo_set_source_rgba (cr,
54 color->red / 65535.0,
55 color->green / 65535.0,
56 color->blue / 65535.0,
57 alpha);
58}
59
60inline GdkWindow *
61create_gdk_window (Window xframe)
62{
63 GdkDisplay *display = gdk_display_get_default ();
64 GdkScreen *screen = gdk_display_get_default_screen (display);
65 GdkWindow *window = create_foreign_window (xframe);
66 GdkColormap *cmap = gdk_screen_get_rgb_colormap (screen);
67
68 gdk_drawable_set_colormap (GDK_DRAWABLE (window), cmap);
69
70 return window;
71}
72
73GdkColormap *
74get_colormap_for_drawable (GdkDrawable *d)
75{
76 GdkDisplay *display = gdk_display_get_default ();
77 GdkScreen *screen = gdk_display_get_default_screen (display);
78
79 if (gdk_drawable_get_depth (d) == 32)
80 return gdk_screen_get_rgba_colormap (screen);
81
82 return gdk_screen_get_rgb_colormap (screen);
83}
84
85XRenderPictFormat *
86get_format_for_drawable (decor_t *d, GdkDrawable *drawable)
87{
88 if (!d->frame_window || gdk_drawable_get_depth (drawable) == 32)
89 return xformat_rgba;
90
91 return xformat_rgb;
92}
93
94GdkPixmap *
95create_pixmap (int w,
96 int h,
97 GtkWidget *parent_style_window)
98{
99 GdkWindow *window;
100
101 if (w == 0 || h == 0)
102 abort ();
103
104 window = gtk_widget_get_window (parent_style_window);
105 return gdk_pixmap_new (GDK_DRAWABLE (window), w, h, -1 /* CopyFromParent */);
106}
1070
=== added file 'gtk/window-decorator/style.c'
--- gtk/window-decorator/style.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/style.c 2012-05-17 07:01:21 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24void
25update_style (GtkWidget *widget)
26{
27 GtkStyle *style;
28 decor_color_t spot_color;
29
30 style = gtk_widget_get_style (widget);
31 g_object_ref (G_OBJECT (style));
32
33 style = gtk_style_attach (style, widget->window);
34
35 spot_color.r = style->bg[GTK_STATE_SELECTED].red / 65535.0;
36 spot_color.g = style->bg[GTK_STATE_SELECTED].green / 65535.0;
37 spot_color.b = style->bg[GTK_STATE_SELECTED].blue / 65535.0;
38
39 g_object_unref (G_OBJECT (style));
40
41 shade (&spot_color, &_title_color[0], 1.05);
42 shade (&_title_color[0], &_title_color[1], 0.85);
43
44}
45
46void
47style_changed (GtkWidget *widget,
48 void *user_data)
49{
50 GdkDisplay *gdkdisplay;
51 GdkScreen *gdkscreen;
52 WnckScreen *screen;
53
54 PangoContext *context = (PangoContext *) user_data;
55
56 gdkdisplay = gdk_display_get_default ();
57 gdkscreen = gdk_display_get_default_screen (gdkdisplay);
58 screen = wnck_screen_get_default ();
59
60 update_style (widget);
61
62 pango_cairo_context_set_resolution (context,
63 gdk_screen_get_resolution (gdkscreen));
64
65 decorations_changed (screen);
66}
067
=== removed file 'gtk/window-decorator/style.c'
--- gtk/window-decorator/style.c 2011-02-21 09:53:08 +0000
+++ gtk/window-decorator/style.c 1970-01-01 00:00:00 +0000
@@ -1,66 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24void
25update_style (GtkWidget *widget)
26{
27 GtkStyle *style;
28 decor_color_t spot_color;
29
30 style = gtk_widget_get_style (widget);
31 g_object_ref (G_OBJECT (style));
32
33 style = gtk_style_attach (style, widget->window);
34
35 spot_color.r = style->bg[GTK_STATE_SELECTED].red / 65535.0;
36 spot_color.g = style->bg[GTK_STATE_SELECTED].green / 65535.0;
37 spot_color.b = style->bg[GTK_STATE_SELECTED].blue / 65535.0;
38
39 g_object_unref (G_OBJECT (style));
40
41 shade (&spot_color, &_title_color[0], 1.05);
42 shade (&_title_color[0], &_title_color[1], 0.85);
43
44}
45
46void
47style_changed (GtkWidget *widget,
48 void *user_data)
49{
50 GdkDisplay *gdkdisplay;
51 GdkScreen *gdkscreen;
52 WnckScreen *screen;
53
54 PangoContext *context = (PangoContext *) user_data;
55
56 gdkdisplay = gdk_display_get_default ();
57 gdkscreen = gdk_display_get_default_screen (gdkdisplay);
58 screen = wnck_screen_get_default ();
59
60 update_style (widget);
61
62 pango_cairo_context_set_resolution (context,
63 gdk_screen_get_resolution (gdkscreen));
64
65 decorations_changed (screen);
66}
670
=== added file 'gtk/window-decorator/util.c'
--- gtk/window-decorator/util.c 1970-01-01 00:00:00 +0000
+++ gtk/window-decorator/util.c 2012-05-17 07:01:21 +0000
@@ -0,0 +1,299 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24double
25square (double x)
26{
27 return x * x;
28}
29
30double
31dist (double x1, double y1,
32 double x2, double y2)
33{
34 return sqrt (square (x1 - x2) + square (y1 - y2));
35}
36
37gboolean
38get_window_prop (Window xwindow,
39 Atom atom,
40 Window *val)
41{
42 Atom type;
43 int format;
44 gulong nitems;
45 gulong bytes_after;
46 Window *w;
47 int err, result;
48
49 *val = 0;
50
51 gdk_error_trap_push ();
52
53 type = None;
54 result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
55 xwindow,
56 atom,
57 0, G_MAXLONG,
58 False, XA_WINDOW, &type, &format, &nitems,
59 &bytes_after, (void*) &w);
60 err = gdk_error_trap_pop ();
61 if (err != Success || result != Success)
62 return FALSE;
63
64 if (type != XA_WINDOW)
65 {
66 XFree (w);
67 return FALSE;
68 }
69
70 *val = *w;
71 XFree (w);
72
73 return TRUE;
74}
75
76unsigned int
77get_mwm_prop (Window xwindow)
78{
79 Display *xdisplay;
80 Atom actual;
81 int err, result, format;
82 unsigned long n, left;
83 unsigned char *data;
84 unsigned int decor = MWM_DECOR_ALL;
85
86 xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
87
88 gdk_error_trap_push ();
89
90 result = XGetWindowProperty (xdisplay, xwindow, mwm_hints_atom,
91 0L, 20L, FALSE, mwm_hints_atom,
92 &actual, &format, &n, &left, &data);
93
94 err = gdk_error_trap_pop ();
95 if (err != Success || result != Success)
96 return decor;
97
98 if (data)
99 {
100 MwmHints *mwm_hints = (MwmHints *) data;
101
102 if (n >= PROP_MOTIF_WM_HINT_ELEMENTS)
103 {
104 if (mwm_hints->flags & MWM_HINTS_DECORATIONS)
105 decor = mwm_hints->decorations;
106 }
107
108 XFree (data);
109 }
110
111 return decor;
112}
113
114/* from clearlooks theme */
115static void
116rgb_to_hls (gdouble *r,
117 gdouble *g,
118 gdouble *b)
119{
120 gdouble min;
121 gdouble max;
122 gdouble red;
123 gdouble green;
124 gdouble blue;
125 gdouble h, l, s;
126 gdouble delta;
127
128 red = *r;
129 green = *g;
130 blue = *b;
131
132 if (red > green)
133 {
134 if (red > blue)
135 max = red;
136 else
137 max = blue;
138
139 if (green < blue)
140 min = green;
141 else
142 min = blue;
143 }
144 else
145 {
146 if (green > blue)
147 max = green;
148 else
149 max = blue;
150
151 if (red < blue)
152 min = red;
153 else
154 min = blue;
155 }
156
157 l = (max + min) / 2;
158 s = 0;
159 h = 0;
160
161 if (max != min)
162 {
163 if (l <= 0.5)
164 s = (max - min) / (max + min);
165 else
166 s = (max - min) / (2 - max - min);
167
168 delta = max -min;
169 if (red == max)
170 h = (green - blue) / delta;
171 else if (green == max)
172 h = 2 + (blue - red) / delta;
173 else if (blue == max)
174 h = 4 + (red - green) / delta;
175
176 h *= 60;
177 if (h < 0.0)
178 h += 360;
179 }
180
181 *r = h;
182 *g = l;
183 *b = s;
184}
185
186static void
187hls_to_rgb (gdouble *h,
188 gdouble *l,
189 gdouble *s)
190{
191 gdouble hue;
192 gdouble lightness;
193 gdouble saturation;
194 gdouble m1, m2;
195 gdouble r, g, b;
196
197 lightness = *l;
198 saturation = *s;
199
200 if (lightness <= 0.5)
201 m2 = lightness * (1 + saturation);
202 else
203 m2 = lightness + saturation - lightness * saturation;
204
205 m1 = 2 * lightness - m2;
206
207 if (saturation == 0)
208 {
209 *h = lightness;
210 *l = lightness;
211 *s = lightness;
212 }
213 else
214 {
215 hue = *h + 120;
216 while (hue > 360)
217 hue -= 360;
218 while (hue < 0)
219 hue += 360;
220
221 if (hue < 60)
222 r = m1 + (m2 - m1) * hue / 60;
223 else if (hue < 180)
224 r = m2;
225 else if (hue < 240)
226 r = m1 + (m2 - m1) * (240 - hue) / 60;
227 else
228 r = m1;
229
230 hue = *h;
231 while (hue > 360)
232 hue -= 360;
233 while (hue < 0)
234 hue += 360;
235
236 if (hue < 60)
237 g = m1 + (m2 - m1) * hue / 60;
238 else if (hue < 180)
239 g = m2;
240 else if (hue < 240)
241 g = m1 + (m2 - m1) * (240 - hue) / 60;
242 else
243 g = m1;
244
245 hue = *h - 120;
246 while (hue > 360)
247 hue -= 360;
248 while (hue < 0)
249 hue += 360;
250
251 if (hue < 60)
252 b = m1 + (m2 - m1) * hue / 60;
253 else if (hue < 180)
254 b = m2;
255 else if (hue < 240)
256 b = m1 + (m2 - m1) * (240 - hue) / 60;
257 else
258 b = m1;
259
260 *h = r;
261 *l = g;
262 *s = b;
263 }
264}
265
266void
267shade (const decor_color_t *a,
268 decor_color_t *b,
269 float k)
270{
271 double red;
272 double green;
273 double blue;
274
275 red = a->r;
276 green = a->g;
277 blue = a->b;
278
279 rgb_to_hls (&red, &green, &blue);
280
281 green *= k;
282 if (green > 1.0)
283 green = 1.0;
284 else if (green < 0.0)
285 green = 0.0;
286
287 blue *= k;
288 if (blue > 1.0)
289 blue = 1.0;
290 else if (blue < 0.0)
291 blue = 0.0;
292
293 hls_to_rgb (&red, &green, &blue);
294
295 b->r = red;
296 b->g = green;
297 b->b = blue;
298}
299
0300
=== removed file 'gtk/window-decorator/util.c'
--- gtk/window-decorator/util.c 2011-02-21 09:53:08 +0000
+++ gtk/window-decorator/util.c 1970-01-01 00:00:00 +0000
@@ -1,299 +0,0 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24double
25square (double x)
26{
27 return x * x;
28}
29
30double
31dist (double x1, double y1,
32 double x2, double y2)
33{
34 return sqrt (square (x1 - x2) + square (y1 - y2));
35}
36
37gboolean
38get_window_prop (Window xwindow,
39 Atom atom,
40 Window *val)
41{
42 Atom type;
43 int format;
44 gulong nitems;
45 gulong bytes_after;
46 Window *w;
47 int err, result;
48
49 *val = 0;
50
51 gdk_error_trap_push ();
52
53 type = None;
54 result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
55 xwindow,
56 atom,
57 0, G_MAXLONG,
58 False, XA_WINDOW, &type, &format, &nitems,
59 &bytes_after, (void*) &w);
60 err = gdk_error_trap_pop ();
61 if (err != Success || result != Success)
62 return FALSE;
63
64 if (type != XA_WINDOW)
65 {
66 XFree (w);
67 return FALSE;
68 }
69
70 *val = *w;
71 XFree (w);
72
73 return TRUE;
74}
75
76unsigned int
77get_mwm_prop (Window xwindow)
78{
79 Display *xdisplay;
80 Atom actual;
81 int err, result, format;
82 unsigned long n, left;
83 unsigned char *data;
84 unsigned int decor = MWM_DECOR_ALL;
85
86 xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
87
88 gdk_error_trap_push ();
89
90 result = XGetWindowProperty (xdisplay, xwindow, mwm_hints_atom,
91 0L, 20L, FALSE, mwm_hints_atom,
92 &actual, &format, &n, &left, &data);
93
94 err = gdk_error_trap_pop ();
95 if (err != Success || result != Success)
96 return decor;
97
98 if (data)
99 {
100 MwmHints *mwm_hints = (MwmHints *) data;
101
102 if (n >= PROP_MOTIF_WM_HINT_ELEMENTS)
103 {
104 if (mwm_hints->flags & MWM_HINTS_DECORATIONS)
105 decor = mwm_hints->decorations;
106 }
107
108 XFree (data);
109 }
110
111 return decor;
112}
113
114/* from clearlooks theme */
115static void
116rgb_to_hls (gdouble *r,
117 gdouble *g,
118 gdouble *b)
119{
120 gdouble min;
121 gdouble max;
122 gdouble red;
123 gdouble green;
124 gdouble blue;
125 gdouble h, l, s;
126 gdouble delta;
127
128 red = *r;
129 green = *g;
130 blue = *b;
131
132 if (red > green)
133 {
134 if (red > blue)
135 max = red;
136 else
137 max = blue;
138
139 if (green < blue)
140 min = green;
141 else
142 min = blue;
143 }
144 else
145 {
146 if (green > blue)
147 max = green;
148 else
149 max = blue;
150
151 if (red < blue)
152 min = red;
153 else
154 min = blue;
155 }
156
157 l = (max + min) / 2;
158 s = 0;
159 h = 0;
160
161 if (max != min)
162 {
163 if (l <= 0.5)
164 s = (max - min) / (max + min);
165 else
166 s = (max - min) / (2 - max - min);
167
168 delta = max -min;
169 if (red == max)
170 h = (green - blue) / delta;
171 else if (green == max)
172 h = 2 + (blue - red) / delta;
173 else if (blue == max)
174 h = 4 + (red - green) / delta;
175
176 h *= 60;
177 if (h < 0.0)
178 h += 360;
179 }
180
181 *r = h;
182 *g = l;
183 *b = s;
184}
185
186static void
187hls_to_rgb (gdouble *h,
188 gdouble *l,
189 gdouble *s)
190{
191 gdouble hue;
192 gdouble lightness;
193 gdouble saturation;
194 gdouble m1, m2;
195 gdouble r, g, b;
196
197 lightness = *l;
198 saturation = *s;
199
200 if (lightness <= 0.5)
201 m2 = lightness * (1 + saturation);
202 else
203 m2 = lightness + saturation - lightness * saturation;
204
205 m1 = 2 * lightness - m2;
206
207 if (saturation == 0)
208 {
209 *h = lightness;
210 *l = lightness;
211 *s = lightness;
212 }
213 else
214 {
215 hue = *h + 120;
216 while (hue > 360)
217 hue -= 360;
218 while (hue < 0)
219 hue += 360;
220
221 if (hue < 60)
222 r = m1 + (m2 - m1) * hue / 60;
223 else if (hue < 180)
224 r = m2;
225 else if (hue < 240)
226 r = m1 + (m2 - m1) * (240 - hue) / 60;
227 else
228 r = m1;
229
230 hue = *h;
231 while (hue > 360)
232 hue -= 360;
233 while (hue < 0)
234 hue += 360;
235
236 if (hue < 60)
237 g = m1 + (m2 - m1) * hue / 60;
238 else if (hue < 180)
239 g = m2;
240 else if (hue < 240)
241 g = m1 + (m2 - m1) * (240 - hue) / 60;
242 else
243 g = m1;
244
245 hue = *h - 120;
246 while (hue > 360)
247 hue -= 360;
248 while (hue < 0)
249 hue += 360;
250
251 if (hue < 60)
252 b = m1 + (m2 - m1) * hue / 60;
253 else if (hue < 180)
254 b = m2;
255 else if (hue < 240)
256 b = m1 + (m2 - m1) * (240 - hue) / 60;
257 else
258 b = m1;
259
260 *h = r;
261 *l = g;
262 *s = b;
263 }
264}
265
266void
267shade (const decor_color_t *a,
268 decor_color_t *b,
269 float k)
270{
271 double red;
272 double green;
273 double blue;
274
275 red = a->r;
276 green = a->g;
277 blue = a->b;
278
279 rgb_to_hls (&red, &green, &blue);
280
281 green *= k;
282 if (green > 1.0)
283 green = 1.0;
284 else if (green < 0.0)
285 green = 0.0;
286
287 blue *= k;
288 if (blue > 1.0)
289 blue = 1.0;
290 else if (blue < 0.0)
291 blue = 0.0;
292
293 hls_to_rgb (&red, &green, &blue);
294
295 b->r = red;
296 b->g = green;
297 b->b = blue;
298}
299
3000
=== modified file 'plugins/annotate/src/annotate.cpp'
--- plugins/annotate/src/annotate.cpp 2012-01-30 05:12:24 +0000
+++ plugins/annotate/src/annotate.cpp 2012-05-17 07:01:21 +0000
@@ -629,11 +629,14 @@
629629
630 if (status)630 if (status)
631 {631 {
632 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
633 GLfloat vertexData[18];
634 GLfloat textureData[12];
632 CompRect rect;635 CompRect rect;
633 GLMatrix sTransform = transform;636 GLMatrix sTransform = transform;
634 int numRect;637 int numRect;
635 int pos = 0;638 int pos = 0;
636 float vectorX, vectorY, offset;639 float offset;
637 int angle;640 int angle;
638641
639 offset = optionGetStrokeWidth () / 2;642 offset = optionGetStrokeWidth () / 2;
@@ -641,10 +644,6 @@
641 /* This replaced prepareXCoords (s, output, -DEFAULT_Z_CAMERA) */644 /* This replaced prepareXCoords (s, output, -DEFAULT_Z_CAMERA) */
642 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);645 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
643646
644 glPushMatrix ();
645 glLoadMatrixf (sTransform.getMatrix ());
646
647 glDisableClientState (GL_TEXTURE_COORD_ARRAY);
648 glEnable (GL_BLEND);647 glEnable (GL_BLEND);
649648
650 if (content && !region.isEmpty ())649 if (content && !region.isEmpty ())
@@ -656,34 +655,66 @@
656655
657 tex->enable (GLTexture::Fast);656 tex->enable (GLTexture::Fast);
658657
659 glBegin (GL_QUADS);658 streamingBuffer->begin (GL_TRIANGLES);
660659
661 while (numRect--)660 while (numRect--)
662 {661 {
663 glTexCoord2f (662 GLfloat tx1 = COMP_TEX_COORD_X (tex->matrix (),
664 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x1 ()),663 rect.at (pos).x1 ());
665 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y2 ()));664 GLfloat tx2 = COMP_TEX_COORD_X (tex->matrix (),
666 glVertex2i (rect.at (pos).x1 (), rect.at (pos).y2 ());665 rect.at (pos).x2 ());
667666 GLfloat ty1 = COMP_TEX_COORD_Y (tex->matrix (),
668 glTexCoord2f (667 rect.at (pos).y1 ());
669 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x2 ()),668 GLfloat ty2 = COMP_TEX_COORD_Y (tex->matrix (),
670 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y2 ()));669 rect.at (pos).y2 ());
671 glVertex2i (rect.at (pos).x2 (), rect.at (pos).y2 ());670
672671 vertexData[0] = rect.at (pos).x1 ();
673 glTexCoord2f (672 vertexData[1] = rect.at (pos).y1 ();
674 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x2 ()),673 vertexData[2] = 0.0f;
675 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y1 ()));674 vertexData[3] = rect.at (pos).x1 ();
676 glVertex2i (rect.at (pos).x2 (), rect.at (pos).y1 ());675 vertexData[4] = rect.at (pos).y2 ();
677676 vertexData[5] = 0.0f;
678 glTexCoord2f (677 vertexData[6] = rect.at (pos).x2 ();
679 COMP_TEX_COORD_X (tex->matrix (), rect.at (pos).x1 ()),678 vertexData[7] = rect.at (pos).y1 ();
680 COMP_TEX_COORD_Y (tex->matrix (), rect.at (pos).y1 ()));679 vertexData[8] = 0.0f;
681 glVertex2i (rect.at (pos).x1 (), rect.at (pos).y1 ());680 vertexData[9] = rect.at (pos).x1 ();
682681 vertexData[10] = rect.at (pos).y2 ();
682 vertexData[11] = 0.0f;
683
684 vertexData[12] = rect.at (pos).x2 ();
685 vertexData[13] = rect.at (pos).y2 ();
686 vertexData[14] = 0.0f;
687
688 vertexData[15] = rect.at (pos).x2 ();
689 vertexData[16] = rect.at (pos).y1 ();
690 vertexData[17] = 0.0f;
691
692 textureData[0] = tx1;
693 textureData[1] = ty1;
694
695 textureData[2] = tx1;
696 textureData[3] = ty2;
697
698 textureData[4] = tx2;
699 textureData[5] = ty1;
700
701 textureData[6] = tx1;
702 textureData[7] = ty2;
703
704 textureData[8] = tx2;
705 textureData[9] = ty2;
706
707 textureData[10] = tx2;
708 textureData[11] = ty1;
709
710 streamingBuffer->addVertices (6, vertexData);
711 streamingBuffer->addTexCoords (0, 6, textureData);
683 pos++;712 pos++;
684 }713 }
685714
686 glEnd ();715 streamingBuffer->end ();
716 streamingBuffer->render (sTransform);
717
687 tex->disable ();718 tex->disable ();
688 }719 }
689 }720 }
@@ -691,85 +722,132 @@
691 switch (drawMode)722 switch (drawMode)
692 {723 {
693 case LineMode:724 case LineMode:
694 glColor4usv (optionGetStrokeColor ());
695 glLineWidth (optionGetStrokeWidth ());725 glLineWidth (optionGetStrokeWidth ());
696 glBegin (GL_LINES);726
697 glVertex2i (initialPointerX, initialPointerY);727 streamingBuffer->begin (GL_LINES);
698 glVertex2i (lineVector.x (), lineVector.y ());728
699 glEnd ();729 streamingBuffer->addColors (1, optionGetStrokeColor ());
730
731 vertexData[0] = initialPointerX;
732 vertexData[1] = initialPointerY;
733 vertexData[2] = 0.0f;
734 vertexData[3] = lineVector.x ();
735 vertexData[4] = lineVector.y ();
736 vertexData[5] = 0.0f;
737 streamingBuffer->addVertices (2, vertexData);
738
739 streamingBuffer->end ();
740 streamingBuffer->render (sTransform);
700 break;741 break;
701742
702 case RectangleMode:743 case RectangleMode:
744 vertexData[0] = rectangle.x1 ();
745 vertexData[1] = rectangle.y1 ();
746 vertexData[2] = 0.0f;
747 vertexData[3] = rectangle.x1 ();
748 vertexData[4] = rectangle.y2 ();
749 vertexData[5] = 0.0f;
750 vertexData[6] = rectangle.x2 ();
751 vertexData[7] = rectangle.y1 ();
752 vertexData[8] = 0.0f;
753 vertexData[9] = rectangle.x2 ();
754 vertexData[10] = rectangle.y2 ();
755 vertexData[11] = 0.0f;
756
703 /* fill rectangle */757 /* fill rectangle */
704 glColor4usv (optionGetFillColor ());758 streamingBuffer->begin (GL_TRIANGLE_STRIP);
705 glRecti (rectangle.x1 (), rectangle.y2 (),759
706 rectangle.x2 (), rectangle.y1 ());760 streamingBuffer->addColors (1, optionGetFillColor ());
761 streamingBuffer->addVertices (4, vertexData);
762
763 streamingBuffer->end ();
764 streamingBuffer->render (sTransform);
707765
708 /* draw rectangle outline */766 /* draw rectangle outline */
709 glColor4usv (optionGetStrokeColor ());767/* streamingBuffer->begin ();
710 glRecti (rectangle.x1 () - offset, rectangle.y2 (),768
711 rectangle.x1 () + offset, rectangle.y1 ());769 streamingBuffer->addColors (1, optionGetStrokeColor ());
770
771 vertexData[0] = rectangle.x1 () - offset;
772 vertexData[3] = rectangle.x1 () - offset;
773 streamingBuffer->addVertices (4, vertexData);
774
712 glRecti (rectangle.x2 () - offset, rectangle.y2 (),775 glRecti (rectangle.x2 () - offset, rectangle.y2 (),
713 rectangle.x2 () + offset, rectangle.y1 ());776 rectangle.x2 () + offset, rectangle.y1 ());
714 glRecti (rectangle.x1 () - offset, rectangle.y1 () + offset,777 glRecti (rectangle.x1 () - offset, rectangle.y1 () + offset,
715 rectangle.x2 () + offset, rectangle.y1 () - offset);778 rectangle.x2 () + offset, rectangle.y1 () - offset);
716 glRecti (rectangle.x1 () - offset, rectangle.y2 () + offset,779 glRecti (rectangle.x1 () - offset, rectangle.y2 () + offset,
717 rectangle.x2 () + offset, rectangle.y2 () - offset);780 rectangle.x2 () + offset, rectangle.y2 () - offset);*/
718 break;781 break;
719782
720 case EllipseMode:783 case EllipseMode:
721 /* fill ellipse */784 /* fill ellipse */
722 glColor4usv (optionGetFillColor ());785 streamingBuffer->begin (GL_TRIANGLE_FAN);
723786
724 glBegin (GL_TRIANGLE_FAN);787 streamingBuffer->addColors (1, optionGetFillColor ());
725 glVertex2d (ellipse.center.x (), ellipse.center.y ());788
789 vertexData[0] = ellipse.center.x ();
790 vertexData[1] = ellipse.center.y ();
791 vertexData[2] = 0.0f;
792 streamingBuffer->addVertices (1, vertexData);
793
726 for (angle = 0; angle <= 360; angle += 1)794 for (angle = 0; angle <= 360; angle += 1)
727 {795 {
728 vectorX = ellipse.center.x () +796 vertexData[0] = ellipse.center.x () +
729 (ellipse.radiusX * sinf (angle * DEG2RAD));797 (ellipse.radiusX * sinf (angle * DEG2RAD));
730 vectorY = ellipse.center.y () +798 vertexData[1] = ellipse.center.y () +
731 (ellipse.radiusY * cosf (angle * DEG2RAD));799 (ellipse.radiusY * cosf (angle * DEG2RAD));
732 glVertex2d (vectorX, vectorY);800 streamingBuffer->addVertices (1, vertexData);
733 }801 }
734 glVertex2d (ellipse.center.x (), ellipse.center.y () +802
735 ellipse.radiusY);803 vertexData[0] = ellipse.center.x ();
736 glEnd();804 vertexData[1] = ellipse.center.y () + ellipse.radiusY;
805 streamingBuffer->addVertices (1, vertexData);
806
807 streamingBuffer->end ();
808 streamingBuffer->render (sTransform);
737809
738 /* draw ellipse outline */810 /* draw ellipse outline */
739 glColor4usv (optionGetStrokeColor ());
740 glLineWidth (optionGetStrokeWidth ());811 glLineWidth (optionGetStrokeWidth ());
741812
742 glBegin (GL_TRIANGLE_STRIP);813 streamingBuffer->begin (GL_TRIANGLE_STRIP);
743 glVertex2d (ellipse.center.x (), ellipse.center.y () +814
744 ellipse.radiusY - offset);815 streamingBuffer->addColors (1, optionGetStrokeColor ());
816
817
818 vertexData[0] = ellipse.center.x ();
819 vertexData[1] = ellipse.center.y () + ellipse.radiusY - offset;
820 vertexData[2] = 0.0f;
821 streamingBuffer->addVertices (1, vertexData);
822
745 for (angle = 360; angle >= 0; angle -= 1)823 for (angle = 360; angle >= 0; angle -= 1)
746 {824 {
747 vectorX = ellipse.center.x () + ((ellipse.radiusX -825 vertexData[0] = ellipse.center.x () + ((ellipse.radiusX -
748 offset) * sinf (angle * DEG2RAD));826 offset) * sinf (angle * DEG2RAD));
749 vectorY = ellipse.center.y () + ((ellipse.radiusY -827 vertexData[1] = ellipse.center.y () + ((ellipse.radiusY -
750 offset) * cosf (angle * DEG2RAD));828 offset) * cosf (angle * DEG2RAD));
751 glVertex2d (vectorX, vectorY);829 vertexData[2] = 0.0f;
752 vectorX = ellipse.center.x () + ((ellipse.radiusX +830 vertexData[3] = ellipse.center.x () + ((ellipse.radiusX +
753 offset) * sinf (angle * DEG2RAD));831 offset) * sinf (angle * DEG2RAD));
754 vectorY = ellipse.center.y () + ((ellipse.radiusY +832 vertexData[4] = ellipse.center.y () + ((ellipse.radiusY +
755 offset) * cosf (angle * DEG2RAD));833 offset) * cosf (angle * DEG2RAD));
756 glVertex2d (vectorX, vectorY);834 vertexData[5] = 0.0f;
835 streamingBuffer->addVertices (2, vertexData);
757 }836 }
758 glVertex2d (ellipse.center.x (), ellipse.center.y () +837
759 ellipse.radiusY + offset);838 vertexData[0] = ellipse.center.x ();
760 glEnd();839 vertexData[1] = ellipse.center.y () + ellipse.radiusY + offset;
840 streamingBuffer->addVertices (1, vertexData);
841
842 streamingBuffer->end ();
843 streamingBuffer->render (sTransform);
761 break;844 break;
762845
763 default:846 default:
764 break;847 break;
765 }848 }
766849
767 /* clean up */
768 glColor4usv (defaultColor);
769 glDisable (GL_BLEND);850 glDisable (GL_BLEND);
770 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
771
772 glPopMatrix ();
773 }851 }
774852
775 return status;853 return status;
776854
=== modified file 'plugins/blur/CMakeLists.txt'
--- plugins/blur/CMakeLists.txt 2011-01-24 06:28:52 +0000
+++ plugins/blur/CMakeLists.txt 2012-05-17 07:01:21 +0000
@@ -2,15 +2,15 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5find_package (OpenGL)5#find_package (OpenGL)
66
7if (OPENGL_GLU_FOUND)7#if (OPENGL_GLU_FOUND)
8 compiz_plugin(blur PLUGINDEPS composite opengl LIBRARIES decoration ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})8# compiz_plugin(blur PLUGINDEPS composite opengl LIBRARIES decoration ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
99
10 if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)10# if (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)
11 set_target_properties (11# set_target_properties (
12 blur PROPERTIES12# blur PROPERTIES
13 INSTALL_RPATH "${COMPIZ_LIBDIR}"13# INSTALL_RPATH "${COMPIZ_LIBDIR}"
14 )14# )
15 endif (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)15# endif (COMPIZ_BUILD_WITH_RPATH AND NOT COMPIZ_DISABLE_PLUGIN_BLUR)
16endif ()16#endif ()
1717
=== modified file 'plugins/clone/src/clone.cpp'
--- plugins/clone/src/clone.cpp 2010-02-04 17:16:02 +0000
+++ plugins/clone/src/clone.cpp 2012-05-17 07:01:21 +0000
@@ -295,9 +295,6 @@
295 0.0f);295 0.0f);
296 sTransform.scale (zoomX, zoomY, 1.0f);296 sTransform.scale (zoomX, zoomY, 1.0f);
297297
298 glPushMatrix ();
299 glLoadMatrixf (sTransform.getMatrix ());
300
301 filter = gScreen->textureFilter ();298 filter = gScreen->textureFilter ();
302299
303 if (offset == 0.0f)300 if (offset == 0.0f)
@@ -325,8 +322,6 @@
325 }322 }
326323
327 gScreen->setTextureFilter (filter);324 gScreen->setTextureFilter (filter);
328
329 glPopMatrix ();
330 }325 }
331326
332 return status;327 return status;
333328
=== modified file 'plugins/compiztoolbox/src/compiztoolbox.cpp'
--- plugins/compiztoolbox/src/compiztoolbox.cpp 2012-01-18 16:26:45 +0000
+++ plugins/compiztoolbox/src/compiztoolbox.cpp 2012-05-17 07:01:21 +0000
@@ -465,9 +465,7 @@
465 sAttrib.yTranslate = wy - g.y () +465 sAttrib.yTranslate = wy - g.y () +
466 window->border ().top * sAttrib.yScale;466 window->border ().top * sAttrib.yScale;
467467
468 GLFragment::Attrib fragment (sAttrib);468 if (window->alpha () || sAttrib.opacity != OPAQUE)
469
470 if (window->alpha () || fragment.getOpacity () != OPAQUE)
471 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;469 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
472470
473 wTransform.translate (g.x (), g.y (), 0.0f);471 wTransform.translate (g.x (), g.y (), 0.0f);
@@ -476,9 +474,6 @@
476 sAttrib.yTranslate / sAttrib.yScale - g.y (),474 sAttrib.yTranslate / sAttrib.yScale - g.y (),
477 0.0f);475 0.0f);
478476
479 glPushMatrix ();
480 glLoadMatrixf (wTransform.getMatrix ());
481
482 filter = gScreen->textureFilter ();477 filter = gScreen->textureFilter ();
483478
484 if (baseScreen->getMipmap ())479 if (baseScreen->getMipmap ())
@@ -488,13 +483,11 @@
488 very ugly but necessary until the vertex stage has been made483 very ugly but necessary until the vertex stage has been made
489 fully pluggable. */484 fully pluggable. */
490 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);485 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);
491 gWindow->glDraw (wTransform, fragment, infiniteRegion, mask);486 gWindow->glDraw (wTransform, sAttrib, infiniteRegion, mask);
492 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);487 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);
493488
494 gScreen->setTextureFilter (filter);489 gScreen->setTextureFilter (filter);
495490
496 glPopMatrix ();
497
498 if (iconMode != HideIcon)491 if (iconMode != HideIcon)
499 {492 {
500 icon = gWindow->getIcon (MAX_ICON_SIZE, MAX_ICON_SIZE);493 icon = gWindow->getIcon (MAX_ICON_SIZE, MAX_ICON_SIZE);
@@ -535,30 +528,23 @@
535 sAttrib.xTranslate = wx - g.x ();528 sAttrib.xTranslate = wx - g.x ();
536 sAttrib.yTranslate = wy - g.y ();529 sAttrib.yTranslate = wy - g.y ();
537530
538 gWindow->geometry ().reset ();531 gWindow->vertexBuffer ()->begin ();
539532
540 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);533 gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);
541 gWindow->glAddGeometry (matrix, iconReg, infiniteRegion);534 gWindow->glAddGeometry (matrix, iconReg, infiniteRegion);
542 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);535 gWindow->glAddGeometrySetCurrentIndex (addWindowGeometryIndex);
543536
544 if (gWindow->geometry ().vCount)537 gWindow->vertexBuffer ()->end ();
545 {538
546 GLFragment::Attrib fragment (sAttrib);539 GLMatrix wTransform (transform);
547 GLMatrix wTransform (transform);540
548541 wTransform.translate (g.x (), g.y (), 0.0f);
549 wTransform.translate (g.x (), g.y (), 0.0f);542 wTransform.scale (sAttrib.xScale, sAttrib.yScale, 1.0f);
550 wTransform.scale (sAttrib.xScale, sAttrib.yScale, 1.0f);543 wTransform.translate (sAttrib.xTranslate / sAttrib.xScale - g.x (),
551 wTransform.translate (sAttrib.xTranslate / sAttrib.xScale - g.x (),544 sAttrib.yTranslate / sAttrib.yScale - g.y (),
552 sAttrib.yTranslate / sAttrib.yScale - g.y (),545 0.0f);
553 0.0f);546
554547 gWindow->glDrawTexture (icon, wTransform, sAttrib, mask);
555 glPushMatrix ();
556 glLoadMatrixf (wTransform.getMatrix ());
557
558 gWindow->glDrawTexture (icon, fragment, mask);
559
560 glPopMatrix ();
561 }
562 }548 }
563}549}
564550
565551
=== modified file 'plugins/copytex/src/copytex.cpp'
--- plugins/copytex/src/copytex.cpp 2011-06-01 03:33:04 +0000
+++ plugins/copytex/src/copytex.cpp 2012-05-17 07:01:21 +0000
@@ -112,6 +112,14 @@
112 GLenum target;112 GLenum target;
113 GLTexture::Matrix matrix = _identity_matrix;113 GLTexture::Matrix matrix = _identity_matrix;
114114
115#ifdef USE_GLES
116 target = GL_TEXTURE_2D;
117 matrix.xx = 1.0f / dim.width ();
118 matrix.yy = 1.0f / dim.height ();
119 matrix.x0 = -dim.x () * matrix.xx;
120 matrix.y0 = -dim.y () * matrix.yy;
121#else
122
115 if (GL::textureNonPowerOfTwo ||123 if (GL::textureNonPowerOfTwo ||
116 (POWER_OF_TWO (dim.width ()) && POWER_OF_TWO (dim.height ())))124 (POWER_OF_TWO (dim.width ()) && POWER_OF_TWO (dim.height ())))
117 {125 {
@@ -129,6 +137,7 @@
129 matrix.x0 = -dim.x ();137 matrix.x0 = -dim.x ();
130 matrix.y0 = -dim.y ();138 matrix.y0 = -dim.y ();
131 }139 }
140#endif
132141
133 setData (target, matrix, false);142 setData (target, matrix, false);
134 setGeometry (dim.x1 (), dim.y1 (), dim.x2 () - dim.x1 (), dim.y2 () - dim.y1 ());143 setGeometry (dim.x1 (), dim.y1 (), dim.x2 () - dim.x1 (), dim.y2 () - dim.y1 ());
135144
=== modified file 'plugins/cube/CMakeLists.txt'
--- plugins/cube/CMakeLists.txt 2009-11-03 20:14:43 +0000
+++ plugins/cube/CMakeLists.txt 2012-05-17 07:01:21 +0000
@@ -2,4 +2,4 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5compiz_plugin(cube PLUGINDEPS composite opengl)
6\ No newline at end of file5\ No newline at end of file
6compiz_plugin(cube PLUGINDEPS composite opengl)
77
=== modified file 'plugins/cube/include/cube/cube.h'
--- plugins/cube/include/cube/cube.h 2012-01-18 16:26:45 +0000
+++ plugins/cube/include/cube/cube.h 2012-05-17 07:01:21 +0000
@@ -62,15 +62,18 @@
62 virtual void cubePaintTop (const GLScreenPaintAttrib &sAttrib,62 virtual void cubePaintTop (const GLScreenPaintAttrib &sAttrib,
63 const GLMatrix &transform,63 const GLMatrix &transform,
64 CompOutput *output,64 CompOutput *output,
65 int size);65 int size,
66 const GLVector &normal);
66 virtual void cubePaintBottom (const GLScreenPaintAttrib &sAttrib,67 virtual void cubePaintBottom (const GLScreenPaintAttrib &sAttrib,
67 const GLMatrix &transform,68 const GLMatrix &transform,
68 CompOutput *output,69 CompOutput *output,
69 int size);70 int size,
71 const GLVector &normal);
70 virtual void cubePaintInside (const GLScreenPaintAttrib &sAttrib,72 virtual void cubePaintInside (const GLScreenPaintAttrib &sAttrib,
71 const GLMatrix &transform,73 const GLMatrix &transform,
72 CompOutput *output,74 CompOutput *output,
73 int size);75 int size,
76 const GLVector &normal);
74 virtual bool cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib,77 virtual bool cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib,
75 const GLMatrix &transform,78 const GLMatrix &transform,
76 CompOutput *output,79 CompOutput *output,
@@ -120,13 +123,13 @@
120 float, float);123 float, float);
121 WRAPABLE_HND (2, CubeScreenInterface, void, cubePaintTop,124 WRAPABLE_HND (2, CubeScreenInterface, void, cubePaintTop,
122 const GLScreenPaintAttrib &, const GLMatrix &,125 const GLScreenPaintAttrib &, const GLMatrix &,
123 CompOutput *, int);126 CompOutput *, int, const GLVector &);
124 WRAPABLE_HND (3, CubeScreenInterface, void, cubePaintBottom,127 WRAPABLE_HND (3, CubeScreenInterface, void, cubePaintBottom,
125 const GLScreenPaintAttrib &, const GLMatrix &,128 const GLScreenPaintAttrib &, const GLMatrix &,
126 CompOutput *, int);129 CompOutput *, int, const GLVector &);
127 WRAPABLE_HND (4, CubeScreenInterface, void, cubePaintInside,130 WRAPABLE_HND (4, CubeScreenInterface, void, cubePaintInside,
128 const GLScreenPaintAttrib &, const GLMatrix &,131 const GLScreenPaintAttrib &, const GLMatrix &,
129 CompOutput *, int);132 CompOutput *, int, const GLVector &);
130 WRAPABLE_HND (5, CubeScreenInterface, bool, cubeCheckOrientation,133 WRAPABLE_HND (5, CubeScreenInterface, bool, cubeCheckOrientation,
131 const GLScreenPaintAttrib &, const GLMatrix &,134 const GLScreenPaintAttrib &, const GLMatrix &,
132 CompOutput *, std::vector<GLVector> &);135 CompOutput *, std::vector<GLVector> &);
133136
=== modified file 'plugins/cube/src/cube.cpp'
--- plugins/cube/src/cube.cpp 2012-01-16 09:50:28 +0000
+++ plugins/cube/src/cube.cpp 2012-05-17 07:01:21 +0000
@@ -55,22 +55,25 @@
55CubeScreenInterface::cubePaintTop (const GLScreenPaintAttrib &sAttrib,55CubeScreenInterface::cubePaintTop (const GLScreenPaintAttrib &sAttrib,
56 const GLMatrix &transform,56 const GLMatrix &transform,
57 CompOutput *output,57 CompOutput *output,
58 int size)58 int size,
59 WRAPABLE_DEF (cubePaintTop, sAttrib, transform, output, size)59 const GLVector &normal)
60 WRAPABLE_DEF (cubePaintTop, sAttrib, transform, output, size, normal)
60 61
61void62void
62CubeScreenInterface::cubePaintBottom (const GLScreenPaintAttrib &sAttrib,63CubeScreenInterface::cubePaintBottom (const GLScreenPaintAttrib &sAttrib,
63 const GLMatrix &transform,64 const GLMatrix &transform,
64 CompOutput *output,65 CompOutput *output,
65 int size)66 int size,
66 WRAPABLE_DEF (cubePaintBottom, sAttrib, transform, output, size)67 const GLVector &normal)
68 WRAPABLE_DEF (cubePaintBottom, sAttrib, transform, output, size, normal)
6769
68void70void
69CubeScreenInterface::cubePaintInside (const GLScreenPaintAttrib &sAttrib,71CubeScreenInterface::cubePaintInside (const GLScreenPaintAttrib &sAttrib,
70 const GLMatrix &transform,72 const GLMatrix &transform,
71 CompOutput *output,73 CompOutput *output,
72 int size)74 int size,
73 WRAPABLE_DEF (cubePaintInside, sAttrib, transform, output, size)75 const GLVector &normal)
76 WRAPABLE_DEF (cubePaintInside, sAttrib, transform, output, size, normal)
7477
75bool78bool
76CubeScreenInterface::cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib,79CubeScreenInterface::cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib,
@@ -433,6 +436,7 @@
433 }436 }
434}437}
435438
439#ifndef USE_GLES
436static bool440static bool
437fillCircleTable (GLfloat **ppSint,441fillCircleTable (GLfloat **ppSint,
438 GLfloat **ppCost,442 GLfloat **ppCost,
@@ -467,10 +471,12 @@
467471
468 return true;472 return true;
469}473}
474#endif
470475
471void476void
472PrivateCubeScreen::updateSkydomeList (GLfloat fRadius)477PrivateCubeScreen::updateSkydomeList (GLfloat fRadius)
473{478{
479#ifndef USE_GLES
474 GLint iSlices = 128;480 GLint iSlices = 128;
475 GLint iStacks = 64;481 GLint iStacks = 64;
476 GLfloat afTexCoordX[4];482 GLfloat afTexCoordX[4];
@@ -532,6 +538,7 @@
532 afTexCoordX[3] = 1.0f;538 afTexCoordX[3] = 1.0f;
533 afTexCoordY[3] = 1.0f;539 afTexCoordY[3] = 1.0f;
534540
541
535 if (!mSkyListId)542 if (!mSkyListId)
536 mSkyListId = glGenLists (1);543 mSkyListId = glGenLists (1);
537544
@@ -616,6 +623,8 @@
616 free (cost1);623 free (cost1);
617 free (sint2);624 free (sint2);
618 free (cost2);625 free (cost2);
626
627#endif
619}628}
620629
621bool630bool
@@ -818,7 +827,7 @@
818{827{
819 WRAPABLE_HND_FUNCTN_RETURN (bool, cubeCheckOrientation, sAttrib, transform, output, points)828 WRAPABLE_HND_FUNCTN_RETURN (bool, cubeCheckOrientation, sAttrib, transform, output, points)
820 GLMatrix sTransform = transform;829 GLMatrix sTransform = transform;
821 GLMatrix mvp, pm (priv->gScreen->projectionMatrix ());830 GLMatrix mvp, pm (priv->gScreen->projectionMatrix ()->getMatrix ());
822 GLVector pntA, pntB, pntC;831 GLVector pntA, pntB, pntC;
823 GLVector vecA, vecB, ortho;832 GLVector vecA, vecB, ortho;
824 bool rv = false;833 bool rv = false;
@@ -1063,7 +1072,7 @@
1063 if (priv->mSky.size () > 0)1072 if (priv->mSky.size () > 0)
1064 {1073 {
1065 priv->gScreen->setLighting (false);1074 priv->gScreen->setLighting (false);
10661075#ifndef USE_GLES
1067 glPushMatrix ();1076 glPushMatrix ();
10681077
1069 if (priv->optionGetSkydomeAnimated () &&1078 if (priv->optionGetSkydomeAnimated () &&
@@ -1079,6 +1088,7 @@
10791088
1080 glCallList (priv->mSkyListId);1089 glCallList (priv->mSkyListId);
1081 glPopMatrix ();1090 glPopMatrix ();
1091#endif
1082 }1092 }
1083 else1093 else
1084 {1094 {
@@ -1090,9 +1100,10 @@
1090CubeScreen::cubePaintTop (const GLScreenPaintAttrib &sAttrib,1100CubeScreen::cubePaintTop (const GLScreenPaintAttrib &sAttrib,
1091 const GLMatrix &transform,1101 const GLMatrix &transform,
1092 CompOutput *output,1102 CompOutput *output,
1093 int size)1103 int size,
1104 const GLVector &normal)
1094{1105{
1095 WRAPABLE_HND_FUNCTN (cubePaintTop, sAttrib, transform, output, size)1106 WRAPABLE_HND_FUNCTN (cubePaintTop, sAttrib, transform, output, size, normal)
10961107
1097 GLScreenPaintAttrib sa = sAttrib;1108 GLScreenPaintAttrib sa = sAttrib;
1098 GLMatrix sTransform = transform;1109 GLMatrix sTransform = transform;
@@ -1105,51 +1116,49 @@
1105 color = priv->optionGetTopColor ();1116 color = priv->optionGetTopColor ();
1106 opacity = priv->mDesktopOpacity * color[3] / 0xffff;1117 opacity = priv->mDesktopOpacity * color[3] / 0xffff;
11071118
1108 glColor4us (color[0] * opacity / 0xffff,1119 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
1109 color[1] * opacity / 0xffff,1120 std::vector <GLushort> colorData;
1110 color[2] * opacity / 0xffff,
1111 opacity);
11121121
1113 glPushMatrix ();1122 colorData.push_back (color[0] * opacity / 0xffff);
1123 colorData.push_back (color[1] * opacity / 0xffff);
1124 colorData.push_back (color[2] * opacity / 0xffff);
1125 colorData.push_back (opacity);
11141126
1115 sa.yRotate += (360.0f / size) * (priv->mXRotations + 1);1127 sa.yRotate += (360.0f / size) * (priv->mXRotations + 1);
11161128
1117 priv->gScreen->glApplyTransform (sa, output, &sTransform);1129 priv->gScreen->glApplyTransform (sa, output, &sTransform);
11181130
1119 glLoadMatrixf (sTransform.getMatrix ());1131 sTransform.translate (priv->mOutputXOffset, -priv->mOutputYOffset, 0.0f);
1120 glTranslatef (priv->mOutputXOffset, -priv->mOutputYOffset, 0.0f);1132 sTransform.scale (priv->mOutputXScale, priv->mOutputYScale, 1.0f);
1121 glScalef (priv->mOutputXScale, priv->mOutputYScale, 1.0f);
11221133
1123 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))1134 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))
1124 {1135 {
1136#ifndef USE_GLES
1125 priv->gScreen->setTexEnvMode (GL_MODULATE);1137 priv->gScreen->setTexEnvMode (GL_MODULATE);
1126 glEnable (GL_BLEND);1138#endif
1127 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);1139 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1128 }1140 }
11291141
1130 glVertexPointer (3, GL_FLOAT, 0, priv->mVertices);1142 bool withTexture = priv->mInvert == 1 && size == 4 && priv->mTexture.size ();
11311143
1132 if (priv->mInvert == 1 && size == 4 && priv->mTexture.size ())1144 if (withTexture)
1133 {
1134 priv->mTexture[0]->enable (GLTexture::Good);1145 priv->mTexture[0]->enable (GLTexture::Good);
1135 glTexCoordPointer (2, GL_FLOAT, 0, priv->mTc);1146
1136 glDrawArrays (GL_TRIANGLE_FAN, 0, priv->mNVertices >> 1);1147 streamingBuffer->begin (GL_TRIANGLE_FAN);
1148 streamingBuffer->addColors (1, &(colorData[0]));
1149 streamingBuffer->addVertices (priv->mNVertices >> 1, priv->mVertices);
1150 streamingBuffer->addNormals (1, const_cast <GLfloat *> (&normal[0]));
1151
1152 if (withTexture)
1153 streamingBuffer->addTexCoords (0, 2, priv->mTc);
1154
1155 streamingBuffer->end ();
1156 streamingBuffer->render (sTransform);
1157
1158 if (withTexture)
1137 priv->mTexture[0]->disable ();1159 priv->mTexture[0]->disable ();
1138 glDisableClientState (GL_TEXTURE_COORD_ARRAY);
1139 }
1140 else
1141 {
1142 glDisableClientState (GL_TEXTURE_COORD_ARRAY);
1143 glDrawArrays (GL_TRIANGLE_FAN, 0, priv->mNVertices >> 1);
1144 }
1145
1146 glPopMatrix ();
1147
1148 glColor4usv (defaultColor);
1149 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
11501160
1151 priv->gScreen->setTexEnvMode (GL_REPLACE);1161 priv->gScreen->setTexEnvMode (GL_REPLACE);
1152 glDisable (GL_BLEND);
1153 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);1162 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1154}1163}
11551164
@@ -1157,9 +1166,10 @@
1157CubeScreen::cubePaintBottom (const GLScreenPaintAttrib &sAttrib,1166CubeScreen::cubePaintBottom (const GLScreenPaintAttrib &sAttrib,
1158 const GLMatrix &transform,1167 const GLMatrix &transform,
1159 CompOutput *output,1168 CompOutput *output,
1160 int size)1169 int size,
1170 const GLVector &normal)
1161{1171{
1162 WRAPABLE_HND_FUNCTN (cubePaintBottom, sAttrib, transform, output, size)1172 WRAPABLE_HND_FUNCTN (cubePaintBottom, sAttrib, transform, output, size, normal)
11631173
1164 GLScreenPaintAttrib sa = sAttrib;1174 GLScreenPaintAttrib sa = sAttrib;
1165 GLMatrix sTransform = transform;1175 GLMatrix sTransform = transform;
@@ -1172,41 +1182,40 @@
1172 color = priv->optionGetBottomColor ();1182 color = priv->optionGetBottomColor ();
1173 opacity = priv->mDesktopOpacity * color[3] / 0xffff;1183 opacity = priv->mDesktopOpacity * color[3] / 0xffff;
11741184
1175 glColor4us (color[0] * opacity / 0xffff,1185 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
1176 color[1] * opacity / 0xffff,1186 std::vector <GLushort> colorData;
1177 color[2] * opacity / 0xffff,
1178 opacity);
11791187
1180 glPushMatrix ();1188 colorData.push_back (color[0] * opacity / 0xffff);
1189 colorData.push_back (color[1] * opacity / 0xffff);
1190 colorData.push_back (color[2] * opacity / 0xffff);
1191 colorData.push_back (opacity);
11811192
1182 sa.yRotate += (360.0f / size) * (priv->mXRotations + 1);1193 sa.yRotate += (360.0f / size) * (priv->mXRotations + 1);
11831194
1184 priv->gScreen->glApplyTransform (sa, output, &sTransform);1195 priv->gScreen->glApplyTransform (sa, output, &sTransform);
11851196
1186 glLoadMatrixf (sTransform.getMatrix ());1197 sTransform.translate (priv->mOutputXOffset, -priv->mOutputYOffset, 0.0f);
1187 glTranslatef (priv->mOutputXOffset, -priv->mOutputYOffset, 0.0f);1198 sTransform.scale (priv->mOutputXScale, priv->mOutputYScale, 1.0f);
1188 glScalef (priv->mOutputXScale, priv->mOutputYScale, 1.0f);
11891199
1190 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))1200 if ((priv->mDesktopOpacity != OPAQUE) || (color[3] != OPAQUE))
1191 {1201 {
1202#ifndef USE_GLES
1192 priv->gScreen->setTexEnvMode (GL_MODULATE);1203 priv->gScreen->setTexEnvMode (GL_MODULATE);
1193 glEnable (GL_BLEND);1204#endif
1194 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);1205 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1195 }1206 }
11961207
1197 glVertexPointer (3, GL_FLOAT, 0, priv->mVertices);1208 streamingBuffer->begin (GL_TRIANGLE_FAN);
11981209 streamingBuffer->addColors (1, &(colorData[0]));
11991210 streamingBuffer->addVertices (priv->mNVertices, priv->mVertices);
1200 glDisableClientState (GL_TEXTURE_COORD_ARRAY);1211 streamingBuffer->addNormals (1, const_cast <GLfloat *> (&normal[0]));
1201 glDrawArrays (GL_TRIANGLE_FAN, priv->mNVertices >> 1, priv->mNVertices >> 1);1212 streamingBuffer->setVertexOffset (priv->mNVertices >> 1);
12021213 streamingBuffer->setMaxVertices (priv->mNVertices >> 1);
1203 glPopMatrix ();1214
12041215 streamingBuffer->end ();
1205 glColor4usv (defaultColor);1216 streamingBuffer->render (sTransform);
1206 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
12071217
1208 priv->gScreen->setTexEnvMode (GL_REPLACE);1218 priv->gScreen->setTexEnvMode (GL_REPLACE);
1209 glDisable (GL_BLEND);
1210 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);1219 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1211}1220}
12121221
@@ -1214,9 +1223,10 @@
1214CubeScreen::cubePaintInside (const GLScreenPaintAttrib &sAttrib,1223CubeScreen::cubePaintInside (const GLScreenPaintAttrib &sAttrib,
1215 const GLMatrix &transform,1224 const GLMatrix &transform,
1216 CompOutput *output,1225 CompOutput *output,
1217 int size)1226 int size,
1227 const GLVector &normal)
1218{1228{
1219 WRAPABLE_HND_FUNCTN (cubePaintInside, sAttrib, transform, output, size)1229 WRAPABLE_HND_FUNCTN (cubePaintInside, sAttrib, transform, output, size, normal)
1220}1230}
12211231
1222void 1232void
@@ -1226,6 +1236,8 @@
1226{1236{
1227 if (mRotationState != CubeScreen::RotationNone)1237 if (mRotationState != CubeScreen::RotationNone)
1228 {1238 {
1239 /* FIXME: No output clipping in OpenGL|ES yet */
1240 #ifndef USE_GLES
1229 glPushMatrix ();1241 glPushMatrix ();
1230 glLoadMatrixf (transform.getMatrix ());1242 glLoadMatrixf (transform.getMatrix ());
1231 glTranslatef (mOutputXOffset, -mOutputYOffset, 0.0f);1243 glTranslatef (mOutputXOffset, -mOutputYOffset, 0.0f);
@@ -1260,6 +1272,7 @@
1260 glEnable (GL_CLIP_PLANE3);1272 glEnable (GL_CLIP_PLANE3);
12611273
1262 glPopMatrix ();1274 glPopMatrix ();
1275 #endif
1263 }1276 }
1264 else1277 else
1265 gScreen->glEnableOutputClipping (transform, region, output);1278 gScreen->glEnableOutputClipping (transform, region, output);
@@ -1447,38 +1460,28 @@
14471460
1448 if (topDir && bottomDir)1461 if (topDir && bottomDir)
1449 {1462 {
1450 glNormal3f (0.0f, -1.0f, 0.0f);
1451 if (allCaps)1463 if (allCaps)
1452 {1464 {
1453 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize);1465 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize, GLVector (0.0f, -1.0f, 0.0f, 1.0f));
1454 glNormal3f (0.0f, 0.0f, -1.0f);1466 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize, GLVector (0.0f, 0.0f, -1.0f, 1.0f));
1455 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize);
1456 glNormal3f (0.0f, -1.0f, 0.0f);
1457 }1467 }
1458 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize);1468 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize, GLVector (0.0f, -1.0f, 0.0f, 1.0f));
1459 }1469 }
1460 else if (!topDir && !bottomDir)1470 else if (!topDir && !bottomDir)
1461 {1471 {
1462 glNormal3f (0.0f, 1.0f, 0.0f);
1463 if (allCaps)1472 if (allCaps)
1464 {1473 {
1465 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize);1474 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize, GLVector (0.0f, 1.0f, 0.0f, 1.0f));
1466 glNormal3f (0.0f, 0.0f, -1.0f);1475 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize, GLVector (0.0f, 0.0f, -1.0f, 1.0f));
1467 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize);
1468 glNormal3f (0.0f, 1.0f, 0.0f);
1469 }1476 }
1470 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize);1477 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize, GLVector (0.0f, -1.0f, 0.0f, 1.0f));
1471 }1478 }
1472 else if (allCaps)1479 else if (allCaps)
1473 {1480 {
1474 glNormal3f (0.0f, 1.0f, 0.0f);1481 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize, GLVector (0.0f, 1.0f, 0.0f, 1.0f));
1475 cubeScreen->cubePaintTop (sa, transform, outputPtr, hsize);1482 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize, GLVector (0.0f, -1.0f, 0.0f, 1.0f));
1476 glNormal3f (0.0f, -1.0f, 0.0f);1483 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize, GLVector (0.0f, 0.0f, -1.0f, 1.0f));
1477 cubeScreen->cubePaintBottom (sa, transform, outputPtr, hsize);
1478 glNormal3f (0.0f, 0.0f, -1.0f);
1479 cubeScreen->cubePaintInside (sa, transform, outputPtr, hsize);
1480 }1484 }
1481 glNormal3f (0.0f, 0.0f, -1.0f);
1482 }1485 }
14831486
1484 if (wasCulled)1487 if (wasCulled)
@@ -1705,8 +1708,10 @@
1705 if (mVertices)1708 if (mVertices)
1706 free (mVertices);1709 free (mVertices);
17071710
1711#ifndef USE_GLES
1708 if (mSkyListId)1712 if (mSkyListId)
1709 glDeleteLists (mSkyListId, 1);1713 glDeleteLists (mSkyListId, 1);
1714#endif
1710}1715}
17111716
17121717
17131718
=== modified file 'plugins/decor/src/decor.cpp'
--- plugins/decor/src/decor.cpp 2012-05-10 15:40:25 +0000
+++ plugins/decor/src/decor.cpp 2012-05-17 07:01:21 +0000
@@ -177,15 +177,13 @@
177 */177 */
178178
179bool179bool
180DecorWindow::glDraw (const GLMatrix &transform,180DecorWindow::glDraw (const GLMatrix &transform,
181 GLFragment::Attrib &attrib,181 const GLWindowPaintAttrib &attrib,
182 const CompRegion &region,182 const CompRegion &region,
183 unsigned int mask)183 unsigned int mask)
184{184{
185 bool status;185 bool status;
186186
187 status = gWindow->glDraw (transform, attrib, region, mask);
188
189 /* Don't render dock decorations (shadows) on just any old window */187 /* Don't render dock decorations (shadows) on just any old window */
190 if (!(window->type () & CompWindowTypeDockMask))188 if (!(window->type () & CompWindowTypeDockMask))
191 {189 {
@@ -205,15 +203,19 @@
205 }203 }
206 }204 }
207205
206 status = gWindow->glDraw (transform, attrib, region, mask);
207
208 return status;208 return status;
209}209}
210210
211void211void
212DecorWindow::glDecorate (const GLMatrix &transform,212DecorWindow::glDecorate (const GLMatrix &transform,
213 GLFragment::Attrib &attrib,213 const GLWindowPaintAttrib &attrib,
214 const CompRegion &region,214 const CompRegion &region,
215 unsigned int mask)215 unsigned int mask)
216{216{
217 GLboolean isBlendingEnabled;
218
217 if (wd &&219 if (wd &&
218 wd->decor->type == WINDOW_DECORATION_TYPE_PIXMAP)220 wd->decor->type == WINDOW_DECORATION_TYPE_PIXMAP)
219 {221 {
@@ -221,6 +223,7 @@
221 GLTexture::MatrixList ml (1);223 GLTexture::MatrixList ml (1);
222 mask |= PAINT_WINDOW_BLEND_MASK;224 mask |= PAINT_WINDOW_BLEND_MASK;
223225
226 gWindow->vertexBuffer ()->begin ();
224 const CompRegion *preg = NULL;227 const CompRegion *preg = NULL;
225228
226 if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |229 if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |
@@ -247,8 +250,6 @@
247250
248 const CompRegion &reg (*preg);251 const CompRegion &reg (*preg);
249252
250 gWindow->geometry ().reset ();
251
252 if (updateMatrix)253 if (updateMatrix)
253 updateDecorationScale ();254 updateDecorationScale ();
254255
@@ -267,9 +268,14 @@
267 }268 }
268 }269 }
269270
270 if (gWindow->geometry ().vCount)271 gWindow->vertexBuffer ()->end ();
271 gWindow->glDrawTexture (wd->decor->texture->textures[0],272
272 attrib, mask);273 glGetBooleanv (GL_BLEND, &isBlendingEnabled);
274 glEnable (GL_BLEND);
275 gWindow->glDrawTexture (wd->decor->texture->textures[0], transform,
276 attrib, mask);
277 if (!isBlendingEnabled)
278 glDisable (GL_BLEND);
273 }279 }
274 else if (wd && wd->decor->type == WINDOW_DECORATION_TYPE_WINDOW)280 else if (wd && wd->decor->type == WINDOW_DECORATION_TYPE_WINDOW)
275 {281 {
@@ -282,15 +288,18 @@
282288
283 if (updateMatrix)289 if (updateMatrix)
284 updateDecorationScale ();290 updateDecorationScale ();
291 glGetBooleanv (GL_BLEND, &isBlendingEnabled);
292 glEnable (GL_BLEND);
285293
286 if (gWindow->textures ().size () == 1)294 if (gWindow->textures ().size () == 1)
287 {295 {
288 ml[0] = gWindow->matrices ()[0];296 ml[0] = gWindow->matrices ()[0];
289 gWindow->geometry ().reset ();297 gWindow->vertexBuffer ()->begin ();
290 gWindow->glAddGeometry (ml, window->frameRegion (), region);298 gWindow->glAddGeometry (ml, window->frameRegion (), region);
299 gWindow->vertexBuffer ()->end ();
291300
292 if (gWindow->geometry ().vCount)301 gWindow->glDrawTexture (gWindow->textures ()[0], transform,
293 gWindow->glDrawTexture (gWindow->textures ()[0], attrib, mask);302 attrib, mask);
294 }303 }
295 else304 else
296 {305 {
@@ -299,14 +308,17 @@
299 for (unsigned int i = 0; i < gWindow->textures ().size (); i++)308 for (unsigned int i = 0; i < gWindow->textures ().size (); i++)
300 {309 {
301 ml[0] = gWindow->matrices ()[i];310 ml[0] = gWindow->matrices ()[i];
302 gWindow->geometry ().reset ();311 gWindow->vertexBuffer ()->begin ();
303 gWindow->glAddGeometry (ml, regions[i], region);312 gWindow->glAddGeometry (ml, regions[i], region);
313 gWindow->vertexBuffer ()->end ();
304314
305 if (gWindow->geometry ().vCount)315 gWindow->glDrawTexture (gWindow->textures ()[i], transform,
306 gWindow->glDrawTexture (gWindow->textures ()[i], attrib,316 attrib, mask);
307 mask);
308 }317 }
309 }318 }
319
320 if (!isBlendingEnabled)
321 glDisable (GL_BLEND);
310 }322 }
311}323}
312324
313325
=== modified file 'plugins/decor/src/decor.h'
--- plugins/decor/src/decor.h 2012-05-10 15:40:25 +0000
+++ plugins/decor/src/decor.h 2012-05-17 07:01:21 +0000
@@ -276,10 +276,10 @@
276276
277 bool damageRect (bool, const CompRect &);277 bool damageRect (bool, const CompRect &);
278278
279 bool glDraw (const GLMatrix &, GLFragment::Attrib &,279 bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
280 const CompRegion &, unsigned int);280 const CompRegion &, unsigned int);
281 void glDecorate (const GLMatrix &, GLFragment::Attrib &,281 void glDecorate (const GLMatrix &, const GLWindowPaintAttrib &,
282 const CompRegion &, unsigned int);282 const CompRegion &, unsigned int);
283283
284 void windowNotify (CompWindowNotify n);284 void windowNotify (CompWindowNotify n);
285285
286286
=== modified file 'plugins/imgsvg/src/imgsvg.cpp'
--- plugins/imgsvg/src/imgsvg.cpp 2012-01-18 16:26:45 +0000
+++ plugins/imgsvg/src/imgsvg.cpp 2012-05-17 07:01:21 +0000
@@ -220,12 +220,12 @@
220}220}
221221
222bool222bool
223SvgWindow::glDraw (const GLMatrix &transform,223SvgWindow::glDraw (const GLMatrix &transform,
224 GLFragment::Attrib &fragment,224 const GLWindowPaintAttrib &attrib,
225 const CompRegion &region,225 const CompRegion &region,
226 unsigned int mask)226 unsigned int mask)
227{227{
228 bool status = gWindow->glDraw (transform, fragment, region, mask);228 bool status = gWindow->glDraw (transform, attrib, region, mask);
229229
230 if (!status)230 if (!status)
231 return status;231 return status;
@@ -251,13 +251,15 @@
251 {251 {
252 matrix[0] = context->texture[0].matrices[i];252 matrix[0] = context->texture[0].matrices[i];
253253
254 gWindow->geometry ().reset ();254 gWindow->vertexBuffer ()->begin ();
255 gWindow->glAddGeometry (matrix, context->box, reg);255 gWindow->glAddGeometry (matrix, context->box, reg);
256 gWindow->vertexBuffer ()->end ();
256257
257 if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)258 if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
258 mask |= PAINT_WINDOW_BLEND_MASK;259 mask |= PAINT_WINDOW_BLEND_MASK;
259260
260 gWindow->glDrawTexture (context->texture[0].textures[i], fragment, mask);261 gWindow->glDrawTexture (context->texture[0].textures[i], transform,
262 attrib, mask);
261263
262 if (rect.width () > 0 && rect.height () > 0)264 if (rect.width () > 0 && rect.height () > 0)
263 {265 {
@@ -321,11 +323,12 @@
321 saveFilter = gScreen->filter (SCREEN_TRANS_FILTER);323 saveFilter = gScreen->filter (SCREEN_TRANS_FILTER);
322 gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good);324 gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good);
323325
324 gWindow->geometry ().reset ();326 gWindow->vertexBuffer ()->begin ();
325 gWindow->glAddGeometry (matrix, r, reg);327 gWindow->glAddGeometry (matrix, r, reg);
328 gWindow->vertexBuffer ()->end ();
326329
327 gWindow->glDrawTexture (context->texture[1].textures[j],330 gWindow->glDrawTexture (context->texture[1].textures[j],
328 fragment, mask);331 transform, attrib, mask);
329332
330 gScreen->setFilter (SCREEN_TRANS_FILTER, saveFilter);333 gScreen->setFilter (SCREEN_TRANS_FILTER, saveFilter);
331 }334 }
332335
=== modified file 'plugins/imgsvg/src/imgsvg.h'
--- plugins/imgsvg/src/imgsvg.h 2012-01-18 16:26:45 +0000
+++ plugins/imgsvg/src/imgsvg.h 2012-05-17 07:01:21 +0000
@@ -76,7 +76,8 @@
76 SvgWindow (CompWindow *window);76 SvgWindow (CompWindow *window);
77 ~SvgWindow ();77 ~SvgWindow ();
7878
79 bool glDraw (const GLMatrix &transform, GLFragment::Attrib &fragment,79 bool glDraw (const GLMatrix &transform,
80 const GLWindowPaintAttrib &attrib,
80 const CompRegion &region, unsigned int mask);81 const CompRegion &region, unsigned int mask);
81 void moveNotify (int dx, int dy, bool immediate);82 void moveNotify (int dx, int dy, bool immediate);
82 void resizeNotify (int dx, int dy, int dwidth, int dheight);83 void resizeNotify (int dx, int dy, int dwidth, int dheight);
8384
=== modified file 'plugins/obs/src/obs.cpp'
--- plugins/obs/src/obs.cpp 2010-07-02 02:49:24 +0000
+++ plugins/obs/src/obs.cpp 2012-05-17 07:01:21 +0000
@@ -151,29 +151,30 @@
151 we wrap into glDrawWindow here */151 we wrap into glDrawWindow here */
152152
153bool153bool
154ObsWindow::glDraw (const GLMatrix& transform,154ObsWindow::glDraw (const GLMatrix &transform,
155 GLFragment::Attrib& attrib,155 const GLWindowPaintAttrib &attrib,
156 const CompRegion& region,156 const CompRegion &region,
157 unsigned int mask)157 unsigned int mask)
158{158{
159 GLWindowPaintAttrib wAttrib (attrib);
159 int factor;160 int factor;
160161
161 factor = customFactor[MODIFIER_OPACITY];162 factor = customFactor[MODIFIER_OPACITY];
162 if (factor != 100)163 if (factor != 100)
163 {164 {
164 attrib.setOpacity (factor * attrib.getOpacity () / 100);165 wAttrib.opacity = factor * wAttrib.opacity / 100;
165 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;166 mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
166 }167 }
167168
168 factor = customFactor[MODIFIER_BRIGHTNESS];169 factor = customFactor[MODIFIER_BRIGHTNESS];
169 if (factor != 100)170 if (factor != 100)
170 attrib.setBrightness (factor * attrib.getBrightness () / 100);171 wAttrib.brightness = factor * wAttrib.brightness / 100;
171172
172 factor = customFactor[MODIFIER_SATURATION];173 factor = customFactor[MODIFIER_SATURATION];
173 if (factor != 100)174 if (factor != 100)
174 attrib.setSaturation (factor * attrib.getSaturation () / 100);175 wAttrib.saturation = factor * wAttrib.saturation / 100;
175176
176 return gWindow->glDraw (transform, attrib, region, mask);177 return gWindow->glDraw (transform, wAttrib, region, mask);
177}178}
178179
179void180void
180181
=== modified file 'plugins/obs/src/obs.h'
--- plugins/obs/src/obs.h 2012-01-18 16:26:45 +0000
+++ plugins/obs/src/obs.h 2012-05-17 07:01:21 +0000
@@ -66,7 +66,7 @@
6666
67 bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,67 bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
68 const CompRegion &, unsigned int);68 const CompRegion &, unsigned int);
69 bool glDraw (const GLMatrix &, GLFragment::Attrib &,69 bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
70 const CompRegion &, unsigned int);70 const CompRegion &, unsigned int);
7171
72 void changePaintModifier (unsigned int, int);72 void changePaintModifier (unsigned int, int);
7373
=== modified file 'plugins/opengl/CMakeLists.txt'
--- plugins/opengl/CMakeLists.txt 2009-03-15 05:09:18 +0000
+++ plugins/opengl/CMakeLists.txt 2012-05-17 07:01:21 +0000
@@ -2,7 +2,12 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5find_package (OpenGL)
6if (OPENGL_FOUND)
7 compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
8endif ()
9\ No newline at end of file5\ No newline at end of file
6if (USE_GLES)
7 compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD "-DUSE_GLES -std=c++0x" LIBRARIES ${OPENGLES2_LIBRARIES} INCDIRS ${OPENGLES2_INCLUDE_DIR})
8else (USE_GLES)
9 find_package (OpenGL)
10 if (OPENGL_FOUND)
11 compiz_plugin(opengl PLUGINDEPS composite CFLAGSADD -std=c++0x LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
12 endif (OPENGL_FOUND)
13endif (USE_GLES)
14
1015
=== modified file 'plugins/opengl/compiz-opengl.pc.in'
--- plugins/opengl/compiz-opengl.pc.in 2009-03-15 05:09:18 +0000
+++ plugins/opengl/compiz-opengl.pc.in 2012-05-17 07:01:21 +0000
@@ -8,5 +8,5 @@
8Version: @VERSION@8Version: @VERSION@
99
10Requires: compiz compiz-composite10Requires: compiz compiz-composite
11Libs: -lGL -L${libdir} -lopengl
12Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz
13\ No newline at end of file11\ No newline at end of file
12Libs: @PKGCONFIG_LIBS@ -L${libdir} -lopengl
13Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz
1414
=== removed file 'plugins/opengl/include/opengl/fragment.h'
--- plugins/opengl/include/opengl/fragment.h 2012-01-18 16:26:45 +0000
+++ plugins/opengl/include/opengl/fragment.h 1970-01-01 00:00:00 +0000
@@ -1,125 +0,0 @@
1/*
2 * Copyright © 2008 Dennis Kasprzyk
3 * Copyright © 2007 Novell, Inc.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software
6 * and its documentation for any purpose is hereby granted without
7 * fee, provided that the above copyright notice appear in all copies
8 * and that both that copyright notice and this permission notice
9 * appear in supporting documentation, and that the name of
10 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior permission.
12 * Dennis Kasprzyk makes no representations about the suitability of this
13 * software for any purpose. It is provided "as is" without express or
14 * implied warranty.
15 *
16 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
22 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 *
24 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
25 * David Reveman <davidr@novell.com>
26 */
27
28#ifndef _GLFRAGMENT_H
29#define _GLFRAGMENT_H
30
31#define MAX_FRAGMENT_FUNCTIONS 16
32
33#define COMP_FETCH_TARGET_2D 0
34#define COMP_FETCH_TARGET_RECT 1
35#define COMP_FETCH_TARGET_NUM 2
36
37struct GLWindowPaintAttrib;
38class GLScreen;
39class GLTexture;
40
41/**
42 * Describes a texture modification fragment program
43 * for a texture
44 */
45namespace GLFragment {
46
47 class Storage;
48
49 typedef unsigned int FunctionId;
50
51 class PrivateFunctionData;
52 class PrivateAttrib;
53
54 class FunctionData {
55 public:
56 FunctionData ();
57 ~FunctionData ();
58
59 /**
60 * Returns the status of this fragment program
61 * (valid or invalid)
62 */
63 bool status ();
64
65 void addTempHeaderOp (const char *name);
66
67 void addParamHeaderOp (const char *name);
68
69 void addAttribHeaderOp (const char *name);
70
71
72 void addFetchOp (const char *dst, const char *offset, int target);
73
74 void addColorOp (const char *dst, const char *src);
75
76 void addDataOp (const char *str, ...);
77
78 void addBlendOp (const char *str, ...);
79
80 FunctionId createFragmentFunction (const char *name);
81
82 private:
83 PrivateFunctionData *priv;
84 };
85
86 class Attrib {
87 public:
88 Attrib (const GLWindowPaintAttrib &paint);
89 Attrib (const Attrib&);
90 ~Attrib ();
91
92 Attrib &operator= (const Attrib &rhs);
93
94 unsigned int allocTextureUnits (unsigned int nTexture);
95
96 unsigned int allocParameters (unsigned int nParam);
97
98 void addFunction (FunctionId function);
99
100 bool enable (bool *blending);
101 void disable ();
102
103 unsigned short getSaturation ();
104 unsigned short getBrightness ();
105 unsigned short getOpacity ();
106
107 void setSaturation (unsigned short);
108 void setBrightness (unsigned short);
109 void setOpacity (unsigned short);
110
111 bool hasFunctions ();
112
113 private:
114 PrivateAttrib *priv;
115 };
116
117 void destroyFragmentFunction (FunctionId id);
118
119 FunctionId getSaturateFragmentFunction (GLTexture *texture,
120 int param);
121};
122
123
124
125#endif
1260
=== added file 'plugins/opengl/include/opengl/framebufferobject.h'
--- plugins/opengl/include/opengl/framebufferobject.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/framebufferobject.h 2012-05-17 07:01:21 +0000
@@ -0,0 +1,107 @@
1/*
2 * Copyright (c) 2011 Collabora, Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Collabora Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Collabora Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * COLLABORA LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL COLLABORA LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Pekka Paalanen <ppaalanen@gmail.com>
24 */
25
26#ifndef _COMPIZ_GLFRAMEBUFFEROBJECT_H
27#define _COMPIZ_GLFRAMEBUFFEROBJECT_H
28
29#include <opengl/opengl.h>
30
31struct PrivateGLFramebufferObject;
32
33/**
34 * Class representing a framebuffer object in GL, supporting only one
35 * color attachment as per GLES 2 spec. The color attachment is referred
36 * to as the texture (of the FBO).
37 *
38 * Usage:
39 * 1. create a GLFramebufferObject (requires a GL context)
40 * 2. call allocate (size), and check status ()
41 * 3. old = bind ()
42 * 4. do your rendering
43 * 5. rebind (old)
44 * 6. use the rendered texture via tex ()
45 * 7. go to 2 or 3, or delete to quit (requires a GL context)
46 *
47 * TODO: add depth/stencil attachments
48 * FIXME: written for OpenGL ES 2 only, desktop OpenGL might not work.
49 */
50class GLFramebufferObject
51{
52 public:
53 GLFramebufferObject ();
54 ~GLFramebufferObject ();
55
56 /**
57 * Ensure the texture is of the given size, recreating it if needed,
58 * and replace the FBO color attachment with it. The texture contents
59 * become undefined, unless specified in the 'image' argument.
60 * When specifying 'image', it's also possible to pass-in the
61 * desired image's 'format' and 'type'.
62 *
63 * Returns true on success, and false on texture allocation failure.
64 */
65 bool allocate (const CompSize &size,
66 const char *image = NULL,
67 GLenum format = GL_RGBA,
68 GLenum type = GL_UNSIGNED_BYTE);
69
70 /**
71 * Bind this as the current FBO, previous binding in GL context is
72 * undone. GL rendering is now targeted to this FBO.
73 * Returns a pointer to the previously bound FBO, or NULL if
74 * the previous binding was zero (the window system provided
75 * framebuffer).
76 *
77 * The previous FBO is no longer bound, so you can use its
78 * texture. To restore the previous FBO, call rebind (FBO) with
79 * the returned pointer as the argument.
80 */
81 GLFramebufferObject *bind ();
82
83 /**
84 * Bind the given FBO as the current FBO, without looking up the
85 * previous binding. The argument can be NULL, in which case the
86 * window system provided framebuffer gets bound (FBO is unbound).
87 */
88 static void rebind (GLFramebufferObject *fbo);
89
90 /**
91 * Check the FBO completeness. Returns true on complete.
92 * Otherwise returns false and reports the error to log.
93 */
94 bool checkStatus ();
95
96 /**
97 * Return a pointer to the texture that is the color attachment.
98 * This will return NULL, if allocate () has not been called, or
99 * the last allocate () call failed.
100 */
101 GLTexture *tex ();
102
103 private:
104 PrivateGLFramebufferObject *priv;
105};
106
107#endif // _COMPIZ_GLFRAMEBUFFEROBJECT_H
0108
=== modified file 'plugins/opengl/include/opengl/matrix.h'
--- plugins/opengl/include/opengl/matrix.h 2009-03-15 05:09:18 +0000
+++ plugins/opengl/include/opengl/matrix.h 2012-05-17 07:01:21 +0000
@@ -44,6 +44,8 @@
44 void reset ();44 void reset ();
45 void toScreenSpace (const CompOutput *output, float z);45 void toScreenSpace (const CompOutput *output, float z);
4646
47 bool invert ();
48
47 void rotate (const float angle, const float x,49 void rotate (const float angle, const float x,
48 const float y, const float z);50 const float y, const float z);
49 void rotate (const float angle, const GLVector& vector);51 void rotate (const float angle, const GLVector& vector);
5052
=== modified file 'plugins/opengl/include/opengl/opengl.h'
--- plugins/opengl/include/opengl/opengl.h 2012-01-20 09:05:56 +0000
+++ plugins/opengl/include/opengl/opengl.h 2012-05-17 07:01:21 +0000
@@ -28,16 +28,45 @@
28#ifndef _COMPIZ_OPENGL_H28#ifndef _COMPIZ_OPENGL_H
29#define _COMPIZ_OPENGL_H29#define _COMPIZ_OPENGL_H
3030
31#ifdef USE_GLES
32#define SUPPORT_X11
33#include <GLES2/gl2.h>
34#include <GLES2/gl2ext.h>
35#include <EGL/egl.h>
36#include <EGL/eglext.h>
37#else
31#include <GL/gl.h>38#include <GL/gl.h>
32#include <GL/glx.h>39#include <GL/glx.h>
40#endif
41
42#include <core/size.h>
43#include <core/pluginclasshandler.h>
3344
34#include <opengl/matrix.h>45#include <opengl/matrix.h>
35#include <opengl/texture.h>46#include <opengl/texture.h>
36#include <opengl/fragment.h>47#include <opengl/framebufferobject.h>
48#include <opengl/vertexbuffer.h>
49#include <opengl/program.h>
50#include <opengl/programcache.h>
51#include <opengl/shadercache.h>
3752
38#define COMPIZ_OPENGL_ABI 453#define COMPIZ_OPENGL_ABI 4
3954
40#include <core/pluginclasshandler.h>55#if !defined(GL_BGRA)
56 #if !defined(GL_BGRA_EXT)
57 #error GL_BGRA support is required
58 #else
59 #define GL_BGRA GL_BGRA_EXT
60 #endif
61#endif
62
63#if !defined(GL_BGRA)
64 #if !defined(GL_BGRA_EXT)
65 #error GL_BGRA support is required
66 #else
67 #define GL_BGRA GL_BGRA_EXT
68 #endif
69#endif
4170
42/**71/**
43 * camera distance from screen, 0.5 * tan (FOV)72 * camera distance from screen, 0.5 * tan (FOV)
@@ -75,8 +104,26 @@
75#endif104#endif
76105
77namespace GL {106namespace GL {
78107 #ifdef USE_GLES
108 typedef EGLImageKHR (*EGLCreateImageKHRProc) (EGLDisplay dpy,
109 EGLContext ctx,
110 EGLenum target,
111 EGLClientBuffer buffer,
112 const EGLint *attrib_list);
113 typedef EGLBoolean (*EGLDestroyImageKHRProc) (EGLDisplay dpy,
114 EGLImageKHR image);
115
116 typedef void (*GLEGLImageTargetTexture2DOESProc) (GLenum target,
117 GLeglImageOES image);
118
119 typedef EGLBoolean (*EGLPostSubBufferNVProc) (EGLDisplay dpy,
120 EGLSurface surface,
121 EGLint x, EGLint y,
122 EGLint width, EGLint height);
123
124 #else
79 typedef void (*FuncPtr) (void);125 typedef void (*FuncPtr) (void);
126
80 typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);127 typedef FuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
81128
82 typedef void (*GLXBindTexImageProc) (Display *display,129 typedef void (*GLXBindTexImageProc) (Display *display,
@@ -122,11 +169,6 @@
122 const int *attribList);169 const int *attribList);
123 typedef void (*GLXDestroyPixmapProc) (Display *display,170 typedef void (*GLXDestroyPixmapProc) (Display *display,
124 GLXPixmap pixmap);171 GLXPixmap pixmap);
125
126 typedef void (*GLActiveTextureProc) (GLenum texture);
127 typedef void (*GLClientActiveTextureProc) (GLenum texture);
128 typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
129
130 typedef void (*GLGenProgramsProc) (GLsizei n,172 typedef void (*GLGenProgramsProc) (GLsizei n,
131 GLuint *programs);173 GLuint *programs);
132 typedef void (*GLDeleteProgramsProc) (GLsizei n,174 typedef void (*GLDeleteProgramsProc) (GLsizei n,
@@ -146,11 +188,16 @@
146 typedef void (*GLGetProgramivProc) (GLenum target,188 typedef void (*GLGetProgramivProc) (GLenum target,
147 GLenum pname,189 GLenum pname,
148 int *params);190 int *params);
191 #endif
192
193 typedef void (*GLActiveTextureProc) (GLenum texture);
194 typedef void (*GLClientActiveTextureProc) (GLenum texture);
195 typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat);
149196
150 typedef void (*GLGenFramebuffersProc) (GLsizei n,197 typedef void (*GLGenFramebuffersProc) (GLsizei n,
151 GLuint *framebuffers);198 GLuint *framebuffers);
152 typedef void (*GLDeleteFramebuffersProc) (GLsizei n,199 typedef void (*GLDeleteFramebuffersProc) (GLsizei n,
153 GLuint *framebuffers);200 const GLuint *framebuffers);
154 typedef void (*GLBindFramebufferProc) (GLenum target,201 typedef void (*GLBindFramebufferProc) (GLenum target,
155 GLuint framebuffer);202 GLuint framebuffer);
156 typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target);203 typedef GLenum (*GLCheckFramebufferStatusProc) (GLenum target);
@@ -161,6 +208,96 @@
161 GLint level);208 GLint level);
162 typedef void (*GLGenerateMipmapProc) (GLenum target);209 typedef void (*GLGenerateMipmapProc) (GLenum target);
163210
211 typedef void (*GLBindBufferProc) (GLenum target,
212 GLuint buffer);
213 typedef void (*GLDeleteBuffersProc) (GLsizei n,
214 const GLuint *buffers);
215 typedef void (*GLGenBuffersProc) (GLsizei n,
216 GLuint *buffers);
217 typedef void (*GLBufferDataProc) (GLenum target,
218 GLsizeiptr size,
219 const GLvoid *data,
220 GLenum usage);
221 typedef void (*GLBufferSubDataProc) (GLenum target,
222 GLintptr offset,
223 GLsizeiptr size,
224 const GLvoid *data);
225
226 typedef void (*GLGetShaderivProc) (GLuint shader,
227 GLenum pname,
228 GLint *params);
229 typedef void (*GLGetShaderInfoLogProc) (GLuint shader,
230 GLsizei bufsize,
231 GLsizei *length,
232 GLchar *infoLog);
233 typedef void (*GLGetProgramivProc) (GLuint program,
234 GLenum pname,
235 GLint* params);
236 typedef void (*GLGetProgramInfoLogProc) (GLuint program,
237 GLsizei bufsize,
238 GLsizei *length,
239 GLchar *infoLog);
240 typedef GLuint (*GLCreateShaderProc) (GLenum type);
241 typedef void (*GLShaderSourceProc) (GLuint shader,
242 GLsizei count,
243 const GLchar **string,
244 const GLint* length);
245 typedef void (*GLCompileShaderProc) (GLuint shader);
246 typedef GLuint (*GLCreateProgramProc) ();
247 typedef void (*GLAttachShaderProc) (GLuint program,
248 GLuint shader);
249 typedef void (*GLLinkProgramProc) (GLuint program);
250 typedef void (*GLValidateProgramProc) (GLuint program);
251 typedef void (*GLDeleteShaderProc) (GLuint shader);
252 typedef void (*GLDeleteProgramProc) (GLuint program);
253 typedef void (*GLUseProgramProc) (GLuint program);
254 typedef int (*GLGetUniformLocationProc) (GLuint program,
255 const GLchar* name);
256 typedef void (*GLUniform1fProc) (GLint location, GLfloat x);
257 typedef void (*GLUniform1iProc) (GLint location, GLint x);
258 typedef void (*GLUniform2fProc) (GLint location, GLfloat x, GLfloat y);
259 typedef void (*GLUniform3fProc) (GLint location,
260 GLfloat x,
261 GLfloat y,
262 GLfloat z);
263 typedef void (*GLUniform4fProc) (GLint location,
264 GLfloat x,
265 GLfloat y,
266 GLfloat z,
267 GLfloat w);
268 typedef void (*GLUniform2iProc) (GLint location, GLint x, GLint y);
269 typedef void (*GLUniform3iProc) (GLint location,
270 GLint x,
271 GLint y,
272 GLint z);
273 typedef void (*GLUniform4iProc) (GLint location,
274 GLint x,
275 GLint y,
276 GLint z,
277 GLint w);
278 typedef void (*GLUniformMatrix4fvProc) (GLint location,
279 GLsizei count,
280 GLboolean transpose,
281 const GLfloat *value);
282 typedef int (*GLGetAttribLocationProc) (GLuint program,
283 const GLchar *name);
284
285 typedef void (*GLEnableVertexAttribArrayProc) (GLuint index);
286 typedef void (*GLDisableVertexAttribArrayProc) (GLuint index);
287 typedef void (*GLVertexAttribPointerProc) (GLuint index,
288 GLint size,
289 GLenum type,
290 GLboolean normalized,
291 GLsizei stride,
292 const GLvoid *ptr);
293
294 #ifdef USE_GLES
295 extern EGLCreateImageKHRProc createImage;
296 extern EGLDestroyImageKHRProc destroyImage;
297
298 extern GLEGLImageTargetTexture2DOESProc eglImageTargetTexture;
299
300 #else
164 extern GLXBindTexImageProc bindTexImage;301 extern GLXBindTexImageProc bindTexImage;
165 extern GLXReleaseTexImageProc releaseTexImage;302 extern GLXReleaseTexImageProc releaseTexImage;
166 extern GLXQueryDrawableProc queryDrawable;303 extern GLXQueryDrawableProc queryDrawable;
@@ -172,11 +309,6 @@
172 extern GLXGetFBConfigAttribProc getFBConfigAttrib;309 extern GLXGetFBConfigAttribProc getFBConfigAttrib;
173 extern GLXCreatePixmapProc createPixmap;310 extern GLXCreatePixmapProc createPixmap;
174 extern GLXDestroyPixmapProc destroyPixmap;311 extern GLXDestroyPixmapProc destroyPixmap;
175
176 extern GLActiveTextureProc activeTexture;
177 extern GLClientActiveTextureProc clientActiveTexture;
178 extern GLMultiTexCoord2fProc multiTexCoord2f;
179
180 extern GLGenProgramsProc genPrograms;312 extern GLGenProgramsProc genPrograms;
181 extern GLDeleteProgramsProc deletePrograms;313 extern GLDeleteProgramsProc deletePrograms;
182 extern GLBindProgramProc bindProgram;314 extern GLBindProgramProc bindProgram;
@@ -184,6 +316,11 @@
184 extern GLProgramParameter4fProc programEnvParameter4f;316 extern GLProgramParameter4fProc programEnvParameter4f;
185 extern GLProgramParameter4fProc programLocalParameter4f;317 extern GLProgramParameter4fProc programLocalParameter4f;
186 extern GLGetProgramivProc getProgramiv;318 extern GLGetProgramivProc getProgramiv;
319 #endif
320
321 extern GLActiveTextureProc activeTexture;
322 extern GLClientActiveTextureProc clientActiveTexture;
323 extern GLMultiTexCoord2fProc multiTexCoord2f;
187324
188 extern GLGenFramebuffersProc genFramebuffers;325 extern GLGenFramebuffersProc genFramebuffers;
189 extern GLDeleteFramebuffersProc deleteFramebuffers;326 extern GLDeleteFramebuffersProc deleteFramebuffers;
@@ -192,16 +329,56 @@
192 extern GLFramebufferTexture2DProc framebufferTexture2D;329 extern GLFramebufferTexture2DProc framebufferTexture2D;
193 extern GLGenerateMipmapProc generateMipmap;330 extern GLGenerateMipmapProc generateMipmap;
194331
332 extern GLBindBufferProc bindBuffer;
333 extern GLDeleteBuffersProc deleteBuffers;
334 extern GLGenBuffersProc genBuffers;
335 extern GLBufferDataProc bufferData;
336 extern GLBufferSubDataProc bufferSubData;
337
338
339 extern GLGetShaderivProc getShaderiv;
340 extern GLGetShaderInfoLogProc getShaderInfoLog;
341 extern GLGetProgramivProc getProgramiv;
342 extern GLGetProgramInfoLogProc getProgramInfoLog;
343 extern GLCreateShaderProc createShader;
344 extern GLShaderSourceProc shaderSource;
345 extern GLCompileShaderProc compileShader;
346 extern GLCreateProgramProc createProgram;
347 extern GLAttachShaderProc attachShader;
348 extern GLLinkProgramProc linkProgram;
349 extern GLValidateProgramProc validateProgram;
350 extern GLDeleteShaderProc deleteShader;
351 extern GLDeleteProgramProc deleteProgram;
352 extern GLUseProgramProc useProgram;
353 extern GLGetUniformLocationProc getUniformLocation;
354 extern GLUniform1fProc uniform1f;
355 extern GLUniform1iProc uniform1i;
356 extern GLUniform2fProc uniform2f;
357 extern GLUniform2iProc uniform2i;
358 extern GLUniform3fProc uniform3f;
359 extern GLUniform3iProc uniform3i;
360 extern GLUniform4fProc uniform4f;
361 extern GLUniform4iProc uniform4i;
362 extern GLUniformMatrix4fvProc uniformMatrix4fv;
363 extern GLGetAttribLocationProc getAttribLocation;
364
365 extern GLEnableVertexAttribArrayProc enableVertexAttribArray;
366 extern GLDisableVertexAttribArrayProc disableVertexAttribArray;
367 extern GLVertexAttribPointerProc vertexAttribPointer;
368
369
195 extern bool textureFromPixmap;370 extern bool textureFromPixmap;
196 extern bool textureRectangle;371 extern bool textureRectangle;
197 extern bool textureNonPowerOfTwo;372 extern bool textureNonPowerOfTwo;
373 extern bool textureNonPowerOfTwoMipmap;
198 extern bool textureEnvCombine;374 extern bool textureEnvCombine;
199 extern bool textureEnvCrossbar;375 extern bool textureEnvCrossbar;
200 extern bool textureBorderClamp;376 extern bool textureBorderClamp;
201 extern bool textureCompression;377 extern bool textureCompression;
202 extern GLint maxTextureSize;378 extern GLint maxTextureSize;
203 extern bool fbo;379 extern bool fbo;
204 extern bool fragmentProgram;380 extern bool vbo;
381 extern bool shaders;
205 extern GLint maxTextureUnits;382 extern GLint maxTextureUnits;
206383
207 extern bool canDoSaturated;384 extern bool canDoSaturated;
@@ -220,6 +397,7 @@
220397
221#define MAX_DEPTH 32398#define MAX_DEPTH 32
222399
400#ifndef USE_GLES
223struct GLFBConfig {401struct GLFBConfig {
224 GLXFBConfig fbConfig;402 GLXFBConfig fbConfig;
225 int yInverted;403 int yInverted;
@@ -227,6 +405,7 @@
227 int textureFormat;405 int textureFormat;
228 int textureTargets;406 int textureTargets;
229};407};
408#endif
230409
231#define NOTHING_TRANS_FILTER 0410#define NOTHING_TRANS_FILTER 0
232#define SCREEN_TRANS_FILTER 1411#define SCREEN_TRANS_FILTER 1
@@ -236,6 +415,7 @@
236extern GLScreenPaintAttrib defaultScreenPaintAttrib;415extern GLScreenPaintAttrib defaultScreenPaintAttrib;
237416
238class GLScreen;417class GLScreen;
418class GLFramebufferObject;
239419
240class GLScreenInterface :420class GLScreenInterface :
241 public WrapableInterface<GLScreen, GLScreenInterface>421 public WrapableInterface<GLScreen, GLScreenInterface>
@@ -302,11 +482,24 @@
302 CompOutput *);482 CompOutput *);
303 virtual void glDisableOutputClipping ();483 virtual void glDisableOutputClipping ();
304484
485 virtual GLMatrix *projectionMatrix ();
486
487 /**
488 * Hookable function used by plugins to shade the final composited
489 * Output.
490 *
491 * @param tmpRegion Describes the final composited output region
492 * @param scratchFbo Describes the final composited FBO that is
493 * to be rendered.
494 */
495 virtual void glPaintCompositedOutput (const CompRegion &region,
496 GLFramebufferObject *fbo,
497 unsigned int mask);
305};498};
306499
307500
308class GLScreen :501class GLScreen :
309 public WrapableHandler<GLScreenInterface, 6>,502 public WrapableHandler<GLScreenInterface, 7>,
310 public PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI>,503 public PluginClassHandler<GLScreen, CompScreen, COMPIZ_OPENGL_ABI>,
311 public CompOption::Class504 public CompOption::Class
312{505{
@@ -332,7 +525,9 @@
332 /**525 /**
333 * Gets the libGL address of a particular openGL functor526 * Gets the libGL address of a particular openGL functor
334 */527 */
528 #ifndef USE_GLES
335 GL::FuncPtr getProcAddress (const char *name);529 GL::FuncPtr getProcAddress (const char *name);
530 #endif
336531
337 void updateBackground ();532 void updateBackground ();
338533
@@ -346,8 +541,6 @@
346 */541 */
347 void setFilter (int, GLTexture::Filter);542 void setFilter (int, GLTexture::Filter);
348543
349 GLFragment::Storage * fragmentStorage ();
350
351 /**544 /**
352 * Sets a new compiz-wid openGL texture environment mode545 * Sets a new compiz-wid openGL texture environment mode
353 */546 */
@@ -356,7 +549,6 @@
356 /**549 /**
357 * Turns lighting on and off550 * Turns lighting on and off
358 */551 */
359
360 void setLighting (bool lighting);552 void setLighting (bool lighting);
361553
362 /**554 /**
@@ -371,7 +563,28 @@
371 GLTexture::BindPixmapHandle registerBindPixmap (GLTexture::BindPixmapProc);563 GLTexture::BindPixmapHandle registerBindPixmap (GLTexture::BindPixmapProc);
372 void unregisterBindPixmap (GLTexture::BindPixmapHandle);564 void unregisterBindPixmap (GLTexture::BindPixmapHandle);
373565
566 #ifndef USE_GLES
374 GLFBConfig * glxPixmapFBConfig (unsigned int depth);567 GLFBConfig * glxPixmapFBConfig (unsigned int depth);
568 #endif
569
570 #ifdef USE_GLES
571 EGLContext getEGLContext ();
572 #endif
573
574 /**
575 * Returns a GLProgram from the cache or creates one and caches it
576 */
577 GLProgram *getProgram (std::list<const GLShaderData*>);
578
579 /**
580 * Returns a GLShaderData from the cache or creates one and caches it
581 */
582 const GLShaderData *getShaderData (GLShaderParameters &params);
583
584 /**
585 * Returns the FBO compiz is using for the screen
586 */
587 GLFramebufferObject *fbo ();
375588
376 /**589 /**
377 * Returns a default icon texture590 * Returns a default icon texture
@@ -380,12 +593,6 @@
380593
381 void resetRasterPos ();594 void resetRasterPos ();
382595
383 /**
384 * Returns a 4x4 const float array which
385 * represents the current projection matrix
386 */
387 const float * projectionMatrix ();
388
389 bool glInitContext (XVisualInfo *);596 bool glInitContext (XVisualInfo *);
390597
391 WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput,598 WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput,
@@ -402,7 +609,12 @@
402 const GLMatrix &, const CompRegion &, CompOutput *);609 const GLMatrix &, const CompRegion &, CompOutput *);
403 WRAPABLE_HND (4, GLScreenInterface, void, glDisableOutputClipping);610 WRAPABLE_HND (4, GLScreenInterface, void, glDisableOutputClipping);
404611
612 WRAPABLE_HND (5, GLScreenInterface, GLMatrix *, projectionMatrix);
613 WRAPABLE_HND (6, GLScreenInterface, void, glPaintCompositedOutput,
614 const CompRegion &, GLFramebufferObject *, unsigned int);
615
405 friend class GLTexture;616 friend class GLTexture;
617 friend class GLWindow;
406618
407 private:619 private:
408 PrivateGLScreen *priv;620 PrivateGLScreen *priv;
@@ -453,10 +665,10 @@
453 * @param region Describes which region will be drawn665 * @param region Describes which region will be drawn
454 * @param mask Bitmask which describes how this window is drawn666 * @param mask Bitmask which describes how this window is drawn
455 */667 */
456 virtual bool glDraw (const GLMatrix &matrix,668 virtual bool glDraw (const GLMatrix &matrix,
457 GLFragment::Attrib &attrib,669 const GLWindowPaintAttrib &attrib,
458 const CompRegion &region,670 const CompRegion &region,
459 unsigned int mask);671 unsigned int mask);
460672
461 /**673 /**
462 * Hookable function to add points to a window674 * Hookable function to add points to a window
@@ -479,51 +691,18 @@
479 const CompRegion &clipRegion,691 const CompRegion &clipRegion,
480 unsigned int min = MAXSHORT,692 unsigned int min = MAXSHORT,
481 unsigned int max = MAXSHORT);693 unsigned int max = MAXSHORT);
482 virtual void glDrawTexture (GLTexture *texture, GLFragment::Attrib &,694 virtual void glDrawTexture (GLTexture *texture, const GLMatrix &,
483 unsigned int);695 const GLWindowPaintAttrib &, unsigned int);
484 virtual void glDrawGeometry ();
485};696};
486697
487class GLWindow :698class GLWindow :
488 public WrapableHandler<GLWindowInterface, 5>,699 public WrapableHandler<GLWindowInterface, 4>,
489 public PluginClassHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI>700 public PluginClassHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI>
490{701{
491 public:702 public:
492703
493 /**
494 * Class which describes the texture geometry and transformation points
495 * of a window
496 */
497 class Geometry {
498 public:
499 Geometry ();
500 ~Geometry ();
501
502 void reset ();
503
504 /**
505 * Set the number of vertices in the texture geometry
506 */
507 bool moreVertices (int newSize);
508
509 /**
510 * Set the number of indices in the texture geometry
511 */
512 bool moreIndices (int newSize);
513
514 public:
515 GLfloat *vertices;
516 int vertexSize;
517 int vertexStride;
518 GLushort *indices;
519 int indexSize;
520 int vCount;
521 int texUnits;
522 int texCoordSize;
523 int indexCount;
524 };
525
526 static GLWindowPaintAttrib defaultPaintAttrib;704 static GLWindowPaintAttrib defaultPaintAttrib;
705
527 public:706 public:
528707
529 GLWindow (CompWindow *w);708 GLWindow (CompWindow *w);
@@ -566,9 +745,20 @@
566 void updatePaintAttribs ();745 void updatePaintAttribs ();
567746
568 /**747 /**
569 * Returns the window texture geometry748 * Returns the window vertex buffer object
570 */749 */
571 Geometry & geometry ();750 GLVertexBuffer * vertexBuffer ();
751
752 /**
753 * Add a vertex and/or fragment shader function to the pipeline.
754 *
755 * @param name Name of the plugin adding the functions
756 * @param vertex_shader Function to add to the vertex shader
757 * @param fragment_shader Function to add to the fragment shader
758 */
759 void addShaders (std::string name,
760 std::string vertex_shader,
761 std::string fragment_shader);
572762
573 GLTexture *getIcon (int width, int height);763 GLTexture *getIcon (int width, int height);
574764
@@ -576,14 +766,15 @@
576 const GLWindowPaintAttrib &, const GLMatrix &,766 const GLWindowPaintAttrib &, const GLMatrix &,
577 const CompRegion &, unsigned int);767 const CompRegion &, unsigned int);
578 WRAPABLE_HND (1, GLWindowInterface, bool, glDraw, const GLMatrix &,768 WRAPABLE_HND (1, GLWindowInterface, bool, glDraw, const GLMatrix &,
579 GLFragment::Attrib &, const CompRegion &, unsigned int);769 const GLWindowPaintAttrib &, const CompRegion &,
770 unsigned int);
580 WRAPABLE_HND (2, GLWindowInterface, void, glAddGeometry,771 WRAPABLE_HND (2, GLWindowInterface, void, glAddGeometry,
581 const GLTexture::MatrixList &, const CompRegion &,772 const GLTexture::MatrixList &, const CompRegion &,
582 const CompRegion &,773 const CompRegion &,
583 unsigned int = MAXSHORT, unsigned int = MAXSHORT);774 unsigned int = MAXSHORT, unsigned int = MAXSHORT);
584 WRAPABLE_HND (3, GLWindowInterface, void, glDrawTexture,775 WRAPABLE_HND (3, GLWindowInterface, void, glDrawTexture,
585 GLTexture *texture, GLFragment::Attrib &, unsigned int);776 GLTexture *texture, const GLMatrix &,
586 WRAPABLE_HND (4, GLWindowInterface, void, glDrawGeometry);777 const GLWindowPaintAttrib &, unsigned int);
587778
588 friend class GLScreen;779 friend class GLScreen;
589 friend class PrivateGLScreen;780 friend class PrivateGLScreen;
@@ -593,3 +784,4 @@
593};784};
594785
595#endif786#endif
787
596788
=== added file 'plugins/opengl/include/opengl/program.h'
--- plugins/opengl/include/opengl/program.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/program.h 2012-05-17 07:01:21 +0000
@@ -0,0 +1,75 @@
1/*
2 * Copyright © 2011 Linaro Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Linaro Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Linaro Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Travis Watkins <travis.watkins@linaro.org>
24 */
25
26#ifndef _COMPIZ_GLPROGRAM_H
27#define _COMPIZ_GLPROGRAM_H
28
29#ifdef USE_GLES
30#include <GLES2/gl2.h>
31#else
32#include <GL/gl.h>
33#endif
34
35#include <core/core.h>
36#include <opengl/matrix.h>
37
38class PrivateProgram;
39
40class GLProgram
41{
42 public:
43 GLProgram (CompString &vertexShader, CompString &fragmentShader);
44 ~GLProgram ();
45
46 bool valid ();
47 void bind ();
48 void unbind ();
49
50 bool setUniform (const char *name, GLfloat value);
51 bool setUniform (const char *name, GLint value);
52 bool setUniform (const char *name, const GLMatrix &value);
53 bool setUniform2f (const char *name, GLfloat x, GLfloat y);
54 bool setUniform3f (const char *name, GLfloat x, GLfloat y, GLfloat z);
55 bool setUniform4f (const char *name,
56 GLfloat x,
57 GLfloat y,
58 GLfloat z,
59 GLfloat w);
60 bool setUniform2i (const char *name, GLint x, GLint y);
61 bool setUniform3i (const char *name, GLint x, GLint y, GLint z);
62 bool setUniform4i (const char *name,
63 GLint x,
64 GLint y,
65 GLint z,
66 GLint w);
67
68 GLuint attributeLocation (const char *name);
69
70 private:
71 PrivateProgram *priv;
72};
73
74#endif // _COMPIZ_GLPROGRAM_H
75
076
=== added file 'plugins/opengl/include/opengl/programcache.h'
--- plugins/opengl/include/opengl/programcache.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/programcache.h 2012-05-17 07:01:21 +0000
@@ -0,0 +1,51 @@
1/*
2 * Copyright © 2011 Linaro Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Linaro Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Linaro Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Travis Watkins <travis.watkins@linaro.org>
24 */
25
26#ifndef _COMPIZ_GLPROGRAMCACHE_H
27#define _COMPIZ_GLPROGRAMCACHE_H
28
29#include <string>
30#include <list>
31#include <map>
32#include <boost/bind.hpp>
33#include <opengl/program.h>
34
35class PrivateProgramCache;
36struct GLShaderData;
37
38class GLProgramCache
39{
40 private:
41 PrivateProgramCache *priv;
42
43 public:
44 GLProgramCache (size_t);
45 ~GLProgramCache ();
46
47 GLProgram* operator () (std::list<const GLShaderData*>);
48};
49
50#endif // _COMPIZ_GLPROGRAMCACHE_H
51
052
=== added file 'plugins/opengl/include/opengl/shadercache.h'
--- plugins/opengl/include/opengl/shadercache.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/shadercache.h 2012-05-17 07:01:21 +0000
@@ -0,0 +1,100 @@
1/*
2 * Copyright © 2012 Linaro Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Linaro Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Linaro Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Alexandros Frantzis <alexandros.frantzis@linaro.org>
24 */
25#ifndef GL_SHADER_CACHE_H_
26#define GL_SHADER_CACHE_H_
27
28#include <string>
29
30/**
31 * How to use a variable in a shader.
32 */
33enum GLShaderVariableType
34{
35 /** The variable is not used */
36 GLShaderVariableNone,
37 /** The variable value is held in a uniform */
38 GLShaderVariableUniform,
39 /** The variable value is held in a varying (from a vertex attribute) */
40 GLShaderVariableVarying,
41};
42
43/**
44 * Parameters that define a vertex-fragment shader pair.
45 */
46struct GLShaderParameters
47{
48 /** Whether this shader supports opacity */
49 bool opacity;
50 /** Whether this shader supports brightness */
51 bool brightness;
52 /** Whether this shader supports saturation */
53 bool saturation;
54 /** Whether this shader supports color and how */
55 GLShaderVariableType color;
56 /** Whether this shader supports normals and how */
57 GLShaderVariableType normal;
58 /** The number of textures this shader uses */
59 int numTextures;
60
61 /** Gets a minimalistic string representation of the parameters */
62 std::string id() const;
63 /** Gets a unique hash value for this set of parameters */
64 int hash() const;
65};
66
67/**
68 * An object representing a named vertex-fragment shader pair.
69 */
70struct GLShaderData
71{
72 std::string name;
73 std::string vertexShader;
74 std::string fragmentShader;
75};
76
77class PrivateShaderCache;
78
79/**
80 * A cache of vertex-fragment shader pairs (GLShaderData).
81 */
82class GLShaderCache
83{
84public:
85 GLShaderCache ();
86
87 /**
88 * Gets the GLShaderData associated with the specified parameters.
89 *
90 * @param params the parameters to get the GLShaderData for.
91 *
92 * @return the GLShaderData
93 */
94 const GLShaderData &getShaderData (const GLShaderParameters &params);
95
96private:
97 PrivateShaderCache *priv;
98};
99
100#endif
0101
=== modified file 'plugins/opengl/include/opengl/texture.h'
--- plugins/opengl/include/opengl/texture.h 2012-01-18 16:26:45 +0000
+++ plugins/opengl/include/opengl/texture.h 2012-05-17 07:01:21 +0000
@@ -32,7 +32,12 @@
32#include "core/string.h"32#include "core/string.h"
3333
34#include <X11/Xlib-xcb.h>34#include <X11/Xlib-xcb.h>
35
36#ifdef USE_GLES
37#include <GLES2/gl2.h>
38#else
35#include <GL/gl.h>39#include <GL/gl.h>
40#endif
3641
37#include <boost/function.hpp>42#include <boost/function.hpp>
3843
3944
=== modified file 'plugins/opengl/include/opengl/vector.h'
--- plugins/opengl/include/opengl/vector.h 2010-04-03 16:24:05 +0000
+++ plugins/opengl/include/opengl/vector.h 2012-05-17 07:01:21 +0000
@@ -40,7 +40,7 @@
40 } VectorCoordsEnum;40 } VectorCoordsEnum;
4141
42 GLVector ();42 GLVector ();
43 GLVector (float x, float y, float z, float w);43 GLVector (float x, float y, float z, float w = 0.0f);
4444
45 /**45 /**
46 * Returns a reference to the x, y, z or w value by using46 * Returns a reference to the x, y, z or w value by using
@@ -58,13 +58,13 @@
58 * Returns a readonly x, y, z or w value by using58 * Returns a readonly x, y, z or w value by using
59 * 0, 1, 2, 3 as array-access items59 * 0, 1, 2, 3 as array-access items
60 */60 */
61 const float operator[] (int item) const;61 const float & operator[] (int item) const;
6262
63 /**63 /**
64 * Returns a readonly x, y, z or w value by using64 * Returns a readonly x, y, z or w value by using
65 * x, y, z, w as array-access items65 * x, y, z, w as array-access items
66 */66 */
67 const float operator[] (VectorCoordsEnum coord) const;67 const float & operator[] (VectorCoordsEnum coord) const;
6868
69 /**69 /**
70 * Adds all elements in a GLVector70 * Adds all elements in a GLVector
7171
=== added file 'plugins/opengl/include/opengl/vertexbuffer.h'
--- plugins/opengl/include/opengl/vertexbuffer.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/include/opengl/vertexbuffer.h 2012-05-17 07:01:21 +0000
@@ -0,0 +1,123 @@
1/*
2 * Copyright © 2011 Linaro Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Linaro Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Linaro Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * LINARO LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL LINARO LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Travis Watkins <travis.watkins@linaro.org>
24 * Frederic Plourde <frederic.plourde@collabora.co.uk>
25 */
26
27#ifndef _COMPIZ_GLVERTEXBUFFER_H
28#define _COMPIZ_GLVERTEXBUFFER_H
29
30#ifdef USE_GLES
31#include <GLES2/gl2.h>
32#else
33#include <GL/gl.h>
34#endif
35
36#include <core/core.h>
37#include <opengl/program.h>
38#include <opengl/shadercache.h>
39
40class PrivateVertexBuffer;
41struct GLWindowPaintAttrib;
42
43namespace compiz
44{
45 namespace gl
46 {
47 class AutoProgram
48 {
49 public:
50 virtual ~AutoProgram () {}
51
52 virtual GLProgram *getProgram(GLShaderParameters &params) = 0;
53 };
54 }
55}
56
57class GLVertexBuffer
58{
59 public:
60
61 GLVertexBuffer ();
62 GLVertexBuffer (GLenum usage);
63 ~GLVertexBuffer ();
64
65 typedef compiz::gl::AutoProgram AutoProgram;
66
67 static GLVertexBuffer *streamingBuffer ();
68
69 void begin (GLenum primitiveType);
70 // default primitiveType is GL_TRIANGLES
71 void begin ();
72 int end ();
73
74 // vertices and normals are 3 parts, count is number of xyz groups
75 void addVertices (GLuint nVertices, GLfloat *vertices);
76 void addNormals (GLuint nNormals, GLfloat *normals);
77
78 // color is always RGBA (4 parts), count is number of rgba groups
79 void addColors (GLuint nColors, GLushort *colors);
80
81 // texture is index, texcoords are 2 parts, count is number of pairs
82 void addTexCoords (GLuint texture,
83 GLuint nTexcoords,
84 GLfloat *texcoords);
85
86 void addUniform (const char *name, GLfloat value);
87 void addUniform (const char *name, GLint value);
88 bool addUniform (const char *name, const GLMatrix &value);
89 void addUniform2f (const char *name, GLfloat x, GLfloat y);
90 void addUniform3f (const char *name, GLfloat x, GLfloat y, GLfloat z);
91 void addUniform4f (const char *name, GLfloat x, GLfloat y,
92 GLfloat z, GLfloat w);
93 void addUniform2i (const char *name, GLint x, GLint y);
94 void addUniform3i (const char *name, GLint x, GLint y, GLint z);
95 void addUniform4i (const char *name, GLint x, GLint y,
96 GLint z, GLint w);
97
98 void setProgram (GLProgram *program);
99
100 void setAutoProgram (AutoProgram *autoProgram);
101
102 // This no-argument render () function is intended for use by plugins
103 // that have custom programs.
104 int render ();
105
106 int render (const GLMatrix &modelview);
107
108 int render (const GLMatrix &modelview,
109 const GLWindowPaintAttrib &attrib);
110
111 int render (const GLMatrix &projection,
112 const GLMatrix &modelview,
113 const GLWindowPaintAttrib &attrib);
114
115 void setVertexOffset (GLuint vOffset);
116 void setMaxVertices (GLint vMax);
117
118 private:
119 PrivateVertexBuffer *priv;
120};
121
122#endif // _COMPIZ_GLVERTEXBUFFER_H
123
0124
=== removed file 'plugins/opengl/src/fragment.cpp'
--- plugins/opengl/src/fragment.cpp 2012-01-18 16:26:45 +0000
+++ plugins/opengl/src/fragment.cpp 1970-01-01 00:00:00 +0000
@@ -1,1146 +0,0 @@
1/*
2 * Copyright © 2007 Novell, Inc.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Novell, Inc. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Novell, Inc. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Author: David Reveman <davidr@novell.com>
24 */
25
26#include "privatefragment.h"
27#include "privates.h"
28
29#include "core/string.h"
30
31#include <boost/function.hpp>
32#include <boost/bind.hpp>
33#include <boost/foreach.hpp>
34#define foreach BOOST_FOREACH
35
36#include <opengl/texture.h>
37
38#include <string.h>
39#include <stdlib.h>
40#include <stdarg.h>
41
42#define COMP_FUNCTION_TYPE_ARB 0
43#define COMP_FUNCTION_TYPE_NUM 1
44
45#define COMP_FUNCTION_ARB_MASK (1 << 0)
46#define COMP_FUNCTION_MASK (COMP_FUNCTION_ARB_MASK)
47
48namespace GLFragment {
49
50 class Program {
51 public:
52 Program () :
53 signature (0),
54 blending (false),
55 name (0),
56 type (GL_FRAGMENT_PROGRAM_ARB)
57 {};
58 ~Program ()
59 {
60 if (name)
61 (*GL::deletePrograms) (1, &name);
62 };
63
64 public:
65 std::vector<FunctionId> signature;
66
67 bool blending;
68
69 GLuint name;
70 GLenum type;
71 };
72
73 typedef enum {
74 OpTypeData,
75 OpTypeDataStore,
76 OpTypeDataOffset,
77 OpTypeDataBlend,
78 OpTypeHeaderTemp,
79 OpTypeHeaderParam,
80 OpTypeHeaderAttrib,
81 OpTypeColor,
82 OpTypeFetch,
83 OpTypeLoad
84 } OpType;
85
86 class HeaderOp {
87 public:
88 HeaderOp () : type (OpTypeHeaderTemp), name ("") {}
89 public:
90 OpType type;
91 CompString name;
92 };
93
94 class BodyOp {
95 public:
96 BodyOp () :
97 type (OpTypeData),
98 data (""),
99 dst (""),
100 src (""),
101 target (0)
102 {
103 foreach (CompString &str, noOffset)
104 str = "";
105 foreach (CompString &str, offset)
106 str = "";
107 };
108
109 public:
110 OpType type;
111 CompString data;
112 CompString dst;
113 CompString src;
114 unsigned int target;
115 CompString noOffset[COMP_FETCH_TARGET_NUM];
116 CompString offset[COMP_FETCH_TARGET_NUM];
117
118 };
119
120 class PrivateFunctionData {
121 public:
122 PrivateFunctionData () : header (0), body (0), status (true) {}
123 PrivateFunctionData (const PrivateFunctionData&, CompString);
124
125 public:
126 std::vector<HeaderOp> header;
127 std::vector<BodyOp> body;
128 bool status;
129 };
130
131 class Function {
132 public:
133 Function ():
134 id (0),
135 name (""),
136 mask (0)
137 {};
138
139 public:
140 FunctionId id;
141 CompString name;
142 PrivateFunctionData data[COMP_FUNCTION_TYPE_NUM];
143 unsigned int mask;
144 };
145
146 class PrivateAttrib {
147 public:
148 PrivateAttrib () :
149 opacity (0xffff),
150 brightness (0xffff),
151 saturation (0xffff),
152 nTexture (0),
153 nFunction (0),
154 nParam (0)
155 {}
156
157 PrivateAttrib (const PrivateAttrib &pa) :
158 opacity (pa.opacity),
159 brightness (pa.brightness),
160 saturation (pa.saturation),
161 nTexture (pa.nTexture),
162 nFunction (pa.nFunction),
163 nParam (pa.nParam)
164 {
165 for (int i = 0; i < MAX_FRAGMENT_FUNCTIONS; i++)
166 function[i] = pa.function[i];
167 }
168
169 public:
170 GLushort opacity;
171 GLushort brightness;
172 GLushort saturation;
173 int nTexture;
174 FunctionId function[MAX_FRAGMENT_FUNCTIONS];
175 int nFunction;
176 int nParam;
177 };
178
179 typedef boost::function<void (BodyOp *, int)> DataOpCallBack;
180
181 class InitialLoadFunction : public Function {
182 public:
183 InitialLoadFunction ()
184 {
185 id = 0;
186 name = "__core_load";
187 mask = COMP_FUNCTION_MASK;
188
189 BodyOp b;
190 b.type = OpTypeLoad;
191 b.noOffset[0] = "TEX output, fragment.texcoord[0], texture[0], 2D;";
192 b.noOffset[1] = "TEX output, fragment.texcoord[0], texture[0], RECT;";
193 b.offset[0] = "TEX output, __tmp_texcoord0, texture[0], 2D;";
194 b.offset[1] = "TEX output, __tmp_texcoord0, texture[0], RECT;";
195 data[0].body.push_back (b);
196 };
197 };
198
199 static InitialLoadFunction initialLoadFunction;
200
201 static Function *
202 findFragmentFunction (GLScreen *s,
203 FunctionId id)
204 {
205 foreach (Function *f, s->fragmentStorage ()->functions)
206 if (f->id == id)
207 return f;
208 return NULL;
209 }
210
211 static Function *
212 findFragmentFunctionWithName (GLScreen *s,
213 CompString name)
214 {
215 foreach (Function *f, s->fragmentStorage ()->functions)
216 if (f->name.compare (name) == 0)
217 return f;
218 return NULL;
219 }
220
221 static Program *
222 findFragmentProgram (GLScreen *s,
223 FunctionId *signature,
224 unsigned int nSignature)
225 {
226 unsigned int i;
227
228 foreach (Program *p, s->fragmentStorage ()->programs)
229 {
230 if (p->signature.size () != nSignature)
231 continue;
232
233 for (i = 0; i < nSignature; i++)
234 if (signature[i] != p->signature[i])
235 break;
236
237 if (i == nSignature)
238 return p;
239 }
240 return NULL;
241 }
242
243 static unsigned int
244 functionMaskToType (int mask)
245 {
246 static struct {
247 unsigned int type;
248 unsigned int mask;
249 } maskToType[] = {
250 { COMP_FUNCTION_TYPE_ARB, COMP_FUNCTION_ARB_MASK }
251 };
252
253 unsigned int i;
254
255 for (i = 0; i < sizeof (maskToType) / sizeof (maskToType[0]); i++)
256 if (mask & maskToType[i].mask)
257 return maskToType[i].type;
258
259 return 0;
260 }
261
262 static void
263 forEachDataOpInFunction (std::vector<Function *> list,
264 int index,
265 int type,
266 int loadTarget,
267 CompString loadOffset,
268 bool *color,
269 bool *blend,
270 DataOpCallBack callBack)
271 {
272 Function *f = list[index];
273 BodyOp dataOp;
274 bool colorDone = false;
275 bool blendDone = false;
276
277 *color = false;
278 *blend = false;
279
280 foreach (BodyOp &bodyOp, f->data[type].body)
281 {
282 switch (bodyOp.type) {
283 case OpTypeFetch: {
284 CompString offset = loadOffset;
285
286 /* add offset */
287 if (bodyOp.data.size ())
288 {
289 if (loadOffset.size ())
290 {
291 dataOp.type = OpTypeDataOffset;
292 dataOp.data =
293 compPrintf ("ADD __tmp_texcoord%d, %s, %s;",
294 index, loadOffset.c_str (),
295 bodyOp.data.c_str ());
296
297 callBack (&dataOp, index);
298
299 offset = compPrintf ("__tmp_texcoord%d", index);
300 }
301 else
302 {
303 offset = bodyOp.data;
304 }
305 }
306
307 forEachDataOpInFunction (list, index - 1, type,
308 bodyOp.target,
309 offset, &colorDone, &blendDone,
310 callBack);
311
312 if (bodyOp.dst.compare ("output"))
313 {
314 dataOp.type = OpTypeDataStore;
315 dataOp.data =
316 compPrintf ("MOV %s, output;", bodyOp.dst.c_str ());
317
318 /* move to destination */
319 callBack (&dataOp, index);
320 }
321 } break;
322 case OpTypeLoad:
323 if (loadOffset.size ())
324 {
325 dataOp.type = OpTypeDataOffset;
326 dataOp.data =
327 compPrintf ("ADD __tmp_texcoord0, fragment.texcoord[0], %s;",
328 loadOffset.c_str ());
329
330 callBack (&dataOp, index);
331
332 dataOp.data = bodyOp.offset[loadTarget];
333 }
334 else
335 {
336 dataOp.data = bodyOp.noOffset[loadTarget];
337 }
338
339 dataOp.type = OpTypeData;
340
341 callBack (&dataOp, index);
342
343 break;
344 case OpTypeColor:
345 if (!colorDone)
346 {
347 dataOp.type = OpTypeData;
348 dataOp.data =
349 compPrintf ("MUL %s, fragment.color, %s;",
350 bodyOp.dst.c_str (),
351 bodyOp.src.c_str ());
352
353 callBack (&dataOp, index);
354 }
355 else if (bodyOp.dst.compare (bodyOp.src))
356 {
357 dataOp.type = OpTypeData;
358 dataOp.data =
359 compPrintf ("MOV %s, %s;",
360 bodyOp.dst.c_str (),
361 bodyOp.src.c_str ());
362
363 callBack (&dataOp, index);
364 }
365 *color = true;
366 break;
367 case OpTypeDataBlend:
368 *blend = true;
369 /* fall-through */
370 case OpTypeData:
371 callBack (&bodyOp, index);
372 break;
373 case OpTypeDataStore:
374 case OpTypeDataOffset:
375 case OpTypeHeaderTemp:
376 case OpTypeHeaderParam:
377 case OpTypeHeaderAttrib:
378 break;
379 }
380 }
381
382 if (colorDone)
383 *color = true;
384
385 if (blendDone)
386 *blend = true;
387 }
388
389 static int
390 forEachHeaderOpWithType (std::vector<HeaderOp> list,
391 int index,
392 OpType type,
393 CompString prefix,
394 CompString functionPrefix,
395 int count,
396 DataOpCallBack callBack)
397 {
398 BodyOp dataOp;
399
400 dataOp.type = OpTypeData;
401
402 foreach (HeaderOp &header, list)
403 {
404 if (header.type == type)
405 {
406 if (count)
407 {
408 dataOp.data = ", ";
409 }
410 else
411 {
412 dataOp.data = prefix;
413 }
414
415 dataOp.data += functionPrefix;
416 dataOp.data += "_";
417 dataOp.data += header.name;
418
419 callBack (&dataOp, index);
420
421 count++;
422 }
423 }
424
425 return count;
426 }
427
428 static bool
429 forEachDataOp (std::vector<Function *> list,
430 int type,
431 DataOpCallBack callBack)
432 {
433 BodyOp dataOp;
434 bool colorDone;
435 bool blendDone;
436 int count, nList = list.size ();
437
438 dataOp.type = OpTypeData;
439
440 count = 1;
441
442 dataOp.data = "TEMP output";
443
444 callBack (&dataOp, nList);
445
446 foreach (Function *f, list)
447 count = forEachHeaderOpWithType (f->data[type].header,
448 nList, OpTypeHeaderTemp,
449 "", f->name, count, callBack);
450
451 dataOp.data = ";";
452
453 callBack (&dataOp, nList);
454
455 count = 0;
456
457 foreach (Function *f, list)
458 count = forEachHeaderOpWithType (f->data[type].header,
459 nList, OpTypeHeaderParam,
460 "PARAM ", f->name, count,
461 callBack);
462
463 if (count)
464 {
465 dataOp.data = ";";
466
467 callBack (&dataOp, nList);
468 }
469
470 count = 0;
471
472 foreach (Function *f, list)
473 count = forEachHeaderOpWithType (f->data[type].header,
474 nList, OpTypeHeaderAttrib,
475 "ATTRIB ", f->name, count,
476 callBack);
477
478 if (count)
479 {
480 dataOp.data = ";";
481
482 callBack (&dataOp, nList);
483 }
484
485 forEachDataOpInFunction (list, nList - 1, type, 0, "",
486 &colorDone, &blendDone,
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches