gdk: Add Cairo context implementations for all backends
authorBenjamin Otte <otte@redhat.com>
Thu, 12 Apr 2018 14:48:31 +0000 (16:48 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 24 Apr 2018 21:16:12 +0000 (23:16 +0200)
And make the GdkCairoContext as abstract.

The idea of this and thje following commits is to get rid of all
Cairo code in gdksurface.c (and $backend/gdksurface-$backend.c)
by moving that code into the Cairo context files.
In particular, the GdkSurfaceClass.begin_frame/end_frame()
functions (which are currently exclusively used by the Cairo code
should end up being moved to GdkDrawContextClass.begin/end_frame().

This has multiple benefits:

1. It unifies code between the different drawing contexts.
   GL lives in GLContext, Vulkan in VulkanContext and Cairo in
   CairoContext. In turn, this makes it way easier to reason about
   what's going on in surface-specific code. Currently pretty much
   all backends do things wrong when they want to sync to drawing
   or to the frame clock.

2. It makes the API of GdkSurface smaller. No drawing code (apart
   from creating the contexts) needs to remain.

3. It confines Cairo to the Drawcontext, thereby making it way
   more obvious when backends are still using it in situations
   where it may now conflict with OpenGL (like when doing the dnd
   failed animation or in the APIs that I'm removing in this
   branch).

4. We have 2 very different types of Cairo contexts: The X/win32
   model, where we have a natively supported Cairo backend but do
   double buffering ourselves and use similar surfaces and the
   Wayland/Broadway model where we use image surfaces without any
   Cairo backend support and have to submit the buffers manually.
   By not sharing code between those 2 versions, we can make the
   actual code way smaller. We also get around the need to create
   1x1 image surfaces in the Wayland backend where we pretend
   there's a native Cairo surface.

23 files changed:
gdk/broadway/gdkcairocontext-broadway.c [new file with mode: 0644]
gdk/broadway/gdkcairocontext-broadway.h [new file with mode: 0644]
gdk/broadway/gdkdisplay-broadway.c
gdk/broadway/meson.build
gdk/gdkcairocontext.c
gdk/gdkdisplayprivate.h
gdk/gdksurface.c
gdk/quartz/gdkcairocontext-quartz.c [new file with mode: 0644]
gdk/quartz/gdkcairocontext-quartz.h [new file with mode: 0644]
gdk/quartz/gdkdisplay-quartz.c
gdk/quartz/meson.build
gdk/wayland/gdkcairocontext-wayland.c [new file with mode: 0644]
gdk/wayland/gdkcairocontext-wayland.h [new file with mode: 0644]
gdk/wayland/gdkdisplay-wayland.c
gdk/wayland/meson.build
gdk/win32/gdkcairocontext-win32.c [new file with mode: 0644]
gdk/win32/gdkcairocontext-win32.h [new file with mode: 0644]
gdk/win32/gdkdisplay-win32.c
gdk/win32/meson.build
gdk/x11/gdkcairocontext-x11.c [new file with mode: 0644]
gdk/x11/gdkcairocontext-x11.h [new file with mode: 0644]
gdk/x11/gdkdisplay-x11.c
gdk/x11/meson.build

diff --git a/gdk/broadway/gdkcairocontext-broadway.c b/gdk/broadway/gdkcairocontext-broadway.c
new file mode 100644 (file)
index 0000000..245e335
--- /dev/null
@@ -0,0 +1,36 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * Copyright © 2018  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkconfig.h"
+
+#include "gdkcairocontext-broadway.h"
+
+G_DEFINE_TYPE (GdkBroadwayCairoContext, gdk_broadway_cairo_context, GDK_TYPE_CAIRO_CONTEXT)
+
+static void
+gdk_broadway_cairo_context_class_init (GdkBroadwayCairoContextClass *klass)
+{
+}
+
+static void
+gdk_broadway_cairo_context_init (GdkBroadwayCairoContext *self)
+{
+}
+
diff --git a/gdk/broadway/gdkcairocontext-broadway.h b/gdk/broadway/gdkcairocontext-broadway.h
new file mode 100644 (file)
index 0000000..a5b9368
--- /dev/null
@@ -0,0 +1,53 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * Copyright © 2018  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_BROADWAY_CAIRO_CONTEXT__
+#define __GDK_BROADWAY_CAIRO_CONTEXT__
+
+#include "gdkconfig.h"
+
+#include "gdkcairocontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_BROADWAY_CAIRO_CONTEXT                (gdk_broadway_cairo_context_get_type ())
+#define GDK_BROADWAY_CAIRO_CONTEXT(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_BROADWAY_CAIRO_CONTEXT, GdkBroadwayCairoContext))
+#define GDK_IS_BROADWAY_CAIRO_CONTEXT(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_BROADWAY_CAIRO_CONTEXT))
+#define GDK_BROADWAY_CAIRO_CONTEXT_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_CAIRO_CONTEXT, GdkBroadwayCairoContextClass))
+#define GDK_IS_BROADWAY_CAIRO_CONTEXT_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_CAIRO_CONTEXT))
+#define GDK_BROADWAY_CAIRO_CONTEXT_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_CAIRO_CONTEXT, GdkBroadwayCairoContextClass))
+
+typedef struct _GdkBroadwayCairoContext GdkBroadwayCairoContext;
+typedef struct _GdkBroadwayCairoContextClass GdkBroadwayCairoContextClass;
+
+struct _GdkBroadwayCairoContext
+{
+  GdkCairoContext parent_instance;
+};
+
+struct _GdkBroadwayCairoContextClass
+{
+  GdkCairoContextClass parent_class;
+};
+
+GDK_AVAILABLE_IN_ALL
+GType gdk_broadway_cairo_context_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_BROADWAY_CAIRO_CONTEXT__ */
index 329dfcf19f0370636234be5988851a670513394e..254e0a2bc794f1648eaa1690fac304f7c209121d 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "gdkdisplay-broadway.h"
 
+#include "gdkcairocontext-broadway.h"
 #include "gdkdisplay.h"
 #include "gdkeventsource.h"
 #include "gdkmonitor-broadway.h"
@@ -521,6 +522,7 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
   object_class->finalize = gdk_broadway_display_finalize;
 
   display_class->surface_type = GDK_TYPE_BROADWAY_SURFACE;
+  display_class->cairo_context_type = GDK_TYPE_BROADWAY_CAIRO_CONTEXT;
 
   display_class->get_name = gdk_broadway_display_get_name;
   display_class->beep = gdk_broadway_display_beep;
index 81e29cc9c1cbcb6dbac7e4524fb98addb18d25a0..aaa517ee6f0c3e391a824cf2958358bc2a864172 100644 (file)
@@ -3,6 +3,7 @@ gdk_broadway_sources = files([
   'broadway-server.c',
   'broadwayd.c',
   'gdkbroadway-server.c',
+  'gdkcairocontext-broadway.c',
   'gdkcursor-broadway.c',
   'gdkdevice-broadway.c',
   'gdkdisplay-broadway.c',
index 596eaabfa6b26f450421e014b3dc1e2b9fed37d3..13be76cb286224de1925c1a4782d73a65239168f 100644 (file)
@@ -53,8 +53,8 @@ struct _GdkCairoContextPrivate {
   gpointer unused;
 };
 
-G_DEFINE_TYPE_WITH_CODE (GdkCairoContext, gdk_cairo_context, GDK_TYPE_DRAW_CONTEXT,
-                         G_ADD_PRIVATE (GdkCairoContext))
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GdkCairoContext, gdk_cairo_context, GDK_TYPE_DRAW_CONTEXT,
+                                  G_ADD_PRIVATE (GdkCairoContext))
 
 static cairo_surface_t *
 gdk_surface_ref_impl_surface (GdkSurface *surface)
index 579f266bf11c6dc7267a57c737e4056294eb4a68..ac873281b5244957f791235e42bc6756115474e2 100644 (file)
@@ -114,7 +114,8 @@ struct _GdkDisplayClass
 {
   GObjectClass parent_class;
 
-  GType surface_type;          /* type for native surfaces for this display, set in class_init */
+  GType surface_type;         /* type for native surfaces for this display, set in class_init */
+  GType cairo_context_type;   /* type for GdkCairoContext, must be set */
   GType vk_context_type;      /* type for GdkVulkanContext, must be set if vk_extension_name != NULL */
   const char *vk_extension_name; /* Name of required windowing vulkan extension or %NULL (default) if Vulkan isn't supported */
 
index ee556358ac37547536c699dfda0816cef4e4d739..08fd046125a2db556ddc4b24c22b9b4036121c4d 100644 (file)
@@ -1483,10 +1483,24 @@ gdk_surface_create_gl_context (GdkSurface   *surface,
                                                                         error);
 }
 
+/**
+ * gdk_surface_create_cairo_context:
+ * @surface: a #GdkSurface
+ *
+ * Creates a new #GdkCairoContext for rendering on @surface.
+ *
+ * Returns: (transfer full): the newly created #GdkCairoContext
+ **/
 GdkCairoContext *
 gdk_surface_create_cairo_context (GdkSurface *surface)
 {
-  return g_object_new (GDK_TYPE_CAIRO_CONTEXT,
+  GdkDisplay *display;
+
+  g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
+
+  display = gdk_surface_get_display (surface);
+
+  return g_object_new (GDK_DISPLAY_GET_CLASS (display)->cairo_context_type,
                        "surface", surface,
                        NULL);
 }
diff --git a/gdk/quartz/gdkcairocontext-quartz.c b/gdk/quartz/gdkcairocontext-quartz.c
new file mode 100644 (file)
index 0000000..2b23ab1
--- /dev/null
@@ -0,0 +1,36 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * Copyright © 2018  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkconfig.h"
+
+#include "gdkcairocontext-quartz.h"
+
+G_DEFINE_TYPE (GdkQuartzCairoContext, gdk_quartz_cairo_context, GDK_TYPE_CAIRO_CONTEXT)
+
+static void
+gdk_quartz_cairo_context_class_init (GdkQuartzCairoContextClass *klass)
+{
+}
+
+static void
+gdk_quartz_cairo_context_init (GdkQuartzCairoContext *self)
+{
+}
+
diff --git a/gdk/quartz/gdkcairocontext-quartz.h b/gdk/quartz/gdkcairocontext-quartz.h
new file mode 100644 (file)
index 0000000..98811b0
--- /dev/null
@@ -0,0 +1,53 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * Copyright © 2018  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_QUARTZ_CAIRO_CONTEXT__
+#define __GDK_QUARTZ_CAIRO_CONTEXT__
+
+#include "gdkconfig.h"
+
+#include "gdkcairocontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_QUARTZ_CAIRO_CONTEXT          (gdk_quartz_cairo_context_get_type ())
+#define GDK_QUARTZ_CAIRO_CONTEXT(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_QUARTZ_CAIRO_CONTEXT, GdkQuartzCairoContext))
+#define GDK_IS_QUARTZ_CAIRO_CONTEXT(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_QUARTZ_CAIRO_CONTEXT))
+#define GDK_QUARTZ_CAIRO_CONTEXT_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_QUARTZ_CAIRO_CONTEXT, GdkQuartzCairoContextClass))
+#define GDK_IS_QUARTZ_CAIRO_CONTEXT_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_QUARTZ_CAIRO_CONTEXT))
+#define GDK_QUARTZ_CAIRO_CONTEXT_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_QUARTZ_CAIRO_CONTEXT, GdkQuartzCairoContextClass))
+
+typedef struct _GdkQuartzCairoContext GdkQuartzCairoContext;
+typedef struct _GdkQuartzCairoContextClass GdkQuartzCairoContextClass;
+
+struct _GdkQuartzCairoContext
+{
+  GdkCairoContext parent_instance;
+};
+
+struct _GdkQuartzCairoContextClass
+{
+  GdkCairoContextClass parent_class;
+};
+
+GDK_AVAILABLE_IN_ALL
+GType gdk_quartz_cairo_context_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_QUARTZ_CAIRO_CONTEXT__ */
index dc933f91067f5c903be33312bce82c15a83bc17e..342080197812b1c3dc55a4966c1d7a49828823b4 100644 (file)
@@ -28,6 +28,7 @@
 #include "gdkquartzdevicemanager-core.h"
 #include "gdkmonitorprivate.h"
 #include "gdkdisplay-quartz.h"
+#include "gdkcairocontext-quartz.h"
 
 
 static GdkSurface *
@@ -216,6 +217,7 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class)
   object_class->dispose = gdk_quartz_display_dispose;
 
   display_class->surface_type = GDK_TYPE_QUARTZ_SURFACE;
+  display_class->cairo_context_type = GDK_TYPE_QUARTZ_CAIRO_CONTEXT;
 
   display_class->get_name = gdk_quartz_display_get_name;
   display_class->beep = gdk_quartz_display_beep;
index 8d2e0fc2c309b2b335e6bc617a4dc04dfb6d71eb..dabeb6b5b61c214e9d79307fa5ff21ad174ffb55 100644 (file)
@@ -2,6 +2,7 @@
 gdk_quartz_sources = files([
   'GdkQuartzView.c',
   'GdkQuartzNSWindow.c',
+  'gdkcairocontext-quartz.c',
   'gdkcursor-quartz.c',
   'gdkdevice-core-quartz.c',
   'gdkdevicemanager-core-quartz.c',
diff --git a/gdk/wayland/gdkcairocontext-wayland.c b/gdk/wayland/gdkcairocontext-wayland.c
new file mode 100644 (file)
index 0000000..f5ee327
--- /dev/null
@@ -0,0 +1,36 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * Copyright © 2018  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkconfig.h"
+
+#include "gdkcairocontext-wayland.h"
+
+G_DEFINE_TYPE (GdkWaylandCairoContext, gdk_wayland_cairo_context, GDK_TYPE_CAIRO_CONTEXT)
+
+static void
+gdk_wayland_cairo_context_class_init (GdkWaylandCairoContextClass *klass)
+{
+}
+
+static void
+gdk_wayland_cairo_context_init (GdkWaylandCairoContext *self)
+{
+}
+
diff --git a/gdk/wayland/gdkcairocontext-wayland.h b/gdk/wayland/gdkcairocontext-wayland.h
new file mode 100644 (file)
index 0000000..278415d
--- /dev/null
@@ -0,0 +1,53 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * Copyright © 2018  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_WAYLAND_CAIRO_CONTEXT__
+#define __GDK_WAYLAND_CAIRO_CONTEXT__
+
+#include "gdkconfig.h"
+
+#include "gdkcairocontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_WAYLAND_CAIRO_CONTEXT         (gdk_wayland_cairo_context_get_type ())
+#define GDK_WAYLAND_CAIRO_CONTEXT(obj)         (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_WAYLAND_CAIRO_CONTEXT, GdkWaylandCairoContext))
+#define GDK_IS_WAYLAND_CAIRO_CONTEXT(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_WAYLAND_CAIRO_CONTEXT))
+#define GDK_WAYLAND_CAIRO_CONTEXT_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WAYLAND_CAIRO_CONTEXT, GdkWaylandCairoContextClass))
+#define GDK_IS_WAYLAND_CAIRO_CONTEXT_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WAYLAND_CAIRO_CONTEXT))
+#define GDK_WAYLAND_CAIRO_CONTEXT_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WAYLAND_CAIRO_CONTEXT, GdkWaylandCairoContextClass))
+
+typedef struct _GdkWaylandCairoContext GdkWaylandCairoContext;
+typedef struct _GdkWaylandCairoContextClass GdkWaylandCairoContextClass;
+
+struct _GdkWaylandCairoContext
+{
+  GdkCairoContext parent_instance;
+};
+
+struct _GdkWaylandCairoContextClass
+{
+  GdkCairoContextClass parent_class;
+};
+
+GDK_AVAILABLE_IN_ALL
+GType gdk_wayland_cairo_context_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_WAYLAND_CAIRO_CONTEXT__ */
index 2c35b65beb5839dd26ff150e9c8ad8da2c86d033..4999ce0905a5b96be6428170b0e11c1cc23e7926 100644 (file)
@@ -42,6 +42,7 @@
 #include "gdkdeviceprivate.h"
 #include "gdkkeysprivate.h"
 #include "gdkprivate-wayland.h"
+#include "gdkcairocontext-wayland.h"
 #include "gdkglcontext-wayland.h"
 #include "gdkvulkancontext-wayland.h"
 #include "gdkwaylandmonitor.h"
@@ -954,6 +955,7 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
   object_class->finalize = gdk_wayland_display_finalize;
 
   display_class->surface_type = gdk_wayland_surface_get_type ();
+  display_class->cairo_context_type = GDK_TYPE_WAYLAND_CAIRO_CONTEXT;
 
 #ifdef GDK_RENDERING_VULKAN
   display_class->vk_context_type = GDK_TYPE_WAYLAND_VULKAN_CONTEXT;
index 8bf47186110e316051ed16f1c1d16cfa658c3115..e6e66158bb9e7aa832d9da8399f13892900fa217 100644 (file)
@@ -1,5 +1,6 @@
 gdk_wayland_sources = files([
   'gdkapplaunchcontext-wayland.c',
+  'gdkcairocontext-wayland.c',
   'gdkclipboard-wayland.c',
   'gdkcursor-wayland.c',
   'gdkdevice-wayland.c',
diff --git a/gdk/win32/gdkcairocontext-win32.c b/gdk/win32/gdkcairocontext-win32.c
new file mode 100644 (file)
index 0000000..e7be8fc
--- /dev/null
@@ -0,0 +1,36 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * Copyright © 2018  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkconfig.h"
+
+#include "gdkcairocontext-win32.h"
+
+G_DEFINE_TYPE (GdkWin32CairoContext, gdk_win32_cairo_context, GDK_TYPE_CAIRO_CONTEXT)
+
+static void
+gdk_win32_cairo_context_class_init (GdkWin32CairoContextClass *klass)
+{
+}
+
+static void
+gdk_win32_cairo_context_init (GdkWin32CairoContext *self)
+{
+}
+
diff --git a/gdk/win32/gdkcairocontext-win32.h b/gdk/win32/gdkcairocontext-win32.h
new file mode 100644 (file)
index 0000000..c1a6ac5
--- /dev/null
@@ -0,0 +1,53 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * Copyright © 2018  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_WIN32_CAIRO_CONTEXT__
+#define __GDK_WIN32_CAIRO_CONTEXT__
+
+#include "gdkconfig.h"
+
+#include "gdkcairocontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_WIN32_CAIRO_CONTEXT           (gdk_win32_cairo_context_get_type ())
+#define GDK_WIN32_CAIRO_CONTEXT(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_WIN32_CAIRO_CONTEXT, GdkWin32CairoContext))
+#define GDK_IS_WIN32_CAIRO_CONTEXT(obj)                (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_WIN32_CAIRO_CONTEXT))
+#define GDK_WIN32_CAIRO_CONTEXT_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WIN32_CAIRO_CONTEXT, GdkWin32CairoContextClass))
+#define GDK_IS_WIN32_CAIRO_CONTEXT_CLASS(klass)        (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WIN32_CAIRO_CONTEXT))
+#define GDK_WIN32_CAIRO_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WIN32_CAIRO_CONTEXT, GdkWin32CairoContextClass))
+
+typedef struct _GdkWin32CairoContext GdkWin32CairoContext;
+typedef struct _GdkWin32CairoContextClass GdkWin32CairoContextClass;
+
+struct _GdkWin32CairoContext
+{
+  GdkCairoContext parent_instance;
+};
+
+struct _GdkWin32CairoContextClass
+{
+  GdkCairoContextClass parent_class;
+};
+
+GDK_AVAILABLE_IN_ALL
+GType gdk_win32_cairo_context_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_WIN32_CAIRO_CONTEXT__ */
index 9834b69cc7dd70fb406bef8a26aa1e14afb0757f..d610cb4dc3f86837b9f97f88ef9f71a014246ae8 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "gdk.h"
 #include "gdkprivate-win32.h"
+#include "gdkcairocontext-win32.h"
 #include "gdkclipboardprivate.h"
 #include "gdkclipboard-win32.h"
 #include "gdkdisplay-win32.h"
@@ -1090,6 +1091,7 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
   object_class->finalize = gdk_win32_display_finalize;
 
   display_class->surface_type = GDK_TYPE_WIN32_SURFACE;
+  display_class->cairo_context_type = GDK_TYPE_WIN32_CAIRO_CONTEXT;
 
   display_class->get_name = gdk_win32_display_get_name;
   display_class->beep = gdk_win32_display_beep;
index c1df54cda1cfbdc6b52e2a198eabe33c0bcfbe9a..534772b495a9a55dfb1a3747b3122a9d363fbfa1 100644 (file)
@@ -1,4 +1,5 @@
 gdk_win32_sources = files([
+  'gdkcairocontext-win32.c',
   'gdkcursor-win32.c',
   'gdkclipboard-win32.c',
   'gdkclipdrop-win32.c',
diff --git a/gdk/x11/gdkcairocontext-x11.c b/gdk/x11/gdkcairocontext-x11.c
new file mode 100644 (file)
index 0000000..ee464d8
--- /dev/null
@@ -0,0 +1,38 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * gdkcairocontext-x11.c: X11 specific Cairo wrappers
+ *
+ * Copyright © 2016  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkconfig.h"
+
+#include "gdkcairocontext-x11.h"
+
+G_DEFINE_TYPE (GdkX11CairoContext, gdk_x11_cairo_context, GDK_TYPE_CAIRO_CONTEXT)
+
+static void
+gdk_x11_cairo_context_class_init (GdkX11CairoContextClass *klass)
+{
+}
+
+static void
+gdk_x11_cairo_context_init (GdkX11CairoContext *self)
+{
+}
+
diff --git a/gdk/x11/gdkcairocontext-x11.h b/gdk/x11/gdkcairocontext-x11.h
new file mode 100644 (file)
index 0000000..2fb4d8d
--- /dev/null
@@ -0,0 +1,55 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * gdkcairocontext-x11.h: X11 specific Cairo wrappers
+ *
+ * Copyright © 2016  Benjamin Otte
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_X11_CAIRO_CONTEXT__
+#define __GDK_X11_CAIRO_CONTEXT__
+
+#include "gdkconfig.h"
+
+#include "gdkcairocontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_X11_CAIRO_CONTEXT             (gdk_x11_cairo_context_get_type ())
+#define GDK_X11_CAIRO_CONTEXT(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_X11_CAIRO_CONTEXT, GdkX11CairoContext))
+#define GDK_IS_X11_CAIRO_CONTEXT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_X11_CAIRO_CONTEXT))
+#define GDK_X11_CAIRO_CONTEXT_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X11_CAIRO_CONTEXT, GdkX11CairoContextClass))
+#define GDK_IS_X11_CAIRO_CONTEXT_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X11_CAIRO_CONTEXT))
+#define GDK_X11_CAIRO_CONTEXT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_X11_CAIRO_CONTEXT, GdkX11CairoContextClass))
+
+typedef struct _GdkX11CairoContext GdkX11CairoContext;
+typedef struct _GdkX11CairoContextClass GdkX11CairoContextClass;
+
+struct _GdkX11CairoContext
+{
+  GdkCairoContext parent_instance;
+};
+
+struct _GdkX11CairoContextClass
+{
+  GdkCairoContextClass parent_class;
+};
+
+GDK_AVAILABLE_IN_ALL
+GType gdk_x11_cairo_context_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_X11_CAIRO_CONTEXT__ */
index 15dd1a5a5fb4947f6854011f428be086094cbb4d..4ac989d3de3299b7abc8f4781376ad5b9272cc45 100644 (file)
@@ -40,6 +40,7 @@
 #include "gdkclipboard-x11.h"
 #include "gdkprivate-x11.h"
 #include "gdkscreen-x11.h"
+#include "gdkcairocontext-x11.h"
 #include "gdkglcontext-x11.h"
 #include "gdkvulkancontext-x11.h"
 #include "gdk-private.h"
@@ -3032,6 +3033,7 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
   object_class->finalize = gdk_x11_display_finalize;
 
   display_class->surface_type = GDK_TYPE_X11_SURFACE;
+  display_class->cairo_context_type = GDK_TYPE_X11_CAIRO_CONTEXT;
 #ifdef GDK_RENDERING_VULKAN
   display_class->vk_context_type = GDK_TYPE_X11_VULKAN_CONTEXT;
   display_class->vk_extension_name = VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
index dbffdcca5f1ea63295939d48b6d1f1bb65c10203..38df0746eb492ab185cd5d20293d5137675a14a1 100644 (file)
@@ -2,6 +2,7 @@
 gdk_x11_sources = files([
   'gdkapplaunchcontext-x11.c',
   'gdkasync.c',
+  'gdkcairocontext-x11.c',
   'gdkclipboard-x11.c',
   'gdkcursor-x11.c',
   'gdkdevice-core-x11.c',