[gtk/wip/chergert/macos-iosurface] macos: setup initial swap rectangle



commit 3ed7ffbf4c12a098e13a7a3cb9ce34b53352c73b
Author: Christian Hergert <christian hergert me>
Date:   Sat Feb 12 00:22:21 2022 -0800

    macos: setup initial swap rectangle

 gdk/macos/gdkmacosglcontext.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gdk/macos/gdkmacosglcontext.c b/gdk/macos/gdkmacosglcontext.c
index 47331a70e9..4d455aee05 100644
--- a/gdk/macos/gdkmacosglcontext.c
+++ b/gdk/macos/gdkmacosglcontext.c
@@ -349,6 +349,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext  *context,
   GLint sync_to_framerate = 1;
   GLint validate = 0;
   GLint renderer_id = 0;
+  GLint swapRect[4];
   int major, minor;
 
   g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
@@ -363,7 +364,6 @@ 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));
   display = gdk_gl_context_get_display (context);
   shared = gdk_display_get_gl_context (display);
 
@@ -406,7 +406,21 @@ gdk_macos_gl_context_real_realize (GdkGLContext  *context,
       return 0;
    }
 
-  CGLEnable (cgl_context, kCGLCESwapRectangle);
+  surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
+
+  if (surface != NULL)
+    {
+      /* Setup initial swap rectangle. We might not actually need this
+       * anymore though as we are rendering to an IOSurface and we have
+       * a scissor clip when rendering to it.
+       */
+      swapRect[0] = 0;
+      swapRect[1] = 0;
+      swapRect[2] = surface->width;
+      swapRect[3] = surface->height;
+      CGLSetParameter (cgl_context, kCGLCPSwapRectangle, swapRect);
+      CGLEnable (cgl_context, kCGLCESwapRectangle);
+    }
 
   GDK_DISPLAY_NOTE (display,
                     OPENGL,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]