Merge lp:~robert-ancell/unity-system-compositor/video-blacklist into lp:unity-system-compositor

Proposed by Robert Ancell
Status: Merged
Approved by: Chris Halse Rogers
Approved revision: 84
Merged at revision: 77
Proposed branch: lp:~robert-ancell/unity-system-compositor/video-blacklist
Merge into: lp:unity-system-compositor
Diff against target: 195 lines (+96/-5)
5 files modified
CMakeLists.txt (+5/-0)
cmake/FindGLESv2.cmake (+25/-0)
debian/control (+1/-0)
src/CMakeLists.txt (+1/-0)
src/system_compositor.cpp (+64/-5)
To merge this branch: bzr merge lp:~robert-ancell/unity-system-compositor/video-blacklist
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Chris Halse Rogers Approve
Review via email: mp+186771@code.launchpad.net

Commit message

Implement regex blacklist for supported OpenGL drivers (copied from Compiz blacklist)

To post a comment you must log in.
79. By Robert Ancell

Add build-dep on libgles2-mesa-dev

80. By Robert Ancell

Take the opportunity to correct the add_options() usage

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
81. By Robert Ancell

Override mir::DefaultServerConfiguration::parse_options() correctly

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
82. By Robert Ancell

Merge with trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
83. By Robert Ancell

Load command line options

84. By Robert Ancell

Log the blacklist

Revision history for this message
Robert Ancell (robert-ancell) wrote :
Revision history for this message
Chris Halse Rogers (raof) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-06-28 00:16:30 +0000
3+++ CMakeLists.txt 2013-09-20 19:06:20 +0000
4@@ -21,6 +21,7 @@
5 set(USC_VERSION "${USC_VERSION_MAJOR}.${USC_VERSION_MINOR}.${USC_VERSION_PATCH}")
6
7 cmake_minimum_required(VERSION 2.8)
8+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
9
10 # Set location of outputs
11 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
12@@ -40,4 +41,8 @@
13 find_package(Boost 1.48.0 COMPONENTS chrono date_time filesystem system thread program_options regex REQUIRED)
14 include_directories(${Boost_INCLUDE_DIRS})
15
16+# Check for GL
17+find_package(GLESv2 REQUIRED)
18+include_directories (${GLESv2_INCLUDE_DIRS})
19+
20 add_subdirectory(src/)
21
22=== added directory 'cmake'
23=== added file 'cmake/FindGLESv2.cmake'
24--- cmake/FindGLESv2.cmake 1970-01-01 00:00:00 +0000
25+++ cmake/FindGLESv2.cmake 2013-09-20 19:06:20 +0000
26@@ -0,0 +1,25 @@
27+# - Try to find GLESv2
28+# Once done this will define
29+# GLESv2_FOUND - System has GLESv2
30+# GLESv2_INCLUDE_DIRS - The GLESv2 include directories
31+# GLESv2_LIBRARIES - The libraries needed to use GLESv2
32+
33+find_package(PkgConfig)
34+pkg_check_modules(PC_GLESv2 QUIET glesv2)
35+
36+find_path(GLESv2_INCLUDE_DIR GLES2/gl2.h
37+ HINTS ${PC_GLESv2_INCLUDEDIR} ${PC_GLESv2_INCLUDE_DIRS})
38+
39+find_library(GLESv2_LIBRARY GLESv2
40+ HINTS ${PC_GLESv2_LIBDIR} ${PC_GLESv2_LIBRARY_DIRS})
41+
42+set(GLESv2_LIBRARIES ${GLESv2_LIBRARY})
43+set(GLESv2_INCLUDE_DIRS ${GLESv2_INCLUDE_DIR})
44+
45+include(FindPackageHandleStandardArgs)
46+# handle the QUIETLY and REQUIRED arguments and set GLESv2_FOUND to TRUE
47+# if all listed variables are TRUE
48+find_package_handle_standard_args(GLESv2 DEFAULT_MSG
49+ GLESv2_LIBRARY GLESv2_INCLUDE_DIR)
50+
51+mark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY)
52
53=== modified file 'debian/control'
54--- debian/control 2013-08-28 07:28:30 +0000
55+++ debian/control 2013-09-20 19:06:20 +0000
56@@ -7,6 +7,7 @@
57 debhelper (>= 9),
58 libboost1.48-all-dev | libboost-all-dev,
59 libmirserver-dev,
60+ libgles2-mesa-dev,
61 libprotobuf-dev,
62 pkg-config,
63 python (>= 2.7),
64
65=== modified file 'src/CMakeLists.txt'
66--- src/CMakeLists.txt 2013-06-26 07:16:43 +0000
67+++ src/CMakeLists.txt 2013-09-20 19:06:20 +0000
68@@ -29,6 +29,7 @@
69 mirserver
70 pthread
71 ${Boost_LIBRARIES}
72+ ${GLESv2_LIBRARIES}
73 )
74
75 # Install into bin directory
76
77=== modified file 'src/system_compositor.cpp'
78--- src/system_compositor.cpp 2013-09-19 13:14:47 +0000
79+++ src/system_compositor.cpp 2013-09-20 19:06:20 +0000
80@@ -19,6 +19,7 @@
81 #include "system_compositor.h"
82
83 #include <mir/run_mir.h>
84+#include <mir/abnormal_exit.h>
85 #include <mir/pause_resume_listener.h>
86 #include <mir/shell/application_session.h>
87 #include <mir/shell/session.h>
88@@ -28,9 +29,13 @@
89
90 #include <iostream>
91 #include <thread>
92+#include <regex.h>
93+#include <GLES2/gl2.h>
94+#include <boost/algorithm/string.hpp>
95
96 namespace msh = mir::shell;
97 namespace mi = mir::input;
98+namespace po = boost::program_options;
99
100 class SystemCompositorServerConfiguration : public mir::DefaultServerConfiguration
101 {
102@@ -38,12 +43,10 @@
103 SystemCompositorServerConfiguration(SystemCompositor *compositor, int argc, char const** argv)
104 : mir::DefaultServerConfiguration(argc, argv), compositor{compositor}
105 {
106- namespace po = boost::program_options;
107-
108 add_options()
109 ("from-dm-fd", po::value<int>(), "File descriptor of read end of pipe from display manager [int]")
110- ("to-dm-fd", po::value<int>(), "File descriptor of write end of pipe to display manager [int]");
111- add_options()
112+ ("to-dm-fd", po::value<int>(), "File descriptor of write end of pipe to display manager [int]")
113+ ("blacklist", po::value<std::string>(), "Video blacklist regex to use")
114 ("version", "Show version of Unity System Compositor");
115 }
116
117@@ -61,7 +64,20 @@
118 {
119 return the_options()->is_set ("version");
120 }
121-
122+
123+ std::string blacklist()
124+ {
125+ auto x = the_options()->get ("blacklist", "");
126+ boost::trim(x);
127+ return x;
128+ }
129+
130+ void parse_options(boost::program_options::options_description& options_description, mir::options::ProgramOption& options) const override
131+ {
132+ mir::DefaultServerConfiguration::parse_options(options_description, options);
133+ options.parse_file(options_description, "unity-system-compositor.conf");
134+ }
135+
136 std::shared_ptr<mi::CursorListener> the_cursor_listener() override
137 {
138 struct NullCursorListener : public mi::CursorListener
139@@ -98,6 +114,39 @@
140 SystemCompositor *compositor;
141 };
142
143+bool check_blacklist(std::string blacklist, const char *vendor, const char *renderer, const char *version)
144+{
145+ if (blacklist.empty())
146+ return true;
147+
148+ std::cerr << "Using blacklist \"" << blacklist << "\"" << std::endl;
149+
150+ regex_t re;
151+ auto result = regcomp (&re, blacklist.c_str(), REG_EXTENDED);
152+ if (result == 0)
153+ {
154+ char driver_string[1024];
155+ snprintf (driver_string, 1024, "%s\n%s\n%s",
156+ vendor ? vendor : "",
157+ renderer ? renderer : "",
158+ version ? version : "");
159+
160+ auto result = regexec (&re, driver_string, 0, NULL, 0);
161+ regfree (&re);
162+
163+ if (result == 0)
164+ return false;
165+ }
166+ else
167+ {
168+ char error_string[1024];
169+ regerror (result, &re, error_string, 1024);
170+ std::cerr << "Failed to compile blacklist regex: " << error_string << std::endl;
171+ }
172+
173+ return true;
174+}
175+
176 void SystemCompositor::run(int argc, char const** argv)
177 {
178 auto c = std::make_shared<SystemCompositorServerConfiguration>(this, argc, argv);
179@@ -122,6 +171,16 @@
180
181 mir::run_mir(*config, [&](mir::DisplayServer&)
182 {
183+ auto vendor = (char *) glGetString(GL_VENDOR);
184+ auto renderer = (char *) glGetString (GL_RENDERER);
185+ auto version = (char *) glGetString (GL_VERSION);
186+ std::cerr << "GL_VENDOR = " << vendor << std::endl;
187+ std::cerr << "GL_RENDERER = " << renderer << std::endl;
188+ std::cerr << "GL_VERSION = " << version << std::endl;
189+
190+ if (!check_blacklist(c->blacklist(), vendor, renderer, version))
191+ throw mir::AbnormalExit ("Video driver is blacklisted, exiting");
192+
193 guard.thread = std::thread(&SystemCompositor::main, this);
194 });
195 }

Subscribers

People subscribed via source and target branches