| Flutter Linux Embedder |

Classes | Enumerations | Functions
fl_renderer.h File Reference
`#include <gtk/gtk.h>`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_dart_project.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_view.h"`
`#include "flutter/shell/platform/embedder/embedder.h"`

Go to the source code of this file.

## Classes
struct | _FlRendererClass

## Enumerations
enum | FlRendererError { FL_RENDERER_ERROR_FAILED }

## Functions
GQuark | fl_renderer_error_quark (void) G_GNUC_CONST
gboolean | fl_renderer_start (FlRenderer *renderer, FlView *view, GError **error)
FlView * | fl_renderer_get_view (FlRenderer *renderer)
GdkGLContext * | fl_renderer_get_context (FlRenderer *renderer)
: a function name.
fl_renderer_get_proc_address: @renderer: an #FlRenderer. Gets the rendering API function that matches the given name. Returns: a function pointer.
void * | fl_renderer_get_proc_address (FlRenderer *renderer, const char *name)
gboolean | fl_renderer_make_current (FlRenderer *renderer, GError **error)
gboolean | fl_renderer_make_resource_current (FlRenderer *renderer, GError **error)
gboolean | fl_renderer_clear_current (FlRenderer *renderer, GError **error)
guint32 | fl_renderer_get_fbo (FlRenderer *renderer)
gboolean | fl_renderer_create_backing_store (FlRenderer *renderer, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
gboolean | fl_renderer_collect_backing_store (FlRenderer *renderer, const FlutterBackingStore *backing_store)
gboolean | fl_renderer_present_layers (FlRenderer *renderer, const FlutterLayer **layers, size_t layers_count)
void | fl_renderer_wait_for_frame (FlRenderer *renderer, int target_width, int target_height)

## Enumeration Type Documentation

## ◆ FlRendererError

enum FlRendererError

FlRendererError: Errors for #FlRenderer objects to set on failures.

Enumerator
FL_RENDERER_ERROR_FAILED |

Definition at line 22 of file fl_renderer.h.

22 {
23 FL_RENDERER_ERROR_FAILED,
24 } FlRendererError;

## Function Documentation

## ◆ fl_renderer_clear_current()

gboolean fl_renderer_clear_current | ( | FlRenderer * | renderer,
|  | GError ** | error
| ) |  |

fl_renderer_clear_current: @renderer: an #FlRenderer. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Clears the current rendering context.

Returns TRUE if successful.

Definition at line 115 of file fl_renderer.cc.

115 {
116 gdk_gl_context_clear_current();
117 return TRUE;
118 }

References TRUE.

Referenced by fl_engine_gl_clear_current().

## ◆ fl_renderer_collect_backing_store()

gboolean fl_renderer_collect_backing_store | ( | FlRenderer * | renderer,
|  | const FlutterBackingStore * | backing_store
| ) |  |

fl_renderer_collect_backing_store: @renderer: an #FlRenderer. @backing_store: backing store to be released.

A callback invoked by the engine to release the backing store. The embedder may collect any resources associated with the backing store.

Returns TRUE if successful.

Definition at line 133 of file fl_renderer.cc.

135 {
136 return FL_RENDERER_GET_CLASS(self)->collect_backing_store(self,
137 backing_store);
138 }

Referenced by compositor_collect_backing_store_callback().

## ◆ fl_renderer_create_backing_store()

gboolean fl_renderer_create_backing_store | ( | FlRenderer * | renderer,
|  | const FlutterBackingStoreConfig * | config,
|  | FlutterBackingStore * | backing_store_out
| ) |  |

fl_renderer_create_backing_store: @renderer: an #FlRenderer. @config: backing store config. @backing_store_out: saves created backing store.

Obtain a backing store for a specific #FlutterLayer.

Returns TRUE if successful.

Definition at line 125 of file fl_renderer.cc.

128 {
129 return FL_RENDERER_GET_CLASS(self)->create_backing_store(self, config,
130 backing_store_out);
131 }

Referenced by compositor_create_backing_store_callback().

## ◆ fl_renderer_error_quark()

GQuark fl_renderer_error_quark | ( | void |  | ) |

## ◆ fl_renderer_get_context()

GdkGLContext* fl_renderer_get_context | ( | FlRenderer * | renderer | ) |

fl_renderer_get_context: @renderer: an #FlRenderer.

Returns: GL context for GLAreas or NULL if headless.

Definition at line 85 of file fl_renderer.cc.

85 {
86 FlRendererPrivate* priv = reinterpret_cast<FlRendererPrivate*>(
87 fl_renderer_get_instance_private(self));
88 return priv->main_context;
89 }

References priv.

Referenced by fl_renderer_gl_present_layers().

## ◆ fl_renderer_get_fbo()

guint32 fl_renderer_get_fbo | ( | FlRenderer * | renderer | ) |

fl_renderer_get_fbo: @renderer: an #FlRenderer.

Gets the frame buffer object to render to.

Returns: a frame buffer object index.

Definition at line 120 of file fl_renderer.cc.

120 {
121 // There is only one frame buffer object - always return that.
122 return 0;
123 }

Referenced by fl_engine_gl_get_fbo().

## ◆ fl_renderer_get_proc_address()

void* fl_renderer_get_proc_address | ( | FlRenderer * | renderer,
|  | const char * | name
| ) |  |

Definition at line 91 of file fl_renderer.cc.

91 {
92 return reinterpret_cast<void*>(eglGetProcAddress(name));
93 }

Referenced by fl_engine_gl_proc_resolver().

## ◆ fl_renderer_get_view()

FlView* fl_renderer_get_view | ( | FlRenderer * | renderer | ) |

fl_renderer_get_view: @renderer: an #FlRenderer.

Returns: targeted #FlView or NULL if headless.

Definition at line 79 of file fl_renderer.cc.

79 {
80 FlRendererPrivate* priv = reinterpret_cast<FlRendererPrivate*>(
81 fl_renderer_get_instance_private(self));
82 return priv->view;
83 }

References priv.

Referenced by fl_renderer_gl_present_layers().

## ◆ fl_renderer_make_current()

gboolean fl_renderer_make_current | ( | FlRenderer * | renderer,
|  | GError ** | error
| ) |  |

fl_renderer_make_current: @renderer: an #FlRenderer. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Makes the rendering context current.

Returns TRUE if successful.

Definition at line 95 of file fl_renderer.cc.

95 {
96 FlRendererPrivate* priv = reinterpret_cast<FlRendererPrivate*>(
97 fl_renderer_get_instance_private(self));
98 if (priv->main_context) {
99 gdk_gl_context_make_current(priv->main_context);
100 }
101
102 return TRUE;
103 }

References priv, and TRUE.

Referenced by fl_engine_gl_make_current(), fl_renderer_gl_collect_backing_store(), and fl_renderer_gl_create_backing_store().

## ◆ fl_renderer_make_resource_current()

gboolean fl_renderer_make_resource_current | ( | FlRenderer * | renderer,
|  | GError ** | error
| ) |  |

fl_renderer_make_resource_current: @renderer: an #FlRenderer. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Makes the resource rendering context current.

Returns TRUE if successful.

Definition at line 105 of file fl_renderer.cc.

105 {
106 FlRendererPrivate* priv = reinterpret_cast<FlRendererPrivate*>(
107 fl_renderer_get_instance_private(self));
108 if (priv->resource_context) {
109 gdk_gl_context_make_current(priv->resource_context);
110 }
111
112 return TRUE;
113 }

References priv, and TRUE.

Referenced by fl_engine_gl_make_resource_current().

## ◆ fl_renderer_present_layers()

gboolean fl_renderer_present_layers | ( | FlRenderer * | renderer,
|  | const FlutterLayer ** | layers,
|  | size_t | layers_count
| ) |  |

fl_renderer_present_layers: @renderer: an #FlRenderer. @layers: layers to be composited. @layers_count: number of layers.

Callback invoked by the engine to composite the contents of each layer onto the screen.

Returns TRUE if successful.

Definition at line 157 of file fl_renderer.cc.

159 {
160 FlRendererPrivate* priv = reinterpret_cast<FlRendererPrivate*>(
161 fl_renderer_get_instance_private(self));
162
163 // ignore incoming frame with wrong dimensions in trivial case with just one
164 // layer
165 if (priv->blocking_main_thread && layers_count == 1 &&
166 layers[0]->offset.x == 0 && layers[0]->offset.y == 0 &&
167 (layers[0]->size.width != priv->target_width ||
168 layers[0]->size.height != priv->target_height)) {
169 return true;
170 }
171
172 priv->had_first_frame = true;
173
174 fl_renderer_unblock_main_thread(self);
175
176 return FL_RENDERER_GET_CLASS(self)->present_layers(self, layers,
177 layers_count);
178 }

References fl_renderer_unblock_main_thread(), and priv.

Referenced by compositor_present_layers_callback().

## ◆ fl_renderer_start()

gboolean fl_renderer_start | ( | FlRenderer * | renderer,
|  | FlView * | view,
|  | GError ** | error
| ) |  |

fl_renderer_start: @renderer: an #FlRenderer. @view: the view Flutter is renderering to. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Start the renderer.

Returns: TRUE if successfully started.

Definition at line 59 of file fl_renderer.cc.

59 {
60 g_return_val_if_fail(FL_IS_RENDERER(self), FALSE);
61 FlRendererPrivate* priv = reinterpret_cast<FlRendererPrivate*>(
62 fl_renderer_get_instance_private(self));
63 priv->view = view;
64 gboolean result = FL_RENDERER_GET_CLASS(self)->create_contexts(
65 self, GTK_WIDGET(view), &priv->main_context, &priv->resource_context,
66 error);
67
68 if (result) {
69 gdk_gl_context_realize(priv->main_context, error);
70 gdk_gl_context_realize(priv->resource_context, error);
71 }
72
73 if (*error != nullptr) {
74 return FALSE;
75 }
76 return TRUE;
77 }

References error, priv, result, and TRUE.

Referenced by realize_cb().

## ◆ fl_renderer_wait_for_frame()

void fl_renderer_wait_for_frame | ( | FlRenderer * | renderer,
|  | int | target_width,
|  | int | target_height
| ) |  |

fl_renderer_wait_for_frame: @renderer: an #FlRenderer. @target_width: width of frame being waited for @target_height: height of frame being waited for

Holds the thread until frame with requested dimensions is presented. While waiting for frame Flutter platform and raster tasks are being processed.

Definition at line 140 of file fl_renderer.cc.

142 {
143 FlRendererPrivate* priv = reinterpret_cast<FlRendererPrivate*>(
144 fl_renderer_get_instance_private(self));
145
146 priv->target_width = target_width;
147 priv->target_height = target_height;
148
149 if (priv->had_first_frame && !priv->blocking_main_thread) {
150 priv->blocking_main_thread = true;
151 FlTaskRunner* runner =
152 fl_engine_get_task_runner(fl_view_get_engine(priv->view));
153 fl_task_runner_block_main_thread(runner);
154 }
155 }

References fl_engine_get_task_runner(), fl_task_runner_block_main_thread(), fl_view_get_engine(), and priv.

Referenced by handle_geometry_changed().

FL_RENDERER_ERROR_FAILED
@ FL_RENDERER_ERROR_FAILED
Definition: fl_renderer.h:23
priv
FlPixelBufferTexturePrivate * priv
Definition: fl_pixel_buffer_texture.cc:30
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
fl_view_get_engine
G_MODULE_EXPORT FlEngine * fl_view_get_engine(FlView *self)
Definition: fl_view.cc:744
fl_renderer_unblock_main_thread
static void fl_renderer_unblock_main_thread(FlRenderer *self)
Definition: fl_renderer.cc:36
result
GAsyncResult * result
Definition: fl_text_input_plugin.cc:106
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_engine_get_task_runner
FlTaskRunner * fl_engine_get_task_runner(FlEngine *self)
Definition: fl_engine.cc:899
FlRendererError
FlRendererError
Definition: fl_renderer.h:22
FlRendererPrivate
Definition: fl_renderer.cc:16
fl_task_runner_block_main_thread
void fl_task_runner_block_main_thread(FlTaskRunner *self)
Definition: fl_task_runner.cc:184