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 logging { class Logger; }
33 
34 namespace frontend
35 {
36 class Surface;
37 }
38 namespace options
39 {
40 class Option;
41 class ProgramOption;
42 }
43 
46 namespace graphics
47 {
48 class Buffer;
49 class Display;
50 class DisplayReport;
51 class DisplayConfigurationPolicy;
52 class GraphicBufferAllocator;
53 class GLConfig;
54 class PlatformIpcOperations;
55 class NestedContext;
56 
67 class Platform
68 {
69 public:
70  Platform() = default;
71  Platform(const Platform& p) = delete;
72  Platform& operator=(const Platform& p) = delete;
73 
74  virtual ~Platform() = default;
75 
79  virtual UniqueModulePtr<GraphicBufferAllocator> create_buffer_allocator() = 0;
80 
84  virtual UniqueModulePtr<Display> create_display(
85  std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
86  std::shared_ptr<GLConfig> const& gl_config) = 0;
87 
92  virtual UniqueModulePtr<PlatformIpcOperations> make_ipc_operations() const = 0;
93 };
94 
103 enum PlatformPriority : uint32_t
104 {
106  dummy = 1,
108  supported = 128,
111  best = 256
114 };
115 
117  std::shared_ptr<mir::options::Option> const& options,
118  std::shared_ptr<mir::EmergencyCleanupRegistry> const& emergency_cleanup_registry,
119  std::shared_ptr<mir::graphics::DisplayReport> const& report,
120  std::shared_ptr<mir::logging::Logger> const& logger);
121 
122 typedef mir::UniqueModulePtr<mir::graphics::Platform>(*CreateGuestPlatform)(
123  std::shared_ptr<mir::graphics::DisplayReport> const& report,
124  std::shared_ptr<mir::graphics::NestedContext> const& nested_context);
125 
126 
127 typedef void(*AddPlatformOptions)(
128  boost::program_options::options_description& config);
129 
130 typedef mir::graphics::PlatformPriority(*PlatformProbe)(mir::options::ProgramOption const& options);
131 
132 typedef mir::ModuleProperties const*(*DescribeModule)();
133 }
134 }
135 
136 extern "C"
137 {
138 #if defined(__clang__)
139 #pragma clang diagnostic push
140 // These functions are given "C" linkage to avoid name-mangling, not for C compatibility.
141 // (We don't want a warning for doing this intentionally.)
142 #pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
143 #endif
144 
158  std::shared_ptr<mir::options::Option> const& options,
159  std::shared_ptr<mir::EmergencyCleanupRegistry> const& emergency_cleanup_registry,
160  std::shared_ptr<mir::graphics::DisplayReport> const& report,
161  std::shared_ptr<mir::logging::Logger> const& logger);
162 
175  std::shared_ptr<mir::graphics::DisplayReport> const& report,
176  std::shared_ptr<mir::graphics::NestedContext> const& nested_context);
177 
188  boost::program_options::options_description& config);
189 
190 // TODO: We actually need to be more granular here; on a device with more
191 // than one graphics system we may need a different platform per GPU,
192 // so we should be associating platforms with graphics devices in some way
193 mir::graphics::PlatformPriority probe_graphics_platform(mir::options::ProgramOption const& options);
194 
196 
197 #if defined(__clang__)
198 #pragma clang diagnostic pop
199 #endif
200 }
201 
202 #endif // MIR_GRAPHICS_PLATFORM_H_
Definition: as_render_target.h:27
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.
Capable of providing a Platform with the best features and performance this device is capable of...
Definition: platform.h:111
mir::ModuleProperties const * describe_graphics_module()
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, std::shared_ptr< mir::logging::Logger > const &logger)
Function prototype used to return a new host graphics platform.
Unable to function at all on this device.
Definition: platform.h:105
Interface to platform specific support for graphics operations.
Definition: platform.h:67
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...
mir::graphics::PlatformPriority probe_graphics_platform(mir::options::ProgramOption const &options)
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:96
Describes a platform module.
Definition: module_properties.h:33
PlatformPriority
A measure of how well a platform supports a device.
Definition: platform.h:103
Used only for dummy or stub platforms.
Definition: platform.h:106
Capable of providing a functioning Platform on this device, possibly with degraded performance or fea...
Definition: platform.h:108
mir::graphics::PlatformPriority(* PlatformProbe)(mir::options::ProgramOption const &options)
Definition: platform.h:130
Definition: option.h:33

Copyright © 2012-2016 Canonical Ltd.
Generated on Wed May 10 10:41:27 UTC 2017