[gtk+] gdk: Make each backend have a custom GdkDrawingContext subclass
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdk: Make each backend have a custom GdkDrawingContext subclass
- Date: Sun, 20 Nov 2016 10:52:45 +0000 (UTC)
commit cb18752f94c33f3b5886faa472a11bad872923a2
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 20 07:16:32 2016 +0100
gdk: Make each backend have a custom GdkDrawingContext subclass
gdk/broadway/Makefile.am | 2 +
gdk/broadway/gdkdrawingcontext-broadway.c | 33 +++++++++++++++
gdk/broadway/gdkdrawingcontext-broadway.h | 48 ++++++++++++++++++++++
gdk/broadway/gdkwindow-broadway.c | 12 +++++
gdk/gdkwindow.c | 14 +------
gdk/mir/Makefile.am | 1 +
gdk/mir/gdkmir-private.h | 2 +
gdk/mir/gdkmirdrawingcontext.c | 63 +++++++++++++++++++++++++++++
gdk/mir/gdkmirwindowimpl.c | 1 +
gdk/quartz/Makefile.am | 2 +
gdk/quartz/gdkdrawingcontext-quartz.c | 33 +++++++++++++++
gdk/quartz/gdkdrawingcontext-quartz.h | 48 ++++++++++++++++++++++
gdk/quartz/gdkwindow-quartz.c | 12 +++++
gdk/wayland/Makefile.am | 2 +
gdk/wayland/gdkdrawingcontext-wayland.c | 33 +++++++++++++++
gdk/wayland/gdkdrawingcontext-wayland.h | 48 ++++++++++++++++++++++
gdk/wayland/gdkwindow-wayland.c | 12 +++++
gdk/win32/Makefile.am | 2 +
gdk/win32/gdkdrawingcontext-win32.c | 33 +++++++++++++++
gdk/win32/gdkdrawingcontext-win32.h | 48 ++++++++++++++++++++++
gdk/win32/gdkwindow-win32.c | 12 +++++
gdk/x11/Makefile.am | 2 +
gdk/x11/gdkdrawingcontext-x11.c | 33 +++++++++++++++
gdk/x11/gdkdrawingcontext-x11.h | 48 ++++++++++++++++++++++
gdk/x11/gdkwindow-x11.c | 12 +++++
25 files changed, 543 insertions(+), 13 deletions(-)
---
diff --git a/gdk/broadway/Makefile.am b/gdk/broadway/Makefile.am
index be5304a..5858eeb 100644
--- a/gdk/broadway/Makefile.am
+++ b/gdk/broadway/Makefile.am
@@ -61,6 +61,8 @@ libgdk_broadway_la_SOURCES = \
gdkdisplay-broadway.c \
gdkdisplay-broadway.h \
gdkdnd-broadway.c \
+ gdkdrawingcontext-broadway.c \
+ gdkdrawingcontext-broadway.h \
gdkeventsource.c \
gdkeventsource.h \
gdkglobals-broadway.c \
diff --git a/gdk/broadway/gdkdrawingcontext-broadway.c b/gdk/broadway/gdkdrawingcontext-broadway.c
new file mode 100644
index 0000000..ea1ec85
--- /dev/null
+++ b/gdk/broadway/gdkdrawingcontext-broadway.c
@@ -0,0 +1,33 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright 2016 Benjamin Otte <otte gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkdrawingcontext-broadway.h"
+
+G_DEFINE_TYPE (GdkBroadwayDrawingContext, gdk_broadway_drawing_context, GDK_TYPE_DRAWING_CONTEXT)
+
+static void
+gdk_broadway_drawing_context_class_init (GdkBroadwayDrawingContextClass *klass)
+{
+}
+
+static void
+gdk_broadway_drawing_context_init (GdkBroadwayDrawingContext *self)
+{
+}
+
diff --git a/gdk/broadway/gdkdrawingcontext-broadway.h b/gdk/broadway/gdkdrawingcontext-broadway.h
new file mode 100644
index 0000000..03883d8
--- /dev/null
+++ b/gdk/broadway/gdkdrawingcontext-broadway.h
@@ -0,0 +1,48 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_BROADWAY_DRAWING_CONTEXT_H__
+#define __GDK_BROADWAY_DRAWING_CONTEXT_H__
+
+#include "gdk/gdkdrawingcontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_BROADWAY_DRAWING_CONTEXT (gdk_broadway_drawing_context_get_type ())
+#define GDK_BROADWAY_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GDK_TYPE_BROADWAY_DRAWING_CONTEXT, GdkBroadwayDrawingContext))
+#define GDK_IS_BROADWAY_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GDK_TYPE_BROADWAY_DRAWING_CONTEXT))
+#define GDK_BROADWAY_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GDK_TYPE_BROADWAY_DRAWING_CONTEXT, GdkBroadwayDrawingContextClass))
+#define GDK_IS_BROADWAY_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GDK_TYPE_BROADWAY_DRAWING_CONTEXT))
+#define GDK_BROADWAY_DRAWING_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GDK_TYPE_BROADWAY_DRAWING_CONTEXT, GdkBroadwayDrawingContextClass))
+
+typedef struct _GdkBroadwayDrawingContext GdkBroadwayDrawingContext;
+typedef struct _GdkBroadwayDrawingContextClass GdkBroadwayDrawingContextClass;
+
+struct _GdkBroadwayDrawingContext
+{
+ GdkDrawingContext parent_instance;
+};
+
+struct _GdkBroadwayDrawingContextClass
+{
+ GdkDrawingContextClass parent_instance;
+};
+
+GType gdk_broadway_drawing_context_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_BROADWAY_DRAWING_CONTEXT_H__ */
diff --git a/gdk/broadway/gdkwindow-broadway.c b/gdk/broadway/gdkwindow-broadway.c
index e54abd2..1ddc444 100644
--- a/gdk/broadway/gdkwindow-broadway.c
+++ b/gdk/broadway/gdkwindow-broadway.c
@@ -33,6 +33,7 @@
#include "gdkwindow.h"
#include "gdkwindowimpl.h"
#include "gdkdisplay-broadway.h"
+#include "gdkdrawingcontext-broadway.h"
#include "gdkprivate-broadway.h"
#include "gdkinternals.h"
#include "gdkdeviceprivate.h"
@@ -1510,6 +1511,16 @@ gdk_broadway_get_last_seen_time (GdkWindow *window)
return _gdk_broadway_server_get_last_seen_time (GDK_BROADWAY_DISPLAY (display)->server);
}
+static GdkDrawingContext *
+gdk_broadway_window_create_draw_context (GdkWindow *window,
+ const cairo_region_t *region)
+{
+ return g_object_new (GDK_TYPE_BROADWAY_DRAWING_CONTEXT,
+ "window", window,
+ "clip", region,
+ NULL);
+}
+
static void
gdk_window_impl_broadway_class_init (GdkWindowImplBroadwayClass *klass)
{
@@ -1588,4 +1599,5 @@ gdk_window_impl_broadway_class_init (GdkWindowImplBroadwayClass *klass)
impl_class->change_property = _gdk_broadway_window_change_property;
impl_class->delete_property = _gdk_broadway_window_delete_property;
impl_class->get_drag_protocol = _gdk_broadway_window_get_drag_protocol;
+ impl_class->create_draw_context = gdk_broadway_window_create_draw_context;
}
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 0fd2023..f3661b8 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -2892,7 +2892,6 @@ gdk_window_begin_draw_frame (GdkWindow *window,
const cairo_region_t *region)
{
GdkDrawingContext *context;
- GdkWindowImplClass *impl_class;
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
@@ -2907,18 +2906,7 @@ gdk_window_begin_draw_frame (GdkWindow *window,
if (gdk_window_has_native (window) && gdk_window_is_toplevel (window))
gdk_window_begin_paint_internal (window, region);
- impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
- if (impl_class->create_draw_context != NULL)
- {
- context = impl_class->create_draw_context (window, region);
- }
- else
- {
- context = g_object_new (GDK_TYPE_DRAWING_CONTEXT,
- "window", window,
- "clip", region,
- NULL);
- }
+ context = GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_draw_context (window, region);
/* Do not take a reference, to avoid creating cycles */
window->drawing_context = context;
diff --git a/gdk/mir/Makefile.am b/gdk/mir/Makefile.am
index 654b8f9..87ec55b 100644
--- a/gdk/mir/Makefile.am
+++ b/gdk/mir/Makefile.am
@@ -24,6 +24,7 @@ libgdk_mir_la_SOURCES = \
gdkmircursor.c \
gdkmirdevicemanager.c \
gdkmirdisplay.c \
+ gdkmirdrawingcontext.c \
gdkmireventsource.c \
gdkmirglcontext.c \
gdkmirkeyboard.c \
diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h
index 69f927f..afe7a7c 100644
--- a/gdk/mir/gdkmir-private.h
+++ b/gdk/mir/gdkmir-private.h
@@ -95,6 +95,8 @@ void _gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl, gdouble x, g
void _gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl, gdouble *x, gdouble *y, gboolean
*cursor_inside, guint *button_state);
+GdkDrawingContext *gdk_mir_drawing_context_new (GdkWindow *window, const cairo_region_t *region);
+
GdkMirEventSource *_gdk_mir_display_get_event_source (GdkDisplay *display);
GdkMirEventSource *_gdk_mir_event_source_new (GdkDisplay *display);
diff --git a/gdk/mir/gdkmirdrawingcontext.c b/gdk/mir/gdkmirdrawingcontext.c
new file mode 100644
index 0000000..e888a4a
--- /dev/null
+++ b/gdk/mir/gdkmirdrawingcontext.c
@@ -0,0 +1,63 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright 2016 Benjamin Otte <otte gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#define GDK_TYPE_MIR_DRAWING_CONTEXT (gdk_mir_drawing_context_get_type ())
+#define GDK_MIR_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GDK_TYPE_MIR_DRAWING_CONTEXT, GdkMirDrawingContext))
+#define GDK_IS_MIR_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GDK_TYPE_MIR_DRAWING_CONTEXT))
+#define GDK_MIR_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GDK_TYPE_MIR_DRAWING_CONTEXT, GdkMirDrawingContextClass))
+#define GDK_IS_MIR_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GDK_TYPE_MIR_DRAWING_CONTEXT))
+#define GDK_MIR_DRAWING_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GDK_TYPE_MIR_DRAWING_CONTEXT, GdkMirDrawingContextClass))
+
+typedef struct _GdkMirDrawingContext GdkMirDrawingContext;
+typedef struct _GdkMirDrawingContextClass GdkMirDrawingContextClass;
+
+struct _GdkMirDrawingContext
+{
+ GdkDrawingContext parent_instance;
+};
+
+struct _GdkMirDrawingContextClass
+{
+ GdkDrawingContextClass parent_instance;
+};
+
+GType gdk_mir_drawing_context_get_type (void) G_GNUC_CONST;
+
+G_DEFINE_TYPE (GdkMirDrawingContext, gdk_mir_drawing_context, GDK_TYPE_DRAWING_CONTEXT)
+
+static void
+gdk_mir_drawing_context_class_init (GdkMirDrawingContextClass *klass)
+{
+}
+
+static void
+gdk_mir_drawing_context_init (GdkMirDrawingContext *self)
+{
+}
+
+GdkDrawingContext *
+gdk_mir_drawing_context_new (GdkWindow *window,
+ const cairo_region_t *region)
+{
+ return g_object_new (GDK_TYPE_MIR_DRAWING_CONTEXT,
+ "window", window,
+ "clip", region,
+ NULL);
+}
+
diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c
index ec76ac5..96f65a4 100644
--- a/gdk/mir/gdkmirwindowimpl.c
+++ b/gdk/mir/gdkmirwindowimpl.c
@@ -1832,5 +1832,6 @@ gdk_mir_window_impl_class_init (GdkMirWindowImplClass *klass)
impl_class->set_opaque_region = gdk_mir_window_impl_set_opaque_region;
impl_class->set_shadow_width = gdk_mir_window_impl_set_shadow_width;
impl_class->create_gl_context = gdk_mir_window_impl_create_gl_context;
+ impl_class->create_draw_context = gdk_mir_drawing_context_new;
impl_class->invalidate_for_new_frame = gdk_mir_window_impl_invalidate_for_new_frame;
}
diff --git a/gdk/quartz/Makefile.am b/gdk/quartz/Makefile.am
index eda5263..ba5e8d2 100644
--- a/gdk/quartz/Makefile.am
+++ b/gdk/quartz/Makefile.am
@@ -30,6 +30,8 @@ libgdk_quartz_la_SOURCES = \
gdkdevicemanager-core-quartz.h \
gdkdisplay-quartz.c \
gdkdisplaymanager-quartz.c \
+ gdkdrawingcontext-quartz.c \
+ gdkdrawingcontext-quartz.h \
gdkdnd-quartz.c \
gdkdnd-quartz.h \
gdkevents-quartz.c \
diff --git a/gdk/quartz/gdkdrawingcontext-quartz.c b/gdk/quartz/gdkdrawingcontext-quartz.c
new file mode 100644
index 0000000..1e30ed7
--- /dev/null
+++ b/gdk/quartz/gdkdrawingcontext-quartz.c
@@ -0,0 +1,33 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright 2016 Benjamin Otte <otte gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkdrawingcontext-quartz.h"
+
+G_DEFINE_TYPE (GdkQuartzDrawingContext, gdk_quartz_drawing_context, GDK_TYPE_DRAWING_CONTEXT)
+
+static void
+gdk_quartz_drawing_context_class_init (GdkQuartzDrawingContextClass *klass)
+{
+}
+
+static void
+gdk_quartz_drawing_context_init (GdkQuartzDrawingContext *self)
+{
+}
+
diff --git a/gdk/quartz/gdkdrawingcontext-quartz.h b/gdk/quartz/gdkdrawingcontext-quartz.h
new file mode 100644
index 0000000..55c9d69
--- /dev/null
+++ b/gdk/quartz/gdkdrawingcontext-quartz.h
@@ -0,0 +1,48 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_QUARTZ_DRAWING_CONTEXT_H__
+#define __GDK_QUARTZ_DRAWING_CONTEXT_H__
+
+#include "gdk/gdkdrawingcontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_QUARTZ_DRAWING_CONTEXT (gdk_quartz_drawing_context_get_type ())
+#define GDK_QUARTZ_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GDK_TYPE_QUARTZ_DRAWING_CONTEXT, GdkQuartzDrawingContext))
+#define GDK_IS_QUARTZ_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GDK_TYPE_QUARTZ_DRAWING_CONTEXT))
+#define GDK_QUARTZ_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GDK_TYPE_QUARTZ_DRAWING_CONTEXT, GdkQuartzDrawingContextClass))
+#define GDK_IS_QUARTZ_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GDK_TYPE_QUARTZ_DRAWING_CONTEXT))
+#define GDK_QUARTZ_DRAWING_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GDK_TYPE_QUARTZ_DRAWING_CONTEXT, GdkQuartzDrawingContextClass))
+
+typedef struct _GdkQuartzDrawingContext GdkQuartzDrawingContext;
+typedef struct _GdkQuartzDrawingContextClass GdkQuartzDrawingContextClass;
+
+struct _GdkQuartzDrawingContext
+{
+ GdkDrawingContext parent_instance;
+};
+
+struct _GdkQuartzDrawingContextClass
+{
+ GdkDrawingContextClass parent_instance;
+};
+
+GType gdk_quartz_drawing_context_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_QUARTZ_DRAWING_CONTEXT_H__ */
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 9349537..1c548cc 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -25,6 +25,7 @@
#include "gdkwindowimpl.h"
#include "gdkprivate-quartz.h"
+#include "gdkdrawingcontext-quartz.h"
#include "gdkglcontext-quartz.h"
#include "gdkquartzscreen.h"
#include "gdkquartzcursor.h"
@@ -2825,6 +2826,16 @@ gdk_quartz_window_get_scale_factor (GdkWindow *window)
return 1;
}
+static GdkDrawingContext *
+gdk_quartz_window_create_draw_context (GdkWindow *window,
+ const cairo_region_t *region)
+{
+ return g_object_new (GDK_TYPE_QUARTZ_DRAWING_CONTEXT,
+ "window", window,
+ "clip", region,
+ NULL);
+}
+
static void
gdk_window_impl_quartz_class_init (GdkWindowImplQuartzClass *klass)
{
@@ -2909,6 +2920,7 @@ gdk_window_impl_quartz_class_init (GdkWindowImplQuartzClass *klass)
impl_class->delete_property = _gdk_quartz_window_delete_property;
impl_class->create_gl_context = gdk_quartz_window_create_gl_context;
+ impl_class->create_draw_context = gdk_quartz_window_create_draw_context;
impl_quartz_class->get_context = gdk_window_impl_quartz_get_context;
impl_quartz_class->release_context = gdk_window_impl_quartz_release_context;
diff --git a/gdk/wayland/Makefile.am b/gdk/wayland/Makefile.am
index 127e091..c40e24f 100644
--- a/gdk/wayland/Makefile.am
+++ b/gdk/wayland/Makefile.am
@@ -46,6 +46,8 @@ libgdk_wayland_la_SOURCES = \
gdkdevice-wayland.c \
gdkdisplay-wayland.c \
gdkdisplay-wayland.h \
+ gdkdrawingcontext-wayland.c \
+ gdkdrawingcontext-wayland.h \
gdkdnd-wayland.c \
gdkeventsource.c \
gdkkeys-wayland.c \
diff --git a/gdk/wayland/gdkdrawingcontext-wayland.c b/gdk/wayland/gdkdrawingcontext-wayland.c
new file mode 100644
index 0000000..927e569
--- /dev/null
+++ b/gdk/wayland/gdkdrawingcontext-wayland.c
@@ -0,0 +1,33 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright 2016 Benjamin Otte <otte gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkdrawingcontext-wayland.h"
+
+G_DEFINE_TYPE (GdkWaylandDrawingContext, gdk_wayland_drawing_context, GDK_TYPE_DRAWING_CONTEXT)
+
+static void
+gdk_wayland_drawing_context_class_init (GdkWaylandDrawingContextClass *klass)
+{
+}
+
+static void
+gdk_wayland_drawing_context_init (GdkWaylandDrawingContext *self)
+{
+}
+
diff --git a/gdk/wayland/gdkdrawingcontext-wayland.h b/gdk/wayland/gdkdrawingcontext-wayland.h
new file mode 100644
index 0000000..2577f74
--- /dev/null
+++ b/gdk/wayland/gdkdrawingcontext-wayland.h
@@ -0,0 +1,48 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_WAYLAND_DRAWING_CONTEXT_H__
+#define __GDK_WAYLAND_DRAWING_CONTEXT_H__
+
+#include "gdk/gdkdrawingcontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_WAYLAND_DRAWING_CONTEXT (gdk_wayland_drawing_context_get_type ())
+#define GDK_WAYLAND_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GDK_TYPE_WAYLAND_DRAWING_CONTEXT, GdkWaylandDrawingContext))
+#define GDK_IS_WAYLAND_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GDK_TYPE_WAYLAND_DRAWING_CONTEXT))
+#define GDK_WAYLAND_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GDK_TYPE_WAYLAND_DRAWING_CONTEXT, GdkWaylandDrawingContextClass))
+#define GDK_IS_WAYLAND_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GDK_TYPE_WAYLAND_DRAWING_CONTEXT))
+#define GDK_WAYLAND_DRAWING_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GDK_TYPE_WAYLAND_DRAWING_CONTEXT, GdkWaylandDrawingContextClass))
+
+typedef struct _GdkWaylandDrawingContext GdkWaylandDrawingContext;
+typedef struct _GdkWaylandDrawingContextClass GdkWaylandDrawingContextClass;
+
+struct _GdkWaylandDrawingContext
+{
+ GdkDrawingContext parent_instance;
+};
+
+struct _GdkWaylandDrawingContextClass
+{
+ GdkDrawingContextClass parent_instance;
+};
+
+GType gdk_wayland_drawing_context_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_WAYLAND_DRAWING_CONTEXT_H__ */
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 010add3..12ce613 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -26,6 +26,7 @@
#include "gdkwindow.h"
#include "gdkwindowimpl.h"
#include "gdkdisplay-wayland.h"
+#include "gdkdrawingcontext-wayland.h"
#include "gdkglcontext-wayland.h"
#include "gdkframeclockprivate.h"
#include "gdkprivate-wayland.h"
@@ -3563,6 +3564,16 @@ gdk_wayland_window_show_window_menu (GdkWindow *window,
return TRUE;
}
+static GdkDrawingContext *
+gdk_wayland_window_create_draw_context (GdkWindow *window,
+ const cairo_region_t *region)
+{
+ return g_object_new (GDK_TYPE_WAYLAND_DRAWING_CONTEXT,
+ "window", window,
+ "clip", region,
+ NULL);
+}
+
static void
_gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
{
@@ -3650,6 +3661,7 @@ _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
impl_class->set_shadow_width = gdk_wayland_window_set_shadow_width;
impl_class->show_window_menu = gdk_wayland_window_show_window_menu;
impl_class->create_gl_context = gdk_wayland_window_create_gl_context;
+ impl_class->create_draw_context = gdk_wayland_window_create_draw_context;
impl_class->invalidate_for_new_frame = gdk_wayland_window_invalidate_for_new_frame;
signals[COMMITTED] = g_signal_new ("committed",
diff --git a/gdk/win32/Makefile.am b/gdk/win32/Makefile.am
index ebd4ae6..eb76bbc 100644
--- a/gdk/win32/Makefile.am
+++ b/gdk/win32/Makefile.am
@@ -40,6 +40,8 @@ libgdk_win32_la_SOURCES = \
gdkdisplay-win32.c \
gdkdisplay-win32.h \
gdkdisplaymanager-win32.c \
+ gdkdrawingcontext-win32.c \
+ gdkdrawingcontext-win32.h \
gdkdnd-win32.c \
gdkevents-win32.c \
gdkgeometry-win32.c \
diff --git a/gdk/win32/gdkdrawingcontext-win32.c b/gdk/win32/gdkdrawingcontext-win32.c
new file mode 100644
index 0000000..6938422
--- /dev/null
+++ b/gdk/win32/gdkdrawingcontext-win32.c
@@ -0,0 +1,33 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright 2016 Benjamin Otte <otte gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkdrawingcontext-win32.h"
+
+G_DEFINE_TYPE (GdkWin32DrawingContext, gdk_win32_drawing_context, GDK_TYPE_DRAWING_CONTEXT)
+
+static void
+gdk_win32_drawing_context_class_init (GdkWin32DrawingContextClass *klass)
+{
+}
+
+static void
+gdk_win32_drawing_context_init (GdkWin32DrawingContext *self)
+{
+}
+
diff --git a/gdk/win32/gdkdrawingcontext-win32.h b/gdk/win32/gdkdrawingcontext-win32.h
new file mode 100644
index 0000000..fe6fa45
--- /dev/null
+++ b/gdk/win32/gdkdrawingcontext-win32.h
@@ -0,0 +1,48 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_WIN32_DRAWING_CONTEXT_H__
+#define __GDK_WIN32_DRAWING_CONTEXT_H__
+
+#include "gdk/gdkdrawingcontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_WIN32_DRAWING_CONTEXT (gdk_win32_drawing_context_get_type ())
+#define GDK_WIN32_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GDK_TYPE_WIN32_DRAWING_CONTEXT, GdkWin32DrawingContext))
+#define GDK_IS_WIN32_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GDK_TYPE_WIN32_DRAWING_CONTEXT))
+#define GDK_WIN32_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GDK_TYPE_WIN32_DRAWING_CONTEXT, GdkWin32DrawingContextClass))
+#define GDK_IS_WIN32_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GDK_TYPE_WIN32_DRAWING_CONTEXT))
+#define GDK_WIN32_DRAWING_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GDK_TYPE_WIN32_DRAWING_CONTEXT, GdkWin32DrawingContextClass))
+
+typedef struct _GdkWin32DrawingContext GdkWin32DrawingContext;
+typedef struct _GdkWin32DrawingContextClass GdkWin32DrawingContextClass;
+
+struct _GdkWin32DrawingContext
+{
+ GdkDrawingContext parent_instance;
+};
+
+struct _GdkWin32DrawingContextClass
+{
+ GdkDrawingContextClass parent_instance;
+};
+
+GType gdk_win32_drawing_context_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_WIN32_DRAWING_CONTEXT_H__ */
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index cddd9ef..84e0d7d 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -41,6 +41,7 @@
#include "gdkwin32window.h"
#include "gdkglcontext-win32.h"
#include "gdkdisplay-win32.h"
+#include "gdkdrawingcontext-win32.h"
#include <cairo-win32.h>
#include <dwmapi.h>
@@ -6025,6 +6026,16 @@ _gdk_win32_window_get_unscaled_size (GdkWindow *window,
*unscaled_height = impl->unscaled_height;
}
+static GdkDrawingContext *
+gdk_win32_window_create_draw_context (GdkWindow *window,
+ const cairo_region_t *region)
+{
+ return g_object_new (GDK_TYPE_WIN32_DRAWING_CONTEXT,
+ "window", window,
+ "clip", region,
+ NULL);
+}
+
static void
gdk_window_impl_win32_class_init (GdkWindowImplWin32Class *klass)
{
@@ -6114,6 +6125,7 @@ gdk_window_impl_win32_class_init (GdkWindowImplWin32Class *klass)
impl_class->change_property = _gdk_win32_window_change_property;
impl_class->delete_property = _gdk_win32_window_delete_property;
impl_class->create_gl_context = _gdk_win32_window_create_gl_context;
+ impl_class->create_draw_context = _gdk_win32_window_create_draw_context;
impl_class->invalidate_for_new_frame = _gdk_win32_window_invalidate_for_new_frame;
impl_class->get_scale_factor = _gdk_win32_window_get_scale_factor;
impl_class->get_unscaled_size = _gdk_win32_window_get_unscaled_size;
diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am
index c233520..cd4d0e0 100644
--- a/gdk/x11/Makefile.am
+++ b/gdk/x11/Makefile.am
@@ -35,6 +35,8 @@ libgdk_x11_la_SOURCES = \
gdkdisplay-x11.c \
gdkdisplay-x11.h \
gdkdnd-x11.c \
+ gdkdrawingcontext-x11.c \
+ gdkdrawingcontext-x11.h \
gdkeventsource.c \
gdkeventsource.h \
gdkeventtranslator.c \
diff --git a/gdk/x11/gdkdrawingcontext-x11.c b/gdk/x11/gdkdrawingcontext-x11.c
new file mode 100644
index 0000000..6941124
--- /dev/null
+++ b/gdk/x11/gdkdrawingcontext-x11.c
@@ -0,0 +1,33 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright 2016 Benjamin Otte <otte gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkdrawingcontext-x11.h"
+
+G_DEFINE_TYPE (GdkX11DrawingContext, gdk_x11_drawing_context, GDK_TYPE_DRAWING_CONTEXT)
+
+static void
+gdk_x11_drawing_context_class_init (GdkX11DrawingContextClass *klass)
+{
+}
+
+static void
+gdk_x11_drawing_context_init (GdkX11DrawingContext *self)
+{
+}
+
diff --git a/gdk/x11/gdkdrawingcontext-x11.h b/gdk/x11/gdkdrawingcontext-x11.h
new file mode 100644
index 0000000..e2858fc
--- /dev/null
+++ b/gdk/x11/gdkdrawingcontext-x11.h
@@ -0,0 +1,48 @@
+/* GDK - The GIMP Drawing Kit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_X11_DRAWING_CONTEXT_H__
+#define __GDK_X11_DRAWING_CONTEXT_H__
+
+#include "gdk/gdkdrawingcontextprivate.h"
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_X11_DRAWING_CONTEXT (gdk_x11_drawing_context_get_type ())
+#define GDK_X11_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GDK_TYPE_X11_DRAWING_CONTEXT, GdkX11DrawingContext))
+#define GDK_IS_X11_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GDK_TYPE_X11_DRAWING_CONTEXT))
+#define GDK_X11_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GDK_TYPE_X11_DRAWING_CONTEXT, GdkX11DrawingContextClass))
+#define GDK_IS_X11_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GDK_TYPE_X11_DRAWING_CONTEXT))
+#define GDK_X11_DRAWING_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GDK_TYPE_X11_DRAWING_CONTEXT, GdkX11DrawingContextClass))
+
+typedef struct _GdkX11DrawingContext GdkX11DrawingContext;
+typedef struct _GdkX11DrawingContextClass GdkX11DrawingContextClass;
+
+struct _GdkX11DrawingContext
+{
+ GdkDrawingContext parent_instance;
+};
+
+struct _GdkX11DrawingContextClass
+{
+ GdkDrawingContextClass parent_instance;
+};
+
+GType gdk_x11_drawing_context_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_X11_DRAWING_CONTEXT_H__ */
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index b13e246..998d302 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -36,6 +36,7 @@
#include "gdkasync.h"
#include "gdkeventsource.h"
#include "gdkdisplay-x11.h"
+#include "gdkdrawingcontext-x11.h"
#include "gdkglcontext-x11.h"
#include "gdkprivate-x11.h"
#include "gdk-private.h"
@@ -210,6 +211,16 @@ gdk_x11_window_get_unscaled_size (GdkWindow *window,
*unscaled_height = impl->unscaled_height;
}
+static GdkDrawingContext *
+gdk_x11_window_create_draw_context (GdkWindow *window,
+ const cairo_region_t *region)
+{
+ return g_object_new (GDK_TYPE_X11_DRAWING_CONTEXT,
+ "window", window,
+ "clip", region,
+ NULL);
+}
+
static void
set_sync_counter(Display *display,
XSyncCounter counter,
@@ -5409,5 +5420,6 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
impl_class->show_window_menu = gdk_x11_window_show_window_menu;
impl_class->create_gl_context = gdk_x11_window_create_gl_context;
impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame;
+ impl_class->create_draw_context = gdk_x11_window_create_draw_context;
impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]