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 "wayland_surface.h"
21 
22 #include <EGL/egl.h>
23 
24 #include <memory>
25 #include <vector>
26 
27 class MirEglApp;
28 class MirEglSurface;
29 
30 std::shared_ptr<MirEglApp> make_mir_eglapp(struct wl_display* display);
31 std::vector<std::shared_ptr<MirEglSurface>> mir_surface_init(std::shared_ptr<MirEglApp> const& app);
32 
34 {
35 public:
36  MirEglSurface(std::shared_ptr<MirEglApp> const& mir_egl_app, struct wl_output* wl_output);
37 
39 
40  template<typename Painter>
41  void paint(Painter const& functor)
42  {
43  egl_make_current();
44  functor(width_, height_);
45  swap_buffers();
46  }
47 
48 private:
49  void egl_make_current();
50 
51  void swap_buffers();
52 
53  std::shared_ptr<MirEglApp> const mir_egl_app;
54 
55  void* content_area = nullptr;
56  struct wl_callback* new_frame_signal = nullptr;
57  struct Buffers
58  {
59  struct wl_buffer* buffer;
60  bool available;
61  } buffers[4];
62  bool waiting_for_buffer = true;
63 
64  EGLSurface eglsurface;
65  int width_{0};
66  int height_{0};
67 
68  static void shell_surface_ping(void *data, struct wl_shell_surface *wl_shell_surface, uint32_t serial);
69 
70  static void shell_surface_configure(void *data,
71  struct wl_shell_surface *wl_shell_surface,
72  uint32_t edges,
73  int32_t width,
74  int32_t height);
75  static void shell_surface_popup_done(void *data, struct wl_shell_surface *wl_shell_surface);
76 
77 };
78 
79 #endif //UNITYSYSTEMCOMPOSITOR_MIREGL_H
Definition: miregl.h:34
void paint(Painter const &functor)
Definition: miregl.h:41
MirEglSurface(std::shared_ptr< MirEglApp > const &mir_egl_app, struct wl_output *wl_output)
Definition: miregl.cpp:76
~MirEglSurface()
Definition: miregl.cpp:93
Definition: wayland_surface.h:28
auto app() const -> WaylandApp const *
Definition: wayland_surface.h:38
std::vector< std::shared_ptr< MirEglSurface > > mir_surface_init(std::shared_ptr< MirEglApp > const &app)
Definition: miregl.cpp:64
std::shared_ptr< MirEglApp > make_mir_eglapp(struct wl_display *display)
Definition: miregl.cpp:59

Copyright © 2012-2021 Canonical Ltd.
Generated on Wed Mar 31 08:25:47 UTC 2021
This documentation is licensed under the GPL version 2 or 3.