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 "hwc_configuration.h"
25 #include "display_configuration.h"
26 #include "overlay_optimization.h"
27 
28 #include <memory>
29 #include <mutex>
30 #include <array>
31 
32 namespace mir
33 {
34 namespace graphics
35 {
36 
37 class DisplayReport;
38 class GLConfig;
39 class GLProgramFactory;
40 
41 namespace android
42 {
43 class DisplayComponentFactory;
44 class DisplaySupportProvider;
45 class ConfigurableDisplayBuffer;
46 class DisplayChangePipe;
47 
48 class Display : public graphics::Display
49 {
50 public:
51  explicit Display(
52  std::shared_ptr<DisplayComponentFactory> const& display_buffer_builder,
53  std::shared_ptr<GLProgramFactory> const& gl_program_factory,
54  std::shared_ptr<GLConfig> const& gl_config,
55  std::shared_ptr<DisplayReport> const& display_report,
56  OverlayOptimization overlay_option);
57  ~Display() noexcept;
58 
59  void for_each_display_buffer(std::function<void(graphics::DisplayBuffer&)> const& f) override;
60 
61  std::unique_ptr<graphics::DisplayConfiguration> configuration() const override;
62  void configure(graphics::DisplayConfiguration const&) override;
63 
65  EventHandlerRegister& handlers,
66  DisplayConfigurationChangeHandler const& conf_change_handler) override;
67 
69  EventHandlerRegister& handlers,
70  DisplayPauseHandler const& pause_handler,
71  DisplayResumeHandler const& resume_handler) override;
72 
73  void pause() override;
74  void resume() override;
75 
76  std::shared_ptr<Cursor> create_hardware_cursor(std::shared_ptr<CursorImage> const& initial_image) override;
77  std::unique_ptr<graphics::GLContext> create_gl_context() override;
78 
79 private:
80  void on_hotplug();
81 
82  std::shared_ptr<DisplayComponentFactory> const display_buffer_builder;
83  std::mutex mutable configuration_mutex;
84  bool mutable configuration_dirty{false};
85  std::unique_ptr<HwcConfiguration> const hwc_config;
86  ConfigChangeSubscription const hotplug_subscription;
87  DisplayAttribs const primary_attribs; //TODO: could be removed, really only useful in construction
88  DisplayConfiguration mutable config;
89  PbufferGLContext gl_context;
90  std::unique_ptr<ConfigurableDisplayBuffer> const display_buffer;
91  std::unique_ptr<DisplayChangePipe> display_change_pipe;
92 };
93 
94 }
95 }
96 }
97 #endif /* MIR_GRAPHICS_ANDROID_DISPLAY_H_ */
All things Mir.
Definition: buffer_stream.h:37
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:210
Interface to an output framebuffer.
Definition: display_buffer.h:38
void resume() override
Resumes the display.
Definition: display.cpp:221
std::shared_ptr< Cursor > create_hardware_cursor(std::shared_ptr< CursorImage > const &initial_image) override
Create a hardware cursor object.
std::shared_ptr< void > ConfigChangeSubscription
Definition: hwc_configuration.h:45
void for_each_display_buffer(std::function< void(graphics::DisplayBuffer &)> const &f) override
OverlayOptimization
Definition: overlay_optimization.h:28
std::unique_ptr< graphics::DisplayConfiguration > configuration() const override
Gets a copy of the current output configuration.
Definition: display.cpp:149
std::function< bool()> DisplayResumeHandler
Definition: display.h:39
~Display() noexcept
Definition: display.cpp:135
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:200
Definition: hwc_configuration.h:35
std::function< bool()> DisplayPauseHandler
Definition: display.h:36
Definition: display.h:48
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:230
Definition: android_input_receiver.h:32
void pause() override
Pauses the display.
Definition: display.cpp:217
Interface to the display subsystem.
Definition: display.h:45
std::function< void()> DisplayConfigurationChangeHandler
Definition: display.h:40
Interface to a configuration of display cards and outputs.
Definition: display_configuration.h:159
Definition: event_handler_register.h:31
void configure(graphics::DisplayConfiguration const &) override
Sets a new output configuration.
Definition: display.cpp:163

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015