Merge lp:~vanvugt/compiz-core/fix-763005-apisafe into lp:compiz-core/0.9.5

Proposed by Daniel van Vugt
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 2815
Merged at revision: 2817
Proposed branch: lp:~vanvugt/compiz-core/fix-763005-apisafe
Merge into: lp:compiz-core/0.9.5
Diff against target: 131 lines (+32/-18)
3 files modified
plugins/opengl/include/opengl/opengl.h (+2/-4)
plugins/opengl/src/privates.h (+0/-1)
plugins/opengl/src/screen.cpp (+30/-13)
To merge this branch: bzr merge lp:~vanvugt/compiz-core/fix-763005-apisafe
Reviewer Review Type Date Requested Status
Sam Spilsbury Pending
Review via email: mp+75482@code.launchpad.net

Description of the change

Updated fix for LP: #763005 (first committed to lp:compiz-core r2804).

This version implements the same fix, but removes the need for any header file changes upstream.

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

As the previous version of this fix was reverted upstream in git.compiz.org, I suggest the easiest way to commit this new version would be just to copy the file: screen.cpp. Because that's all you should need now.

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

The previous comment applies to committing to git.compiz.org AFTER this branch has been merged :)

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

Looks great, thanks Daniel!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/opengl/include/opengl/opengl.h'
2--- plugins/opengl/include/opengl/opengl.h 2011-09-09 15:20:10 +0000
3+++ plugins/opengl/include/opengl/opengl.h 2011-09-15 05:45:39 +0000
4@@ -98,13 +98,11 @@
5 int width,
6 int height);
7
8+ typedef int (*GLXGetVideoSyncProc) (unsigned int *count);
9 typedef int (*GLXWaitVideoSyncProc) (int divisor,
10 int remainder,
11 unsigned int *count);
12
13- // http://www.opengl.org/registry/specs/SGI/swap_control.txt
14- typedef int (*GLXSwapIntervalProc) (int interval);
15-
16 #ifndef GLX_VERSION_1_3
17 typedef struct __GLXFBConfigRec *GLXFBConfig;
18 #endif
19@@ -165,8 +163,8 @@
20 extern GLXReleaseTexImageProc releaseTexImage;
21 extern GLXQueryDrawableProc queryDrawable;
22 extern GLXCopySubBufferProc copySubBuffer;
23+ extern GLXGetVideoSyncProc getVideoSync;
24 extern GLXWaitVideoSyncProc waitVideoSync;
25- extern GLXSwapIntervalProc swapInterval;
26 extern GLXGetFBConfigsProc getFBConfigs;
27 extern GLXGetFBConfigAttribProc getFBConfigAttrib;
28 extern GLXCreatePixmapProc createPixmap;
29
30=== modified file 'plugins/opengl/src/privates.h'
31--- plugins/opengl/src/privates.h 2011-09-09 15:20:10 +0000
32+++ plugins/opengl/src/privates.h 2011-09-15 05:45:39 +0000
33@@ -70,7 +70,6 @@
34
35 void prepareDrawing ();
36
37- void controlSwapVideoSync ();
38 void waitForVideoSync ();
39
40 void paintBackground (const CompRegion &region,
41
42=== modified file 'plugins/opengl/src/screen.cpp'
43--- plugins/opengl/src/screen.cpp 2011-09-09 15:20:10 +0000
44+++ plugins/opengl/src/screen.cpp 2011-09-15 05:45:39 +0000
45@@ -31,12 +31,15 @@
46 #include <math.h>
47
48 namespace GL {
49+ typedef int (*GLXSwapIntervalProc) (int interval);
50+
51+ GLXSwapIntervalProc swapInterval = NULL;
52 GLXBindTexImageProc bindTexImage = NULL;
53 GLXReleaseTexImageProc releaseTexImage = NULL;
54 GLXQueryDrawableProc queryDrawable = NULL;
55 GLXCopySubBufferProc copySubBuffer = NULL;
56+ GLXGetVideoSyncProc getVideoSync = NULL;
57 GLXWaitVideoSyncProc waitVideoSync = NULL;
58- GLXSwapIntervalProc swapInterval = NULL;
59 GLXGetFBConfigsProc getFBConfigs = NULL;
60 GLXGetFBConfigAttribProc getFBConfigAttrib = NULL;
61 GLXCreatePixmapProc createPixmap = NULL;
62@@ -217,6 +220,9 @@
63
64 if (strstr (glxExtensions, "GLX_SGI_video_sync"))
65 {
66+ GL::getVideoSync = (GL::GLXGetVideoSyncProc)
67+ getProcAddress ("glXGetVideoSyncSGI");
68+
69 GL::waitVideoSync = (GL::GLXWaitVideoSyncProc)
70 getProcAddress ("glXWaitVideoSyncSGI");
71 }
72@@ -988,21 +994,13 @@
73 priv->lastViewport.height);
74 }
75
76-void
77-PrivateGLScreen::controlSwapVideoSync ()
78+namespace GL
79 {
80- bool sync = optionGetSyncToVblank ();
81- // Docs: http://www.opengl.org/registry/specs/SGI/swap_control.txt
82- if (GL::swapInterval)
83- (*GL::swapInterval) (sync ? 1 : 0);
84- else if (sync)
85- waitForVideoSync ();
86-}
87
88 void
89-PrivateGLScreen::waitForVideoSync ()
90+waitForVideoSync ()
91 {
92- if (optionGetSyncToVblank () && GL::waitVideoSync)
93+ if (GL::waitVideoSync)
94 {
95 // Don't wait twice. Just in case.
96 if (GL::swapInterval)
97@@ -1015,6 +1013,25 @@
98 }
99
100 void
101+controlSwapVideoSync (bool sync)
102+{
103+ // Docs: http://www.opengl.org/registry/specs/SGI/swap_control.txt
104+ if (GL::swapInterval)
105+ (*GL::swapInterval) (sync ? 1 : 0);
106+ else if (sync)
107+ waitForVideoSync ();
108+}
109+
110+} // namespace GL
111+
112+void
113+PrivateGLScreen::waitForVideoSync ()
114+{
115+ if (optionGetSyncToVblank ())
116+ GL::waitForVideoSync ();
117+}
118+
119+void
120 PrivateGLScreen::paintOutputs (CompOutput::ptrList &outputs,
121 unsigned int mask,
122 const CompRegion &region)
123@@ -1099,7 +1116,7 @@
124 // it won't block the CPU. The waiting is offloaded to the GPU.
125 // Unfortunately it only works with glXSwapBuffers in most drivers.
126 //
127- controlSwapVideoSync ();
128+ GL::controlSwapVideoSync (optionGetSyncToVblank ());
129 glXSwapBuffers (screen->dpy (), cScreen->output ());
130 }
131 else

Subscribers

People subscribed via source and target branches