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 
36 class GLConfig;
37 
38 namespace X
39 {
40 
42 {
43 public:
44  X11EGLDisplay(::Display* x_dpy);
46 
47  operator EGLDisplay() const;
48 
49 private:
50  EGLDisplay const egl_dpy;
51 };
52 
53 class X11Window
54 {
55 public:
56  X11Window(::Display* const x_dpy,
57  EGLDisplay egl_dpy,
58  geometry::Size const size,
59  GLConfig const& gl_config);
60  ~X11Window();
61 
62  operator Window() const;
63  EGLConfig egl_config() const;
64  unsigned long red_mask() const;
65 
66 private:
67  ::Display* const x_dpy;
68  Window win;
69  EGLConfig config;
70  unsigned long r_mask;
71 };
72 
74 {
75 public:
76  X11EGLContext(EGLDisplay egl_dpy, EGLConfig config);
77  ~X11EGLContext();
78 
79  operator EGLContext() const;
80 
81 private:
82  EGLContext egl_ctx;
83  EGLDisplay const egl_dpy;
84 };
85 
87 {
88 public:
89  X11EGLSurface(EGLDisplay egl_dpy, EGLConfig config, Window win);
90  ~X11EGLSurface();
91 
92  operator EGLSurface() const;
93 
94 private:
95  EGLDisplay const egl_dpy;
96  EGLSurface const egl_surf;
97 };
98 
99 class Display : public graphics::Display
100 {
101 public:
102  explicit Display(::Display* x_dpy,
103  geometry::Size const size,
104  GLConfig const& gl_config);
105  ~Display() noexcept;
106 
107  void for_each_display_sync_group(std::function<void(graphics::DisplaySyncGroup&)> const& f) override;
108 
109  std::unique_ptr<graphics::DisplayConfiguration> configuration() const override;
110  void configure(graphics::DisplayConfiguration const&) override;
111 
112  void register_configuration_change_handler(
113  EventHandlerRegister& handlers,
114  DisplayConfigurationChangeHandler const& conf_change_handler) override;
115 
116  void register_pause_resume_handlers(
117  EventHandlerRegister& handlers,
118  DisplayPauseHandler const& pause_handler,
119  DisplayResumeHandler const& resume_handler) override;
120 
121  void pause() override;
122  void resume() override;
123 
124  std::shared_ptr<Cursor> create_hardware_cursor(std::shared_ptr<CursorImage> const& initial_image) override;
125  std::unique_ptr<graphics::GLContext> create_gl_context() override;
126  std::unique_ptr<VirtualOutput> create_virtual_output(int width, int height) override;
127 
128 private:
129  X11EGLDisplay const egl_display;
131  float pixel_width;
132  float pixel_height;
133  X11Window const win;
134  X11EGLContext egl_context;
135  X11EGLSurface egl_surface;
136  MirPixelFormat pf;
137  std::unique_ptr<DisplayGroup> display_group;
138  MirOrientation orientation; //TODO: keep entire current display configuration
139 };
140 
141 }
142 
143 }
144 }
145 #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:53
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:164
Interface for customizing aspects of the GL config used by the server.
Definition: gl_config.h:30
Definition: display.h:73
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:41
unsigned int height
Definition: touchspot_image.c:5
detail::IntWrapper< struct XTag > X
Definition: dimensions.h:111
Definition: display.h:86
Definition: display.h:99
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:168
Definition: event_handler_register.h:32

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016