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);
71  ~X11EGLContext();
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);
84  ~X11EGLSurface();
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 
104  void register_configuration_change_handler(
105  EventHandlerRegister& handlers,
106  DisplayConfigurationChangeHandler const& conf_change_handler) override;
107 
108  void register_pause_resume_handlers(
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  std::unique_ptr<VirtualOutput> create_virtual_output(int width, int height) override;
119 
120 private:
121  X11EGLDisplay const egl_display;
123  X11Window const win;
124  X11EGLContext egl_context;
125  X11EGLSurface egl_surface;
126  MirPixelFormat pf;
127  std::unique_ptr<DisplayGroup> display_group;
128  MirOrientation orientation; //TODO: keep entire current display configuration
129 };
130 
131 }
132 }
133 }
134 #endif /* MIR_GRAPHICS_X_DISPLAY_H_ */
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
DisplaySyncGroup represents a group of displays that need to be output in unison as a single post() c...
Definition: display.h:55
X11EGLDisplay(::Display *x_dpy)
Definition: display.h:50
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:164
Definition: display.h:67
std::function< bool()> DisplayResumeHandler
Definition: display.h:41
unsigned int width
Definition: touchspot_image.c:4
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:38
Definition: display.h:38
unsigned int height
Definition: touchspot_image.c:5
detail::IntWrapper< struct XTag > X
Definition: dimensions.h:111
Definition: display.h:80
Definition: display.h:93
int const size
Definition: make_socket_rpc_channel.cpp:51
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

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