[gtk+/wip/otte/rendernode: 12/100] gsk: Add gsk_texture_node_new()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/rendernode: 12/100] gsk: Add gsk_texture_node_new()
- Date: Sun, 18 Dec 2016 06:29:42 +0000 (UTC)
commit 37437b40f2f94f6377148c9368eff728ad254a3a
Author: Benjamin Otte <otte redhat com>
Date: Sat Dec 10 22:52:22 2016 +0100
gsk: Add gsk_texture_node_new()
Start the transition into the different node types.
docs/reference/gsk/gsk4-sections.txt | 1 +
gsk/gskcairorenderer.c | 2 +-
gsk/gskglrenderer.c | 2 +-
gsk/gskrendernode.c | 34 +++++++++++++++++++---------------
gsk/gskrendernode.h | 8 +++++---
gsk/gskrendernodeprivate.h | 2 +-
gsk/gskvulkanrenderpass.c | 2 +-
gtk/gtkrendericon.c | 5 +++--
8 files changed, 32 insertions(+), 24 deletions(-)
---
diff --git a/docs/reference/gsk/gsk4-sections.txt b/docs/reference/gsk/gsk4-sections.txt
index 6518d1f..642a52d 100644
--- a/docs/reference/gsk/gsk4-sections.txt
+++ b/docs/reference/gsk/gsk4-sections.txt
@@ -55,6 +55,7 @@ gsk_render_node_set_blend_mode
GskScalingFilter
gsk_render_node_set_scaling_filters
gsk_render_node_set_name
+gsk_texture_node_new
<SUBSECTION Standard>
GSK_IS_RENDER_NODE
GSK_RENDER_NODE
diff --git a/gsk/gskcairorenderer.c b/gsk/gskcairorenderer.c
index 7e96052..5a31814 100644
--- a/gsk/gskcairorenderer.c
+++ b/gsk/gskcairorenderer.c
@@ -101,7 +101,7 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self,
frame.origin.x, frame.origin.y));
if (gsk_render_node_has_texture (node))
{
- GskTexture *texture = gsk_render_node_get_texture (node);
+ GskTexture *texture = gsk_texture_node_get_texture (node);
cairo_surface_t *surface = gsk_texture_download (texture);
cairo_set_source_surface (cr, surface, frame.origin.x, frame.origin.y);
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c
index f8524ee..b533cbd 100644
--- a/gsk/gskglrenderer.c
+++ b/gsk/gskglrenderer.c
@@ -721,7 +721,7 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
if (gsk_render_node_has_texture (node))
{
- GskTexture *texture = gsk_render_node_get_texture (node);
+ GskTexture *texture = gsk_texture_node_get_texture (node);
int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST;
get_gl_scaling_filters (node, &gl_min_filter, &gl_mag_filter);
diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c
index aced1e4..c9568c4 100644
--- a/gsk/gskrendernode.c
+++ b/gsk/gskrendernode.c
@@ -768,6 +768,7 @@ gsk_render_node_set_bounds (GskRenderNode *node,
{
g_return_if_fail (GSK_IS_RENDER_NODE (node));
g_return_if_fail (node->is_mutable);
+ g_return_if_fail (node->type == GSK_CONTAINER_NODE);
if (bounds == NULL)
graphene_rect_init_from_rect (&node->bounds, graphene_rect_zero ());
@@ -1041,38 +1042,41 @@ gsk_render_node_has_texture (GskRenderNode *node)
}
GskTexture *
-gsk_render_node_get_texture (GskRenderNode *node)
+gsk_texture_node_get_texture (GskRenderNode *node)
{
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), 0);
+ g_return_val_if_fail (node->type == GSK_TEXTURE_NODE, 0);
return node->texture;
}
/**
- * gsk_render_node_set_texture:
- * @node: a #GskRenderNode
+ * gsk_texture_node_new:
* @texture: the #GskTexture
+ * @bounds: the rectangle to render the texture into
+ *
+ * Creates a #GskRenderNode that will render the given
+ * @texture into the area given by @bounds.
*
- * Associates a #GskTexture to a #GskRenderNode.
+ * Returns: A new #GskRenderNode
*
* Since: 3.90
*/
-void
-gsk_render_node_set_texture (GskRenderNode *node,
- GskTexture *texture)
+GskRenderNode *
+gsk_texture_node_new (GskTexture *texture,
+ const graphene_rect_t *bounds)
{
- g_return_if_fail (GSK_IS_RENDER_NODE (node));
+ GskRenderNode *node;
- if (node->texture == texture)
- return;
+ g_return_val_if_fail (GSK_IS_TEXTURE (texture), NULL);
+ g_return_val_if_fail (bounds != NULL, NULL);
- if (node->texture)
- gsk_texture_unref (node->texture);
+ node = gsk_render_node_new (GSK_TEXTURE_NODE);
- node->texture = texture;
+ node->texture = gsk_texture_ref (texture);
+ graphene_rect_init_from_rect (&node->bounds, bounds);
- if (texture)
- gsk_texture_ref (texture);
+ return node;
}
/*< private >
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index 5af118b..c724ad2 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_texture_node_new (GskTexture *texture,
+ const graphene_rect_t *bounds);
+
+GDK_AVAILABLE_IN_3_90
GskRenderNode * gsk_render_node_get_parent (GskRenderNode *node);
GDK_AVAILABLE_IN_3_90
GskRenderNode * gsk_render_node_get_first_child (GskRenderNode *node);
@@ -110,9 +114,7 @@ cairo_t * gsk_render_node_get_draw_context (GskRenderNode *
GDK_AVAILABLE_IN_3_90
void gsk_render_node_set_blend_mode (GskRenderNode *node,
GskBlendMode blend_mode);
-GDK_AVAILABLE_IN_3_90
-void gsk_render_node_set_texture (GskRenderNode *node,
- GskTexture *texture);
+
GDK_AVAILABLE_IN_3_90
void gsk_render_node_set_scaling_filter (GskRenderNode *node,
GskScalingFilter min_filter,
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index 6307989..c70ef62 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -71,7 +71,7 @@ double gsk_render_node_get_opacity (GskRenderNode *node);
cairo_surface_t *gsk_render_node_get_surface (GskRenderNode *node);
-GskTexture *gsk_render_node_get_texture (GskRenderNode *node);
+GskTexture *gsk_texture_node_get_texture (GskRenderNode *node);
gboolean gsk_render_node_has_surface (GskRenderNode *node);
gboolean gsk_render_node_has_texture (GskRenderNode *node);
diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c
index 892e969..e5c64cc 100644
--- a/gsk/gskvulkanrenderpass.c
+++ b/gsk/gskvulkanrenderpass.c
@@ -168,7 +168,7 @@ gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self,
case GSK_VULKAN_OP_TEXTURE:
{
op->source = gsk_vulkan_renderer_ref_texture_image (GSK_VULKAN_RENDERER
(gsk_vulkan_render_get_renderer (render)),
- gsk_render_node_get_texture (op->node),
+ gsk_texture_node_get_texture (op->node),
command_buffer);
gsk_vulkan_render_add_cleanup_image (render, op->source);
}
diff --git a/gtk/gtkrendericon.c b/gtk/gtkrendericon.c
index b20b743..409e940 100644
--- a/gtk/gtkrendericon.c
+++ b/gtk/gtkrendericon.c
@@ -283,13 +283,14 @@ gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
graphene_rect_init (&bounds, 0, 0, gsk_texture_get_width (texture), gsk_texture_get_height (texture));
- node = gtk_snapshot_append (snapshot, &bounds, "Icon");
+ node = gsk_texture_node_new (texture, &bounds);
+ gsk_render_node_set_name (node, "Icon");
+ gtk_snapshot_append_node (snapshot, node);
if (!_gtk_css_shadows_value_is_none (shadows) && !shadow_warning)
{
g_warning ("Painting shadows not implemented for textures yet.");
shadow_warning = TRUE;
}
- gsk_render_node_set_texture (node, texture);
gsk_render_node_unref (node);
gtk_snapshot_set_transform (snapshot, &saved_matrix);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]