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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_ANDROID_DISPLAY_H_
20 #define MIR_GRAPHICS_ANDROID_DISPLAY_H_
21 
22 #include "mir/graphics/display.h"
23 #include "gl_context.h"
24 #include "display_group.h"
25 #include "hwc_configuration.h"
26 #include "display_configuration.h"
27 #include "overlay_optimization.h"
28 
29 #include <memory>
30 #include <mutex>
31 #include <array>
32 
33 namespace mir
34 {
35 namespace gl { class ProgramFactory; }
36 namespace graphics
37 {
38 
39 class DisplayReport;
40 class GLConfig;
41 
42 namespace android
43 {
44 class DisplayComponentFactory;
45 class DisplaySupportProvider;
46 class ConfigurableDisplayBuffer;
47 class DisplayChangePipe;
48 class DisplayDevice;
49 
50 class Display : public graphics::Display
51 {
52 public:
53  explicit Display(
54  std::shared_ptr<DisplayComponentFactory> const& display_buffer_builder,
55  std::shared_ptr<gl::ProgramFactory> const& gl_program_factory,
56  std::shared_ptr<GLConfig> const& gl_config,
57  std::shared_ptr<DisplayReport> const& display_report,
58  OverlayOptimization overlay_option);
59  ~Display() noexcept;
60 
61  void for_each_display_sync_group(std::function<void(graphics::DisplaySyncGroup&)> const& f) override;
62 
63  std::unique_ptr<graphics::DisplayConfiguration> configuration() const override;
64  void configure(graphics::DisplayConfiguration const&) override;
65 
67  EventHandlerRegister& handlers,
68  DisplayConfigurationChangeHandler const& conf_change_handler) override;
69 
71  EventHandlerRegister& handlers,
72  DisplayPauseHandler const& pause_handler,
73  DisplayResumeHandler const& resume_handler) override;
74 
75  void pause() override;
76  void resume() override;
77 
78  std::shared_ptr<Cursor> create_hardware_cursor(std::shared_ptr<CursorImage> const& initial_image) override;
79  std::unique_ptr<graphics::GLContext> create_gl_context() override;
80 
81 private:
82  void on_hotplug();
83  void on_vsync(DisplayName) const;
84 
85  geometry::Point const origin{0,0};
86  std::shared_ptr<DisplayReport> const display_report;
87  std::shared_ptr<DisplayComponentFactory> const display_buffer_builder;
88  std::mutex mutable configuration_mutex;
89  bool mutable configuration_dirty{false};
90  std::unique_ptr<HwcConfiguration> const hwc_config;
91  ConfigChangeSubscription const hotplug_subscription;
92  DisplayConfiguration mutable config;
93  PbufferGLContext gl_context;
94  std::shared_ptr<DisplayDevice> display_device;
95  std::unique_ptr<DisplayChangePipe> display_change_pipe;
96  std::shared_ptr<gl::ProgramFactory> const gl_program_factory;
97  DisplayGroup mutable displays;
98  OverlayOptimization const overlay_option;
99 
100  void update_configuration(std::lock_guard<decltype(configuration_mutex)> const&) const;
101 };
102 
103 }
104 }
105 }
106 #endif /* MIR_GRAPHICS_ANDROID_DISPLAY_H_ */
All things Mir.
Definition: atomic_callback.h:25
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.
Definition: display.cpp:303
Definition: point.h:30
void resume() override
Resumes the display.
Definition: display.cpp:314
std::shared_ptr< Cursor > create_hardware_cursor(std::shared_ptr< CursorImage > const &initial_image) override
Create a hardware cursor object.
DisplaySyncGroup represents a group of displays that need to be output in unison as a single post() c...
Definition: display.h:54
std::shared_ptr< void > ConfigChangeSubscription
Definition: hwc_configuration.h:35
OverlayOptimization
Definition: overlay_optimization.h:28
DisplayName
Definition: display_name.h:31
std::unique_ptr< graphics::DisplayConfiguration > configuration() const override
Gets a copy of the current output configuration.
Definition: display.cpp:228
std::function< bool()> DisplayResumeHandler
Definition: display.h:40
~Display() noexcept
Definition: display.cpp:198
Definition: gl_context.h:64
void register_configuration_change_handler(EventHandlerRegister &handlers, DisplayConfigurationChangeHandler const &conf_change_handler) override
Registers a handler for display configuration changes.
Definition: display.cpp:293
void for_each_display_sync_group(std::function< void(graphics::DisplaySyncGroup &)> const &f) override
std::function< bool()> DisplayPauseHandler
Definition: display.h:37
Definition: display.h:50
Definition: display_configuration.h:31
std::unique_ptr< graphics::GLContext > create_gl_context() override
Creates a GLContext object that shares resources with the Display's GL context.
Definition: display.cpp:323
Definition: android_input_receiver.h:36
void pause() override
Pauses the display.
Definition: display.cpp:310
Definition: display_group.h:38
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
void configure(graphics::DisplayConfiguration const &) override
Sets a new output configuration.
Definition: display.cpp:235

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