~compiz-team/compiz/0.9.11

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
Index: compiz/plugins/opengl/include/opengl/opengl.h
===================================================================
--- compiz.orig/plugins/opengl/include/opengl/opengl.h	2014-03-03 15:29:29.898235681 +0100
+++ compiz/plugins/opengl/include/opengl/opengl.h	2014-03-03 15:29:29.894235669 +0100
@@ -590,6 +590,17 @@
 
 extern GLScreenPaintAttrib defaultScreenPaintAttrib;
 
+namespace compiz
+{
+namespace opengl
+{
+namespace internal
+{
+class DriverWorkaroundQuery;
+}
+}
+}
+
 class GLScreen;
 class GLFramebufferObject;
 class GLScreenInterface;
@@ -787,6 +798,13 @@
 
 	bool glInitContext (XVisualInfo *);
 
+	/**
+	 * This is only meant to be used internally, here to avoid unnecessarily
+	 * breaking the API and ABI. Fetch any driver workarounds in place
+	 */
+	const compiz::opengl::internal::DriverWorkaroundQuery &
+	fetchDriverWorkarounds ();
+
 	WRAPABLE_HND (0, GLScreenInterface, bool, glPaintOutput,
 		      const GLScreenPaintAttrib &, const GLMatrix &,
 		      const CompRegion &, CompOutput *, unsigned int);
Index: compiz/plugins/opengl/src/privates.h
===================================================================
--- compiz.orig/plugins/opengl/src/privates.h	2014-03-03 15:29:29.898235681 +0100
+++ compiz/plugins/opengl/src/privates.h	2014-03-03 15:29:29.894235669 +0100
@@ -47,6 +47,24 @@
 
 extern CompOutput *targetOutput;
 
+namespace compiz
+{
+namespace opengl
+{
+namespace internal
+{
+class DriverWorkaroundQuery
+{
+    public:
+
+	virtual ~DriverWorkaroundQuery () {};
+
+	virtual bool unsafeForExternalBinds () const = 0;
+};
+}
+}
+}
+
 class GLDoubleBuffer :
     public compiz::opengl::DoubleBuffer
 {
@@ -141,6 +159,7 @@
     public ScreenInterface,
     public CompositeScreenInterface,
     public compiz::composite::PaintHandler,
+    public compiz::opengl::internal::DriverWorkaroundQuery,
     public OpenglOptions
 {
     public:
@@ -232,6 +251,7 @@
 	std::vector<GLTexture::BindPixmapProc> bindPixmap;
 	bool hasCompositing;
 	bool commonFrontbuffer;
+	bool sharedMemoryTFP;
 	bool incorrectRefreshRate; // hack for NVIDIA specifying an incorrect
 				   // refresh rate, causing us to miss vblanks
 
@@ -266,6 +266,10 @@
 	std::vector<XToGLSync*>::size_type currentSyncNum;
 	XToGLSync *currentSync;
 	std::vector<XToGLSync*>::size_type warmupSyncs;
+
+    private:
+
+	bool unsafeForExternalBinds () const;
 };
 
 class PrivateGLWindow :
Index: compiz/plugins/opengl/src/screen.cpp
===================================================================
--- compiz.orig/plugins/opengl/src/screen.cpp	2014-03-03 15:29:29.898235681 +0100
+++ compiz/plugins/opengl/src/screen.cpp	2014-03-03 15:29:29.894235669 +0100
@@ -67,6 +67,7 @@
 
 
 using namespace compiz::opengl;
+namespace cglint = compiz::opengl::internal;
 
 namespace GL {
     #ifdef USE_GLES
@@ -537,6 +538,18 @@
 };
 
 bool
+PrivateGLScreen::unsafeForExternalBinds () const
+{
+    return sharedMemoryTFP;
+}
+
+const cglint::DriverWorkaroundQuery &
+GLScreen::fetchDriverWorkarounds ()
+{
+    return *priv;
+}
+
+bool
 GLScreen::glInitContext (XVisualInfo *visinfo)
 {
 #ifndef USE_GLES
@@ -855,6 +868,7 @@
 
     priv->commonFrontbuffer = true;
     priv->incorrectRefreshRate = false;
+    priv->sharedMemoryTFP = false;
     if (glRenderer != NULL && strstr (glRenderer, "on llvmpipe"))
     {
 	/*
@@ -875,6 +889,18 @@
 	priv->incorrectRefreshRate = true;
     }
 
+    if (glVendor != NULL && strstr (glVendor, "Humper"))
+    {
+	/*
+	 * VirtualBox uses XShm/XCopyArea in order to implement
+	 * texture_from_pixmap. Because of this, they require
+	 * a second X connection to track damage events and
+	 * changes to the pixmap, and this is incompatible with
+	 * taking a server grab on when querying and binding
+	 * externally managed pixmaps */
+	priv->sharedMemoryTFP = true;
+    }
+
     if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
 	GL::textureNonPowerOfTwo = true;
     GL::textureNonPowerOfTwoMipmap = GL::textureNonPowerOfTwo;
Index: compiz/plugins/opengl/src/texture.cpp
===================================================================
--- compiz.orig/plugins/opengl/src/texture.cpp	2014-03-03 15:29:29.898235681 +0100
+++ compiz/plugins/opengl/src/texture.cpp	2014-03-03 15:31:45.974666737 +0100
@@ -41,6 +41,7 @@
 #include "glx-tfp-bind.h"
 
 namespace cgl = compiz::opengl;
+namespace cglint = compiz::opengl::internal;
 
 #ifdef USE_GLES
 std::map<Damage, EglTexture*> boundPixmapTex;
@@ -646,6 +647,12 @@
 				 int               depth,
 				 cgl::PixmapSource source)
 {
+    GLScreen *gs = GLScreen::get (screen);
+    const cglint::DriverWorkaroundQuery &query (gs->fetchDriverWorkarounds ());
+
+    if (query.unsafeForExternalBinds () && source == cgl::ExternallyManaged)
+	return GLTexture::List ();
+
     GLTexture::List   rv (1);
     TfpTexture        *tex = NULL;
     unsigned int      target = 0;