diff options
author | Benjamin Otte <otte@redhat.com> | 2016-11-22 04:12:51 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-12-05 15:02:47 +0100 |
commit | 332ed7be5b9a973e58711cb63f80265ad17b95a6 (patch) | |
tree | e97b3443e7225174998fe4cc3b3caf3f08885d88 /gdk | |
parent | 9c041f6bcc8155436b5b325de16abb575e803196 (diff) | |
download | gtk+-332ed7be5b9a973e58711cb63f80265ad17b95a6.tar.gz |
API: Require passing a GLContext to begin_draw_frame()
This is in preparation for requiring explicit passing of GL contexts
when drawing.
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdkdrawingcontext.c | 44 | ||||
-rw-r--r-- | gdk/gdkdrawingcontext.h | 2 | ||||
-rw-r--r-- | gdk/gdkwindow.c | 8 | ||||
-rw-r--r-- | gdk/gdkwindow.h | 3 |
4 files changed, 53 insertions, 4 deletions
diff --git a/gdk/gdkdrawingcontext.c b/gdk/gdkdrawingcontext.c index cee0ea9cda..ec230a13c9 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 d754fce79d..4f9980f90b 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 86fb756096..b70b3e5f76 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 5a0601c9f5..96d326ca7c 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, |