| Flutter Linux Embedder |

fl_renderer.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_RENDERER_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_H_
7
8 #include <gtk/gtk.h>
9
10 #include "flutter/shell/platform/linux/public/flutter_linux/fl_dart_project.h"
11 #include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"
12
13 #include "flutter/shell/platform/embedder/embedder.h"
14
15 G_BEGIN_DECLS
16
17 /**
18 * FlRendererError:
19 * Errors for #FlRenderer objects to set on failures.
20 */
21
22 typedef enum {
23 // NOLINTBEGIN(readability-identifier-naming)
24 FL_RENDERER_ERROR_FAILED,
25 // NOLINTEND(readability-identifier-naming)
26 } FlRendererError;
27
28 GQuark fl_renderer_error_quark(void) G_GNUC_CONST;
29
30 G_DECLARE_DERIVABLE_TYPE(FlRenderer, fl_renderer, FL, RENDERER, GObject)
31
32 /**
33 * FlRenderer:
34 *
35 * #FlRenderer is an abstract class that allows Flutter to draw pixels.
36 */
37
38 struct _FlRendererClass {
39 GObjectClass parent_class;
40
41 /**
42 * Virtual method called when Flutter needs to make the OpenGL context
43 * current.
44 * @renderer: an #FlRenderer.
45 */
46 void (*make_current)(FlRenderer* renderer);
47
48 /**
49 * Virtual method called when Flutter needs to make the OpenGL resource
50 * context current.
51 * @renderer: an #FlRenderer.
52 */
53 void (*make_resource_current)(FlRenderer* renderer);
54
55 /**
56 * Virtual method called when Flutter needs to clear the OpenGL context.
57 * @renderer: an #FlRenderer.
58 */
59 void (*clear_current)(FlRenderer* renderer);
60
61 /**
62 * Virtual method called when Flutter needs a backing store for a specific
63 * #FlutterLayer.
64 * @renderer: an #FlRenderer.
65 * @config: backing store config.
66 * @backing_store_out: saves created backing store.
67 *
68 * Returns %TRUE if successful.
69 */
70 gboolean (*create_backing_store)(FlRenderer* renderer,
71 const FlutterBackingStoreConfig* config,
72 FlutterBackingStore* backing_store_out);
73
74 /**
75 * Virtual method called when Flutter wants to release the backing store.
76 * @renderer: an #FlRenderer.
77 * @backing_store: backing store to be released.
78 *
79 * Returns %TRUE if successful.
80 */
81 gboolean (*collect_backing_store)(FlRenderer* renderer,
82 const FlutterBackingStore* backing_store);
83 };
84
85 /**
86 * fl_renderer_start:
87 * @renderer: an #FlRenderer.
88 * @view: the view Flutter is renderering to.
89 *
90 * Start the renderer.
91 *
92 * Returns: %TRUE if successfully started.
93 */
94 gboolean fl_renderer_start(FlRenderer* renderer, FlView* view);
95
96 /**
97 * fl_renderer_get_proc_address:
98 * @renderer: an #FlRenderer.
99 * @name: a function name.
100 *
101 * Gets the rendering API function that matches the given name.
102 *
103 * Returns: a function pointer.
104 */
105 void* fl_renderer_get_proc_address(FlRenderer* renderer, const char* name);
106
107 /**
108 * fl_renderer_make_current:
109 * @renderer: an #FlRenderer.
110 *
111 * Makes the rendering context current.
112 */
113 void fl_renderer_make_current(FlRenderer* renderer);
114
115 /**
116 * fl_renderer_make_resource_current:
117 * @renderer: an #FlRenderer.
118 *
119 * Makes the resource rendering context current.
120 */
121 void fl_renderer_make_resource_current(FlRenderer* renderer);
122
123 /**
124 * fl_renderer_clear_current:
125 * @renderer: an #FlRenderer.
126 *
127 * Clears the current rendering context.
128 */
129 void fl_renderer_clear_current(FlRenderer* renderer);
130
131 /**
132 * fl_renderer_get_fbo:
133 * @renderer: an #FlRenderer.
134 *
135 * Gets the frame buffer object to render to.
136 *
137 * Returns: a frame buffer object index.
138 */
139 guint32 fl_renderer_get_fbo(FlRenderer* renderer);
140
141 /**
142 * fl_renderer_create_backing_store:
143 * @renderer: an #FlRenderer.
144 * @config: backing store config.
145 * @backing_store_out: saves created backing store.
146 *
147 * Obtain a backing store for a specific #FlutterLayer.
148 *
149 * Returns %TRUE if successful.
150 */
151 gboolean fl_renderer_create_backing_store(
152 FlRenderer* renderer,
153 const FlutterBackingStoreConfig* config,
154 FlutterBackingStore* backing_store_out);
155
156 /**
157 * fl_renderer_collect_backing_store:
158 * @renderer: an #FlRenderer.
159 * @backing_store: backing store to be released.
160 *
161 * A callback invoked by the engine to release the backing store. The
162 * embedder may collect any resources associated with the backing store.
163 *
164 * Returns %TRUE if successful.
165 */
166 gboolean fl_renderer_collect_backing_store(
167 FlRenderer* renderer,
168 const FlutterBackingStore* backing_store);
169
170 /**
171 * fl_renderer_present_layers:
172 * @renderer: an #FlRenderer.
173 * @layers: layers to be composited.
174 * @layers_count: number of layers.
175 *
176 * Callback invoked by the engine to composite the contents of each layer
177 * onto the screen.
178 *
179 * Returns %TRUE if successful.
180 */
181 gboolean fl_renderer_present_layers(FlRenderer* renderer,
182 const FlutterLayer** layers,
183 size_t layers_count);
184
185 /**
186 * fl_renderer_wait_for_frame:
187 * @renderer: an #FlRenderer.
188 * @target_width: width of frame being waited for
189 * @target_height: height of frame being waited for
190 *
191 * Holds the thread until frame with requested dimensions is presented.
192 * While waiting for frame Flutter platform and raster tasks are being
193 * processed.
194 */
195 void fl_renderer_wait_for_frame(FlRenderer* renderer,
196 int target_width,
197 int target_height);
198
199 /**
200 * fl_renderer_setup:
201 * @renderer: an #FlRenderer.
202 *
203 * Creates OpenGL resources required before rendering. Requires an active OpenGL
204 * context.
205 */
206 void fl_renderer_setup(FlRenderer* renderer);
207
208 /**
209 * fl_renderer_render:
210 * @renderer: an #FlRenderer.
211 * @width: width of the window in pixels.
212 * @height: height of the window in pixels.
213 *
214 * Performs OpenGL commands to render current Flutter view.
215 */
216 void fl_renderer_render(FlRenderer* renderer, int width, int height);
217
218 /**
219 * fl_renderer_cleanup:
220 *
221 * Removes OpenGL resources used for rendering. Requires an active OpenGL
222 * context.
223 */
224 void fl_renderer_cleanup(FlRenderer* renderer);
225
226 G_END_DECLS
227
228 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_H_
G_DECLARE_DERIVABLE_TYPE
G_DECLARE_DERIVABLE_TYPE(FlAccessibleNode, fl_accessible_node, FL, ACCESSIBLE_NODE, AtkObject)
FL_RENDERER_ERROR_FAILED
@ FL_RENDERER_ERROR_FAILED
Definition: fl_renderer.h:24
fl_renderer_error_quark
GQuark fl_renderer_error_quark(void) G_GNUC_CONST
fl_renderer_present_layers
gboolean fl_renderer_present_layers(FlRenderer *renderer, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderer.cc:221
fl_renderer_get_fbo
guint32 fl_renderer_get_fbo(FlRenderer *renderer)
Definition: fl_renderer.cc:156
height
G_BEGIN_DECLS int height
Definition: fl_backing_store_provider.h:37
fl_renderer_render
void fl_renderer_render(FlRenderer *renderer, int width, int height)
Definition: fl_renderer.cc:311
fl_renderer_create_backing_store
gboolean fl_renderer_create_backing_store(FlRenderer *renderer, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_renderer.cc:163
fl_renderer_cleanup
void fl_renderer_cleanup(FlRenderer *renderer)
Definition: fl_renderer.cc:369
fl_dart_project.h
fl_renderer_wait_for_frame
void fl_renderer_wait_for_frame(FlRenderer *renderer, int target_width, int target_height)
Definition: fl_renderer.cc:202
_FlRendererClass
Definition: fl_renderer.h:38
fl_renderer_start
gboolean fl_renderer_start(FlRenderer *renderer, FlView *view)
Definition: fl_renderer.cc:125
FL
FL
Definition: fl_binary_messenger.cc:27
_FlRendererClass::parent_class
GObjectClass parent_class
Definition: fl_renderer.h:39
fl_renderer_clear_current
void fl_renderer_clear_current(FlRenderer *renderer)
Definition: fl_renderer.cc:151
fl_view.h
fl_renderer_setup
void fl_renderer_setup(FlRenderer *renderer)
Definition: fl_renderer.cc:269
FlRendererError
FlRendererError
Definition: fl_renderer.h:22
fl_renderer_make_resource_current
void fl_renderer_make_resource_current(FlRenderer *renderer)
Definition: fl_renderer.cc:146
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38
fl_renderer_collect_backing_store
gboolean fl_renderer_collect_backing_store(FlRenderer *renderer, const FlutterBackingStore *backing_store)
Definition: fl_renderer.cc:192
fl_renderer_get_proc_address
void * fl_renderer_get_proc_address(FlRenderer *renderer, const char *name)
Definition: fl_renderer.cc:135
fl_renderer_make_current
void fl_renderer_make_current(FlRenderer *renderer)
Definition: fl_renderer.cc:141