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 <EGL/egl.h>
9 #include <gtk/gtk.h>
10 
11 #include "flutter/shell/platform/linux/public/flutter_linux/fl_dart_project.h"
12 #include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"
13 
14 G_BEGIN_DECLS
15 
16 /**
17  * FlRendererError:
18  * Errors for #FlRenderer objects to set on failures.
19  */
20 
21 typedef enum {
24 
25 GQuark fl_renderer_error_quark(void) G_GNUC_CONST;
26 
27 G_DECLARE_DERIVABLE_TYPE(FlRenderer, fl_renderer, FL, RENDERER, GObject)
28 
29 /**
30  * FlRenderer:
31  *
32  * #FlRenderer is an abstract class that allows Flutter to draw pixels.
33  */
34 
36  GObjectClass parent_class;
37 
38  /**
39  * Virtual method called before creating a GdkWindow for the widget.
40  * Does not need to be implemented.
41  * @renderer: an #FlRenderer.
42  * @widget: the widget being rendered on.
43  * @display: display to create surfaces on.
44  * @config: EGL configuration.
45  * @window_attributes: window attributes to modify.
46  * @mask: (out): the window mask to use.
47  * @error: (allow-none): #GError location to store the error occurring, or
48  * %NULL to ignore.
49  *
50  * Returns: %TRUE if the window is successfully set up.
51  */
52  gboolean (*setup_window_attr)(FlRenderer* renderer,
53  GtkWidget* widget,
54  EGLDisplay display,
55  EGLConfig config,
56  GdkWindowAttr* window_attributes,
57  gint* mask,
58  GError** error);
59 
60  /**
61  * Virtual method to create a new EGL display.
62  */
63  EGLDisplay (*create_display)(FlRenderer* renderer);
64 
65  /**
66  * Virtual method called when Flutter needs surfaces to render to.
67  * @renderer: an #FlRenderer.
68  * @widget: the widget being rendered on.
69  * @display: display to create surfaces on.
70  * @config: EGL configuration.
71  * @visible: (out): the visible surface that is created.
72  * @resource: (out): the resource surface that is created.
73  * @error: (allow-none): #GError location to store the error occurring, or
74  * %NULL to ignore.
75  *
76  * Returns: %TRUE if both surfaces were created, %FALSE if there was an error.
77  */
78  gboolean (*create_surfaces)(FlRenderer* renderer,
79  GtkWidget* widget,
80  EGLDisplay display,
81  EGLConfig config,
82  EGLSurface* visible,
83  EGLSurface* resource,
84  GError** error);
85 
86  /**
87  * Virtual method called when the EGL window needs to be resized.
88  * Does not need to be implemented.
89  */
90  void (*set_geometry)(FlRenderer* renderer,
91  GdkRectangle* geometry,
92  gint scale);
93 };
94 
95 /**
96  * fl_renderer_start:
97  * @renderer: an #FlRenderer.
98  * @widget: the widget Flutter is renderering to.
99  * @error: (allow-none): #GError location to store the error occurring, or %NULL
100  * to ignore.
101  *
102  * Start the renderer.
103  *
104  * Returns: %TRUE if successfully started.
105  */
106 gboolean fl_renderer_start(FlRenderer* renderer,
107  GtkWidget* widget,
108  GError** error);
109 
110 /**
111  * fl_renderer_set_geometry:
112  * @renderer: an #FlRenderer.
113  * @geometry: New size and position (unscaled) of the EGL window.
114  * @scale: Scale of the window.
115  */
116 void fl_renderer_set_geometry(FlRenderer* renderer,
117  GdkRectangle* geometry,
118  gint scale);
119 
120 /**
121  * fl_renderer_get_proc_address:
122  * @renderer: an #FlRenderer.
123  * @name: a function name.
124  *
125  * Gets the rendering API function that matches the given name.
126  *
127  * Returns: a function pointer.
128  */
129 void* fl_renderer_get_proc_address(FlRenderer* renderer, const char* name);
130 
131 /**
132  * fl_renderer_make_current:
133  * @renderer: an #FlRenderer.
134  * @error: (allow-none): #GError location to store the error occurring, or %NULL
135  * to ignore.
136  *
137  * Makes the rendering context current.
138  *
139  * Returns %TRUE if successful.
140  */
141 gboolean fl_renderer_make_current(FlRenderer* renderer, GError** error);
142 
143 /**
144  * fl_renderer_make_resource_current:
145  * @renderer: an #FlRenderer.
146  * @error: (allow-none): #GError location to store the error occurring, or %NULL
147  * to ignore.
148  *
149  * Makes the resource rendering context current.
150  *
151  * Returns %TRUE if successful.
152  */
153 gboolean fl_renderer_make_resource_current(FlRenderer* renderer,
154  GError** error);
155 
156 /**
157  * fl_renderer_clear_current:
158  * @renderer: an #FlRenderer.
159  * @error: (allow-none): #GError location to store the error occurring, or %NULL
160  * to ignore.
161  *
162  * Clears the current rendering context.
163  *
164  * Returns %TRUE if successful.
165  */
166 gboolean fl_renderer_clear_current(FlRenderer* renderer, GError** error);
167 
168 /**
169  * fl_renderer_get_fbo:
170  * @renderer: an #FlRenderer.
171  *
172  * Gets the frame buffer object to render to.
173  *
174  * Returns: a frame buffer object index.
175  */
176 guint32 fl_renderer_get_fbo(FlRenderer* renderer);
177 
178 /**
179  * fl_renderer_present:
180  * @renderer: an #FlRenderer.
181  * @error: (allow-none): #GError location to store the error occurring, or %NULL
182  * to ignore.
183  *
184  * Presents the current frame.
185  *
186  * Returns %TRUE if successful.
187  */
188 gboolean fl_renderer_present(FlRenderer* renderer, GError** error);
189 
190 G_END_DECLS
191 
192 #endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_RENDERER_H_
gboolean fl_renderer_clear_current(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:261
GObjectClass parent_class
Definition: fl_renderer.h:36
gboolean fl_renderer_make_current(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:216
FlMethodResponse GError ** error
gboolean fl_renderer_present(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:281
gboolean fl_renderer_start(FlRenderer *renderer, GtkWidget *widget, GError **error)
Definition: fl_renderer.cc:182
void fl_renderer_set_geometry(FlRenderer *renderer, GdkRectangle *geometry, gint scale)
Definition: fl_renderer.cc:202
FlRendererError
Definition: fl_renderer.h:21
GQuark fl_renderer_error_quark(void) G_GNUC_CONST
guint32 fl_renderer_get_fbo(FlRenderer *renderer)
Definition: fl_renderer.cc:276
void * fl_renderer_get_proc_address(FlRenderer *renderer, const char *name)
Definition: fl_renderer.cc:212
G_DECLARE_DERIVABLE_TYPE(FlMessageCodec, fl_message_codec, FL, MESSAGE_CODEC, GObject) struct _FlMessageCodecClass
gboolean fl_renderer_make_resource_current(FlRenderer *renderer, GError **error)
Definition: fl_renderer.cc:238
const char * name
Definition: fuchsia.cc:50
G_BEGIN_DECLS FL