diff --git a/gdk/broadway/gdkcairocontext-broadway.c b/gdk/broadway/gdkcairocontext-broadway.c new file mode 100644 index 0000000000..245e33551a --- /dev/null +++ b/gdk/broadway/gdkcairocontext-broadway.c @@ -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 . + */ + +#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 index 0000000000..a5b9368f58 --- /dev/null +++ b/gdk/broadway/gdkcairocontext-broadway.h @@ -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 . + */ + +#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__ */ diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c index 329dfcf19f..254e0a2bc7 100644 --- a/gdk/broadway/gdkdisplay-broadway.c +++ b/gdk/broadway/gdkdisplay-broadway.c @@ -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; diff --git a/gdk/broadway/meson.build b/gdk/broadway/meson.build index 81e29cc9c1..aaa517ee6f 100644 --- a/gdk/broadway/meson.build +++ b/gdk/broadway/meson.build @@ -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', diff --git a/gdk/gdkcairocontext.c b/gdk/gdkcairocontext.c index 596eaabfa6..13be76cb28 100644 --- a/gdk/gdkcairocontext.c +++ b/gdk/gdkcairocontext.c @@ -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) diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index 579f266bf1..ac873281b5 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -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 */ diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index ee556358ac..08fd046125 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -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 index 0000000000..2b23ab1449 --- /dev/null +++ b/gdk/quartz/gdkcairocontext-quartz.c @@ -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 . + */ + +#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 index 0000000000..98811b0e0e --- /dev/null +++ b/gdk/quartz/gdkcairocontext-quartz.h @@ -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 . + */ + +#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__ */ diff --git a/gdk/quartz/gdkdisplay-quartz.c b/gdk/quartz/gdkdisplay-quartz.c index dc933f9106..3420801978 100644 --- a/gdk/quartz/gdkdisplay-quartz.c +++ b/gdk/quartz/gdkdisplay-quartz.c @@ -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; diff --git a/gdk/quartz/meson.build b/gdk/quartz/meson.build index 8d2e0fc2c3..dabeb6b5b6 100644 --- a/gdk/quartz/meson.build +++ b/gdk/quartz/meson.build @@ -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 index 0000000000..f5ee327543 --- /dev/null +++ b/gdk/wayland/gdkcairocontext-wayland.c @@ -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 . + */ + +#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 index 0000000000..278415dded --- /dev/null +++ b/gdk/wayland/gdkcairocontext-wayland.h @@ -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 . + */ + +#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__ */ diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 2c35b65beb..4999ce0905 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -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; diff --git a/gdk/wayland/meson.build b/gdk/wayland/meson.build index 8bf4718611..e6e66158bb 100644 --- a/gdk/wayland/meson.build +++ b/gdk/wayland/meson.build @@ -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 index 0000000000..e7be8fc85c --- /dev/null +++ b/gdk/win32/gdkcairocontext-win32.c @@ -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 . + */ + +#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 index 0000000000..c1a6ac53cc --- /dev/null +++ b/gdk/win32/gdkcairocontext-win32.h @@ -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 . + */ + +#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__ */ diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index 9834b69cc7..d610cb4dc3 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -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; diff --git a/gdk/win32/meson.build b/gdk/win32/meson.build index c1df54cda1..534772b495 100644 --- a/gdk/win32/meson.build +++ b/gdk/win32/meson.build @@ -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 index 0000000000..ee464d8f4a --- /dev/null +++ b/gdk/x11/gdkcairocontext-x11.c @@ -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 . + */ + +#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 index 0000000000..2fb4d8d323 --- /dev/null +++ b/gdk/x11/gdkcairocontext-x11.h @@ -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 . + */ + +#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__ */ diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 15dd1a5a5f..4ac989d3de 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -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; diff --git a/gdk/x11/meson.build b/gdk/x11/meson.build index dbffdcca5f..38df0746eb 100644 --- a/gdk/x11/meson.build +++ b/gdk/x11/meson.build @@ -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',