Mir
display.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 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: Cemil Azizoglu <cemil.azizoglu@canonical.com>
17  */
18 
19 #ifndef MIR_GRAPHICS_X_DISPLAY_H_
20 #define MIR_GRAPHICS_X_DISPLAY_H_
21 
22 #include "mir/graphics/display.h"
23 #include "mir_toolkit/common.h"
24 #include "display_group.h"
25 #include "mir/geometry/size.h"
26 
27 #include <X11/Xlib.h>
28 #include <X11/Xutil.h>
29 #include <EGL/egl.h>
30 
31 namespace mir
32 {
33 namespace graphics
34 {
35 namespace X
36 {
37 
39 {
40 public:
41  X11EGLDisplay(::Display* x_dpy);
43 
44  operator EGLDisplay() const;
45 
46 private:
47  EGLDisplay const egl_dpy;
48 };
49 
50 class X11Window
51 {
52 public:
53  X11Window(::Display* const x_dpy, EGLDisplay egl_dpy, mir::geometry::Size const size);
54  ~X11Window();
55 
56  operator Window() const;
57  EGLConfig egl_config() const;
58  unsigned int color_depth() const;
59 
60 private:
61  ::Display* const x_dpy;
62  Window win;
63  EGLConfig config;
64  unsigned int depth;
65 };
66 
68 {
69 public:
70  X11EGLContext(EGLDisplay egl_dpy, EGLConfig config);
72 
73  operator EGLContext() const;
74 
75 private:
76  EGLContext egl_ctx;
77  EGLDisplay const egl_dpy;
78 };
79 
81 {
82 public:
83  X11EGLSurface(EGLDisplay egl_dpy, EGLConfig config, Window win);
85 
86  operator EGLSurface() const;
87 
88 private:
89  EGLDisplay const egl_dpy;
90  EGLSurface const egl_surf;
91 };
92 
93 class Display : public graphics::Display
94 {
95 public:
96  explicit Display(::Display* x_dpy, mir::geometry::Size const size);
97  ~Display() noexcept;
98 
99  void for_each_display_sync_group(std::function<void(graphics::DisplaySyncGroup&)> const& f) override;
100 
101  std::unique_ptr<graphics::DisplayConfiguration> configuration() const override;
102  void configure(graphics::DisplayConfiguration const&) override;
103 
105  EventHandlerRegister& handlers,
106  DisplayConfigurationChangeHandler const& conf_change_handler) override;
107 
109  EventHandlerRegister& handlers,
110  DisplayPauseHandler const& pause_handler,
111  DisplayResumeHandler const& resume_handler) override;
112 
113  void pause() override;
114  void resume() override;
115 
116  std::shared_ptr<Cursor> create_hardware_cursor(std::shared_ptr<CursorImage> const& initial_image) override;
117  std::unique_ptr<graphics::GLContext> create_gl_context() override;
118 
119 private:
120  X11EGLDisplay const egl_display;
121  mir::geometry::Size const size;
122  X11Window const win;
123  X11EGLContext egl_context;
124  X11EGLSurface egl_surface;
125  MirPixelFormat pf;
126  std::unique_ptr<DisplayGroup> display_group;
127  MirOrientation orientation; //TODO: keep entire current display configuration
128 };
129 
130 }
131 }
132 }
133 #endif /* MIR_GRAPHICS_X_DISPLAY_H_ */
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
std::unique_ptr< graphics::DisplayConfiguration > configuration() const override
Gets a copy of the current output configuration.
void resume() override
Resumes the display.
DisplaySyncGroup represents a group of displays that need to be output in unison as a single post() c...
Definition: display.h:54
void configure(graphics::DisplayConfiguration const &) override
Sets a new output configuration.
void register_configuration_change_handler(EventHandlerRegister &handlers, DisplayConfigurationChangeHandler const &conf_change_handler) override
Registers a handler for display configuration changes.
X11EGLDisplay(::Display *x_dpy)
std::shared_ptr< Cursor > create_hardware_cursor(std::shared_ptr< CursorImage > const &initial_image) override
Create a hardware cursor object.
Definition: display.h:50
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:164
void for_each_display_sync_group(std::function< void(graphics::DisplaySyncGroup &)> const &f) override
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.h:67
std::function< bool()> DisplayResumeHandler
Definition: display.h:40
X11Window(::Display *const x_dpy, EGLDisplay egl_dpy, mir::geometry::Size const size)
MirPixelFormat
32-bit pixel formats (8888): The order of components in the enum matches the order of the components ...
Definition: common.h:134
std::function< bool()> DisplayPauseHandler
Definition: display.h:37
std::unique_ptr< graphics::GLContext > create_gl_context() override
Creates a GLContext object that shares resources with the Display's GL context.
Definition: display.h:38
unsigned int color_depth() const
X11EGLSurface(EGLDisplay egl_dpy, EGLConfig config, Window win)
EGLConfig egl_config() const
void pause() override
Pauses the display.
detail::IntWrapper< struct XTag > X
Definition: dimensions.h:111
Definition: display.h:80
X11EGLContext(EGLDisplay egl_dpy, EGLConfig config)
Definition: display.h:93
int const size
Definition: make_socket_rpc_channel.cpp:51
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

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