Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_OFFSCREEN_DISPLAY_H_
20 #define MIR_GRAPHICS_OFFSCREEN_DISPLAY_H_
21 
22 #include "mir/graphics/display.h"
23 #include "display_configuration.h"
25 
26 #include <mutex>
27 #include <vector>
28 
29 #include <EGL/egl.h>
30 
31 namespace mir
32 {
33 namespace graphics
34 {
35 
36 class BasicPlatform;
37 class DisplayConfigurationPolicy;
38 class DisplayReport;
39 
40 namespace offscreen
41 {
42 namespace detail
43 {
44 
46 {
47 public:
48  explicit EGLDisplayHandle(EGLNativeDisplayType native_type);
50  ~EGLDisplayHandle() noexcept;
51 
52  void initialize();
53  operator EGLDisplay() const { return egl_display; }
54 
55 private:
56  EGLDisplayHandle(EGLDisplayHandle const&) = delete;
57  EGLDisplayHandle operator=(EGLDisplayHandle const&) = delete;
58 
59  EGLDisplay egl_display;
60 };
61 
62 }
63 
64 class Display : public graphics::Display
65 {
66 public:
67  Display(std::shared_ptr<BasicPlatform> const& basic_platform,
68  std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
69  std::shared_ptr<DisplayReport> const& listener);
70  ~Display() noexcept;
71 
72  void for_each_display_buffer(std::function<void(DisplayBuffer&)> const& f);
73 
74  std::unique_ptr<graphics::DisplayConfiguration> configuration() const override;
75  void configure(graphics::DisplayConfiguration const& conf) override;
76 
78  EventHandlerRegister& handlers,
79  DisplayConfigurationChangeHandler const& conf_change_handler);
80 
82  EventHandlerRegister& handlers,
83  DisplayPauseHandler const& pause_handler,
84  DisplayResumeHandler const& resume_handler);
85 
86  void pause();
87  void resume();
88 
89  std::weak_ptr<Cursor> the_cursor();
90  std::unique_ptr<GLContext> create_gl_context();
91 
92 private:
93  std::shared_ptr<BasicPlatform> const basic_platform;
94  detail::EGLDisplayHandle const egl_display;
95  SurfacelessEGLContext const egl_context_shared;
96  mutable std::mutex configuration_mutex;
97  DisplayConfiguration current_display_configuration;
98  std::vector<std::unique_ptr<DisplayBuffer>> display_buffers;
99 };
100 
101 }
102 }
103 }
104 
105 #endif /* MIR_GRAPHICS_OFFSCREEN_DISPLAY_H_ */
void configure(graphics::DisplayConfiguration const &conf) override
Sets a new output configuration.
void register_pause_resume_handlers(EventHandlerRegister &handlers, DisplayPauseHandler const &pause_handler, DisplayResumeHandler const &resume_handler)
Registers handlers for pausing and resuming the display subsystem.
std::unique_ptr< GLContext > create_gl_context()
Creates a GLContext object that shares resources with the Display's GL context.
Definition: surfaceless_egl_context.h:32
std::unique_ptr< graphics::DisplayConfiguration > configuration() const override
Gets a copy of the current output configuration.
void pause()
Pauses the display.
std::function< bool()> DisplayResumeHandler
Definition: display.h:38
void for_each_display_buffer(std::function< void(DisplayBuffer &)> const &f)
EGLDisplayHandle(EGLNativeDisplayType native_type)
Definition: display_buffer.h:59
void resume()
Resumes the display.
std::function< bool()> DisplayPauseHandler
Definition: display.h:35
Definition: display_configuration.h:29
std::weak_ptr< Cursor > the_cursor()
Gets the hardware cursor object.
void register_configuration_change_handler(EventHandlerRegister &handlers, DisplayConfigurationChangeHandler const &conf_change_handler)
Registers a handler for display configuration changes.
Definition: display.h:64
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