| 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 * Virtual method called when Flutter wants to get the refresh rate of the
86 * renderer.
87 * @renderer: an #FlRenderer.
88 *
89 * Returns: The refresh rate of the display in Hz. If the refresh rate is
90 * not available, returns -1.0.
91 */
92 gdouble (*get_refresh_rate)(FlRenderer* renderer);
93 };
94
95 /**
96 * fl_renderer_start:
97 * @renderer: an #FlRenderer.
98 * @view: the view Flutter is renderering to.
99 *
100 * Start the renderer.
101 *
102 * Returns: %TRUE if successfully started.
103 */
104 gboolean fl_renderer_start(FlRenderer* renderer, FlView* view);
105
106 /**
107 * fl_renderer_get_proc_address:
108 * @renderer: an #FlRenderer.
109 * @name: a function name.
110 *
111 * Gets the rendering API function that matches the given name.
112 *
113 * Returns: a function pointer.
114 */
115 void* fl_renderer_get_proc_address(FlRenderer* renderer, const char* name);
116
117 /**
118 * fl_renderer_make_current:
119 * @renderer: an #FlRenderer.
120 *
121 * Makes the rendering context current.
122 */
123 void fl_renderer_make_current(FlRenderer* renderer);
124
125 /**
126 * fl_renderer_make_resource_current:
127 * @renderer: an #FlRenderer.
128 *
129 * Makes the resource rendering context current.
130 */
131 void fl_renderer_make_resource_current(FlRenderer* renderer);
132
133 /**
134 * fl_renderer_clear_current:
135 * @renderer: an #FlRenderer.
136 *
137 * Clears the current rendering context.
138 */
139 void fl_renderer_clear_current(FlRenderer* renderer);
140
141 /**
142 * fl_renderer_get_fbo:
143 * @renderer: an #FlRenderer.
144 *
145 * Gets the frame buffer object to render to.
146 *
147 * Returns: a frame buffer object index.
148 */
149 guint32 fl_renderer_get_fbo(FlRenderer* renderer);
150
151 /**
152 * fl_renderer_create_backing_store:
153 * @renderer: an #FlRenderer.
154 * @config: backing store config.
155 * @backing_store_out: saves created backing store.
156 *
157 * Obtain a backing store for a specific #FlutterLayer.
158 *
159 * Returns %TRUE if successful.
160 */
161 gboolean fl_renderer_create_backing_store(
162 FlRenderer* renderer,
163 const FlutterBackingStoreConfig* config,
164 FlutterBackingStore* backing_store_out);
165
166 /**
167 * fl_renderer_collect_backing_store:
168 * @renderer: an #FlRenderer.
169 * @backing_store: backing store to be released.
170 *
171 * A callback invoked by the engine to release the backing store. The
172 * embedder may collect any resources associated with the backing store.
173 *
174 * Returns %TRUE if successful.
175 */
176 gboolean fl_renderer_collect_backing_store(
177 FlRenderer* renderer,
178 const FlutterBackingStore* backing_store);
179
180 /**
181 * fl_renderer_present_layers:
182 * @renderer: an #FlRenderer.
183 * @layers: layers to be composited.
184 * @layers_count: number of layers.
185 *
186 * Callback invoked by the engine to composite the contents of each layer
187 * onto the screen.
188 *
189 * Returns %TRUE if successful.
190 */
191 gboolean fl_renderer_present_layers(FlRenderer* renderer,
192 const FlutterLayer** layers,
193 size_t layers_count);
194
195 /**
196 * fl_renderer_wait_for_frame:
197 * @renderer: an #FlRenderer.
198 * @target_width: width of frame being waited for
199 * @target_height: height of frame being waited for
200 *
201 * Holds the thread until frame with requested dimensions is presented.
202 * While waiting for frame Flutter platform and raster tasks are being
203 * processed.
204 */
205 void fl_renderer_wait_for_frame(FlRenderer* renderer,
206 int target_width,
207 int target_height);
208
209 /**
210 * fl_renderer_setup:
211 * @renderer: an #FlRenderer.
212 *
213 * Creates OpenGL resources required before rendering. Requires an active OpenGL
214 * context.
215 */
216 void fl_renderer_setup(FlRenderer* renderer);
217
218 /**
219 * fl_renderer_render:
220 * @renderer: an #FlRenderer.
221 * @width: width of the window in pixels.
222 * @height: height of the window in pixels.
223 *
224 * Performs OpenGL commands to render current Flutter view.
225 */
226 void fl_renderer_render(FlRenderer* renderer, int width, int height);
227
228 /**
229 * fl_renderer_cleanup:
230 *
231 * Removes OpenGL resources used for rendering. Requires an active OpenGL
232 * context.
233 */
234 void fl_renderer_cleanup(FlRenderer* renderer);
235
236 /**
237 * fl_renderer_get_refresh_rate:
238 * @renderer: an #FlRenderer.
239 *
240 * Returns: The refresh rate of the display in Hz. If the refresh rate is
241 * not available, returns -1.0.
242 */
243 gdouble fl_renderer_get_refresh_rate(FlRenderer* renderer);
244
245 G_END_DECLS
246
247 #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:230
fl_renderer_get_fbo
guint32 fl_renderer_get_fbo(FlRenderer *renderer)
Definition: fl_renderer.cc:165
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:320
fl_renderer_create_backing_store
gboolean fl_renderer_create_backing_store(FlRenderer *renderer, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_renderer.cc:172
fl_renderer_cleanup
void fl_renderer_cleanup(FlRenderer *renderer)
Definition: fl_renderer.cc:392
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:211
_FlRendererClass
Definition: fl_renderer.h:38
fl_renderer_start
gboolean fl_renderer_start(FlRenderer *renderer, FlView *view)
Definition: fl_renderer.cc:129
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:155
fl_view.h
fl_renderer_setup
void fl_renderer_setup(FlRenderer *renderer)
Definition: fl_renderer.cc:278
FlRendererError
FlRendererError
Definition: fl_renderer.h:22
fl_renderer_make_resource_current
void fl_renderer_make_resource_current(FlRenderer *renderer)
Definition: fl_renderer.cc:150
fl_renderer_get_refresh_rate
gdouble fl_renderer_get_refresh_rate(FlRenderer *renderer)
Definition: fl_renderer.cc:160
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:201
fl_renderer_get_proc_address
void * fl_renderer_get_proc_address(FlRenderer *renderer, const char *name)
Definition: fl_renderer.cc:139
fl_renderer_make_current
void fl_renderer_make_current(FlRenderer *renderer)
Definition: fl_renderer.cc:145