| 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/embedder/embedder.h"
11
12 #include "flutter/shell/platform/linux/fl_renderable.h"
13 #include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.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 to make the OpenGL context
41 * current.
42 * @renderer: an #FlRenderer.
43 */
44 void (*make_current)(FlRenderer* renderer);
45
46 /**
47 * Virtual method called when Flutter needs to make the OpenGL resource
48 * context current.
49 * @renderer: an #FlRenderer.
50 */
51 void (*make_resource_current)(FlRenderer* renderer);
52
53 /**
54 * Virtual method called when Flutter needs to clear the OpenGL context.
55 * @renderer: an #FlRenderer.
56 */
57 void (*clear_current)(FlRenderer* renderer);
58 };
59
60 /**
61 * fl_renderer_set_engine:
62 * @renderer: an #FlRenderer.
63 * @engine: an #FlEngine.
64 *
65 * Called when the renderer is connected to an engine.
66 */
67 void fl_renderer_set_engine(FlRenderer* renderer, FlEngine* engine);
68
69 /**
70 * fl_renderer_add_renderable:
71 * @renderer: an #FlRenderer.
72 * @view_id: the ID of the view.
73 * @renderable: object that is to be rendered on.
74 *
75 * Add a view to render on.
76 */
77 void fl_renderer_add_renderable(FlRenderer* renderer,
78 FlutterViewId view_id,
79 FlRenderable* renderable);
80
81 /**
82 * fl_renderer_remove_view:
83 * @renderer: an #FlRenderer.
84 * @view_id: the ID of the view.
85 *
86 * Remove a view from the renderer.
87 */
88 void fl_renderer_remove_view(FlRenderer* renderer, FlutterViewId view_id);
89
90 /**
91 * fl_renderer_get_proc_address:
92 * @renderer: an #FlRenderer.
93 * @name: a function name.
94 *
95 * Gets the rendering API function that matches the given name.
96 *
97 * Returns: a function pointer.
98 */
99 void* fl_renderer_get_proc_address(FlRenderer* renderer, const char* name);
100
101 /**
102 * fl_renderer_make_current:
103 * @renderer: an #FlRenderer.
104 *
105 * Makes the rendering context current.
106 */
107 void fl_renderer_make_current(FlRenderer* renderer);
108
109 /**
110 * fl_renderer_make_resource_current:
111 * @renderer: an #FlRenderer.
112 *
113 * Makes the resource rendering context current.
114 */
115 void fl_renderer_make_resource_current(FlRenderer* renderer);
116
117 /**
118 * fl_renderer_clear_current:
119 * @renderer: an #FlRenderer.
120 *
121 * Clears the current rendering context.
122 */
123 void fl_renderer_clear_current(FlRenderer* renderer);
124
125 /**
126 * fl_renderer_get_fbo:
127 * @renderer: an #FlRenderer.
128 *
129 * Gets the frame buffer object to render to.
130 *
131 * Returns: a frame buffer object index.
132 */
133 guint32 fl_renderer_get_fbo(FlRenderer* renderer);
134
135 /**
136 * fl_renderer_create_backing_store:
137 * @renderer: an #FlRenderer.
138 * @config: backing store config.
139 * @backing_store_out: saves created backing store.
140 *
141 * Obtain a backing store for a specific #FlutterLayer.
142 *
143 * Returns %TRUE if successful.
144 */
145 gboolean fl_renderer_create_backing_store(
146 FlRenderer* renderer,
147 const FlutterBackingStoreConfig* config,
148 FlutterBackingStore* backing_store_out);
149
150 /**
151 * fl_renderer_collect_backing_store:
152 * @renderer: an #FlRenderer.
153 * @backing_store: backing store to be released.
154 *
155 * A callback invoked by the engine to release the backing store. The
156 * embedder may collect any resources associated with the backing store.
157 *
158 * Returns %TRUE if successful.
159 */
160 gboolean fl_renderer_collect_backing_store(
161 FlRenderer* renderer,
162 const FlutterBackingStore* backing_store);
163
164 /**
165 * fl_renderer_present_layers:
166 * @renderer: an #FlRenderer.
167 * @view_id: view to present.
168 * @layers: layers to be composited.
169 * @layers_count: number of layers.
170 *
171 * Callback invoked by the engine to composite the contents of each layer
172 * onto the screen.
173 *
174 * Returns %TRUE if successful.
175 */
176 gboolean fl_renderer_present_layers(FlRenderer* renderer,
177 FlutterViewId view_id,
178 const FlutterLayer** layers,
179 size_t layers_count);
180
181 /**
182 * fl_renderer_wait_for_frame:
183 * @renderer: an #FlRenderer.
184 * @target_width: width of frame being waited for
185 * @target_height: height of frame being waited for
186 *
187 * Holds the thread until frame with requested dimensions is presented.
188 * While waiting for frame Flutter platform and raster tasks are being
189 * processed.
190 */
191 void fl_renderer_wait_for_frame(FlRenderer* renderer,
192 int target_width,
193 int target_height);
194
195 /**
196 * fl_renderer_setup:
197 * @renderer: an #FlRenderer.
198 *
199 * Creates OpenGL resources required before rendering. Requires an active OpenGL
200 * context.
201 */
202 void fl_renderer_setup(FlRenderer* renderer);
203
204 /**
205 * fl_renderer_render:
206 * @renderer: an #FlRenderer.
207 * @view_id: view to render.
208 * @width: width of the window in pixels.
209 * @height: height of the window in pixels.
210 * @background_color: color to use for background.
211 *
212 * Performs OpenGL commands to render current Flutter view.
213 */
214 void fl_renderer_render(FlRenderer* renderer,
215 FlutterViewId view_id,
216 int width,
217 int height,
218 const GdkRGBA* background_color);
219
220 /**
221 * fl_renderer_cleanup:
222 *
223 * Removes OpenGL resources used for rendering. Requires an active OpenGL
224 * context.
225 */
226 void fl_renderer_cleanup(FlRenderer* renderer);
227
228 G_END_DECLS
229
230 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_H_
FL_RENDERER_ERROR_FAILED
@ FL_RENDERER_ERROR_FAILED
Definition: fl_renderer.h:23
fl_renderer_error_quark
GQuark fl_renderer_error_quark(void) G_GNUC_CONST
fl_renderer_get_fbo
guint32 fl_renderer_get_fbo(FlRenderer *renderer)
Definition: fl_renderer.cc:384
G_DECLARE_DERIVABLE_TYPE
G_BEGIN_DECLS G_DECLARE_DERIVABLE_TYPE(FlAccessibleNode, fl_accessible_node, FL, ACCESSIBLE_NODE, AtkObject)
fl_renderer_remove_view
void fl_renderer_remove_view(FlRenderer *renderer, FlutterViewId view_id)
Definition: fl_renderer.cc:354
fl_renderer_add_renderable
void fl_renderer_add_renderable(FlRenderer *renderer, FlutterViewId view_id, FlRenderable *renderable)
Definition: fl_renderer.cc:341
fl_renderer_create_backing_store
gboolean fl_renderer_create_backing_store(FlRenderer *renderer, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_renderer.cc:391
fl_renderer_cleanup
void fl_renderer_cleanup(FlRenderer *renderer)
Definition: fl_renderer.cc:608
fl_renderable.h
fl_renderer_wait_for_frame
void fl_renderer_wait_for_frame(FlRenderer *renderer, int target_width, int target_height)
Definition: fl_renderer.cc:433
_FlRendererClass
Definition: fl_renderer.h:36
fl_renderer_set_engine
void fl_renderer_set_engine(FlRenderer *renderer, FlEngine *engine)
Definition: fl_renderer.cc:332
FL
FL
Definition: fl_binary_messenger.cc:27
fl_renderer_render
void fl_renderer_render(FlRenderer *renderer, FlutterViewId view_id, int width, int height, const GdkRGBA *background_color)
Definition: fl_renderer.cc:585
_FlRendererClass::parent_class
GObjectClass parent_class
Definition: fl_renderer.h:37
fl_renderer_clear_current
void fl_renderer_clear_current(FlRenderer *renderer)
Definition: fl_renderer.cc:379
fl_renderer_setup
void fl_renderer_setup(FlRenderer *renderer)
Definition: fl_renderer.cc:567
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
fl_renderer_present_layers
gboolean fl_renderer_present_layers(FlRenderer *renderer, FlutterViewId view_id, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderer.cc:453
fl_engine.h
FlRendererError
FlRendererError
Definition: fl_renderer.h:22
fl_renderer_make_resource_current
void fl_renderer_make_resource_current(FlRenderer *renderer)
Definition: fl_renderer.cc:374
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:423
fl_renderer_get_proc_address
void * fl_renderer_get_proc_address(FlRenderer *renderer, const char *name)
Definition: fl_renderer.cc:363
fl_renderer_make_current
void fl_renderer_make_current(FlRenderer *renderer)
Definition: fl_renderer.cc:369