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 
15 G_BEGIN_DECLS
16 
17 /**
18  * FlRendererError:
19  * Errors for #FlRenderer objects to set on failures.
20  */
21 
22 typedef enum {
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 
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_present:
191  * @renderer: an #FlRenderer.
192  * @error: (allow-none): #GError location to store the error occurring, or %NULL
193  * to ignore.
194  *
195  * Presents the current frame.
196  *
197  * Returns %TRUE if successful.
198  */
199 gboolean fl_renderer_present(FlRenderer* renderer, GError** error);
200 
201 /**
202  * fl_renderer_create_backing_store:
203  * @renderer: an #FlRenderer.
204  * @config: backing store config.
205  * @backing_store_out: saves created backing store.
206  *
207  * Obtain a backing store for a specific #FlutterLayer.
208  *
209  * Returns %TRUE if successful.
210  */
212  FlRenderer* renderer,
213  const FlutterBackingStoreConfig* config,
214  FlutterBackingStore* backing_store_out);
215 
216 /**
217  * fl_renderer_collect_backing_store:
218  * @renderer: an #FlRenderer.
219  * @backing_store: backing store to be released.
220  *
221  * A callback invoked by the engine to release the backing store. The
222  * embedder may collect any resources associated with the backing store.
223  *
224  * Returns %TRUE if successful.
225  */
227  FlRenderer* renderer,
228  const FlutterBackingStore* backing_store);
229 
230 /**
231  * fl_renderer_present_layers:
232  * @renderer: an #FlRenderer.
233  * @layers: layers to be composited.
234  * @layers_count: number of layers.
235  *
236  * Callback invoked by the engine to composite the contents of each layer
237  * onto the screen.
238  *
239  * Returns %TRUE if successful.
240  */
241 gboolean fl_renderer_present_layers(FlRenderer* renderer,
242  const FlutterLayer** layers,
243  size_t layers_count);
244 
245 /**
246  * fl_renderer_wait_for_frame:
247  * @renderer: an #FlRenderer.
248  * @target_width: width of frame being waited for
249  * @target_height: height of frame being waited for
250  *
251  * Holds the thread until frame with requested dimensions is presented.
252  * While waiting for frame Flutter platform and raster tasks are being
253  * processed.
254  */
255 void fl_renderer_wait_for_frame(FlRenderer* renderer,
256  int target_width,
257  int target_height);
258 
259 G_END_DECLS
260 
261 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_H_
gboolean fl_renderer_clear_current(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:114
const uint8_t uint32_t uint32_t GError ** error
GObjectClass parent_class
Definition: fl_renderer.h:37
gboolean fl_renderer_make_current(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:94
void fl_renderer_wait_for_frame(FlRenderer *renderer, int target_width, int target_height)
Definition: fl_renderer.cc:143
gboolean fl_renderer_start(FlRenderer *renderer, FlView *view, GError **error)
Definition: fl_renderer.cc:59
gboolean fl_renderer_present(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:124
FlView * fl_renderer_get_view(FlRenderer *renderer)
Definition: fl_renderer.cc:78
gboolean fl_renderer_collect_backing_store(FlRenderer *renderer, const FlutterBackingStore *backing_store)
Definition: fl_renderer.cc:136
GdkGLContext * fl_renderer_get_context(FlRenderer *renderer)
Definition: fl_renderer.cc:84
FlRendererError
Definition: fl_renderer.h:22
GQuark fl_renderer_error_quark(void) G_GNUC_CONST
guint32 fl_renderer_get_fbo(FlRenderer *renderer)
Definition: fl_renderer.cc:119
void * fl_renderer_get_proc_address(FlRenderer *renderer, const char *name)
Definition: fl_renderer.cc:90
gboolean fl_renderer_present_layers(FlRenderer *renderer, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderer.cc:160
gboolean fl_renderer_create_backing_store(FlRenderer *renderer, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_renderer.cc:128
gboolean fl_renderer_make_resource_current(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:104
const char * name
Definition: fuchsia.cc:50
FlView * view
G_BEGIN_DECLS FL
G_BEGIN_DECLS G_DECLARE_DERIVABLE_TYPE(FlTextInputPlugin, fl_text_input_plugin, FL, TEXT_INPUT_PLUGIN, GObject)