[gtk+/wip/otte/rendernode: 36/100] gsk: Add gsk_color_node_new()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/rendernode: 36/100] gsk: Add gsk_color_node_new()
- Date: Sun, 18 Dec 2016 06:31:43 +0000 (UTC)
commit d3c88dda121f94f29231519522019c1de388ded0
Author: Benjamin Otte <otte redhat com>
Date: Tue Dec 13 03:35:56 2016 +0100
gsk: Add gsk_color_node_new()
docs/reference/gsk/gsk4-sections.txt | 1 +
gsk/gskenums.h | 2 +
gsk/gskrendernode.h | 4 ++
gsk/gskrendernodeimpl.c | 92 ++++++++++++++++++++++++++++++++
gsk/gskrendernodeprivate.h | 2 +
gtk/inspector/gtktreemodelrendernode.c | 1 +
6 files changed, 102 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gsk/gsk4-sections.txt b/docs/reference/gsk/gsk4-sections.txt
index 8e6239d..6126c4f 100644
--- a/docs/reference/gsk/gsk4-sections.txt
+++ b/docs/reference/gsk/gsk4-sections.txt
@@ -35,6 +35,7 @@ gsk_render_node_set_blend_mode
GskScalingFilter
gsk_render_node_set_scaling_filters
gsk_render_node_set_name
+gsk_color_node_new
gsk_texture_node_new
gsk_cairo_node_new
gsk_cairo_node_get_draw_context
diff --git a/gsk/gskenums.h b/gsk/gskenums.h
index 26ce47f..579e3d9 100644
--- a/gsk/gskenums.h
+++ b/gsk/gskenums.h
@@ -27,6 +27,7 @@
* @GSK_NOT_A_RENDER_NODE: Error type. No node will ever have this type.
* @GSK_CONTAINER_NODE: A node containing a stack of children
* @GSK_CAIRO_NODE: A node drawing a #cairo_surface_t
+ * @GSK_COLOR_NODE: A node drawing a single color rectangle
* @GSK_TEXTURE_NODE: A node drawing a #GskTexture
* @GSK_TRANSFORM_NODE: A node that renders its child after applying a
* matrix transform
@@ -39,6 +40,7 @@ typedef enum {
GSK_NOT_A_RENDER_NODE = 0,
GSK_CONTAINER_NODE,
GSK_CAIRO_NODE,
+ GSK_COLOR_NODE,
GSK_TEXTURE_NODE,
GSK_TRANSFORM_NODE
} GskRenderNodeType;
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index c874cb5..2119dfb 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -45,6 +45,10 @@ GDK_AVAILABLE_IN_3_90
GskRenderNodeType gsk_render_node_get_node_type (GskRenderNode *node);
GDK_AVAILABLE_IN_3_90
+GskRenderNode * gsk_color_node_new (const GdkRGBA *rgba,
+ const graphene_rect_t *bounds);
+
+GDK_AVAILABLE_IN_3_90
GskRenderNode * gsk_texture_node_new (GskTexture *texture,
const graphene_rect_t *bounds);
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index b80c0f6..feb7f08 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -22,6 +22,98 @@
#include "gskrendererprivate.h"
#include "gsktextureprivate.h"
+/*** GSK_COLOR_NODE ***/
+
+typedef struct _GskColorNode GskColorNode;
+
+struct _GskColorNode
+{
+ GskRenderNode render_node;
+
+ GdkRGBA color;
+ graphene_rect_t bounds;
+};
+
+static void
+gsk_color_node_finalize (GskRenderNode *node)
+{
+}
+
+static void
+gsk_color_node_make_immutable (GskRenderNode *node)
+{
+}
+
+static void
+gsk_color_node_draw (GskRenderNode *node,
+ cairo_t *cr)
+{
+ GskColorNode *self = (GskColorNode *) node;
+
+ gdk_cairo_set_source_rgba (cr, &self->color);
+
+ cairo_rectangle (cr,
+ self->bounds.origin.x, self->bounds.origin.y,
+ self->bounds.size.width, self->bounds.size.height);
+ cairo_fill (cr);
+}
+
+static void
+gsk_color_node_get_bounds (GskRenderNode *node,
+ graphene_rect_t *bounds)
+{
+ GskColorNode *self = (GskColorNode *) node;
+
+ graphene_rect_init_from_rect (bounds, &self->bounds);
+}
+
+static const GskRenderNodeClass GSK_COLOR_NODE_CLASS = {
+ GSK_COLOR_NODE,
+ sizeof (GskColorNode),
+ "GskColorNode",
+ gsk_color_node_finalize,
+ gsk_color_node_make_immutable,
+ gsk_color_node_draw,
+ gsk_color_node_get_bounds
+};
+
+const GdkRGBA *
+gsk_color_node_peek_color (GskRenderNode *node)
+{
+ GskColorNode *self = (GskColorNode *) node;
+
+ return &self->color;
+}
+
+/**
+ * gsk_color_node_new:
+ * @color: the #GskColor
+ * @bounds: the rectangle to render the color into
+ *
+ * Creates a #GskRenderNode that will render the given
+ * @color into the area given by @bounds.
+ *
+ * Returns: A new #GskRenderNode
+ *
+ * Since: 3.90
+ */
+GskRenderNode *
+gsk_color_node_new (const GdkRGBA *rgba,
+ const graphene_rect_t *bounds)
+{
+ GskColorNode *self;
+
+ g_return_val_if_fail (rgba != NULL, NULL);
+ g_return_val_if_fail (bounds != NULL, NULL);
+
+ self = (GskColorNode *) gsk_render_node_new (&GSK_COLOR_NODE_CLASS);
+
+ self->color = *rgba;
+ graphene_rect_init_from_rect (&self->bounds, bounds);
+
+ return &self->render_node;
+}
+
/*** GSK_TEXTURE_NODE ***/
typedef struct _GskTextureNode GskTextureNode;
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index 239e64d..c4e3c48 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -58,6 +58,8 @@ cairo_surface_t *gsk_cairo_node_get_surface (GskRenderNode *node);
GskTexture *gsk_texture_node_get_texture (GskRenderNode *node);
+const GdkRGBA *gsk_color_node_peek_color (GskRenderNode *node);
+
void gsk_transform_node_get_transform (GskRenderNode *node, graphene_matrix_t *transform);
GskBlendMode gsk_render_node_get_blend_mode (GskRenderNode *node);
diff --git a/gtk/inspector/gtktreemodelrendernode.c b/gtk/inspector/gtktreemodelrendernode.c
index 8bfbfe2..617b4b7 100644
--- a/gtk/inspector/gtktreemodelrendernode.c
+++ b/gtk/inspector/gtktreemodelrendernode.c
@@ -522,6 +522,7 @@ append_node (GtkTreeModelRenderNode *nodemodel,
case GSK_CAIRO_NODE:
case GSK_TEXTURE_NODE:
+ case GSK_COLOR_NODE:
/* no children */
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]