Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fl_opengl_manager.cc File Reference
#include <epoxy/egl.h>
#include <gdk/gdkwayland.h>
#include "flutter/shell/platform/linux/fl_opengl_manager.h"

Go to the source code of this file.

Classes

struct  _FlOpenGLManager
 

Functions

static void fl_opengl_manager_dispose (GObject *object)
 
static void fl_opengl_manager_class_init (FlOpenGLManagerClass *klass)
 
static void fl_opengl_manager_init (FlOpenGLManager *self)
 
FlOpenGLManager * fl_opengl_manager_new ()
 
gboolean fl_opengl_manager_make_current (FlOpenGLManager *self)
 
gboolean fl_opengl_manager_make_resource_current (FlOpenGLManager *self)
 
gboolean fl_opengl_manager_clear_current (FlOpenGLManager *self)
 

Function Documentation

◆ fl_opengl_manager_class_init()

static void fl_opengl_manager_class_init ( FlOpenGLManagerClass *  klass)
static

Definition at line 38 of file fl_opengl_manager.cc.

38 {
39 G_OBJECT_CLASS(klass)->dispose = fl_opengl_manager_dispose;
40}
static void fl_opengl_manager_dispose(GObject *object)

References fl_opengl_manager_dispose().

◆ fl_opengl_manager_clear_current()

gboolean fl_opengl_manager_clear_current ( FlOpenGLManager *  manager)

fl_opengl_manager_clear_current: @manager: an #FlOpenGLManager.

Clears the current rendering context.

Returns: TRUE if the context cleared.

Definition at line 90 of file fl_opengl_manager.cc.

90 {
91 return eglMakeCurrent(self->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
92 EGL_NO_CONTEXT) == EGL_TRUE;
93}

References self.

Referenced by fl_engine_gl_clear_current(), and realize_cb().

◆ fl_opengl_manager_dispose()

static void fl_opengl_manager_dispose ( GObject *  object)
static

Definition at line 28 of file fl_opengl_manager.cc.

28 {
29 FlOpenGLManager* self = FL_OPENGL_MANAGER(object);
30
31 eglDestroyContext(self->display, self->render_context);
32 eglDestroyContext(self->display, self->resource_context);
33 eglTerminate(self->display);
34
35 G_OBJECT_CLASS(fl_opengl_manager_parent_class)->dispose(object);
36}

References self.

Referenced by fl_opengl_manager_class_init().

◆ fl_opengl_manager_init()

static void fl_opengl_manager_init ( FlOpenGLManager *  self)
static

Definition at line 42 of file fl_opengl_manager.cc.

42 {
43 GdkDisplay* display = gdk_display_get_default();
44 if (GDK_IS_WAYLAND_DISPLAY(display)) {
45 self->display = eglGetPlatformDisplayEXT(
46 EGL_PLATFORM_WAYLAND_EXT, gdk_wayland_display_get_wl_display(display),
47 NULL);
48#ifdef GDK_WINDOWING_X11
49 } else if (GDK_IS_X11_DISPLAY(display)) {
50 self->display = eglGetPlatformDisplayEXT(
51 EGL_PLATFORM_X11_EXT, gdk_x11_display_get_xdisplay(display), NULL);
52#endif
53 } else {
54 g_critical("Unsupported GDK backend, unable to get EGL display");
55 }
56
57 eglInitialize(self->display, nullptr, nullptr);
58
59 const EGLint config_attributes[] = {EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8,
60 EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8,
61 EGL_DEPTH_SIZE, 8, EGL_STENCIL_SIZE, 8,
62 EGL_NONE};
63 EGLConfig config = nullptr;
64 EGLint num_config = 0;
65 eglChooseConfig(self->display, config_attributes, &config, 1, &num_config);
66
67 const EGLint context_attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
68 self->render_context = eglCreateContext(self->display, config, EGL_NO_CONTEXT,
69 context_attributes);
70 self->resource_context = eglCreateContext(
71 self->display, config, self->render_context, context_attributes);
72}
GdkDisplay * gdk_display_get_default()
Definition mock_gtk.cc:66

References gdk_display_get_default(), and self.

◆ fl_opengl_manager_make_current()

gboolean fl_opengl_manager_make_current ( FlOpenGLManager *  manager)

fl_opengl_manager_make_current: @manager: an #FlOpenGLManager.

Makes the rendering context current.

Returns: TRUE if the context made current.

Definition at line 80 of file fl_opengl_manager.cc.

80 {
81 return eglMakeCurrent(self->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
82 self->render_context) == EGL_TRUE;
83}

References self.

Referenced by cleanup_shader(), collect_opengl_backing_store(), create_opengl_backing_store(), fl_engine_gl_make_current(), and setup_shader().

◆ fl_opengl_manager_make_resource_current()

gboolean fl_opengl_manager_make_resource_current ( FlOpenGLManager *  manager)

fl_opengl_manager_make_resource_current: @manager: an #FlOpenGLManager.

Makes the resource rendering context current.

Returns: TRUE if the context made current.

Definition at line 85 of file fl_opengl_manager.cc.

85 {
86 return eglMakeCurrent(self->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
87 self->resource_context) == EGL_TRUE;
88}

References self.

Referenced by fl_engine_gl_make_resource_current().

◆ fl_opengl_manager_new()

FlOpenGLManager * fl_opengl_manager_new ( )

Definition at line 74 of file fl_opengl_manager.cc.

74 {
75 FlOpenGLManager* self =
76 FL_OPENGL_MANAGER(g_object_new(fl_opengl_manager_get_type(), nullptr));
77 return self;
78}

References self.

Referenced by fl_engine_init(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().