Flutter Engine
The Flutter Engine
Classes | Functions
fl_renderer_gdk.cc File Reference
#include "flutter/shell/platform/linux/fl_renderer_gdk.h"

Go to the source code of this file.

Classes

struct  _FlRendererGdk
 

Functions

static void fl_renderer_gdk_make_current (FlRenderer *renderer)
 
static void fl_renderer_gdk_make_resource_current (FlRenderer *renderer)
 
static void fl_renderer_gdk_clear_current (FlRenderer *renderer)
 
static gdouble fl_renderer_gdk_get_refresh_rate (FlRenderer *renderer)
 
static void fl_renderer_gdk_dispose (GObject *object)
 
static void fl_renderer_gdk_class_init (FlRendererGdkClass *klass)
 
static void fl_renderer_gdk_init (FlRendererGdk *self)
 
FlRendererGdk * fl_renderer_gdk_new (GdkWindow *window)
 
gboolean fl_renderer_gdk_create_contexts (FlRendererGdk *self, GError **error)
 
GdkGLContext * fl_renderer_gdk_get_context (FlRendererGdk *self)
 

Function Documentation

◆ fl_renderer_gdk_class_init()

static void fl_renderer_gdk_class_init ( FlRendererGdkClass *  klass)
static

Definition at line 69 of file fl_renderer_gdk.cc.

69 {
70 G_OBJECT_CLASS(klass)->dispose = fl_renderer_gdk_dispose;
71
72 FL_RENDERER_CLASS(klass)->make_current = fl_renderer_gdk_make_current;
73 FL_RENDERER_CLASS(klass)->make_resource_current =
75 FL_RENDERER_CLASS(klass)->clear_current = fl_renderer_gdk_clear_current;
76 FL_RENDERER_CLASS(klass)->get_refresh_rate = fl_renderer_gdk_get_refresh_rate;
77}
static void fl_renderer_gdk_make_resource_current(FlRenderer *renderer)
static void fl_renderer_gdk_dispose(GObject *object)
static void fl_renderer_gdk_make_current(FlRenderer *renderer)
static gdouble fl_renderer_gdk_get_refresh_rate(FlRenderer *renderer)
static void fl_renderer_gdk_clear_current(FlRenderer *renderer)

◆ fl_renderer_gdk_clear_current()

static void fl_renderer_gdk_clear_current ( FlRenderer *  renderer)
static

Definition at line 38 of file fl_renderer_gdk.cc.

38 {
39 gdk_gl_context_clear_current();
40}

◆ fl_renderer_gdk_create_contexts()

gboolean fl_renderer_gdk_create_contexts ( FlRendererGdk *  renderer,
GError **  error 
)

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

Create rendering contexts.

Returns: TRUE if contexts were created, FALSE if there was an error.

Definition at line 88 of file fl_renderer_gdk.cc.

88 {
89 self->gdk_context = gdk_window_create_gl_context(self->window, error);
90 if (self->gdk_context == nullptr) {
91 return FALSE;
92 }
93 if (!gdk_gl_context_realize(self->gdk_context, error)) {
94 return FALSE;
95 }
96
97 self->main_context = gdk_window_create_gl_context(self->window, error);
98 if (self->main_context == nullptr) {
99 return FALSE;
100 }
101 if (!gdk_gl_context_realize(self->main_context, error)) {
102 return FALSE;
103 }
104
105 self->resource_context = gdk_window_create_gl_context(self->window, error);
106 if (self->resource_context == nullptr) {
107 return FALSE;
108 }
109 if (!gdk_gl_context_realize(self->resource_context, error)) {
110 return FALSE;
111 }
112
113 return TRUE;
114}
const uint8_t uint32_t uint32_t GError ** error
return FALSE

◆ fl_renderer_gdk_dispose()

static void fl_renderer_gdk_dispose ( GObject *  object)
static

Definition at line 59 of file fl_renderer_gdk.cc.

59 {
60 FlRendererGdk* self = FL_RENDERER_GDK(object);
61
62 g_clear_object(&self->gdk_context);
63 g_clear_object(&self->main_context);
64 g_clear_object(&self->resource_context);
65
66 G_OBJECT_CLASS(fl_renderer_gdk_parent_class)->dispose(object);
67}

◆ fl_renderer_gdk_get_context()

GdkGLContext * fl_renderer_gdk_get_context ( FlRendererGdk *  renderer)

fl_renderer_gdk_get_context: @renderer: an #FlRendererGdk.

Returns: the main context used for rendering.

Definition at line 116 of file fl_renderer_gdk.cc.

116 {
117 g_return_val_if_fail(FL_IS_RENDERER_GDK(self), nullptr);
118 return self->gdk_context;
119}

◆ fl_renderer_gdk_get_refresh_rate()

static gdouble fl_renderer_gdk_get_refresh_rate ( FlRenderer *  renderer)
static

Definition at line 42 of file fl_renderer_gdk.cc.

42 {
43 FlRendererGdk* self = FL_RENDERER_GDK(renderer);
44 GdkDisplay* display = gdk_window_get_display(self->window);
45 GdkMonitor* monitor =
46 gdk_display_get_monitor_at_window(display, self->window);
47 if (monitor == nullptr) {
48 return -1.0;
49 }
50
51 int refresh_rate = gdk_monitor_get_refresh_rate(monitor);
52 if (refresh_rate <= 0) {
53 return -1.0;
54 }
55 // the return value is in milli-hertz, convert to hertz
56 return static_cast<gdouble>(refresh_rate) / 1000.0;
57}

◆ fl_renderer_gdk_init()

static void fl_renderer_gdk_init ( FlRendererGdk *  self)
static

Definition at line 79 of file fl_renderer_gdk.cc.

79{}

◆ fl_renderer_gdk_make_current()

static void fl_renderer_gdk_make_current ( FlRenderer *  renderer)
static

Definition at line 26 of file fl_renderer_gdk.cc.

26 {
27 FlRendererGdk* self = FL_RENDERER_GDK(renderer);
28 gdk_gl_context_make_current(self->main_context);
29}

◆ fl_renderer_gdk_make_resource_current()

static void fl_renderer_gdk_make_resource_current ( FlRenderer *  renderer)
static

Definition at line 32 of file fl_renderer_gdk.cc.

32 {
33 FlRendererGdk* self = FL_RENDERER_GDK(renderer);
34 gdk_gl_context_make_current(self->resource_context);
35}

◆ fl_renderer_gdk_new()

FlRendererGdk * fl_renderer_gdk_new ( GdkWindow *  window)

Definition at line 81 of file fl_renderer_gdk.cc.

81 {
82 FlRendererGdk* self =
83 FL_RENDERER_GDK(g_object_new(fl_renderer_gdk_get_type(), nullptr));
84 self->window = window;
85 return self;
86}
GLFWwindow * window
Definition: main.cc:45