23 G_DEFINE_TYPE(FlRendererGdk, fl_renderer_gdk, fl_renderer_get_type())
27 FlRendererGdk*
self = FL_RENDERER_GDK(renderer);
28 gdk_gl_context_make_current(self->main_context);
33 FlRendererGdk*
self = FL_RENDERER_GDK(renderer);
34 gdk_gl_context_make_current(self->resource_context);
39 gdk_gl_context_clear_current();
44 FlRendererGdk*
self = FL_RENDERER_GDK(renderer);
45 GdkDisplay* display = gdk_window_get_display(self->window);
47 gdk_display_get_monitor_at_window(display, self->window);
48 if (monitor ==
nullptr) {
52 int refresh_rate = gdk_monitor_get_refresh_rate(monitor);
53 if (refresh_rate <= 0) {
57 return static_cast<gdouble
>(refresh_rate) / 1000.0;
61 FlRendererGdk*
self = FL_RENDERER_GDK(
object);
63 g_clear_object(&self->gdk_context);
64 g_clear_object(&self->main_context);
65 g_clear_object(&self->resource_context);
67 G_OBJECT_CLASS(fl_renderer_gdk_parent_class)->dispose(
object);
74 FL_RENDERER_CLASS(klass)->make_resource_current =
84 FL_RENDERER_GDK(g_object_new(fl_renderer_gdk_get_type(),
nullptr));
89 g_return_if_fail(FL_IS_RENDERER_GDK(
self));
91 g_assert(self->window ==
nullptr);
92 self->window = window;
96 g_return_val_if_fail(FL_IS_RENDERER_GDK(
self), FALSE);
98 self->gdk_context = gdk_window_create_gl_context(self->window,
error);
99 if (self->gdk_context ==
nullptr) {
102 if (!gdk_gl_context_realize(self->gdk_context,
error)) {
106 self->main_context = gdk_window_create_gl_context(self->window,
error);
107 if (self->main_context ==
nullptr) {
110 if (!gdk_gl_context_realize(self->main_context,
error)) {
114 self->resource_context = gdk_window_create_gl_context(self->window,
error);
115 if (self->resource_context ==
nullptr) {
118 if (!gdk_gl_context_realize(self->resource_context,
error)) {
126 g_return_val_if_fail(FL_IS_RENDERER_GDK(
self),
nullptr);
127 return self->gdk_context;