forked from AuroraMiddleware/gtk
gsk: Add gsk_texture_node_new()
Start the transition into the different node types.
This commit is contained in:
parent
ac5e277a71
commit
8c8691b469
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
*
|
||||
* Associates a #GskTexture to a #GskRenderNode.
|
||||
* Creates a #GskRenderNode that will render the given
|
||||
* @texture into the area given by @bounds.
|
||||
*
|
||||
* 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 >
|
||||
|
@ -44,6 +44,10 @@ void gsk_render_node_unref (GskRenderNode *
|
||||
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
|
||||
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user