[gtk/wip/chergert/macos-iosurface] remove IOSurface* API from macoscairocontext
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/macos-iosurface] remove IOSurface* API from macoscairocontext
- Date: Wed, 9 Feb 2022 22:57:19 +0000 (UTC)
commit 4198d37d7614209c694be543ed6882f177726c05
Author: Christian Hergert <christian hergert me>
Date: Wed Feb 9 14:52:39 2022 -0800
remove IOSurface* API from macoscairocontext
gdk/macos/gdkmacosbuffer-private.h | 1 +
gdk/macos/gdkmacosbuffer.c | 8 ++++++++
gdk/macos/gdkmacoscairocontext.c | 16 ++++++++--------
3 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/gdk/macos/gdkmacosbuffer-private.h b/gdk/macos/gdkmacosbuffer-private.h
index 1a8b0a079c..62e605c609 100644
--- a/gdk/macos/gdkmacosbuffer-private.h
+++ b/gdk/macos/gdkmacosbuffer-private.h
@@ -48,6 +48,7 @@ double _gdk_macos_buffer_get_device_scale (GdkMacosBuffer *self)
const cairo_region_t *_gdk_macos_buffer_get_damage (GdkMacosBuffer *self);
void _gdk_macos_buffer_set_damage (GdkMacosBuffer *self,
cairo_region_t *damage);
+gpointer _gdk_macos_buffer_get_data (GdkMacosBuffer *self);
G_END_DECLS
diff --git a/gdk/macos/gdkmacosbuffer.c b/gdk/macos/gdkmacosbuffer.c
index 252aea77c3..5a19612fac 100644
--- a/gdk/macos/gdkmacosbuffer.c
+++ b/gdk/macos/gdkmacosbuffer.c
@@ -231,3 +231,11 @@ _gdk_macos_buffer_set_damage (GdkMacosBuffer *self,
g_clear_pointer (&self->damage, cairo_region_destroy);
self->damage = damage;
}
+
+gpointer
+_gdk_macos_buffer_get_data (GdkMacosBuffer *self)
+{
+ g_return_val_if_fail (GDK_IS_MACOS_BUFFER (self), NULL);
+
+ return IOSurfaceGetBaseAddress (self->surface);
+}
diff --git a/gdk/macos/gdkmacoscairocontext.c b/gdk/macos/gdkmacoscairocontext.c
index 1f6c611bea..d3d48392e5 100644
--- a/gdk/macos/gdkmacoscairocontext.c
+++ b/gdk/macos/gdkmacoscairocontext.c
@@ -42,6 +42,8 @@ struct _GdkMacosCairoContextClass
G_DEFINE_TYPE (GdkMacosCairoContext, _gdk_macos_cairo_context, GDK_TYPE_CAIRO_CONTEXT)
+static const cairo_user_data_key_t buffer_key;
+
static void
unlock_buffer (gpointer data)
{
@@ -57,15 +59,13 @@ static cairo_t *
_gdk_macos_cairo_context_cairo_create (GdkCairoContext *cairo_context)
{
GdkMacosCairoContext *self = (GdkMacosCairoContext *)cairo_context;
- static const cairo_user_data_key_t buffer_key;
const cairo_region_t *damage;
cairo_surface_t *image_surface;
GdkMacosBuffer *back;
- IOSurfaceRef io_surface;
GdkSurface *surface;
- gpointer base_address;
NSWindow *nswindow;
cairo_t *cr;
+ gpointer data;
double scale;
guint width;
guint height;
@@ -75,18 +75,16 @@ _gdk_macos_cairo_context_cairo_create (GdkCairoContext *cairo_context)
g_assert (GDK_IS_MACOS_CAIRO_CONTEXT (self));
surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (self));
-
nswindow = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (surface));
opaque = [nswindow isOpaque];
back = _gdk_macos_surface_get_back_buffer (GDK_MACOS_SURFACE (surface));
- io_surface = _gdk_macos_buffer_get_native (back);
damage = _gdk_macos_buffer_get_damage (back);
width = _gdk_macos_buffer_get_width (back);
height = _gdk_macos_buffer_get_height (back);
scale = _gdk_macos_buffer_get_device_scale (back);
stride = _gdk_macos_buffer_get_stride (back);
- base_address = IOSurfaceGetBaseAddress (io_surface);
+ data = _gdk_macos_buffer_get_data (back);
/* Instead of forcing cairo to do everything through a CGContext,
* we just use an image surface backed by an IOSurfaceRef mapped
@@ -101,9 +99,11 @@ _gdk_macos_cairo_context_cairo_create (GdkCairoContext *cairo_context)
* the scaling using cairo_surface_set_device_scale() so the renderer
* just thinks it's on a 2x scale surface for HiDPI.
*/
- image_surface = cairo_image_surface_create_for_data (base_address,
+ image_surface = cairo_image_surface_create_for_data (data,
CAIRO_FORMAT_ARGB32,
- width, height, stride);
+ width,
+ height,
+ stride);
cairo_surface_set_device_scale (image_surface, scale, scale);
/* Lock the buffer so we can modify it safely */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]