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 }
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 GLProgramFactory;
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() { /* TODO: make nothrow */ }
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<GLProgramFactory> const& gl_program_factory,
86  std::shared_ptr<GLConfig> const& gl_config) = 0;
87 
92  virtual std::shared_ptr<PlatformIpcOperations> make_ipc_operations() const = 0;
93 
94  virtual EGLNativeDisplayType egl_native_display() const = 0;
95 };
96 
105 enum PlatformPriority : uint32_t
106 {
108  supported = 128,
111  best = 256
114 };
115 
128 extern "C" typedef std::shared_ptr<Platform>(*CreateHostPlatform)(
129  std::shared_ptr<options::Option> const& options,
130  std::shared_ptr<EmergencyCleanupRegistry> const& emergency_cleanup_registry,
131  std::shared_ptr<DisplayReport> const& report);
132 extern "C" std::shared_ptr<Platform> create_host_platform(
133  std::shared_ptr<options::Option> const& options,
134  std::shared_ptr<EmergencyCleanupRegistry> const& emergency_cleanup_registry,
135  std::shared_ptr<DisplayReport> const& report);
136 
148 extern "C" typedef std::shared_ptr<Platform>(*CreateGuestPlatform)(
149  std::shared_ptr<DisplayReport> const& report,
150  std::shared_ptr<NestedContext> const& nested_context);
151 extern "C" std::shared_ptr<Platform> create_guest_platform(
152  std::shared_ptr<DisplayReport> const& report,
153  std::shared_ptr<NestedContext> const& nested_context);
154 
164 extern "C" typedef void(*AddPlatformOptions)(
165  boost::program_options::options_description& config);
166 extern "C" void add_graphics_platform_options(
167  boost::program_options::options_description& config);
168 
169 // TODO: We actually need to be more granular here; on a device with more
170 // than one graphics system we may need a different platform per GPU,
171 // so we should be associating platforms with graphics devices in some way
172 extern "C" typedef PlatformPriority(*PlatformProbe)();
174 
175 extern "C" typedef ModuleProperties const*(*DescribeModule)();
176 extern "C" ModuleProperties const* describe_graphics_module();
177 }
178 }
179 
180 #endif // MIR_GRAPHICS_PLATFORM_H_
std::shared_ptr< Platform > create_guest_platform(std::shared_ptr< DisplayReport > const &report, std::shared_ptr< NestedContext > const &nested_context)
All things Mir.
Definition: buffer_stream.h:37
Platform & operator=(const Platform &p)=delete
Capable of providing a Platform with the best features and performance this device is capable of...
Definition: platform.h:111
PlatformPriority probe_graphcis_platform()
Unable to function at all on this device.
Definition: platform.h:107
Interface to platform specific support for graphics operations.
Definition: platform.h:66
virtual std::shared_ptr< Display > create_display(std::shared_ptr< DisplayConfigurationPolicy > const &initial_conf_policy, std::shared_ptr< GLProgramFactory > const &gl_program_factory, std::shared_ptr< GLConfig > const &gl_config)=0
Creates the display subsystem.
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...
void add_graphics_platform_options(boost::program_options::options_description &config)
Definition: platform.cpp:158
ModuleProperties const * describe_graphics_module()
Definition: platform.cpp:187
Describes a platform module.
Definition: module_properties.h:28
virtual ~Platform()
Definition: platform.h:73
void(* AddPlatformOptions)(boost::program_options::options_description &config)
Function prototype used to add platform specific options to the platform-independant server options...
Definition: platform.h:164
PlatformPriority(* PlatformProbe)()
Definition: platform.h:172
PlatformPriority
A measure of how well a platform supports a device.
Definition: platform.h:105
Capable of providing a functioning Platform on this device, possibly with degraded performance or fea...
Definition: platform.h:108
virtual EGLNativeDisplayType egl_native_display() const =0
virtual std::shared_ptr< GraphicBufferAllocator > create_buffer_allocator()=0
Creates the buffer allocator subsystem.
std::shared_ptr< Platform > create_host_platform(std::shared_ptr< options::Option > const &options, std::shared_ptr< EmergencyCleanupRegistry > const &emergency_cleanup_registry, std::shared_ptr< DisplayReport > const &report)

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015