Mir

Merge lp:~alan-griffiths/mir/configurable-graphicsplatform into lp:~mir-team/mir/trunk

Proposed by Alan Griffiths
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 769
Proposed branch: lp:~alan-griffiths/mir/configurable-graphicsplatform
Merge into: lp:~mir-team/mir/trunk
Prerequisite: lp:~alan-griffiths/mir/dlopen-graphicsplatform
Diff against target: 73 lines (+29/-2)
1 file modified
src/server/default_server_configuration.cpp (+29/-2)
To merge this branch: bzr merge lp:~alan-griffiths/mir/configurable-graphicsplatform
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
Robert Carr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+170853@code.launchpad.net

Commit message

config: allow graphics platform library to be selected by command-line/config

Description of the change

config: allow graphics platform library to be selected by command-line/config

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Interesting approach and probably a good first step.

Though I suspect the final "driver model" needs to be implementable with a pure C API. So maybe it's dangerous to establish a precedent that we load C++ code dynamically. We'd be establishing a C++ ABI when we don't want one, in the end.

Revision history for this message
Robert Carr (robertcarr) wrote :

LGTM. I agree that the "driver model" needs a C API, though I think this is more about correctly supporting mir-on-mir, mir-on-x, etc. Either way

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm too

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/default_server_configuration.cpp'
2--- src/server/default_server_configuration.cpp 2013-06-21 16:21:33 +0000
3+++ src/server/default_server_configuration.cpp 2013-06-21 16:21:33 +0000
4@@ -69,6 +69,8 @@
5 #include "mir/time/high_resolution_clock.h"
6 #include "mir/default_configuration.h"
7
8+#include <map>
9+
10 namespace mc = mir::compositor;
11 namespace me = mir::events;
12 namespace geom = mir::geometry;
13@@ -83,6 +85,7 @@
14 namespace
15 {
16 std::initializer_list<std::shared_ptr<mi::EventFilter> const> empty_filter_list{};
17+mir::SharedLibrary const* load_library(std::string const& libname);
18 }
19
20 namespace
21@@ -157,6 +160,9 @@
22 char const* const log_opt_value = "log";
23 char const* const lttng_opt_value = "lttng";
24
25+char const* const platform_graphics_lib = "platform-graphics-lib";
26+char const* const default_platform_graphics_lib = "libmirplatformgraphics.so";
27+
28 void parse_arguments(
29 boost::program_options::options_description desc,
30 std::shared_ptr<mir::options::ProgramOption> const& options,
31@@ -213,6 +219,8 @@
32 add_options()
33 ("file,f", po::value<std::string>(),
34 "Socket filename")
35+ (platform_graphics_lib, po::value<std::string>(),
36+ "Library to use for platform graphics support [default=libmirplatformgraphics.so")
37 ("enable-input,i", po::value<bool>(),
38 "Enable input. [bool:default=true]")
39 (display_report_opt, po::value<std::string>(),
40@@ -297,8 +305,8 @@
41 return graphics_platform(
42 [this]()
43 {
44- static SharedLibrary libmirplatformgraphics("libmirplatformgraphics.so");
45- static auto create_platform = libmirplatformgraphics.load_function<mg::CreatePlatform>("create_platform");
46+ auto graphics_lib = load_library(the_options()->get(platform_graphics_lib, default_platform_graphics_lib));
47+ auto create_platform = graphics_lib->load_function<mg::CreatePlatform>("create_platform");
48 return create_platform(the_options(), the_display_report());
49 });
50 }
51@@ -729,3 +737,22 @@
52 return std::make_shared<mir::AsioMainLoop>();
53 });
54 }
55+
56+namespace
57+{
58+mir::SharedLibrary const* load_library(std::string const& libname)
59+{
60+ // There's no point in loading twice, and it isn't safe to unload...
61+ static std::map<std::string, std::shared_ptr<mir::SharedLibrary>> libraries_cache;
62+
63+ if (auto& ptr = libraries_cache[libname])
64+ {
65+ return ptr.get();
66+ }
67+ else
68+ {
69+ ptr = std::make_shared<mir::SharedLibrary>(libname);
70+ return ptr.get();
71+ }
72+}
73+}

Subscribers

People subscribed via source and target branches