Flutter Engine
The Flutter Engine
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
15G_BEGIN_DECLS
16
17/**
18 * FlRendererError:
19 * Errors for #FlRenderer objects to set on failures.
20 */
21
22typedef enum {
23 // NOLINTBEGIN(readability-identifier-naming)
25 // NOLINTEND(readability-identifier-naming)
27
28GQuark fl_renderer_error_quark(void) G_GNUC_CONST;
29
30G_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
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 */
104gboolean 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 */
115void* 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 */
123void 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 */
132
133/**
134 * fl_renderer_clear_current:
135 * @renderer: an #FlRenderer.
136 *
137 * Clears the current rendering context.
138 */
139void 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 */
149guint32 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 */
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 */
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 */
191gboolean 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 */
205void 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 */
216void 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 */
226void 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 */
234void 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 */
243gdouble fl_renderer_get_refresh_rate(FlRenderer* renderer);
244
245G_END_DECLS
246
247#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_H_
G_DECLARE_DERIVABLE_TYPE(FlAccessibleNode, fl_accessible_node, FL, ACCESSIBLE_NODE, AtkObject)
void fl_renderer_wait_for_frame(FlRenderer *renderer, int target_width, int target_height)
Definition: fl_renderer.cc:207
void * fl_renderer_get_proc_address(FlRenderer *renderer, const char *name)
Definition: fl_renderer.cc:135
void fl_renderer_make_current(FlRenderer *renderer)
Definition: fl_renderer.cc:141
gdouble fl_renderer_get_refresh_rate(FlRenderer *renderer)
Definition: fl_renderer.cc:156
void fl_renderer_clear_current(FlRenderer *renderer)
Definition: fl_renderer.cc:151
GQuark fl_renderer_error_quark(void) G_GNUC_CONST
void fl_renderer_setup(FlRenderer *renderer)
Definition: fl_renderer.cc:274
FlRendererError
Definition: fl_renderer.h:22
@ FL_RENDERER_ERROR_FAILED
Definition: fl_renderer.h:24
void fl_renderer_cleanup(FlRenderer *renderer)
Definition: fl_renderer.cc:388
void fl_renderer_render(FlRenderer *renderer, int width, int height)
Definition: fl_renderer.cc:316
gboolean fl_renderer_collect_backing_store(FlRenderer *renderer, const FlutterBackingStore *backing_store)
Definition: fl_renderer.cc:197
guint32 fl_renderer_get_fbo(FlRenderer *renderer)
Definition: fl_renderer.cc:161
gboolean fl_renderer_present_layers(FlRenderer *renderer, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderer.cc:226
gboolean fl_renderer_create_backing_store(FlRenderer *renderer, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_renderer.cc:168
gboolean fl_renderer_start(FlRenderer *renderer, FlView *view)
Definition: fl_renderer.cc:125
void fl_renderer_make_resource_current(FlRenderer *renderer)
Definition: fl_renderer.cc:146
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
int32_t height
int32_t width
GObjectClass parent_class
Definition: fl_renderer.h:39