Mir
miregl.h
Go to the documentation of this file.
1/*
2 * Copyright © 2015-2018 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * under the terms of the GNU General Public License version 2 or 3 as
6 * 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITYSYSTEMCOMPOSITOR_MIREGL_H
18#define UNITYSYSTEMCOMPOSITOR_MIREGL_H
19
20#include <EGL/egl.h>
21
22#include <memory>
23#include <vector>
24
25class MirEglApp;
26class MirEglSurface;
27
28std::shared_ptr<MirEglApp> make_mir_eglapp(struct wl_display* display);
29std::vector<std::shared_ptr<MirEglSurface>> mir_surface_init(std::shared_ptr<MirEglApp> const& app);
30
32{
33public:
34 MirEglSurface(std::shared_ptr<MirEglApp> const& mir_egl_app, struct wl_output* wl_output);
35
37
38 template<typename Painter>
39 void paint(Painter const& functor)
40 {
41 egl_make_current();
42 functor(width(), height());
43 swap_buffers();
44 }
45
46private:
47 void egl_make_current();
48
49 void swap_buffers();
50 unsigned int width() const;
51 unsigned int height() const;
52
53 std::shared_ptr<MirEglApp> const mir_egl_app;
54
55 void* content_area = nullptr;
56 struct wl_display* display = nullptr;
57 struct wl_surface* surface = nullptr;
58 struct wl_callback* new_frame_signal = nullptr;
59 struct wl_shell_surface* window = nullptr;
60 struct Buffers
61 {
62 struct wl_buffer* buffer;
63 bool available;
64 } buffers[4];
65 bool waiting_for_buffer = true;
66
67 EGLSurface eglsurface;
68 int width_{640};
69 int height_{480};
70
71 static void shell_surface_ping(void *data, struct wl_shell_surface *wl_shell_surface, uint32_t serial);
72
73 static void shell_surface_configure(void *data,
74 struct wl_shell_surface *wl_shell_surface,
75 uint32_t edges,
76 int32_t width,
77 int32_t height);
78 static void shell_surface_popup_done(void *data, struct wl_shell_surface *wl_shell_surface);
79
80};
81
82#endif //UNITYSYSTEMCOMPOSITOR_MIREGL_H
Definition: miregl.h:32
void paint(Painter const &functor)
Definition: miregl.h:39
MirEglSurface(std::shared_ptr< MirEglApp > const &mir_egl_app, struct wl_output *wl_output)
Definition: miregl.cpp:202
~MirEglSurface()
Definition: miregl.cpp:225
int width
Definition: client_types.h:1
int height
Definition: client_types.h:2
std::vector< std::shared_ptr< MirEglSurface > > mir_surface_init(std::shared_ptr< MirEglApp > const &app)
Definition: miregl.cpp:190
std::shared_ptr< MirEglApp > make_mir_eglapp(struct wl_display *display)
Definition: miregl.cpp:185

Copyright © 2012-2022 Canonical Ltd.
Generated on Sat 3 Dec 14:36:51 UTC 2022
This documentation is licensed under the GPL version 2 or 3.