Mir
display.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser 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_MESA_DISPLAY_H_
20 #define MIR_GRAPHICS_MESA_DISPLAY_H_
21 
22 #include "mir/graphics/display.h"
25 #include "display_helpers.h"
26 #include "platform_common.h"
27 
28 #include <atomic>
29 #include <mutex>
30 #include <vector>
31 
32 namespace mir
33 {
34 namespace geometry
35 {
36 struct Rectangle;
37 }
38 namespace graphics
39 {
40 
41 class DisplayReport;
42 class DisplayBuffer;
43 class DisplayConfigurationPolicy;
44 class EventHandlerRegister;
45 class GLConfig;
46 
47 namespace mesa
48 {
49 
50 namespace helpers
51 {
52 class DRMHelper;
53 class GBMHelper;
54 }
55 
56 class DisplayBuffer;
57 class VirtualTerminal;
58 class KMSOutput;
59 class Cursor;
60 
61 class Display : public graphics::Display
62 {
63 public:
64  Display(std::shared_ptr<helpers::DRMHelper> const& drm,
65  std::shared_ptr<helpers::GBMHelper> const& gbm,
66  std::shared_ptr<VirtualTerminal> const& vt,
67  BypassOption bypass_option,
68  std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
69  std::shared_ptr<GLConfig> const& gl_config,
70  std::shared_ptr<DisplayReport> const& listener);
71  ~Display();
72 
73  geometry::Rectangle view_area() const;
74  void for_each_display_sync_group(
75  std::function<void(graphics::DisplaySyncGroup&)> const& f) override;
76 
77  std::unique_ptr<DisplayConfiguration> configuration() const override;
78  void configure(DisplayConfiguration const& conf) override;
79 
80  void register_configuration_change_handler(
81  EventHandlerRegister& handlers,
82  DisplayConfigurationChangeHandler const& conf_change_handler) override;
83 
84  void register_pause_resume_handlers(
85  EventHandlerRegister& handlers,
86  DisplayPauseHandler const& pause_handler,
87  DisplayResumeHandler const& resume_handler) override;
88 
89  void pause() override;
90  void resume() override;
91 
92  std::shared_ptr<graphics::Cursor> create_hardware_cursor(std::shared_ptr<CursorImage> const& initial_image) override;
93  std::unique_ptr<GLContext> create_gl_context() override;
94  std::unique_ptr<VirtualOutput> create_virtual_output(int width, int height) override;
95 
96 private:
97  void clear_connected_unused_outputs();
98 
99  mutable std::mutex configuration_mutex;
100  std::shared_ptr<helpers::DRMHelper> const drm;
101  std::shared_ptr<helpers::GBMHelper> const gbm;
102  std::shared_ptr<VirtualTerminal> const vt;
103  std::shared_ptr<DisplayReport> const listener;
104  mir::udev::Monitor monitor;
105  helpers::EGLHelper shared_egl;
106  std::vector<std::unique_ptr<DisplayBuffer>> display_buffers;
107  RealKMSOutputContainer output_container;
108  mutable RealKMSDisplayConfiguration current_display_configuration;
109  mutable std::atomic<bool> dirty_configuration;
110 
111  BypassOption bypass_option;
112  std::weak_ptr<Cursor> cursor;
113  std::shared_ptr<GLConfig> const gl_config;
114 };
115 
116 }
117 }
118 }
119 
120 #endif /* MIR_GRAPHICS_MESA_DISPLAY_H_ */
All things Mir.
Definition: atomic_callback.h:25
Definition: wrapper.h:120
Definition: real_kms_display_configuration.h:33
DisplaySyncGroup represents a group of displays that need to be output in unison as a single post() c...
Definition: display.h:55
std::function< bool()> DisplayResumeHandler
Definition: display.h:41
Definition: display_helpers.h:102
unsigned int width
Definition: touchspot_image.c:4
Definition: real_kms_output_container.h:34
std::function< bool()> DisplayPauseHandler
Definition: display.h:38
Definition: rectangle.h:33
unsigned int height
Definition: touchspot_image.c:5
Definition: display.h:61
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
BypassOption
Definition: platform_common.h:29

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