Mir
nested_display.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU 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 General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Eleni Maria Stea <elenimaria.stea@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_NESTED_NESTED_DISPLAY_H_
20 #define MIR_GRAPHICS_NESTED_NESTED_DISPLAY_H_
21 
22 #include "mir/graphics/display.h"
26 
28 
29 #include <EGL/egl.h>
30 
31 #include <mutex>
32 #include <unordered_map>
33 
34 namespace mir
35 {
36 namespace input { class InputDispatcher; }
37 namespace geometry
38 {
39 struct Rectangle;
40 }
41 namespace graphics
42 {
43 class DisplayReport;
44 class DisplayBuffer;
45 class DisplayConfigurationPolicy;
46 class GLConfig;
47 class Platform;
48 
49 namespace nested
50 {
51 namespace detail
52 {
53 
55 {
56 public:
57  explicit EGLSurfaceHandle(EGLDisplay display, EGLNativeWindowType native_window, EGLConfig cfg);
58  ~EGLSurfaceHandle() noexcept;
59 
60  operator EGLSurface() const { return egl_surface; }
61 
62 private:
63  EGLDisplay const egl_display;
64  EGLSurface const egl_surface;
65 };
66 
68 {
69 public:
70  EGLDisplayHandle(EGLNativeDisplayType native_display,
71  std::shared_ptr<GLConfig> const& gl_config);
72  ~EGLDisplayHandle() noexcept;
73 
74  void initialize(MirPixelFormat format);
75  EGLConfig choose_windowed_es_config(MirPixelFormat format) const;
76  EGLContext egl_context() const;
77  operator EGLDisplay() const { return egl_display; }
78 
79 private:
80  EGLDisplay egl_display;
81  EGLContext egl_context_;
82  std::shared_ptr<GLConfig> const gl_config;
83 
84  EGLDisplayHandle(EGLDisplayHandle const&) = delete;
85  EGLDisplayHandle operator=(EGLDisplayHandle const&) = delete;
86 };
87 
88 class NestedOutput;
89 
90 extern EGLint const nested_egl_context_attribs[];
91 }
92 
93 class HostConnection;
94 
95 class NestedDisplay : public Display
96 {
97 public:
99  std::shared_ptr<Platform> const& platform,
100  std::shared_ptr<HostConnection> const& connection,
101  std::shared_ptr<input::InputDispatcher> const& dispatcher,
102  std::shared_ptr<DisplayReport> const& display_report,
103  std::shared_ptr<DisplayConfigurationPolicy> const& conf_policy,
104  std::shared_ptr<GLConfig> const& gl_config);
105 
106  ~NestedDisplay() noexcept;
107 
108  void for_each_display_buffer(std::function<void(DisplayBuffer&)>const& f) override;
109 
110  std::unique_ptr<DisplayConfiguration> configuration() const override;
111  void configure(DisplayConfiguration const&) override;
112 
114  EventHandlerRegister& handlers,
115  DisplayConfigurationChangeHandler const& conf_change_handler) override;
116 
118  EventHandlerRegister& handlers,
119  DisplayPauseHandler const& pause_handler,
120  DisplayResumeHandler const& resume_handler) override;
121 
122  void pause() override;
123  void resume() override;
124 
125  std::shared_ptr<Cursor> create_hardware_cursor(std::shared_ptr<CursorImage> const& initial_image) override;
126  std::unique_ptr<graphics::GLContext> create_gl_context() override;
127 
128 private:
129  std::shared_ptr<Platform> const platform;
130  std::shared_ptr<HostConnection> const connection;
131  std::shared_ptr<input::InputDispatcher> const dispatcher;
132  std::shared_ptr<DisplayReport> const display_report;
133  detail::EGLDisplayHandle egl_display;
134 
135  std::mutex outputs_mutex;
136  std::unordered_map<DisplayConfigurationOutputId, std::shared_ptr<detail::NestedOutput>> outputs;
137  DisplayConfigurationChangeHandler my_conf_change_handler;
138  void create_surfaces(mir::graphics::DisplayConfiguration const& configuration);
139  void apply_to_connection(mir::graphics::DisplayConfiguration const& configuration);
140  void complete_display_initialization(MirPixelFormat format);
141 };
142 
143 }
144 }
145 }
146 
147 #endif // MIR_GRAPHICS_NESTED_NESTED_DISPLAY_H_
~EGLDisplayHandle() noexcept
Definition: nested_display.cpp:117
All things Mir.
Definition: buffer_stream.h:37
void register_pause_resume_handlers(EventHandlerRegister &handlers, DisplayPauseHandler const &pause_handler, DisplayResumeHandler const &resume_handler) override
Registers handlers for pausing and resuming the display subsystem.
Definition: nested_display.cpp:240
void initialize(MirPixelFormat format)
Definition: nested_display.cpp:72
Interface to an output framebuffer.
Definition: display_buffer.h:38
void resume() override
Resumes the display.
Definition: nested_display.cpp:254
Definition: nested_display.h:95
EGLSurfaceHandle(EGLDisplay display, EGLNativeWindowType native_window, EGLConfig cfg)
Definition: nested_display.cpp:45
void configure(DisplayConfiguration const &) override
Sets a new output configuration.
Definition: nested_display.cpp:169
void pause() override
Pauses the display.
Definition: nested_display.cpp:248
std::function< bool()> DisplayResumeHandler
Definition: display.h:39
EGLContext egl_context() const
Definition: nested_display.cpp:112
EGLint const nested_egl_context_attribs[]
MirPixelFormat
The order of components in a format enum matches the order of the components as they would be written...
Definition: common.h:127
NestedDisplay(std::shared_ptr< Platform > const &platform, std::shared_ptr< HostConnection > const &connection, std::shared_ptr< input::InputDispatcher > const &dispatcher, std::shared_ptr< DisplayReport > const &display_report, std::shared_ptr< DisplayConfigurationPolicy > const &conf_policy, std::shared_ptr< GLConfig > const &gl_config)
Definition: nested_display.cpp:122
std::function< bool()> DisplayPauseHandler
Definition: display.h:36
~EGLSurfaceHandle() noexcept
Definition: nested_display.cpp:55
void for_each_display_buffer(std::function< void(DisplayBuffer &)>const &f) override
Executes a functor for each output framebuffer.
Definition: nested_display.cpp:145
~NestedDisplay() noexcept
Definition: nested_display.cpp:141
EGLConfig choose_windowed_es_config(MirPixelFormat format) const
Definition: nested_display.cpp:88
std::shared_ptr< Cursor > create_hardware_cursor(std::shared_ptr< CursorImage > const &initial_image) override
Create a hardware cursor object.
Definition: nested_display.cpp:260
void register_configuration_change_handler(EventHandlerRegister &handlers, DisplayConfigurationChangeHandler const &conf_change_handler) override
Registers a handler for display configuration changes.
Definition: nested_display.cpp:233
std::unique_ptr< graphics::GLContext > create_gl_context() override
Creates a GLContext object that shares resources with the Display's GL context.
Definition: nested_display.cpp:266
std::unique_ptr< DisplayConfiguration > configuration() const override
Gets a copy of the current output configuration.
Definition: nested_display.cpp:152
EGLDisplayHandle(EGLNativeDisplayType native_display, std::shared_ptr< GLConfig > const &gl_config)
Definition: nested_display.cpp:60
Interface to the display subsystem.
Definition: display.h:45
std::function< void()> DisplayConfigurationChangeHandler
Definition: display.h:40
Interface to a configuration of display cards and outputs.
Definition: display_configuration.h:159
Definition: event_handler_register.h:31

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