Mir
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 DisplayConfigurationPolicy;
37 class DisplayReport;
38 
39 namespace offscreen
40 {
41 namespace detail
42 {
43 
45 {
46 public:
47  explicit EGLDisplayHandle(EGLNativeDisplayType native_type);
49  ~EGLDisplayHandle() noexcept;
50 
51  void initialize();
52  operator EGLDisplay() const { return egl_display; }
53 
54 private:
55  EGLDisplayHandle(EGLDisplayHandle const&) = delete;
56  EGLDisplayHandle operator=(EGLDisplayHandle const&) = delete;
57 
58  EGLDisplay egl_display;
59 };
60 
62 {
63 public:
64  DisplaySyncGroup(std::unique_ptr<DisplayBuffer> output);
65  void for_each_display_buffer(std::function<void(DisplayBuffer&)> const&) override;
66  void post() override;
67  std::chrono::milliseconds recommended_sleep() const override;
68 private:
69  std::unique_ptr<DisplayBuffer> const output;
70 };
71 
72 }
73 
74 class Display : public graphics::Display
75 {
76 public:
77  Display(EGLNativeDisplayType egl_native_display,
78  std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
79  std::shared_ptr<DisplayReport> const& listener);
80  ~Display() noexcept;
81 
82  void for_each_display_sync_group(std::function<void(DisplaySyncGroup&)> const& f) override;
83 
84  std::unique_ptr<graphics::DisplayConfiguration> configuration() const override;
85  void configure(graphics::DisplayConfiguration const& conf) override;
86 
88  EventHandlerRegister& handlers,
89  DisplayConfigurationChangeHandler const& conf_change_handler) override;
90 
92  EventHandlerRegister& handlers,
93  DisplayPauseHandler const& pause_handler,
94  DisplayResumeHandler const& resume_handler) override;
95 
96  void pause() override;
97  void resume() override;
98 
99  std::shared_ptr<Cursor> create_hardware_cursor(std::shared_ptr<CursorImage> const& initial_image) override;
100  std::unique_ptr<GLContext> create_gl_context() override;
101 
102 private:
103  detail::EGLDisplayHandle const egl_display;
104  SurfacelessEGLContext const egl_context_shared;
105  mutable std::mutex configuration_mutex;
106  DisplayConfiguration current_display_configuration;
107  std::vector<std::unique_ptr<DisplaySyncGroup>> display_sync_groups;
108 };
109 
110 }
111 }
112 }
113 
114 #endif /* MIR_GRAPHICS_OFFSCREEN_DISPLAY_H_ */
std::unique_ptr< GLContext > create_gl_context() override
Creates a GLContext object that shares resources with the Display's GL context.
All things Mir.
Definition: atomic_callback.h:25
void resume() override
Resumes the display.
void for_each_display_sync_group(std::function< void(DisplaySyncGroup &)> const &f) override
Executes a functor for each output group.
void configure(graphics::DisplayConfiguration const &conf) override
Sets a new output configuration.
void register_configuration_change_handler(EventHandlerRegister &handlers, DisplayConfigurationChangeHandler const &conf_change_handler) override
Registers a handler for display configuration changes.
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.
DisplaySyncGroup represents a group of displays that need to be output in unison as a single post() c...
Definition: display.h:54
Definition: surfaceless_egl_context.h:32
std::unique_ptr< graphics::DisplayConfiguration > configuration() const override
Gets a copy of the current output configuration.
void post() override
Post the content of the DisplayBuffers associated with this DisplaySyncGroup.
std::shared_ptr< Cursor > create_hardware_cursor(std::shared_ptr< CursorImage > const &initial_image) override
Create a hardware cursor object.
std::function< bool()> DisplayResumeHandler
Definition: display.h:40
EGLDisplayHandle(EGLNativeDisplayType native_type)
Definition: display_buffer.h:60
std::function< bool()> DisplayPauseHandler
Definition: display.h:37
Definition: display_configuration.h:29
void pause() override
Pauses the display.
void for_each_display_buffer(std::function< void(DisplayBuffer &)> const &) override
Definition: display.h:74
std::chrono::milliseconds recommended_sleep() const override
Returns a recommendation to the compositor as to how long it should wait before sampling the scene fo...
Interface to the display subsystem.
Definition: display.h:87
std::function< void()> DisplayConfigurationChangeHandler
Definition: display.h:41
Interface to a configuration of display cards and outputs.
Definition: display_configuration.h:166
Definition: event_handler_register.h:31

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015