Flutter Linux Embedder
fl_subsurface_egl.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_SUBSURFACE_EGL_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_FL_SUBSURFACE_EGL_H_
7 
8 #include <epoxy/gl.h>
9 #include <gtk/gtk.h>
10 
14 
15 G_BEGIN_DECLS
16 
17 G_DECLARE_FINAL_TYPE(FlSubsurfaceEGL,
18  fl_subsurface_egl,
19  FL,
20  SUBSURFACE_EGL,
21  GObject)
22 
23 /**
24  * FlSubsurfaceEGL:
25  *
26  * #FlSubsurfaceEGL manages the EGL context and window surface used to present
27  * engine frames onto a Wayland subsurface. Its context shares resources with
28  * the engine's render context, so the engine's frame texture can be blitted to
29  * the subsurface directly, without using EGLImage.
30  */
31 
32 /**
33  * fl_subsurface_egl_new:
34  * @opengl_manager: the #FlOpenGLManager providing the engine's EGL display and
35  * share context.
36  * @subsurface: the #FlSubsurface to present onto.
37  * @width: the surface width in logical pixels.
38  * @height: the surface height in logical pixels.
39  * @scale: the surface buffer scale.
40  *
41  * Creates the EGL context and window surface for presenting frames onto
42  * @subsurface. A reference is kept on @subsurface, so its Wayland surface is
43  * guaranteed to outlive the EGL surface created here. If this fails a warning
44  * is printed and the returned object will fail to present frames, generating
45  * the usual EGL/OpenGL errors.
46  *
47  * Returns: a new #FlSubsurfaceEGL.
48  */
49 FlSubsurfaceEGL* fl_subsurface_egl_new(FlOpenGLManager* opengl_manager,
50  FlSubsurface* subsurface,
51  size_t width,
52  size_t height,
53  gint scale);
54 
55 /**
56  * fl_subsurface_egl_resize:
57  * @egl: an #FlSubsurfaceEGL.
58  * @width: the new width in pixels.
59  * @height: the new height in pixels.
60  *
61  * Resizes the native Wayland window backing the EGL surface.
62  */
63 void fl_subsurface_egl_resize(FlSubsurfaceEGL* egl,
64  size_t width,
65  size_t height);
66 
67 /**
68  * fl_subsurface_egl_present:
69  * @egl: an #FlSubsurfaceEGL.
70  * @texture_id: the OpenGL texture holding the frame to present.
71  * @width: the frame width in pixels.
72  * @height: the frame height in pixels.
73  * @fence: (allow-none): an #FlGLFence reached when @texture_id has finished
74  * rendering, or %NULL if the rendering is known to have completed.
75  *
76  * Blits @texture_id to the subsurface window surface and swaps buffers, then
77  * restores the engine's rendering context. @texture_id must have been rendered
78  * by the engine (or a context sharing resources with it).
79  *
80  * The frame is presented using the subsurface's own context, so @fence is
81  * waited for once that context is current.
82  */
83 void fl_subsurface_egl_present(FlSubsurfaceEGL* egl,
84  GLuint texture_id,
85  size_t width,
86  size_t height,
87  FlGLFence* fence);
88 
89 G_END_DECLS
90 
91 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_SUBSURFACE_EGL_H_
FlSubsurfaceEGL * fl_subsurface_egl_new(FlOpenGLManager *opengl_manager, FlSubsurface *subsurface, size_t width, size_t height, gint scale)
G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(FlSubsurfaceEGL, fl_subsurface_egl, FL, SUBSURFACE_EGL, GObject) FlSubsurfaceEGL *fl_subsurface_egl_new(FlOpenGLManager *opengl_manager
G_BEGIN_DECLS FlSubsurface size_t width
G_BEGIN_DECLS FlSubsurface size_t size_t height
void fl_subsurface_egl_resize(FlSubsurfaceEGL *egl, size_t width, size_t height)
void fl_subsurface_egl_present(FlSubsurfaceEGL *egl, GLuint texture_id, size_t width, size_t height, FlGLFence *fence)
G_BEGIN_DECLS FlSubsurface size_t size_t gint scale
G_BEGIN_DECLS FlSubsurface * subsurface
int64_t texture_id