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 
87  void register_configuration_change_handler(
88  EventHandlerRegister& handlers,
89  DisplayConfigurationChangeHandler const& conf_change_handler) override;
90 
91  void register_pause_resume_handlers(
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  std::unique_ptr<VirtualOutput> create_virtual_output(int width, int height) override;
102 
103 private:
104  detail::EGLDisplayHandle const egl_display;
105  SurfacelessEGLContext const egl_context_shared;
106  mutable std::mutex configuration_mutex;
107  DisplayConfiguration current_display_configuration;
108  std::vector<std::unique_ptr<DisplaySyncGroup>> display_sync_groups;
109 };
110 
111 }
112 }
113 }
114 
115 #endif /* MIR_GRAPHICS_OFFSCREEN_DISPLAY_H_ */
All things Mir.
Definition: atomic_callback.h:25
DisplaySyncGroup represents a group of displays that need to be output in unison as a single post() c...
Definition: display.h:55
Definition: surfaceless_egl_context.h:32
std::function< bool()> DisplayResumeHandler
Definition: display.h:41
EGLDisplayHandle(EGLNativeDisplayType native_type)
Definition: display_buffer.h:60
unsigned int width
Definition: touchspot_image.c:4
std::function< bool()> DisplayPauseHandler
Definition: display.h:38
Definition: display_configuration.h:29
unsigned int height
Definition: touchspot_image.c:5
Definition: display.h:74
Interface to the display subsystem.
Definition: display.h:88
std::function< void()> DisplayConfigurationChangeHandler
Definition: display.h:42
Interface to a configuration of display cards and outputs.
Definition: display_configuration.h:167
Definition: event_handler_register.h:32

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016