Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
46 namespace nested
47 {
48 namespace detail
49 {
50 
52 {
53 public:
54  explicit EGLSurfaceHandle(EGLDisplay display, EGLNativeWindowType native_window, EGLConfig cfg);
55  ~EGLSurfaceHandle() noexcept;
56 
57  operator EGLSurface() const { return egl_surface; }
58 
59 private:
60  EGLDisplay const egl_display;
61  EGLSurface const egl_surface;
62 };
63 
65 {
66 public:
67  explicit EGLDisplayHandle(MirConnection* connection);
68  ~EGLDisplayHandle() noexcept;
69 
70  void initialize();
71  EGLConfig choose_config(const EGLint attrib_list[]) const;
72  EGLNativeWindowType native_window(EGLConfig egl_config, MirSurface* mir_surface) const;
73  EGLContext egl_context() const;
74  operator EGLDisplay() const { return egl_display; }
75 
76 private:
77  EGLDisplay egl_display;
78  EGLContext egl_context_;
79 
80  EGLDisplayHandle(EGLDisplayHandle const&) = delete;
81  EGLDisplayHandle operator=(EGLDisplayHandle const&) = delete;
82 };
83 
84 class NestedOutput;
85 
86 extern EGLint const nested_egl_config_attribs[];
87 extern EGLint const nested_egl_context_attribs[];
88 }
89 
90 class HostConnection;
91 
92 class NestedDisplay : public Display
93 {
94 public:
96  std::shared_ptr<HostConnection> const& connection,
97  std::shared_ptr<input::EventFilter> const& event_handler,
98  std::shared_ptr<DisplayReport> const& display_report);
99 
100  ~NestedDisplay() noexcept;
101 
102  void for_each_display_buffer(std::function<void(DisplayBuffer&)>const& f) override;
103 
104  std::shared_ptr<DisplayConfiguration> configuration() override;
105  void configure(DisplayConfiguration const&) override;
106 
108  EventHandlerRegister& handlers,
109  DisplayConfigurationChangeHandler const& conf_change_handler) override;
110 
112  EventHandlerRegister& handlers,
113  DisplayPauseHandler const& pause_handler,
114  DisplayResumeHandler const& resume_handler) override;
115 
116  void pause() override;
117  void resume() override;
118 
119  std::weak_ptr<Cursor> the_cursor() override;
120  std::unique_ptr<graphics::GLContext> create_gl_context() override;
121 
122 private:
123  std::shared_ptr<HostConnection> const connection;
124  std::shared_ptr<input::EventFilter> const event_handler;
125  std::shared_ptr<DisplayReport> const display_report;
126  detail::EGLDisplayHandle egl_display;
127  MirPixelFormat egl_pixel_format;
128 
129  std::mutex outputs_mutex;
130  std::unordered_map<DisplayConfigurationOutputId, std::shared_ptr<detail::NestedOutput>> outputs;
131  DisplayConfigurationChangeHandler my_conf_change_handler;
132 };
133 
134 }
135 }
136 }
137 
138 #endif // MIR_GRAPHICS_NESTED_NESTED_DISPLAY_H_

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Oct 15 00:23:28 UTC 2013