Flutter Engine
fl_renderer.h File Reference
#include <EGL/egl.h>
#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"

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, GtkWidget *widget, GError **error)
 
void fl_renderer_set_geometry (FlRenderer *renderer, GdkRectangle *geometry, gint scale)
 
: a function name.

fl_renderer_get_proc_address: : 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_present (FlRenderer *renderer, GError **error)
 

Enumeration Type Documentation

◆ FlRendererError

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

Enumerator
FL_RENDERER_ERROR_FAILED 

Definition at line 21 of file fl_renderer.h.

Function Documentation

◆ fl_renderer_clear_current()

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

fl_renderer_clear_current: : an #FlRenderer. : (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 261 of file fl_renderer.cc.

References FlRendererPrivate::egl_display, egl_error_to_string(), eglGetError(), eglMakeCurrent(), FL_RENDERER_ERROR_FAILED, fl_renderer_error_quark(), and TRUE.

Referenced by fl_engine_gl_clear_current().

261  {
262  FlRendererPrivate* priv =
263  static_cast<FlRendererPrivate*>(fl_renderer_get_instance_private(self));
264 
265  if (!eglMakeCurrent(priv->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
266  EGL_NO_CONTEXT)) {
268  "Failed to clear EGL context: %s",
270  return FALSE;
271  }
272 
273  return TRUE;
274 }
FlMethodResponse GError ** error
GQuark fl_renderer_error_quark(void) G_GNUC_CONST
EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
Definition: mock_egl.cc:306
EGLint eglGetError()
Definition: mock_egl.cc:252
const gchar * egl_error_to_string(EGLint error)
Definition: egl_utils.cc:89
EGLDisplay egl_display
Definition: fl_renderer.cc:13
return TRUE
Definition: fl_view.cc:107

◆ fl_renderer_error_quark()

◆ fl_renderer_get_fbo()

guint32 fl_renderer_get_fbo ( FlRenderer *  renderer)

fl_renderer_get_fbo: : an #FlRenderer.

Gets the frame buffer object to render to.

Returns: a frame buffer object index.

Definition at line 276 of file fl_renderer.cc.

Referenced by fl_engine_gl_get_fbo().

276  {
277  // There is only one frame buffer object - always return that.
278  return 0;
279 }

◆ fl_renderer_get_proc_address()

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

Definition at line 212 of file fl_renderer.cc.

References eglGetProcAddress.

Referenced by fl_engine_gl_proc_resolver().

212  {
213  return reinterpret_cast<void*>(eglGetProcAddress(name));
214 }
void(*)(void) eglGetProcAddress(const char *procname)
Definition: mock_egl.cc:258
const char * name
Definition: fuchsia.cc:50

◆ fl_renderer_make_current()

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

fl_renderer_make_current: : an #FlRenderer. : (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 216 of file fl_renderer.cc.

References FlRendererPrivate::egl_context, FlRendererPrivate::egl_display, egl_error_to_string(), FlRendererPrivate::egl_surface, eglGetError(), eglMakeCurrent(), FL_RENDERER_ERROR_FAILED, fl_renderer_error_quark(), and TRUE.

Referenced by fl_engine_gl_make_current().

216  {
217  FlRendererPrivate* priv =
218  static_cast<FlRendererPrivate*>(fl_renderer_get_instance_private(self));
219 
220  if (priv->egl_surface == EGL_NO_SURFACE ||
221  priv->egl_context == EGL_NO_CONTEXT) {
223  "Failed to make EGL context current: No surface created");
224  return FALSE;
225  }
226 
227  if (!eglMakeCurrent(priv->egl_display, priv->egl_surface, priv->egl_surface,
228  priv->egl_context)) {
230  "Failed to make EGL context current: %s",
232  return FALSE;
233  }
234 
235  return TRUE;
236 }
FlMethodResponse GError ** error
EGLSurface egl_surface
Definition: fl_renderer.cc:15
GQuark fl_renderer_error_quark(void) G_GNUC_CONST
EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
Definition: mock_egl.cc:306
EGLint eglGetError()
Definition: mock_egl.cc:252
const gchar * egl_error_to_string(EGLint error)
Definition: egl_utils.cc:89
EGLDisplay egl_display
Definition: fl_renderer.cc:13
EGLContext egl_context
Definition: fl_renderer.cc:16
return TRUE
Definition: fl_view.cc:107

◆ fl_renderer_make_resource_current()

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

fl_renderer_make_resource_current: : an #FlRenderer. : (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 238 of file fl_renderer.cc.

References FlRendererPrivate::egl_display, egl_error_to_string(), eglGetError(), eglMakeCurrent(), FL_RENDERER_ERROR_FAILED, fl_renderer_error_quark(), FlRendererPrivate::resource_context, FlRendererPrivate::resource_surface, and TRUE.

Referenced by fl_engine_gl_make_resource_current().

238  {
239  FlRendererPrivate* priv =
240  static_cast<FlRendererPrivate*>(fl_renderer_get_instance_private(self));
241 
242  if (priv->resource_surface == EGL_NO_SURFACE ||
243  priv->resource_context == EGL_NO_CONTEXT) {
244  g_set_error(
246  "Failed to make EGL resource context current: No surface created");
247  return FALSE;
248  }
249 
250  if (!eglMakeCurrent(priv->egl_display, priv->resource_surface,
251  priv->resource_surface, priv->resource_context)) {
253  "Failed to make EGL resource context current: %s",
255  return FALSE;
256  }
257 
258  return TRUE;
259 }
EGLContext resource_context
Definition: fl_renderer.cc:19
FlMethodResponse GError ** error
GQuark fl_renderer_error_quark(void) G_GNUC_CONST
EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
Definition: mock_egl.cc:306
EGLint eglGetError()
Definition: mock_egl.cc:252
const gchar * egl_error_to_string(EGLint error)
Definition: egl_utils.cc:89
EGLDisplay egl_display
Definition: fl_renderer.cc:13
EGLSurface resource_surface
Definition: fl_renderer.cc:18
return TRUE
Definition: fl_view.cc:107

◆ fl_renderer_present()

gboolean fl_renderer_present ( FlRenderer *  renderer,
GError **  error 
)

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

Presents the current frame.

Returns TRUE if successful.

Definition at line 281 of file fl_renderer.cc.

References FlRendererPrivate::egl_display, egl_error_to_string(), FlRendererPrivate::egl_surface, eglGetError(), eglSwapBuffers(), FL_RENDERER_ERROR_FAILED, fl_renderer_error_quark(), and TRUE.

Referenced by fl_engine_gl_present().

281  {
282  FlRendererPrivate* priv =
283  static_cast<FlRendererPrivate*>(fl_renderer_get_instance_private(self));
284 
285  if (!eglSwapBuffers(priv->egl_display, priv->egl_surface)) {
287  "Failed to swap EGL buffers: %s",
289  return FALSE;
290  }
291 
292  return TRUE;
293 }
FlMethodResponse GError ** error
EGLSurface egl_surface
Definition: fl_renderer.cc:15
GQuark fl_renderer_error_quark(void) G_GNUC_CONST
EGLint eglGetError()
Definition: mock_egl.cc:252
const gchar * egl_error_to_string(EGLint error)
Definition: egl_utils.cc:89
EGLDisplay egl_display
Definition: fl_renderer.cc:13
return TRUE
Definition: fl_view.cc:107
EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
Definition: mock_egl.cc:316

◆ fl_renderer_set_geometry()

void fl_renderer_set_geometry ( FlRenderer *  renderer,
GdkRectangle *  geometry,
gint  scale 
)

fl_renderer_set_geometry: : an #FlRenderer. : New size and position (unscaled) of the EGL window. : Scale of the window.

Definition at line 202 of file fl_renderer.cc.

Referenced by fl_view_geometry_changed().

204  {
205  g_return_if_fail(FL_IS_RENDERER(self));
206 
207  if (FL_RENDERER_GET_CLASS(self)->set_geometry) {
208  FL_RENDERER_GET_CLASS(self)->set_geometry(self, geometry, scale);
209  }
210 }

◆ fl_renderer_start()

gboolean fl_renderer_start ( FlRenderer *  renderer,
GtkWidget *  widget,
GError **  error 
)

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

Start the renderer.

Returns: TRUE if successfully started.

Definition at line 182 of file fl_renderer.cc.

References setup_egl_display(), setup_egl_surfaces(), setup_gdk_window(), and TRUE.

Referenced by fl_view_realize().

184  {
185  g_return_val_if_fail(FL_IS_RENDERER(self), FALSE);
186 
187  if (!setup_egl_display(self, error)) {
188  return FALSE;
189  }
190 
191  if (!setup_gdk_window(self, widget, error)) {
192  return FALSE;
193  }
194 
195  if (!setup_egl_surfaces(self, widget, error)) {
196  return FALSE;
197  }
198 
199  return TRUE;
200 }
FlMethodResponse GError ** error
static gboolean setup_egl_display(FlRenderer *self, GError **error)
Definition: fl_renderer.cc:29
static gboolean setup_gdk_window(FlRenderer *self, GtkWidget *widget, GError **error)
Definition: fl_renderer.cc:94
return TRUE
Definition: fl_view.cc:107
static gboolean setup_egl_surfaces(FlRenderer *self, GtkWidget *widget, GError **error)
Definition: fl_renderer.cc:142