[gtk+/wip/otte/vulkan: 39/59] gskrenderer: Add gsk_renderer_begin_draw_frame()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/vulkan: 39/59] gskrenderer: Add gsk_renderer_begin_draw_frame()
- Date: Mon, 5 Dec 2016 12:30:45 +0000 (UTC)
commit 3af83049bbfc507ad41d2eca83ba05ad790adf18
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 27 16:21:02 2016 +0100
gskrenderer: Add gsk_renderer_begin_draw_frame()
This way, we can hijack the begin/end draw process and do out own
processing before passing it on to GDK.
docs/reference/gsk/gsk4-sections.txt | 3 +-
gsk/gskrenderer.c | 69 ++++++++++++++++++++++++++++-----
gsk/gskrenderer.h | 6 ++-
gsk/gskrendererprivate.h | 4 ++
gtk/gtkwidget.c | 6 +--
5 files changed, 71 insertions(+), 17 deletions(-)
---
diff --git a/docs/reference/gsk/gsk4-sections.txt b/docs/reference/gsk/gsk4-sections.txt
index ec761a2..8fe8a44 100644
--- a/docs/reference/gsk/gsk4-sections.txt
+++ b/docs/reference/gsk/gsk4-sections.txt
@@ -9,8 +9,9 @@ gsk_renderer_get_window
gsk_renderer_get_display
gsk_renderer_realize
gsk_renderer_unrealize
+gsk_renderer_begin_draw_frame
+gsk_renderer_end_draw_frame
gsk_renderer_create_render_node
-gsk_renderer_get_gl_context
gsk_renderer_render
<SUBSECTION Standard>
GSK_IS_RENDERER
diff --git a/gsk/gskrenderer.c b/gsk/gskrenderer.c
index d6d8b2d..fc56378 100644
--- a/gsk/gskrenderer.c
+++ b/gsk/gskrenderer.c
@@ -112,6 +112,27 @@ gsk_renderer_real_unrealize (GskRenderer *self)
GSK_RENDERER_WARN_NOT_IMPLEMENTED_METHOD (self, unrealize);
}
+static GdkDrawingContext *
+gsk_renderer_real_begin_draw_frame (GskRenderer *self,
+ const cairo_region_t *region)
+{
+ GskRendererPrivate *priv = gsk_renderer_get_instance_private (self);
+
+ return gdk_window_begin_draw_frame (priv->window,
+ priv->gl_context,
+ region);
+}
+
+static void
+gsk_renderer_real_end_draw_frame (GskRenderer *self,
+ GdkDrawingContext *context)
+{
+ GskRendererPrivate *priv = gsk_renderer_get_instance_private (self);
+
+ gdk_window_end_draw_frame (priv->window,
+ context);
+}
+
static void
gsk_renderer_real_render (GskRenderer *self,
GskRenderNode *root)
@@ -236,6 +257,8 @@ gsk_renderer_class_init (GskRendererClass *klass)
klass->realize = gsk_renderer_real_realize;
klass->unrealize = gsk_renderer_real_unrealize;
+ klass->begin_draw_frame = gsk_renderer_real_begin_draw_frame;
+ klass->end_draw_frame = gsk_renderer_real_end_draw_frame;
klass->render = gsk_renderer_real_render;
klass->create_cairo_surface = gsk_renderer_real_create_cairo_surface;
@@ -590,9 +613,7 @@ gsk_renderer_unrealize (GskRenderer *renderer)
* gsk_renderer_render:
* @renderer: a #GskRenderer
* @root: a #GskRenderNode
- * @context: a #GdkDrawingContext using the context returned by
- * gsk_renderer_get_gl_context() or %NULL if the renderer was created
- * via gsk_renderer_create_fallback().
+ * @context: The drawing context created via gsk_renderer_begin_draw_frame()
*
* Renders the scene graph, described by a tree of #GskRenderNode instances,
* using the given #GdkDrawingContext.
@@ -612,19 +633,16 @@ gsk_renderer_render (GskRenderer *renderer,
g_return_if_fail (GSK_IS_RENDERER (renderer));
g_return_if_fail (priv->is_realized);
g_return_if_fail (GSK_IS_RENDER_NODE (root));
- g_return_if_fail (context == NULL || GDK_IS_DRAWING_CONTEXT (context));
- g_return_if_fail (priv->drawing_context == NULL);
g_return_if_fail (priv->root_node == NULL);
+ g_return_if_fail (context == priv->drawing_context);
- if (context != NULL)
- priv->drawing_context = g_object_ref (context);
- else
+ if (priv->drawing_context == NULL)
{
if (priv->cairo_context == NULL)
{
g_critical ("The given GskRenderer instance was not created using "
- "gsk_renderer_create_fallback(), but you forgot to pass "
- "a GdkDrawingContext.");
+ "gsk_renderer_create_fallback(), but you forgot to call "
+ "gsk_renderer_begin_draw_frame().");
return;
}
}
@@ -655,7 +673,6 @@ gsk_renderer_render (GskRenderer *renderer,
}
#endif
- g_clear_object (&priv->drawing_context);
g_clear_pointer (&priv->root_node, gsk_render_node_unref);
}
@@ -856,6 +873,36 @@ gsk_renderer_get_gl_context (GskRenderer *renderer)
return priv->gl_context;
}
+GdkDrawingContext *
+gsk_renderer_begin_draw_frame (GskRenderer *renderer,
+ const cairo_region_t *region)
+{
+ GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer);
+
+ g_return_val_if_fail (GSK_IS_RENDERER (renderer), NULL);
+ g_return_val_if_fail (region != NULL, NULL);
+ g_return_val_if_fail (priv->drawing_context == NULL, NULL);
+
+ priv->drawing_context = GSK_RENDERER_GET_CLASS (renderer)->begin_draw_frame (renderer, region);
+
+ return priv->drawing_context;
+}
+
+void
+gsk_renderer_end_draw_frame (GskRenderer *renderer,
+ GdkDrawingContext *context)
+{
+ GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer);
+
+ g_return_if_fail (GSK_IS_RENDERER (renderer));
+ g_return_if_fail (GDK_IS_DRAWING_CONTEXT (context));
+ g_return_if_fail (priv->drawing_context == context);
+
+ priv->drawing_context = NULL;
+
+ GSK_RENDERER_GET_CLASS (renderer)->end_draw_frame (renderer, context);
+}
+
/**
* gsk_renderer_create_fallback:
* @renderer: a #GskRenderer
diff --git a/gsk/gskrenderer.h b/gsk/gskrenderer.h
index 507beb3..1728fc9 100644
--- a/gsk/gskrenderer.h
+++ b/gsk/gskrenderer.h
@@ -77,11 +77,15 @@ GskRenderer * gsk_renderer_create_fallback (GskRenderer
cairo_t *cr);
GDK_AVAILABLE_IN_3_90
-GdkGLContext * gsk_renderer_get_gl_context (GskRenderer *renderer);
+GdkDrawingContext * gsk_renderer_begin_draw_frame (GskRenderer *renderer,
+ const cairo_region_t *region);
GDK_AVAILABLE_IN_3_90
void gsk_renderer_render (GskRenderer *renderer,
GskRenderNode *root,
GdkDrawingContext *context);
+GDK_AVAILABLE_IN_3_90
+void gsk_renderer_end_draw_frame (GskRenderer *renderer,
+ GdkDrawingContext *context);
G_END_DECLS
diff --git a/gsk/gskrendererprivate.h b/gsk/gskrendererprivate.h
index 8671160..2ac3c92 100644
--- a/gsk/gskrendererprivate.h
+++ b/gsk/gskrendererprivate.h
@@ -42,6 +42,10 @@ struct _GskRendererClass
GError **error);
void (* unrealize) (GskRenderer *renderer);
+ GdkDrawingContext * (* begin_draw_frame) (GskRenderer *renderer,
+ const cairo_region_t *region);
+ void (* end_draw_frame) (GskRenderer *renderer,
+ GdkDrawingContext *context);
void (* render) (GskRenderer *renderer,
GskRenderNode *root);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 13045db..da35775 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15640,9 +15640,7 @@ gtk_widget_render (GtkWidget *widget,
if (renderer == NULL)
return;
- context = gdk_window_begin_draw_frame (window,
- gsk_renderer_get_gl_context (renderer),
- region);
+ context = gsk_renderer_begin_draw_frame (renderer, region);
gtk_snapshot_init (&snapshot,
renderer,
@@ -15662,5 +15660,5 @@ gtk_widget_render (GtkWidget *widget,
gsk_render_node_unref (root);
}
- gdk_window_end_draw_frame (window, context);
+ gsk_renderer_end_draw_frame (renderer, context);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]