[gtk/wip/chergert/gdk-macos-gl-renderer: 26/26] macos: wait for begin_frame to switch to GL view
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/gdk-macos-gl-renderer: 26/26] macos: wait for begin_frame to switch to GL view
- Date: Thu, 29 Oct 2020 00:12:13 +0000 (UTC)
commit 1db0132482d6987c7d8fdf9d1759a6774197f37b
Author: Christian Hergert <chergert redhat com>
Date: Wed Oct 28 17:10:16 2020 -0700
macos: wait for begin_frame to switch to GL view
We don't need the GL view unless we intend on rendering the whole
surface with GL. This delays until begin_frame to do that (as that is when
we know the renderer is doing so).
This fixes cairo software rendering with a GtkGLArea.
gdk/macos/gdkmacosglcontext.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/gdk/macos/gdkmacosglcontext.c b/gdk/macos/gdkmacosglcontext.c
index 9a42d9511a..e1d792a41e 100644
--- a/gdk/macos/gdkmacosglcontext.c
+++ b/gdk/macos/gdkmacosglcontext.c
@@ -154,7 +154,6 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
{
GdkMacosGLContext *self = (GdkMacosGLContext *)context;
GdkSurface *surface;
- NSView *nsview;
NSOpenGLContext *shared_gl_context = nil;
NSOpenGLContext *gl_context;
NSOpenGLPixelFormat *pixelFormat;
@@ -176,17 +175,9 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
gdk_gl_context_get_required_version (context, &major, &minor);
surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
- nsview = _gdk_macos_surface_get_view (GDK_MACOS_SURFACE (surface));
shared = gdk_gl_context_get_shared_context (context);
shared_data = gdk_surface_get_shared_data_gl_context (surface);
- /* If we are not attached and have a shared context, then we are
- * trying to draw to our NSView (which must be a GL view). Ensure
- * that we have that up front to save some checking later.
- */
- if (!self->is_attached && shared != NULL)
- nsview = ensure_gl_view (self);
-
if (shared != NULL)
{
if (!(shared_gl_context = get_ns_open_gl_context (GDK_MACOS_GL_CONTEXT (shared), error)))
@@ -264,6 +255,14 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
+ /* If begin frame is called, that means we are trying to draw to
+ * the NSWindow using our view. That might be a GdkMacosCairoView
+ * but we need it to be a GL view.
+ */
+ if (!self->is_attached &&
+ gdk_gl_context_get_shared_context (GDK_GL_CONTEXT (context)))
+ ensure_gl_view (self);
+
if (self->needs_resize)
{
self->needs_resize = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]