[gtk+] API: Require passing a GLContext to begin_draw_frame()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] API: Require passing a GLContext to begin_draw_frame()
- Date: Mon, 5 Dec 2016 14:07:52 +0000 (UTC)
commit 332ed7be5b9a973e58711cb63f80265ad17b95a6
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/gdkdrawingcontext.c | 44 +++++++++++++++++++++++++++++++++++++++++---
gdk/gdkdrawingcontext.h | 2 ++
gdk/gdkwindow.c | 8 ++++++++
gdk/gdkwindow.h | 3 ++-
gtk/gtkwidget.c | 2 +-
5 files changed, 54 insertions(+), 5 deletions(-)
---
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 d754fce..4f9980f 100644
--- a/gdk/gdkdrawingcontext.h
+++ b/gdk/gdkdrawingcontext.h
@@ -38,6 +38,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 86fb756..b70b3e5 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -2856,6 +2856,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
@@ -2894,6 +2895,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;
@@ -2901,6 +2903,11 @@ 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);
+ if (gl_context != NULL)
+ {
+ g_return_val_if_fail (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)
{
@@ -2912,6 +2919,7 @@ gdk_window_begin_draw_frame (GdkWindow *window,
context = g_object_new (GDK_TYPE_DRAWING_CONTEXT,
"window", window,
+ "paint-context", gl_context,
"clip", region,
NULL);
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index 5a0601c..96d326c 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/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 9f212fe..641726d 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15694,7 +15694,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]