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