gsk: Remove gsk_render_node_is_surface/texture()

Use gsk_render_node_get_node_type() instead.
This commit is contained in:
Benjamin Otte 2016-12-11 02:33:58 +01:00
parent cb5c5170f4
commit abd184efc9
6 changed files with 94 additions and 95 deletions

View File

@ -59,10 +59,6 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self,
cairo_save (cr);
if (!gsk_render_node_has_surface (node) &&
!gsk_render_node_has_texture (node))
goto out;
gsk_render_node_get_world_matrix (node, &mvp);
if (graphene_matrix_to_2d (&mvp, &ctm.xx, &ctm.yx, &ctm.xy, &ctm.yy, &ctm.x0, &ctm.y0))
{
@ -98,19 +94,49 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self,
node->name,
node,
frame.origin.x, frame.origin.y));
if (gsk_render_node_has_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);
cairo_paint (cr);
cairo_surface_destroy (surface);
}
else
switch (gsk_render_node_get_node_type (node))
{
cairo_set_source_surface (cr, gsk_cairo_node_get_surface (node), frame.origin.x, frame.origin.y);
cairo_paint (cr);
case GSK_NOT_A_RENDER_NODE:
default:
g_assert_not_reached ();
break;
case GSK_CONTAINER_NODE:
if (gsk_render_node_get_n_children (node) != 0)
{
cairo_matrix_invert (&ctm);
cairo_transform (cr, &ctm);
GSK_NOTE (CAIRO, g_print ("Drawing %d children of node [%p]\n",
gsk_render_node_get_n_children (node),
node));
for (child = gsk_render_node_get_first_child (node);
child != NULL;
child = gsk_render_node_get_next_sibling (child))
{
gsk_cairo_renderer_render_node (self, child, cr);
}
}
break;
case GSK_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);
cairo_paint (cr);
cairo_surface_destroy (surface);
}
break;
case GSK_CAIRO_NODE:
{
cairo_set_source_surface (cr, gsk_cairo_node_get_surface (node), frame.origin.x, frame.origin.y);
cairo_paint (cr);
}
break;
}
if (GSK_RENDER_MODE_CHECK (GEOMETRY))
@ -124,23 +150,6 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self,
cairo_restore (cr);
}
cairo_matrix_invert (&ctm);
cairo_transform (cr, &ctm);
out:
if (gsk_render_node_get_n_children (node) != 0)
{
GSK_NOTE (CAIRO, g_print ("Drawing %d children of node [%p]\n",
gsk_render_node_get_n_children (node),
node));
for (child = gsk_render_node_get_first_child (node);
child != NULL;
child = gsk_render_node_get_next_sibling (child))
{
gsk_cairo_renderer_render_node (self, child, cr);
}
}
if (pop_group)
{
cairo_pop_group_to_source (cr);

View File

@ -719,38 +719,43 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
item.children = NULL;
}
if (gsk_render_node_has_texture (node))
switch (gsk_render_node_get_node_type (node))
{
GskTexture *texture = gsk_texture_node_get_texture (node);
int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST;
case GSK_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);
get_gl_scaling_filters (node, &gl_min_filter, &gl_mag_filter);
item.render_data.texture_id = gsk_gl_driver_get_texture_for_texture (self->gl_driver,
texture,
gl_min_filter,
gl_mag_filter);
}
else if (gsk_render_node_has_surface (node))
{
cairo_surface_t *surface = gsk_cairo_node_get_surface (node);
int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST;
item.render_data.texture_id = gsk_gl_driver_get_texture_for_texture (self->gl_driver,
texture,
gl_min_filter,
gl_mag_filter);
}
break;
get_gl_scaling_filters (node, &gl_min_filter, &gl_mag_filter);
case GSK_CAIRO_NODE:
{
cairo_surface_t *surface = gsk_cairo_node_get_surface (node);
int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST;
/* Upload the Cairo surface to a GL texture */
item.render_data.texture_id = gsk_gl_driver_create_texture (self->gl_driver,
item.size.width,
item.size.height);
gsk_gl_driver_bind_source_texture (self->gl_driver, item.render_data.texture_id);
gsk_gl_driver_init_texture_with_surface (self->gl_driver,
item.render_data.texture_id,
surface,
gl_min_filter,
gl_mag_filter);
}
else
{
get_gl_scaling_filters (node, &gl_min_filter, &gl_mag_filter);
/* Upload the Cairo surface to a GL texture */
item.render_data.texture_id = gsk_gl_driver_create_texture (self->gl_driver,
item.size.width,
item.size.height);
gsk_gl_driver_bind_source_texture (self->gl_driver, item.render_data.texture_id);
gsk_gl_driver_init_texture_with_surface (self->gl_driver,
item.render_data.texture_id,
surface,
gl_min_filter,
gl_mag_filter);
}
break;
default:
/* If the node does not draw anything, we skip it */
if (item.render_data.render_target_id == 0)
goto out;

View File

@ -753,22 +753,6 @@ gsk_render_node_update_world_matrix (GskRenderNode *node,
}
}
gboolean
gsk_render_node_has_surface (GskRenderNode *node)
{
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), FALSE);
return node->surface != NULL;
}
gboolean
gsk_render_node_has_texture (GskRenderNode *node)
{
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), FALSE);
return node->texture != NULL;
}
GskTexture *
gsk_texture_node_get_texture (GskRenderNode *node)
{

View File

@ -73,9 +73,6 @@ cairo_surface_t *gsk_cairo_node_get_surface (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);
GskBlendMode gsk_render_node_get_blend_mode (GskRenderNode *node);
GskRenderNode *gsk_render_node_get_toplevel (GskRenderNode *node);

View File

@ -58,7 +58,6 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
GskVulkanRender *render,
GskRenderNode *node)
{
GskRenderNode *child;
GskVulkanRenderOp op = {
.type = GSK_VULKAN_OP_FALLBACK,
.node = node
@ -67,26 +66,31 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
if (gsk_render_node_get_opacity (node) < 1.0)
goto fallback;
if (gsk_render_node_has_surface (node))
switch (gsk_render_node_get_node_type (node))
{
case GSK_NOT_A_RENDER_NODE:
default:
g_assert_not_reached ();
break;
case GSK_CAIRO_NODE:
op.type = GSK_VULKAN_OP_SURFACE;
g_array_append_val (self->render_ops, op);
}
else if (gsk_render_node_has_texture (node))
{
break;
case GSK_TEXTURE_NODE:
op.type = GSK_VULKAN_OP_TEXTURE;
g_array_append_val (self->render_ops, op);
}
else
{
/* nothing to do for nodes without sources */
}
break;
for (child = gsk_render_node_get_first_child (node);
child;
child = gsk_render_node_get_next_sibling (child))
{
gsk_vulkan_render_pass_add_node (self, render, child);
case GSK_CONTAINER_NODE:
for (GskRenderNode *child = gsk_render_node_get_first_child (node);
child;
child = gsk_render_node_get_next_sibling (child))
{
gsk_vulkan_render_pass_add_node (self, render, child);
}
break;
}
return;

View File

@ -184,12 +184,12 @@ populate_render_node_properties (GtkListStore *store,
gtk_list_store_insert_with_values (store, NULL, -1,
0, "Has Surface",
1, gsk_render_node_has_surface (node) ? "TRUE" : "FALSE",
1, gsk_render_node_get_node_type (node) == GSK_CAIRO_NODE ? "TRUE" : "FALSE",
-1);
gtk_list_store_insert_with_values (store, NULL, -1,
0, "Has Texture",
1, gsk_render_node_has_texture (node) ? "TRUE" : "FALSE",
1, gsk_render_node_get_node_type (node) == GSK_TEXTURE_NODE ? "TRUE" : "FALSE",
-1);
class = g_type_class_ref (gsk_blend_mode_get_type ());