[gtk+/wip/otte/gl-drawing: 4/15] API: Require passing a GLContext to begin_draw_frame()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/gl-drawing: 4/15] API: Require passing a GLContext to begin_draw_frame()
- Date: Wed, 23 Nov 2016 07:50:19 +0000 (UTC)
commit 6a5c1b2b56d00c96ac50410cafc99250eb67c55a
Author: Benjamin Otte <otte redhat com>
Date: Tue Nov 22 04:12:51 2016 +0100
API: Require passing a GLContext to begin_draw_frame()
This is in preparation for requiring explicit passing of GL contexts
when drawing.
gdk/broadway/gdkwindow-broadway.c | 4 ++-
gdk/gdkdrawingcontext.c | 44 ++++++++++++++++++++++++++++++++++--
gdk/gdkdrawingcontext.h | 2 +
gdk/gdkwindow.c | 6 ++++-
gdk/gdkwindow.h | 3 +-
gdk/gdkwindowimpl.h | 1 +
gdk/mir/gdkmir-private.h | 2 +-
gdk/mir/gdkmirdrawingcontext.c | 2 +
gdk/quartz/gdkwindow-quartz.c | 2 +
gdk/wayland/gdkwindow-wayland.c | 2 +
gdk/win32/gdkwindow-win32.c | 2 +
gdk/x11/gdkwindow-x11.c | 2 +
gtk/gtkwidget.c | 2 +-
13 files changed, 66 insertions(+), 8 deletions(-)
---
diff --git a/gdk/broadway/gdkwindow-broadway.c b/gdk/broadway/gdkwindow-broadway.c
index 1ddc444..6f0eb06 100644
--- a/gdk/broadway/gdkwindow-broadway.c
+++ b/gdk/broadway/gdkwindow-broadway.c
@@ -1513,10 +1513,12 @@ gdk_broadway_get_last_seen_time (GdkWindow *window)
static GdkDrawingContext *
gdk_broadway_window_create_draw_context (GdkWindow *window,
- const cairo_region_t *region)
+ GdkGLContext *context,
+ const cairo_region_t *region)
{
return g_object_new (GDK_TYPE_BROADWAY_DRAWING_CONTEXT,
"window", window,
+ "paint-context", context,
"clip", region,
NULL);
}
diff --git a/gdk/gdkdrawingcontext.c b/gdk/gdkdrawingcontext.c
index cee0ea9..ec230a1 100644
--- a/gdk/gdkdrawingcontext.c
+++ b/gdk/gdkdrawingcontext.c
@@ -63,6 +63,7 @@ enum {
PROP_WINDOW,
PROP_CLIP,
+ PROP_PAINT_CONTEXT,
N_PROPS
};
@@ -110,9 +111,9 @@ gdk_drawing_context_set_property (GObject *gobject,
G_OBJECT_TYPE_NAME (gobject));
return;
}
- priv->paint_context = priv->window->gl_paint_context;
- if (priv->paint_context)
- g_object_ref (priv->paint_context);
+
+ case PROP_PAINT_CONTEXT:
+ priv->paint_context = g_value_dup_object (value);
break;
case PROP_CLIP:
@@ -143,6 +144,10 @@ gdk_drawing_context_get_property (GObject *gobject,
g_value_set_boxed (value, priv->clip);
break;
+ case PROP_PAINT_CONTEXT:
+ g_value_set_object (value, priv->paint_context);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
@@ -183,6 +188,19 @@ gdk_drawing_context_class_init (GdkDrawingContextClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
+ /**
+ * GdkDrawingContext:paint-context:
+ *
+ * The #GdkGLContext used to draw or %NULL if Cairo is used.
+ *
+ * Since: 3.90
+ */
+ obj_property[PROP_PAINT_CONTEXT] =
+ g_param_spec_object ("paint-context", "Paint context", "The context used to draw",
+ GDK_TYPE_GL_CONTEXT,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPS, obj_property);
}
@@ -288,6 +306,26 @@ gdk_drawing_context_get_window (GdkDrawingContext *context)
}
/**
+ * gdk_drawing_context_get_paint_context:
+ * @context: a #GdkDrawingContext
+ *
+ * Retrieves the paint context used to draw with.
+ *
+ * Returns: (transfer none): a #GdkGLContext or %NULL
+ *
+ * Since: 3.90
+ */
+GdkGLContext *
+gdk_drawing_context_get_paint_context (GdkDrawingContext *context)
+{
+ GdkDrawingContextPrivate *priv = gdk_drawing_context_get_instance_private (context);
+
+ g_return_val_if_fail (GDK_IS_DRAWING_CONTEXT (context), NULL);
+
+ return priv->paint_context;
+}
+
+/**
* gdk_drawing_context_get_clip:
* @context: a #GdkDrawingContext
*
diff --git a/gdk/gdkdrawingcontext.h b/gdk/gdkdrawingcontext.h
index 6202648..a6c5e59 100644
--- a/gdk/gdkdrawingcontext.h
+++ b/gdk/gdkdrawingcontext.h
@@ -39,6 +39,8 @@ GType gdk_drawing_context_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_22
GdkWindow * gdk_drawing_context_get_window (GdkDrawingContext *context);
+GDK_AVAILABLE_IN_3_90
+GdkGLContext* gdk_drawing_context_get_paint_context (GdkDrawingContext *context);
GDK_AVAILABLE_IN_3_22
cairo_region_t *gdk_drawing_context_get_clip (GdkDrawingContext *context);
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 2741d9c..25c4366 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -2851,6 +2851,7 @@ gdk_window_end_paint_internal (GdkWindow *window)
/**
* gdk_window_begin_draw_frame:
* @window: a #GdkWindow
+ * @context: (allow-none): the context used to draw the frame
* @region: a Cairo region
*
* Indicates that you are beginning the process of redrawing @region
@@ -2889,6 +2890,7 @@ gdk_window_end_paint_internal (GdkWindow *window)
*/
GdkDrawingContext *
gdk_window_begin_draw_frame (GdkWindow *window,
+ GdkGLContext *gl_context,
const cairo_region_t *region)
{
GdkDrawingContext *context;
@@ -2896,6 +2898,8 @@ gdk_window_begin_draw_frame (GdkWindow *window,
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
g_return_val_if_fail (gdk_window_has_native (window), NULL);
g_return_val_if_fail (gdk_window_is_toplevel (window), NULL);
+ g_return_val_if_fail (gl_context == NULL || GDK_IS_GL_CONTEXT (gl_context), NULL);
+ g_return_val_if_fail (gdk_gl_context_get_window (gl_context) == window, NULL);
if (window->drawing_context != NULL)
{
@@ -2905,7 +2909,7 @@ gdk_window_begin_draw_frame (GdkWindow *window,
return NULL;
}
- context = GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_draw_context (window, region);
+ context = GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_draw_context (window, gl_context, region);
/* Do not take a reference, to avoid creating cycles */
window->drawing_context = context;
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index 482cc37..c8a3edd 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -626,8 +626,9 @@ GDK_AVAILABLE_IN_3_16
void gdk_window_mark_paint_from_clip (GdkWindow *window,
cairo_t *cr);
-GDK_AVAILABLE_IN_3_22
+GDK_AVAILABLE_IN_3_90
GdkDrawingContext *gdk_window_begin_draw_frame (GdkWindow *window,
+ GdkGLContext *context,
const cairo_region_t *region);
GDK_AVAILABLE_IN_3_22
void gdk_window_end_draw_frame (GdkWindow *window,
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index ab1c180..7359408 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -306,6 +306,7 @@ struct _GdkWindowImplClass
cairo_region_t *update_area);
GdkDrawingContext *(* create_draw_context) (GdkWindow *window,
+ GdkGLContext *context,
const cairo_region_t *region);
};
diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h
index afe7a7c..7ab8ab4 100644
--- a/gdk/mir/gdkmir-private.h
+++ b/gdk/mir/gdkmir-private.h
@@ -95,7 +95,7 @@ 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);
+GdkDrawingContext *gdk_mir_drawing_context_new (GdkWindow *window, GdkGLContext *context, const
cairo_region_t *region);
GdkMirEventSource *_gdk_mir_display_get_event_source (GdkDisplay *display);
diff --git a/gdk/mir/gdkmirdrawingcontext.c b/gdk/mir/gdkmirdrawingcontext.c
index e888a4a..825924e 100644
--- a/gdk/mir/gdkmirdrawingcontext.c
+++ b/gdk/mir/gdkmirdrawingcontext.c
@@ -53,10 +53,12 @@ gdk_mir_drawing_context_init (GdkMirDrawingContext *self)
GdkDrawingContext *
gdk_mir_drawing_context_new (GdkWindow *window,
+ GdkGLContext *context,
const cairo_region_t *region)
{
return g_object_new (GDK_TYPE_MIR_DRAWING_CONTEXT,
"window", window,
+ "paint-context", context,
"clip", region,
NULL);
}
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 1c548cc..f4b60db 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -2828,10 +2828,12 @@ gdk_quartz_window_get_scale_factor (GdkWindow *window)
static GdkDrawingContext *
gdk_quartz_window_create_draw_context (GdkWindow *window,
+ GdkGLContext *context,
const cairo_region_t *region)
{
return g_object_new (GDK_TYPE_QUARTZ_DRAWING_CONTEXT,
"window", window,
+ "paint-context", context,
"clip", region,
NULL);
}
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 12ce613..4eecf86 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -3566,10 +3566,12 @@ gdk_wayland_window_show_window_menu (GdkWindow *window,
static GdkDrawingContext *
gdk_wayland_window_create_draw_context (GdkWindow *window,
+ GdkGLContext *context,
const cairo_region_t *region)
{
return g_object_new (GDK_TYPE_WAYLAND_DRAWING_CONTEXT,
"window", window,
+ "paint-context", context,
"clip", region,
NULL);
}
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index f5c4be4..391c62a 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -6028,10 +6028,12 @@ _gdk_win32_window_get_unscaled_size (GdkWindow *window,
static GdkDrawingContext *
gdk_win32_window_create_draw_context (GdkWindow *window,
+ GdkGLContext *context,
const cairo_region_t *region)
{
return g_object_new (GDK_TYPE_WIN32_DRAWING_CONTEXT,
"window", window,
+ "paint-context", context,
"clip", region,
NULL);
}
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 998d302..a971ab0 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -213,10 +213,12 @@ gdk_x11_window_get_unscaled_size (GdkWindow *window,
static GdkDrawingContext *
gdk_x11_window_create_draw_context (GdkWindow *window,
+ GdkGLContext *context,
const cairo_region_t *region)
{
return g_object_new (GDK_TYPE_X11_DRAWING_CONTEXT,
"window", window,
+ "paint-context", context,
"clip", region,
NULL);
}
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b5c28d4..901c31f 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15741,7 +15741,7 @@ gtk_widget_render (GtkWidget *widget,
gtk_inspector_record_render (widget, renderer, window, region, root);
- context = gdk_window_begin_draw_frame (window, region);
+ context = gdk_window_begin_draw_frame (window, NULL, region);
gsk_renderer_render (renderer, root, context);
gsk_render_node_unref (root);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]