| 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 #GdkGLContext to render.
43 * @renderer: an #FlRenderer.
44 * @widget: the widget being rendered on.
45 * @visible: (out): the GL context for visible surface.
46 * @resource: (out): the GL context for resource loading.
47 * @error: (allow-none): #GError location to store the error occurring, or
48 * %NULL to ignore.
49 *
50 * Returns: %TRUE if both contexts were created, %FALSE if there was an error.
51 */
52 gboolean (*create_contexts)(FlRenderer* renderer,
53 GtkWidget* widget,
54 GdkGLContext** visible,
55 GdkGLContext** resource,
56 GError** error);
57
58 /**
59 * Virtual method called when Flutter needs OpenGL proc address.
60 * @renderer: an #FlRenderer.
61 * @name: proc name.
62 *
63 * Returns: OpenGL proc address.
64 */
65 void* (*get_proc_address)();
66
67 /**
68 * Virtual method called when Flutter needs a backing store for a specific
69 * #FlutterLayer.
70 * @renderer: an #FlRenderer.
71 * @config: backing store config.
72 * @backing_store_out: saves created backing store.
73 *
74 * Returns %TRUE if successful.
75 */
76 gboolean (*create_backing_store)(FlRenderer* renderer,
77 const FlutterBackingStoreConfig* config,
78 FlutterBackingStore* backing_store_out);
79
80 /**
81 * Virtual method called when Flutter wants to release the backing store.
82 * @renderer: an #FlRenderer.
83 * @backing_store: backing store to be released.
84 *
85 * Returns %TRUE if successful.
86 */
87 gboolean (*collect_backing_store)(FlRenderer* renderer,
88 const FlutterBackingStore* backing_store);
89
90 /**
91 * Virtual method called when Flutter wants to composite layers onto the
92 * screen.
93 * @renderer: an #FlRenderer.
94 * @layers: layers to be composited.
95 * @layers_count: number of layers.
96 *
97 * Returns %TRUE if successful.
98 */
99 gboolean (*present_layers)(FlRenderer* renderer,
100 const FlutterLayer** layers,
101 size_t layers_count);
102 };
103
104 /**
105 * fl_renderer_start:
106 * @renderer: an #FlRenderer.
107 * @view: the view Flutter is renderering to.
108 * @error: (allow-none): #GError location to store the error occurring, or %NULL
109 * to ignore.
110 *
111 * Start the renderer.
112 *
113 * Returns: %TRUE if successfully started.
114 */
115 gboolean fl_renderer_start(FlRenderer* renderer, FlView* view, GError** error);
116
117 /**
118 * fl_renderer_get_view:
119 * @renderer: an #FlRenderer.
120 *
121 * Returns: targeted #FlView or %NULL if headless.
122 */
123 FlView* fl_renderer_get_view(FlRenderer* renderer);
124
125 /**
126 * fl_renderer_get_context:
127 * @renderer: an #FlRenderer.
128 *
129 * Returns: GL context for GLAreas or %NULL if headless.
130 */
131 GdkGLContext* fl_renderer_get_context(FlRenderer* renderer);
132
133 /**
134 * fl_renderer_get_proc_address:
135 * @renderer: an #FlRenderer.
136 * @name: a function name.
137 *
138 * Gets the rendering API function that matches the given name.
139 *
140 * Returns: a function pointer.
141 */
142 void* fl_renderer_get_proc_address(FlRenderer* renderer, const char* name);
143
144 /**
145 * fl_renderer_make_current:
146 * @renderer: an #FlRenderer.
147 * @error: (allow-none): #GError location to store the error occurring, or %NULL
148 * to ignore.
149 *
150 * Makes the rendering context current.
151 *
152 * Returns %TRUE if successful.
153 */
154 gboolean fl_renderer_make_current(FlRenderer* renderer, GError** error);
155
156 /**
157 * fl_renderer_make_resource_current:
158 * @renderer: an #FlRenderer.
159 * @error: (allow-none): #GError location to store the error occurring, or %NULL
160 * to ignore.
161 *
162 * Makes the resource rendering context current.
163 *
164 * Returns %TRUE if successful.
165 */
166 gboolean fl_renderer_make_resource_current(FlRenderer* renderer,
167 GError** error);
168
169 /**
170 * fl_renderer_clear_current:
171 * @renderer: an #FlRenderer.
172 * @error: (allow-none): #GError location to store the error occurring, or %NULL
173 * to ignore.
174 *
175 * Clears the current rendering context.
176 *
177 * Returns %TRUE if successful.
178 */
179 gboolean fl_renderer_clear_current(FlRenderer* renderer, GError** error);
180
181 /**
182 * fl_renderer_get_fbo:
183 * @renderer: an #FlRenderer.
184 *
185 * Gets the frame buffer object to render to.
186 *
187 * Returns: a frame buffer object index.
188 */
189 guint32 fl_renderer_get_fbo(FlRenderer* renderer);
190
191 /**
192 * fl_renderer_create_backing_store:
193 * @renderer: an #FlRenderer.
194 * @config: backing store config.
195 * @backing_store_out: saves created backing store.
196 *
197 * Obtain a backing store for a specific #FlutterLayer.
198 *
199 * Returns %TRUE if successful.
200 */
201 gboolean fl_renderer_create_backing_store(
202 FlRenderer* renderer,
203 const FlutterBackingStoreConfig* config,
204 FlutterBackingStore* backing_store_out);
205
206 /**
207 * fl_renderer_collect_backing_store:
208 * @renderer: an #FlRenderer.
209 * @backing_store: backing store to be released.
210 *
211 * A callback invoked by the engine to release the backing store. The
212 * embedder may collect any resources associated with the backing store.
213 *
214 * Returns %TRUE if successful.
215 */
216 gboolean fl_renderer_collect_backing_store(
217 FlRenderer* renderer,
218 const FlutterBackingStore* backing_store);
219
220 /**
221 * fl_renderer_present_layers:
222 * @renderer: an #FlRenderer.
223 * @layers: layers to be composited.
224 * @layers_count: number of layers.
225 *
226 * Callback invoked by the engine to composite the contents of each layer
227 * onto the screen.
228 *
229 * Returns %TRUE if successful.
230 */
231 gboolean fl_renderer_present_layers(FlRenderer* renderer,
232 const FlutterLayer** layers,
233 size_t layers_count);
234
235 /**
236 * fl_renderer_wait_for_frame:
237 * @renderer: an #FlRenderer.
238 * @target_width: width of frame being waited for
239 * @target_height: height of frame being waited for
240 *
241 * Holds the thread until frame with requested dimensions is presented.
242 * While waiting for frame Flutter platform and raster tasks are being
243 * processed.
244 */
245 void fl_renderer_wait_for_frame(FlRenderer* renderer,
246 int target_width,
247 int target_height);
248
249 G_END_DECLS
250
251 #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_make_resource_current
gboolean fl_renderer_make_resource_current(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:105
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:157
fl_renderer_get_fbo
guint32 fl_renderer_get_fbo(FlRenderer *renderer)
Definition: fl_renderer.cc:120
fl_renderer_create_backing_store
gboolean fl_renderer_create_backing_store(FlRenderer *renderer, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_renderer.cc:125
fl_renderer_clear_current
gboolean fl_renderer_clear_current(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:115
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:140
_FlRendererClass
Definition: fl_renderer.h:38
fl_renderer_start
gboolean fl_renderer_start(FlRenderer *renderer, FlView *view, GError **error)
Definition: fl_renderer.cc:59
FL
FL
Definition: fl_binary_messenger.cc:27
_FlRendererClass::parent_class
GObjectClass parent_class
Definition: fl_renderer.h:39
fl_view.h
fl_renderer_make_current
gboolean fl_renderer_make_current(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:95
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
FlRendererError
FlRendererError
Definition: fl_renderer.h:22
fl_renderer_get_view
FlView * fl_renderer_get_view(FlRenderer *renderer)
Definition: fl_renderer.cc:79
fl_renderer_get_context
GdkGLContext * fl_renderer_get_context(FlRenderer *renderer)
Definition: fl_renderer.cc:85
fl_renderer_collect_backing_store
gboolean fl_renderer_collect_backing_store(FlRenderer *renderer, const FlutterBackingStore *backing_store)
Definition: fl_renderer.cc:133
fl_renderer_get_proc_address
void * fl_renderer_get_proc_address(FlRenderer *renderer, const char *name)
Definition: fl_renderer.cc:91