Flutter Linux Embedder
fl_opengl_frame.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_OPENGL_FRAME_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_FL_OPENGL_FRAME_H_
7 
8 #include <gtk/gtk.h>
9 
10 #include "flutter/shell/platform/embedder/embedder.h"
12 
13 G_BEGIN_DECLS
14 
15 G_DECLARE_FINAL_TYPE(FlOpenGLFrame, fl_opengl_frame, FL, OPENGL_FRAME, GObject)
16 
17 /**
18  * FlOpenGLFrame:
19  *
20  * #FlOpenGLFrame manages the OpenGL framebuffer a rendered frame is composited
21  * into and presented from.
22  *
23  * When the frame can be shared between OpenGL contexts (EGL) the framebuffer is
24  * presented directly. Otherwise (GLX) the composited frame is copied into a CPU
25  * buffer so it can be re-uploaded in the presenting context.
26  */
27 
28 /**
29  * fl_opengl_frame_new:
30  *
31  * Creates a new object that manages the framebuffer and CPU pixel copy a
32  * rendered frame is composited into.
33  *
34  * Returns: a new #FlOpenGLFrame.
35  */
36 FlOpenGLFrame* fl_opengl_frame_new();
37 
38 /**
39  * fl_opengl_frame_composite:
40  * @frame: an #FlOpenGLFrame.
41  * @compositor: the #FlCompositorOpenGL to composite with.
42  * @layers: layers to composite.
43  * @layers_count: number of layers.
44  *
45  * Composites @layers into the frame, (re)creating the underlying framebuffer to
46  * match the frame size and copying the result into CPU memory. Must be called
47  * with an OpenGL context current.
48  */
49 void fl_opengl_frame_composite(FlOpenGLFrame* frame,
50  FlCompositorOpenGL* compositor,
51  const FlutterLayer** layers,
52  size_t layers_count);
53 
54 /**
55  * fl_opengl_frame_get_size:
56  * @frame: an #FlOpenGLFrame.
57  * @width: (out): location for the width in pixels.
58  * @height: (out): location for the height in pixels.
59  *
60  * Gets the size of the current frame in pixels. The size is zero if no frame
61  * has been composited yet.
62  */
63 void fl_opengl_frame_get_size(FlOpenGLFrame* frame,
64  size_t* width,
65  size_t* height);
66 
67 /**
68  * fl_opengl_frame_draw:
69  * @frame: an #FlOpenGLFrame.
70  * @cr: the Cairo context to draw into.
71  * @window: the #GdkWindow being drawn.
72  * @scale_factor: the window scale factor.
73  * @width: the width to draw in pixels.
74  * @height: the height to draw in pixels.
75  *
76  * Draws the current frame into @cr. Must be called with an OpenGL context
77  * current.
78  *
79  * Returns: %TRUE if a frame was drawn.
80  */
81 gboolean fl_opengl_frame_draw(FlOpenGLFrame* frame,
82  cairo_t* cr,
83  GdkWindow* window,
84  gint scale_factor,
85  size_t width,
86  size_t height);
87 
88 G_END_DECLS
89 
90 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_OPENGL_FRAME_H_
G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(FlAccessibilityChannel, fl_accessibility_channel, FL, ACCESSIBILITY_CHANNEL, GObject)
G_BEGIN_DECLS FlOpenGLFrame * fl_opengl_frame_new()
void fl_opengl_frame_composite(FlOpenGLFrame *frame, FlCompositorOpenGL *compositor, const FlutterLayer **layers, size_t layers_count)
gboolean fl_opengl_frame_draw(FlOpenGLFrame *frame, cairo_t *cr, GdkWindow *window, gint scale_factor, size_t width, size_t height)
void fl_opengl_frame_get_size(FlOpenGLFrame *frame, size_t *width, size_t *height)
const uint8_t uint32_t uint32_t * height
const uint8_t uint32_t * width
const FlutterLayer size_t layers_count
const FlutterLayer ** layers