Merge lp:~vanvugt/compiz/blacklist into lp:compiz/0.9.9

Proposed by Daniel van Vugt on 2012-12-12
Status: Merged
Approved by: Timo Jyrinki on 2012-12-12
Approved revision: 3525
Merged at revision: 3525
Proposed branch: lp:~vanvugt/compiz/blacklist
Merge into: lp:compiz/0.9.9
Diff against target: 441 lines (+308/-5)
10 files modified
plugins/opengl/CMakeLists.txt (+2/-0)
plugins/opengl/opengl.xml.in (+5/-0)
plugins/opengl/src/blacklist/CMakeLists.txt (+6/-0)
plugins/opengl/src/blacklist/blacklist.cpp (+67/-0)
plugins/opengl/src/blacklist/blacklist.h (+38/-0)
plugins/opengl/src/blacklist/tests/CMakeLists.txt (+9/-0)
plugins/opengl/src/blacklist/tests/test-blacklist.cpp (+152/-0)
plugins/opengl/src/paint.cpp (+6/-0)
plugins/opengl/src/privates.h (+4/-0)
plugins/opengl/src/screen.cpp (+19/-5)
To merge this branch: bzr merge lp:~vanvugt/compiz/blacklist
Reviewer Review Type Date Requested Status
Timo Jyrinki 2012-12-12 Approve on 2012-12-12
PS Jenkins bot (community) continuous-integration Approve on 2012-12-12
Review via email: mp+139394@code.launchpad.net

Commit message

Add a feature for blacklisting certain graphics drivers from being able to
unredirect fullscreen windows. Right now the only known broken drivers are
nouveau and intel on precise (Mesa 8.0). But the blacklist is a regex that
can be adjusted at any time.
(LP: #1089246)

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Timo Jyrinki (timo-jyrinki) wrote :

Looks, builds and functions fine. My quantal Intel wasn't blacklisted, but I was able to blacklist it by modifying the default regexp.

review: Approve
Michael Terry (mterry) wrote :

Will it always be obvious what "blacklisted" means? Right now it seems it is specific to one feature. We might get a second feature in the future that needs a separate blacklist list. Just saying that maybe the function name should be something like blacklisted_for_unredirect(). But I don't feel strongly about it.

Daniel van Vugt (vanvugt) wrote :

Michael makes a good point and I did think about that. However it's possible and even likely to never be a problem for the lifetime of the Compiz code.

Daniel van Vugt (vanvugt) wrote :

Although, the "blacklisted" function is generic. It is specific to OpenGL drivers but the same function could be applied to other features; not just "unredirected fullscreen windows". So a generic name is appropriate.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/opengl/CMakeLists.txt'
2--- plugins/opengl/CMakeLists.txt 2012-11-08 09:18:59 +0000
3+++ plugins/opengl/CMakeLists.txt 2012-12-12 07:55:25 +0000
4@@ -5,11 +5,13 @@
5 set (INTERNAL_LIBRARIES
6 compiz_opengl_double_buffer
7 compiz_opengl_fsregion
8+ compiz_opengl_blacklist
9 compiz_opengl_glx_tfp_bind
10 )
11
12 add_subdirectory (src/doublebuffer)
13 add_subdirectory (src/fsregion)
14+add_subdirectory (src/blacklist)
15 add_subdirectory (src/glxtfpbind)
16
17 include_directories (src/glxtfpbind/include)
18
19=== modified file 'plugins/opengl/opengl.xml.in'
20--- plugins/opengl/opengl.xml.in 2012-10-15 10:31:51 +0000
21+++ plugins/opengl/opengl.xml.in 2012-12-12 07:55:25 +0000
22@@ -59,6 +59,11 @@
23 <_long>Use glXSwapBuffers to display every frame. This eliminates visible tearing with most drivers and dramatically improves visual smoothness. Automatically enabled when framebuffer_object is on.</_long>
24 <default>true</default>
25 </option>
26+ <option name="unredirect_driver_blacklist" type="string">
27+ <_short>Unredirect Driver Blacklist</_short>
28+ <_long>If non-empty, specifies a POSIX (extended) regular expression to match against the OpenGL driver strings (newline separated): "GL_VENDOR\nGL_RENDERER\nGL_VERSION". If the regular expression matches a substring of that concatenation then no windows will ever be unredirected while using that particular graphics driver.</_long>
29+ <default>(nouveau|Intel).*Mesa 8\\.0</default>
30+ </option>
31 </options>
32 </plugin>
33 </compiz>
34
35=== added directory 'plugins/opengl/src/blacklist'
36=== added file 'plugins/opengl/src/blacklist/CMakeLists.txt'
37--- plugins/opengl/src/blacklist/CMakeLists.txt 1970-01-01 00:00:00 +0000
38+++ plugins/opengl/src/blacklist/CMakeLists.txt 2012-12-12 07:55:25 +0000
39@@ -0,0 +1,6 @@
40+if (COMPIZ_BUILD_TESTING)
41+add_subdirectory (tests)
42+endif ()
43+
44+add_library (compiz_opengl_blacklist STATIC blacklist.cpp)
45+
46
47=== added file 'plugins/opengl/src/blacklist/blacklist.cpp'
48--- plugins/opengl/src/blacklist/blacklist.cpp 1970-01-01 00:00:00 +0000
49+++ plugins/opengl/src/blacklist/blacklist.cpp 2012-12-12 07:55:25 +0000
50@@ -0,0 +1,67 @@
51+/*
52+ * Compiz opengl plugin, Blacklist feature
53+ *
54+ * Copyright (c) 2012 Canonical Ltd.
55+ * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
56+ *
57+ * Permission is hereby granted, free of charge, to any person obtaining a
58+ * copy of this software and associated documentation files (the "Software"),
59+ * to deal in the Software without restriction, including without limitation
60+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
61+ * and/or sell copies of the Software, and to permit persons to whom the
62+ * Software is furnished to do so, subject to the following conditions:
63+ *
64+ * The above copyright notice and this permission notice shall be included in
65+ * all copies or substantial portions of the Software.
66+ *
67+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
68+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
69+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
70+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
71+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
72+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
73+ * DEALINGS IN THE SOFTWARE.
74+ */
75+
76+#include "blacklist.h"
77+#include <cstdio>
78+#include <regex.h>
79+
80+namespace compiz {
81+namespace opengl {
82+
83+bool blacklisted (const char *blacklistRegex, const char *glVendor,
84+ const char *glRenderer, const char *glVersion)
85+{
86+ bool matches = false;
87+
88+ if (blacklistRegex && blacklistRegex[0])
89+ {
90+ regex_t re;
91+
92+ // Ensure the regex contains something other than spaces, or ignore.
93+ const char *p = blacklistRegex;
94+ while (*p == ' ')
95+ p++;
96+
97+ if (*p && !regcomp (&re, blacklistRegex, REG_EXTENDED))
98+ {
99+ char driver[1024];
100+
101+ snprintf (driver, sizeof driver, "%s\n%s\n%s",
102+ glVendor ? glVendor : "",
103+ glRenderer ? glRenderer : "",
104+ glVersion ? glVersion : "");
105+
106+ if (!regexec (&re, driver, 0, NULL, 0))
107+ matches = true;
108+
109+ regfree (&re);
110+ }
111+ }
112+
113+ return matches;
114+}
115+
116+} // namespace opengl
117+} // namespace compiz
118
119=== added file 'plugins/opengl/src/blacklist/blacklist.h'
120--- plugins/opengl/src/blacklist/blacklist.h 1970-01-01 00:00:00 +0000
121+++ plugins/opengl/src/blacklist/blacklist.h 2012-12-12 07:55:25 +0000
122@@ -0,0 +1,38 @@
123+/*
124+ * Compiz opengl plugin, Blacklist function
125+ *
126+ * Copyright (c) 2012 Canonical Ltd.
127+ * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
128+ *
129+ * Permission is hereby granted, free of charge, to any person obtaining a
130+ * copy of this software and associated documentation files (the "Software"),
131+ * to deal in the Software without restriction, including without limitation
132+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
133+ * and/or sell copies of the Software, and to permit persons to whom the
134+ * Software is furnished to do so, subject to the following conditions:
135+ *
136+ * The above copyright notice and this permission notice shall be included in
137+ * all copies or substantial portions of the Software.
138+ *
139+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
140+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
141+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
142+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
143+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
144+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
145+ * DEALINGS IN THE SOFTWARE.
146+ */
147+
148+#ifndef __COMPIZ_OPENGL_BLACKLIST_H
149+#define __COMPIZ_OPENGL_BLACKLIST_H
150+
151+namespace compiz {
152+namespace opengl {
153+
154+bool blacklisted (const char *blacklistRegex, const char *glVendor,
155+ const char *glRenderer, const char *glVersion);
156+
157+} // namespace opengl
158+} // namespace compiz
159+
160+#endif
161
162=== added directory 'plugins/opengl/src/blacklist/tests'
163=== added file 'plugins/opengl/src/blacklist/tests/CMakeLists.txt'
164--- plugins/opengl/src/blacklist/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
165+++ plugins/opengl/src/blacklist/tests/CMakeLists.txt 2012-12-12 07:55:25 +0000
166@@ -0,0 +1,9 @@
167+include_directories (${GTEST_INCLUDE_DIRS} ..)
168+set (exe "compiz_opengl_test_blacklist")
169+add_executable (${exe} test-blacklist.cpp)
170+target_link_libraries (${exe}
171+ compiz_opengl_blacklist
172+ ${GTEST_BOTH_LIBRARIES}
173+)
174+compiz_discover_tests(${exe} COVERAGE compiz_opengl_blacklist)
175+
176
177=== added file 'plugins/opengl/src/blacklist/tests/test-blacklist.cpp'
178--- plugins/opengl/src/blacklist/tests/test-blacklist.cpp 1970-01-01 00:00:00 +0000
179+++ plugins/opengl/src/blacklist/tests/test-blacklist.cpp 2012-12-12 07:55:25 +0000
180@@ -0,0 +1,152 @@
181+/*
182+ * Compiz opengl plugin, Backlist feature
183+ *
184+ * Copyright (c) 2012 Canonical Ltd.
185+ * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
186+ *
187+ * Permission is hereby granted, free of charge, to any person obtaining a
188+ * copy of this software and associated documentation files (the "Software"),
189+ * to deal in the Software without restriction, including without limitation
190+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
191+ * and/or sell copies of the Software, and to permit persons to whom the
192+ * Software is furnished to do so, subject to the following conditions:
193+ *
194+ * The above copyright notice and this permission notice shall be included in
195+ * all copies or substantial portions of the Software.
196+ *
197+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
198+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
199+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
200+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
201+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
202+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
203+ * DEALINGS IN THE SOFTWARE.
204+ */
205+
206+#include "gtest/gtest.h"
207+#include "blacklist.h"
208+
209+using namespace compiz::opengl;
210+
211+static const char *recommendedRegex = "(nouveau|Intel).*Mesa 8\\.0";
212+
213+TEST (DriverBlacklist, QuantalIntelIsGood)
214+{
215+ EXPECT_FALSE (blacklisted (recommendedRegex,
216+ "Intel Open Source Technology Center",
217+ "Mesa DRI Intel(R) Sandybridge Desktop",
218+ "3.0 Mesa 9.0"));
219+}
220+
221+TEST (DriverBlacklist, PreciseIntelIsBad)
222+{
223+ EXPECT_TRUE (blacklisted (recommendedRegex,
224+ "Tungsten Graphics, Inc",
225+ "Mesa DRI Intel(R) Sandybridge Desktop",
226+ "3.0 Mesa 8.0.2"));
227+}
228+
229+TEST (DriverBlacklist, QuantalNouveauIsGood)
230+{
231+ EXPECT_FALSE (blacklisted (recommendedRegex,
232+ "nouveau",
233+ "Gallium 0.4 on NV86",
234+ "3.0 Mesa 9.0-devel"));
235+}
236+
237+TEST (DriverBlacklist, PreciseNouveauIsBad)
238+{
239+ EXPECT_TRUE (blacklisted (recommendedRegex,
240+ "nouveau",
241+ "Gallium 0.4 on NVA8",
242+ "2.1 Mesa 8.0.2"));
243+}
244+
245+TEST (DriverBlacklist, FglrxIsGood)
246+{
247+ EXPECT_FALSE (blacklisted (recommendedRegex,
248+ "Advanced Micro Devices, Inc.",
249+ "ATI Radeon HD 5450",
250+ "4.2.11627 Compatibility Profile Context"));
251+}
252+
253+TEST (DriverBlacklist, NvidiaIsGood)
254+{
255+ EXPECT_FALSE (blacklisted (recommendedRegex,
256+ "NVIDIA Corporation",
257+ "Quadro 1000M/PCIe/SSE2",
258+ "4.2.0 NVIDIA 304.48"));
259+}
260+
261+TEST (DriverBlacklist, RadeonIsGood1)
262+{
263+ EXPECT_FALSE (blacklisted (recommendedRegex,
264+ "X.Org R300 Project",
265+ "Gallium 0.4 on ATI RV350",
266+ "2.1 Mesa 8.0.2"));
267+}
268+
269+TEST (DriverBlacklist, RadeonIsGood2)
270+{
271+ EXPECT_FALSE (blacklisted (recommendedRegex,
272+ "X.Org",
273+ "Gallium 0.4 on AMD CEDAR",
274+ "2.1 Mesa 8.0.3"));
275+}
276+
277+TEST (DriverBlacklist, RadeonIsGood3)
278+{
279+ EXPECT_FALSE (blacklisted (recommendedRegex,
280+ "X.Org",
281+ "Gallium 0.4 on AMD RS880",
282+ "2.1 Mesa 8.0.2"));
283+}
284+
285+TEST (DriverBlacklist, LLVMpipeIsGood)
286+{
287+ EXPECT_FALSE (blacklisted (recommendedRegex,
288+ "VMware, Inc.",
289+ "Gallium 0.4 on llvmpipe (LLVM 0x300)",
290+ "2.1 Mesa 8.0.4"));
291+}
292+
293+TEST (DriverBlacklist, UnknownIsGood)
294+{
295+ EXPECT_FALSE (blacklisted (recommendedRegex,
296+ "Acme",
297+ "Graphics Driver",
298+ "4.2 8.0 9.0 123.456"));
299+}
300+
301+TEST (DriverBlacklist, NoBlacklist)
302+{
303+ EXPECT_FALSE (blacklisted ("",
304+ "Tungsten Graphics, Inc",
305+ "Mesa DRI Intel(R) Sandybridge Desktop",
306+ "3.0 Mesa 8.0.2"));
307+ EXPECT_FALSE (blacklisted ("", "foo", "bar", "blah"));
308+ EXPECT_FALSE (blacklisted ("", "", "", ""));
309+}
310+
311+TEST (DriverBlacklist, LineContinuation)
312+{
313+ EXPECT_FALSE (blacklisted ("alpha", "beta", "gamma", "delta"));
314+ EXPECT_FALSE (blacklisted ("betagam", "beta", "gamma", "delta"));
315+ EXPECT_TRUE (blacklisted ("gamma", "beta", "gamma", "delta"));
316+ EXPECT_TRUE (blacklisted ("del", "beta", "gamma", "delta"));
317+ EXPECT_TRUE (blacklisted ("(mag|gam)", "beta", "gamma", "delta"));
318+ EXPECT_TRUE (blacklisted ("beta.*delt", "beta", "gamma", "delta"));
319+ EXPECT_FALSE (blacklisted ("beta.*felt", "beta", "gamma", "delta"));
320+
321+ EXPECT_TRUE (blacklisted ("beta\ngamma\ndelta", "beta", "gamma", "delta"));
322+}
323+
324+TEST (DriverBlacklist, StraySpaces)
325+{
326+ EXPECT_FALSE (blacklisted (" ", "Hello world", "and", "goodbye"));
327+ EXPECT_FALSE (blacklisted (" ", " ", " ", " "));
328+ EXPECT_FALSE (blacklisted (" ",
329+ "Tungsten Graphics, Inc",
330+ "Mesa DRI Intel(R) Sandybridge Desktop",
331+ "3.0 Mesa 8.0.2"));
332+}
333
334=== modified file 'plugins/opengl/src/paint.cpp'
335--- plugins/opengl/src/paint.cpp 2012-12-12 04:29:49 +0000
336+++ plugins/opengl/src/paint.cpp 2012-12-12 07:55:25 +0000
337@@ -261,6 +261,11 @@
338 const CompMatch &unredirectable = CompositeScreen::get (screen)->
339 getOption ("unredirect_match")->value ().match ();
340
341+ const CompString &blacklist =
342+ getOption ("unredirect_driver_blacklist")->value ().s ();
343+
344+ bool blacklisted = driverIsBlacklisted (blacklist.c_str ());
345+
346 if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
347 {
348 windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
349@@ -354,6 +359,7 @@
350 * beneath them and so neither should be unredirected in that case.
351 */
352 if (unredirectFS &&
353+ !blacklisted &&
354 unredirectable.evaluate (w) &&
355 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
356 !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
357
358=== modified file 'plugins/opengl/src/privates.h'
359--- plugins/opengl/src/privates.h 2012-12-07 08:09:56 +0000
360+++ plugins/opengl/src/privates.h 2012-12-12 07:55:25 +0000
361@@ -161,6 +161,8 @@
362
363 void updateView ();
364
365+ bool driverIsBlacklisted (const char *regex) const;
366+
367 public:
368
369 GLScreen *gScreen;
370@@ -219,6 +221,8 @@
371
372 Pixmap rootPixmapCopy;
373 CompSize rootPixmapSize;
374+
375+ const char *glVendor, *glRenderer, *glVersion;
376 };
377
378 class PrivateGLWindow :
379
380=== modified file 'plugins/opengl/src/screen.cpp'
381--- plugins/opengl/src/screen.cpp 2012-12-10 03:28:47 +0000
382+++ plugins/opengl/src/screen.cpp 2012-12-12 07:55:25 +0000
383@@ -36,6 +36,7 @@
384 #include <boost/make_shared.hpp>
385
386 #include "privates.h"
387+#include "blacklist/blacklist.h"
388
389 #include <dlfcn.h>
390 #include <math.h>
391@@ -600,8 +601,6 @@
392 GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 0.0f };
393 GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f };
394 GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f };
395- const char *glRenderer;
396- const char *glVendor;
397 CompOption::Vector o (0);
398
399 priv->ctx = glXCreateContext (dpy, visinfo, NULL, True);
400@@ -640,8 +639,14 @@
401 return false;
402 }
403
404- glRenderer = (const char *) glGetString (GL_RENDERER);
405- glVendor = (const char *) glGetString (GL_VENDOR);
406+ const char *glVendor = (const char *) glGetString (GL_VENDOR);
407+ const char *glRenderer = (const char *) glGetString (GL_RENDERER);
408+ const char *glVersion = (const char *) glGetString (GL_VERSION);
409+
410+ priv->glVendor = glVendor;
411+ priv->glRenderer = glRenderer;
412+ priv->glVersion = glVersion;
413+
414 if (glRenderer != NULL &&
415 (strcmp (glRenderer, "Software Rasterizer") == 0 ||
416 strcmp (glRenderer, "Mesa X11") == 0))
417@@ -1240,7 +1245,10 @@
418 shaderCache (),
419 autoProgram (new GLScreenAutoProgram(gs)),
420 rootPixmapCopy (None),
421- rootPixmapSize ()
422+ rootPixmapSize (),
423+ glVendor (NULL),
424+ glRenderer (NULL),
425+ glVersion (NULL)
426 {
427 ScreenInterface::setHandler (screen);
428 }
429@@ -2144,6 +2152,12 @@
430 CompositeScreen::get (screen)->damageScreen ();
431 }
432
433+bool
434+PrivateGLScreen::driverIsBlacklisted (const char *regex) const
435+{
436+ return blacklisted (regex, glVendor, glRenderer, glVersion);
437+}
438+
439 GLTexture::BindPixmapHandle
440 GLScreen::registerBindPixmap (GLTexture::BindPixmapProc proc)
441 {

Subscribers

People subscribed via source and target branches