Mir
platform.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by:
17  * Thomas Guest <thomas.guest@canonical.com>
18  */
19 
20 #ifndef MIR_GRAPHICS_PLATFORM_H_
21 #define MIR_GRAPHICS_PLATFORM_H_
22 
23 #include <boost/program_options/options_description.hpp>
24 
25 #include "mir/module_properties.h"
26 #include "mir/module_deleter.h"
27 
28 namespace mir
29 {
30 class EmergencyCleanupRegistry;
31 
32 namespace frontend
33 {
34 class Surface;
35 }
36 namespace options
37 {
38 class Option;
39 class ProgramOption;
40 }
41 
44 namespace graphics
45 {
46 class Buffer;
47 class Display;
48 class DisplayReport;
49 class DisplayConfigurationPolicy;
50 class GraphicBufferAllocator;
51 class GLConfig;
52 class PlatformIpcOperations;
53 class NestedContext;
54 
65 class Platform
66 {
67 public:
68  Platform() = default;
69  Platform(const Platform& p) = delete;
70  Platform& operator=(const Platform& p) = delete;
71 
72  virtual ~Platform() = default;
73 
77  virtual UniqueModulePtr<GraphicBufferAllocator> create_buffer_allocator() = 0;
78 
82  virtual UniqueModulePtr<Display> create_display(
83  std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
84  std::shared_ptr<GLConfig> const& gl_config) = 0;
85 
90  virtual UniqueModulePtr<PlatformIpcOperations> make_ipc_operations() const = 0;
91 };
92 
101 enum PlatformPriority : uint32_t
102 {
104  dummy = 1,
106  supported = 128,
109  best = 256
112 };
113 
115  std::shared_ptr<mir::options::Option> const& options,
116  std::shared_ptr<mir::EmergencyCleanupRegistry> const& emergency_cleanup_registry,
117  std::shared_ptr<mir::graphics::DisplayReport> const& report);
118 
119 typedef mir::UniqueModulePtr<mir::graphics::Platform>(*CreateGuestPlatform)(
120  std::shared_ptr<mir::graphics::DisplayReport> const& report,
121  std::shared_ptr<mir::graphics::NestedContext> const& nested_context);
122 
123 
124 typedef void(*AddPlatformOptions)(
125  boost::program_options::options_description& config);
126 
128 
129 typedef mir::ModuleProperties const*(*DescribeModule)();
130 }
131 }
132 
133 extern "C"
134 {
135 
149  std::shared_ptr<mir::options::Option> const& options,
150  std::shared_ptr<mir::EmergencyCleanupRegistry> const& emergency_cleanup_registry,
151  std::shared_ptr<mir::graphics::DisplayReport> const& report);
152 
165  std::shared_ptr<mir::graphics::DisplayReport> const& report,
166  std::shared_ptr<mir::graphics::NestedContext> const& nested_context);
167 
178  boost::program_options::options_description& config);
179 
180 // TODO: We actually need to be more granular here; on a device with more
181 // than one graphics system we may need a different platform per GPU,
182 // so we should be associating platforms with graphics devices in some way
184 
186 }
187 
188 #endif // MIR_GRAPHICS_PLATFORM_H_
All things Mir.
Definition: atomic_callback.h:25
mir::UniqueModulePtr< mir::graphics::Platform > create_guest_platform(std::shared_ptr< mir::graphics::DisplayReport > const &report, std::shared_ptr< mir::graphics::NestedContext > const &nested_context)
Function prototype used to return a new guest graphics platform.
Definition: program_option.h:32
Capable of providing a Platform with the best features and performance this device is capable of...
Definition: platform.h:109
mir::graphics::PlatformPriority probe_graphics_platform(mir::options::ProgramOption const &options)
Definition: platform.cpp:216
Unable to function at all on this device.
Definition: platform.h:103
Interface to platform specific support for graphics operations.
Definition: platform.h:65
mir::UniqueModulePtr< mir::graphics::Platform > create_host_platform(std::shared_ptr< mir::options::Option > const &options, std::shared_ptr< mir::EmergencyCleanupRegistry > const &emergency_cleanup_registry, std::shared_ptr< mir::graphics::DisplayReport > const &report)
Function prototype used to return a new host graphics platform.
void add_graphics_platform_options(boost::program_options::options_description &config)
Function prototype used to add platform specific options to the platform-independent server options...
Definition: platform.cpp:199
std::unique_ptr< T, ModuleDeleter< T >> UniqueModulePtr
Use UniqueModulePtr to ensure that your loadable libray outlives instances created within it...
Definition: module_deleter.h:83
void(* AddPlatformOptions)(boost::program_options::options_description &config)
Definition: platform.h:99
mir::ModuleProperties const * describe_graphics_module()
Definition: platform.cpp:238
Describes a platform module.
Definition: module_properties.h:33
PlatformPriority
A measure of how well a platform supports a device.
Definition: platform.h:101
Used only for dummy or stub platforms.
Definition: platform.h:104
Capable of providing a functioning Platform on this device, possibly with degraded performance or fea...
Definition: platform.h:106
mir::graphics::PlatformPriority(* PlatformProbe)(mir::options::ProgramOption const &options)
Definition: platform.h:127

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016