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: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIR_GRAPHICS_DISPLAY_H_
20 #define MIR_GRAPHICS_DISPLAY_H_
21 
22 #include <memory>
23 #include <functional>
24 #include <chrono>
25 
26 namespace mir
27 {
28 
29 namespace graphics
30 {
31 
32 class DisplayBuffer;
33 class DisplayConfiguration;
34 class Cursor;
35 class CursorImage;
36 class GLContext;
38 
39 typedef std::function<bool()> DisplayPauseHandler;
40 typedef std::function<bool()> DisplayResumeHandler;
41 typedef std::function<void()> DisplayConfigurationChangeHandler;
42 
55 {
56 public:
60  virtual void for_each_display_buffer(std::function<void(DisplayBuffer&)> const& f) = 0;
61 
66  virtual void post() = 0;
67 
75  virtual std::chrono::milliseconds recommended_sleep() const = 0;
76 
77  virtual ~DisplaySyncGroup() = default;
78 protected:
79  DisplaySyncGroup() = default;
80  DisplaySyncGroup(DisplaySyncGroup const&) = delete;
82 };
83 
87 class Display
88 {
89 public:
93  virtual void for_each_display_sync_group(std::function<void(DisplaySyncGroup&)> const& f) = 0;
94 
98  virtual std::unique_ptr<DisplayConfiguration> configuration() const = 0;
99 
103  virtual void configure(DisplayConfiguration const& conf) = 0;
104 
115  EventHandlerRegister& handlers,
116  DisplayConfigurationChangeHandler const& conf_change_handler) = 0;
117 
124  virtual void register_pause_resume_handlers(
125  EventHandlerRegister& handlers,
126  DisplayPauseHandler const& pause_handler,
127  DisplayResumeHandler const& resume_handler) = 0;
128 
135  virtual void pause() = 0;
136 
140  virtual void resume() = 0;
141 
145  virtual std::shared_ptr<Cursor> create_hardware_cursor(std::shared_ptr<CursorImage> const& initial_image) = 0;
146 
153  virtual std::unique_ptr<GLContext> create_gl_context() = 0;
154 
155 protected:
156  Display() = default;
157  virtual ~Display() {/* TODO: make nothrow */}
158 private:
159  Display(Display const&) = delete;
160  Display& operator=(Display const&) = delete;
161 };
162 }
163 }
164 
165 #endif /* MIR_GRAPHICS_DISPLAY_H_ */
virtual void pause()=0
Pauses the display.
All things Mir.
Definition: atomic_callback.h:25
virtual void resume()=0
Resumes the display.
virtual ~Display()
Definition: display.h:157
Interface to an output framebuffer.
Definition: display_buffer.h:47
DisplaySyncGroup represents a group of displays that need to be output in unison as a single post() c...
Definition: display.h:54
virtual void register_configuration_change_handler(EventHandlerRegister &handlers, DisplayConfigurationChangeHandler const &conf_change_handler)=0
Registers a handler for display configuration changes.
virtual std::unique_ptr< DisplayConfiguration > configuration() const =0
Gets a copy of the current output configuration.
virtual void for_each_display_buffer(std::function< void(DisplayBuffer &)> const &f)=0
Executes a functor that allows the DisplayBuffer contents to be updated.
virtual void configure(DisplayConfiguration const &conf)=0
Sets a new output configuration.
std::function< bool()> DisplayResumeHandler
Definition: display.h:40
DisplaySyncGroup & operator=(DisplaySyncGroup const &)=delete
virtual void register_pause_resume_handlers(EventHandlerRegister &handlers, DisplayPauseHandler const &pause_handler, DisplayResumeHandler const &resume_handler)=0
Registers handlers for pausing and resuming the display subsystem.
std::function< bool()> DisplayPauseHandler
Definition: display.h:37
virtual ~DisplaySyncGroup()=default
virtual std::chrono::milliseconds recommended_sleep() const =0
Returns a recommendation to the compositor as to how long it should wait before sampling the scene fo...
virtual void post()=0
Post the content of the DisplayBuffers associated with this DisplaySyncGroup.
virtual std::shared_ptr< Cursor > create_hardware_cursor(std::shared_ptr< CursorImage > const &initial_image)=0
Create a hardware cursor object.
virtual void for_each_display_sync_group(std::function< void(DisplaySyncGroup &)> const &f)=0
Executes a functor for each output group.
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
virtual std::unique_ptr< GLContext > create_gl_context()=0
Creates a GLContext object that shares resources with the Display's GL context.
Definition: event_handler_register.h:31

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