Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 EventFilter; }
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 
48 namespace nested
49 {
50 namespace detail
51 {
52 
54 {
55 public:
56  explicit EGLSurfaceHandle(EGLDisplay display, EGLNativeWindowType native_window, EGLConfig cfg);
57  ~EGLSurfaceHandle() noexcept;
58 
59  operator EGLSurface() const { return egl_surface; }
60 
61 private:
62  EGLDisplay const egl_display;
63  EGLSurface const egl_surface;
64 };
65 
67 {
68 public:
69  EGLDisplayHandle(MirConnection* connection,
70  std::shared_ptr<GLConfig> const& gl_config);
71  ~EGLDisplayHandle() noexcept;
72 
73  void initialize(MirPixelFormat format);
74  EGLConfig choose_windowed_es_config(MirPixelFormat format) const;
75  EGLNativeWindowType native_window(EGLConfig egl_config, MirSurface* mir_surface) 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<HostConnection> const& connection,
100  std::shared_ptr<input::EventFilter> const& event_handler,
101  std::shared_ptr<DisplayReport> const& display_report,
102  std::shared_ptr<DisplayConfigurationPolicy> const& conf_policy,
103  std::shared_ptr<GLConfig> const& gl_config);
104 
105  ~NestedDisplay() noexcept;
106 
107  void for_each_display_buffer(std::function<void(DisplayBuffer&)>const& f) override;
108 
109  std::unique_ptr<DisplayConfiguration> configuration() const override;
110  void configure(DisplayConfiguration const&) override;
111 
113  EventHandlerRegister& handlers,
114  DisplayConfigurationChangeHandler const& conf_change_handler) override;
115 
117  EventHandlerRegister& handlers,
118  DisplayPauseHandler const& pause_handler,
119  DisplayResumeHandler const& resume_handler) override;
120 
121  void pause() override;
122  void resume() override;
123 
124  std::weak_ptr<Cursor> the_cursor() override;
125  std::unique_ptr<graphics::GLContext> create_gl_context() override;
126 
127 private:
128  std::shared_ptr<HostConnection> const connection;
129  std::shared_ptr<input::EventFilter> const event_handler;
130  std::shared_ptr<DisplayReport> const display_report;
131  detail::EGLDisplayHandle egl_display;
132 
133  std::mutex outputs_mutex;
134  std::unordered_map<DisplayConfigurationOutputId, std::shared_ptr<detail::NestedOutput>> outputs;
135  DisplayConfigurationChangeHandler my_conf_change_handler;
136  void complete_display_initialization(MirPixelFormat format);
137 };
138 
139 }
140 }
141 }
142 
143 #endif // MIR_GRAPHICS_NESTED_NESTED_DISPLAY_H_
~EGLDisplayHandle() noexcept
Definition: nested_display.cpp:130
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:262
Definition: mir_surface.h:54
void initialize(MirPixelFormat format)
Definition: nested_display.cpp:75
EGLNativeWindowType native_window(EGLConfig egl_config, MirSurface *mir_surface) const
Definition: nested_display.cpp:115
Interface to an output framebuffer.
Definition: display_buffer.h:39
void resume() override
Resumes the display.
Definition: nested_display.cpp:276
Definition: nested_display.h:95
EGLSurfaceHandle(EGLDisplay display, EGLNativeWindowType native_window, EGLConfig cfg)
Definition: nested_display.cpp:47
std::weak_ptr< Cursor > the_cursor() override
Gets the hardware cursor object.
Definition: nested_display.cpp:282
void configure(DisplayConfiguration const &) override
Sets a new output configuration.
Definition: nested_display.cpp:181
void pause() override
Pauses the display.
Definition: nested_display.cpp:270
std::function< bool()> DisplayResumeHandler
Definition: display.h:38
EGLContext egl_context() const
Definition: nested_display.cpp:125
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:99
EGLDisplayHandle(MirConnection *connection, std::shared_ptr< GLConfig > const &gl_config)
Definition: nested_display.cpp:62
std::function< bool()> DisplayPauseHandler
Definition: display.h:35
NestedDisplay(std::shared_ptr< HostConnection > const &connection, std::shared_ptr< input::EventFilter > const &event_handler, 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:135
~EGLSurfaceHandle() noexcept
Definition: nested_display.cpp:57
void for_each_display_buffer(std::function< void(DisplayBuffer &)>const &f) override
Executes a functor for each output framebuffer.
Definition: nested_display.cpp:157
~NestedDisplay() noexcept
Definition: nested_display.cpp:153
EGLConfig choose_windowed_es_config(MirPixelFormat format) const
Definition: nested_display.cpp:91
Definition: mir_connection.h:69
void register_configuration_change_handler(EventHandlerRegister &handlers, DisplayConfigurationChangeHandler const &conf_change_handler) override
Registers a handler for display configuration changes.
Definition: nested_display.cpp:252
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:288
std::unique_ptr< DisplayConfiguration > configuration() const override
Gets a copy of the current output configuration.
Definition: nested_display.cpp:164
Interface to the display subsystem.
Definition: display.h:44
std::function< void()> DisplayConfigurationChangeHandler
Definition: display.h:39
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 Fri Apr 11 21:14:53 UTC 2014