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

Subscribers

People subscribed via source and target branches