diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 8a1b4eefc8..39dfbef89c 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -1160,8 +1160,6 @@ gdk_surface_get_egl_surface (GdkSurface *self) { GdkSurfacePrivate *priv = gdk_surface_get_instance_private (self); - gdk_surface_ensure_egl_surface (self, priv->egl_surface_depth); - return priv->egl_surface; } diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c index 83feca9a2c..9acd6961d5 100644 --- a/gdk/wayland/gdkglcontext-wayland.c +++ b/gdk/wayland/gdkglcontext-wayland.c @@ -46,14 +46,21 @@ G_DEFINE_TYPE (GdkWaylandGLContext, gdk_wayland_gl_context, GDK_TYPE_GL_CONTEXT) -static gboolean -gdk_wayland_gl_context_make_current (GdkGLContext *context, - gboolean surfaceless) +static void +gdk_wayland_gl_context_begin_frame (GdkDrawContext *draw_context, + GdkMemoryDepth depth, + cairo_region_t *region, + GdkColorState **out_color_state, + GdkMemoryDepth *out_depth) { - if (!surfaceless) - gdk_wayland_surface_ensure_wl_egl_window (gdk_gl_context_get_surface (context)); + gboolean created_window; - return GDK_GL_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->make_current (context, surfaceless); + created_window = gdk_wayland_surface_ensure_wl_egl_window (gdk_draw_context_get_surface (draw_context)); + + GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->begin_frame (draw_context, depth, region, out_color_state, out_depth); + + if (created_window) + gdk_gl_context_make_current (GDK_GL_CONTEXT (draw_context)); } static void @@ -95,13 +102,13 @@ static void gdk_wayland_gl_context_class_init (GdkWaylandGLContextClass *klass) { GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass); - GdkGLContextClass *gl_context_class = GDK_GL_CONTEXT_CLASS (klass); + GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass); + draw_context_class->begin_frame = gdk_wayland_gl_context_begin_frame; draw_context_class->end_frame = gdk_wayland_gl_context_end_frame; draw_context_class->empty_frame = gdk_wayland_gl_context_empty_frame; - gl_context_class->make_current = gdk_wayland_gl_context_make_current; - gl_context_class->backend_type = GDK_GL_EGL; + context_class->backend_type = GDK_GL_EGL; } static void diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 5a3c4ee656..ded954e179 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -1447,20 +1447,21 @@ _gdk_wayland_surface_offset_next_wl_buffer (GdkSurface *surface, impl->pending_buffer_offset_y = y; } -void +gboolean gdk_wayland_surface_ensure_wl_egl_window (GdkSurface *surface) { GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface); + int width, height; - if (impl->display_server.egl_window == NULL) - { - int width, height; + if (impl->display_server.egl_window != NULL) + return FALSE; - get_egl_window_size (surface, &width, &height); - impl->display_server.egl_window = - wl_egl_window_create (impl->display_server.wl_surface, width, height); - gdk_surface_set_egl_native_window (surface, impl->display_server.egl_window); - } + get_egl_window_size (surface, &width, &height); + impl->display_server.egl_window = + wl_egl_window_create (impl->display_server.wl_surface, width, height); + gdk_surface_set_egl_native_window (surface, impl->display_server.egl_window); + + return TRUE; } /* }}} */ diff --git a/gdk/wayland/gdksurface-wayland.h b/gdk/wayland/gdksurface-wayland.h index b64a29eedb..93f77b84d7 100644 --- a/gdk/wayland/gdksurface-wayland.h +++ b/gdk/wayland/gdksurface-wayland.h @@ -26,6 +26,6 @@ G_BEGIN_DECLS -void gdk_wayland_surface_ensure_wl_egl_window (GdkSurface *surface); +gboolean gdk_wayland_surface_ensure_wl_egl_window (GdkSurface *surface); G_END_DECLS