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 
25 class MirEglApp;
26 class MirEglSurface;
27 
28 std::shared_ptr<MirEglApp> make_mir_eglapp(struct wl_display* display);
29 std::vector<std::shared_ptr<MirEglSurface>> mir_surface_init(std::shared_ptr<MirEglApp> const& app);
30 
32 {
33 public:
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 
46 private:
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
MirEglSurface::paint
void paint(Painter const &functor)
Definition: miregl.h:39
MirEglSurface
Definition: miregl.h:31
make_mir_eglapp
std::shared_ptr< MirEglApp > make_mir_eglapp(struct wl_display *display)
Definition: miregl.cpp:185
MirEglSurface::MirEglSurface
MirEglSurface(std::shared_ptr< MirEglApp > const &mir_egl_app, struct wl_output *wl_output)
Definition: miregl.cpp:202
height
int height
Definition: client_types.h:179
MirEglSurface::~MirEglSurface
~MirEglSurface()
Definition: miregl.cpp:225
mir_surface_init
std::vector< std::shared_ptr< MirEglSurface > > mir_surface_init(std::shared_ptr< MirEglApp > const &app)
Definition: miregl.cpp:190
width
int width
Definition: client_types.h:178

Copyright © 2012-2021 Canonical Ltd.
Generated on Fri Nov 19 11:53:53 UTC 2021
This documentation is licensed under the GPL version 2 or 3.