[gtk+/wip/otte/rendernode: 52/110] cssimage: Implement a fallback draw() vfunc
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/rendernode: 52/110] cssimage: Implement a fallback draw() vfunc
- Date: Mon, 19 Dec 2016 04:48:35 +0000 (UTC)
commit a9290772b1f1b63004c2d6c575846f11a38c3fef
Author: Benjamin Otte <otte redhat com>
Date: Tue Dec 13 05:10:05 2016 +0100
cssimage: Implement a fallback draw() vfunc
... that chains into snapshot. This way, we can stop implementing draw()
in GtkCssImage subclasses and focus on snapshot() instead.
gtk/gtkcssimage.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssimage.c b/gtk/gtkcssimage.c
index 8797ec9..d45a3f7 100644
--- a/gtk/gtkcssimage.c
+++ b/gtk/gtkcssimage.c
@@ -22,6 +22,7 @@
#include "gtkcssimageprivate.h"
#include "gtkcssstyleprivate.h"
+#include "gtksnapshotprivate.h"
/* for the types only */
#include "gtk/gtkcssimagecrossfadeprivate.h"
@@ -96,6 +97,28 @@ gtk_css_image_real_transition (GtkCssImage *start,
}
static void
+gtk_css_image_real_draw (GtkCssImage *image,
+ cairo_t *cr,
+ double width,
+ double height)
+{
+ GtkSnapshot snapshot;
+ GskRenderNode *node;
+ cairo_region_t *clip;
+
+ clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) { 0, 0, width, height });
+ gtk_snapshot_init (&snapshot, NULL, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
+ gtk_css_image_snapshot (image, &snapshot, width, height);
+ node = gtk_snapshot_finish (&snapshot);
+
+ if (node != NULL)
+ {
+ gsk_render_node_draw (node, cr);
+ gsk_render_node_unref (node);
+ }
+}
+
+static void
gtk_css_image_real_snapshot (GtkCssImage *image,
GtkSnapshot *snapshot,
double width,
@@ -119,6 +142,7 @@ _gtk_css_image_class_init (GtkCssImageClass *klass)
klass->compute = gtk_css_image_real_compute;
klass->equal = gtk_css_image_real_equal;
klass->transition = gtk_css_image_real_transition;
+ klass->draw = gtk_css_image_real_draw;
klass->snapshot = gtk_css_image_real_snapshot;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]