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 #include <EGL/egl.h>
25 #include <memory>
26 
27 #include "mir/module_properties.h"
28 
29 namespace mir
30 {
31 class EmergencyCleanupRegistry;
32 
33 namespace frontend
34 {
35 class Surface;
36 }
37 namespace options
38 {
39 class Option;
40 class ProgramOption;
41 }
42 
45 namespace graphics
46 {
47 class Buffer;
48 class Display;
49 class DisplayReport;
50 class DisplayConfigurationPolicy;
51 class GraphicBufferAllocator;
52 class GLConfig;
53 class PlatformIpcOperations;
54 class NestedContext;
55 
66 class Platform
67 {
68 public:
69  Platform() = default;
70  Platform(const Platform& p) = delete;
71  Platform& operator=(const Platform& p) = delete;
72 
73  virtual ~Platform() = default;
74 
78  virtual std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator() = 0;
79 
83  virtual std::shared_ptr<Display> create_display(
84  std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
85  std::shared_ptr<GLConfig> const& gl_config) = 0;
86 
91  virtual std::shared_ptr<PlatformIpcOperations> make_ipc_operations() const = 0;
92 
93  virtual EGLNativeDisplayType egl_native_display() const = 0;
94 };
95 
104 enum PlatformPriority : uint32_t
105 {
107  dummy = 1,
109  supported = 128,
112  best = 256
115 };
116 
117 typedef std::shared_ptr<mir::graphics::Platform>(*CreateHostPlatform)(
118  std::shared_ptr<mir::options::Option> const& options,
119  std::shared_ptr<mir::EmergencyCleanupRegistry> const& emergency_cleanup_registry,
120  std::shared_ptr<mir::graphics::DisplayReport> const& report);
121 
122 typedef std::shared_ptr<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 
131 
132 typedef mir::ModuleProperties const*(*DescribeModule)();
133 }
134 }
135 
136 extern "C"
137 {
138 
151 std::shared_ptr<mir::graphics::Platform> create_host_platform(
152  std::shared_ptr<mir::options::Option> const& options,
153  std::shared_ptr<mir::EmergencyCleanupRegistry> const& emergency_cleanup_registry,
154  std::shared_ptr<mir::graphics::DisplayReport> const& report);
155 
167 std::shared_ptr<mir::graphics::Platform> create_guest_platform(
168  std::shared_ptr<mir::graphics::DisplayReport> const& report,
169  std::shared_ptr<mir::graphics::NestedContext> const& nested_context);
170 
181  boost::program_options::options_description& config);
182 
183 // TODO: We actually need to be more granular here; on a device with more
184 // than one graphics system we may need a different platform per GPU,
185 // so we should be associating platforms with graphics devices in some way
187 
189 }
190 
191 #endif // MIR_GRAPHICS_PLATFORM_H_
std::shared_ptr< 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.
All things Mir.
Definition: atomic_callback.h:25
Platform & operator=(const Platform &p)=delete
Definition: program_option.h:32
Capable of providing a Platform with the best features and performance this device is capable of...
Definition: platform.h:112
mir::graphics::PlatformPriority probe_graphics_platform(mir::options::ProgramOption const &options)
Definition: platform.cpp:179
Unable to function at all on this device.
Definition: platform.h:106
virtual std::shared_ptr< Display > create_display(std::shared_ptr< DisplayConfigurationPolicy > const &initial_conf_policy, std::shared_ptr< GLConfig > const &gl_config)=0
Creates the display subsystem.
Interface to platform specific support for graphics operations.
Definition: platform.h:66
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:166
virtual ~Platform()=default
virtual std::shared_ptr< PlatformIpcOperations > make_ipc_operations() const =0
Creates an object capable of doing platform specific processing of buffers before they are sent or af...
mir::ModuleProperties const * describe_graphics_module()
Definition: platform.cpp:196
Describes a platform module.
Definition: module_properties.h:28
PlatformPriority
A measure of how well a platform supports a device.
Definition: platform.h:104
std::shared_ptr< 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.
Used only for dummy or stub platforms.
Definition: platform.h:107
Capable of providing a functioning Platform on this device, possibly with degraded performance or fea...
Definition: platform.h:109
virtual EGLNativeDisplayType egl_native_display() const =0
virtual std::shared_ptr< GraphicBufferAllocator > create_buffer_allocator()=0
Creates the buffer allocator subsystem.
mir::graphics::PlatformPriority(* PlatformProbe)(mir::options::ProgramOption const &options)
Definition: platform.h:130
void(* AddPlatformOptions)(boost::program_options::options_description &config)
Definition: platform.h:127

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015