forked from AuroraMiddleware/gtk
gsk: Remove world matrix support
Use the real transform and compute it manually.
This commit is contained in:
parent
3eb7c4719b
commit
a8f2b3e75e
@ -53,14 +53,14 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self,
|
||||
{
|
||||
GskRenderNode *child;
|
||||
gboolean pop_group = FALSE;
|
||||
graphene_matrix_t mvp;
|
||||
graphene_matrix_t mat;
|
||||
cairo_matrix_t ctm;
|
||||
graphene_rect_t frame;
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
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))
|
||||
gsk_render_node_get_transform (node, &mat);
|
||||
if (graphene_matrix_to_2d (&mat, &ctm.xx, &ctm.yx, &ctm.xy, &ctm.yy, &ctm.x0, &ctm.y0))
|
||||
{
|
||||
GSK_NOTE (CAIRO, g_print ("CTM = { .xx = %g, .yx = %g, .xy = %g, .yy = %g, .x0 = %g, .y0 = %g }\n",
|
||||
ctm.xx, ctm.yx,
|
||||
@ -105,9 +105,6 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self,
|
||||
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));
|
||||
|
@ -617,12 +617,13 @@ render_node_needs_render_target (GskRenderNode *node)
|
||||
static void
|
||||
gsk_gl_renderer_add_render_item (GskGLRenderer *self,
|
||||
const graphene_matrix_t *projection,
|
||||
const graphene_matrix_t *parent_modelview,
|
||||
GArray *render_items,
|
||||
GskRenderNode *node,
|
||||
RenderItem *parent)
|
||||
{
|
||||
graphene_rect_t viewport;
|
||||
graphene_matrix_t mv;
|
||||
graphene_matrix_t mv, transform;
|
||||
graphene_rect_t bounds;
|
||||
GskRenderNode *child;
|
||||
RenderItem item;
|
||||
@ -659,7 +660,8 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
|
||||
item.max.z = 0.f;
|
||||
|
||||
/* The location of the item, in normalized world coordinates */
|
||||
gsk_render_node_get_world_matrix (node, &mv);
|
||||
gsk_render_node_get_transform (node, &transform);
|
||||
graphene_matrix_multiply (&transform, parent_modelview, &mv);
|
||||
graphene_matrix_multiply (&mv, &self->mvp, &item.mvp);
|
||||
item.z = project_item (projection, &mv);
|
||||
|
||||
@ -791,7 +793,7 @@ out:
|
||||
child != NULL;
|
||||
child = gsk_render_node_get_next_sibling (child))
|
||||
{
|
||||
gsk_gl_renderer_add_render_item (self, projection, render_items, child, ritem);
|
||||
gsk_gl_renderer_add_render_item (self, projection, &mv, render_items, child, ritem);
|
||||
}
|
||||
}
|
||||
|
||||
@ -800,12 +802,16 @@ gsk_gl_renderer_validate_tree (GskGLRenderer *self,
|
||||
GskRenderNode *root,
|
||||
const graphene_matrix_t *projection)
|
||||
{
|
||||
graphene_matrix_t identity;
|
||||
|
||||
if (self->gl_context == NULL)
|
||||
{
|
||||
GSK_NOTE (OPENGL, g_print ("No valid GL context associated to the renderer"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
graphene_matrix_init_identity (&identity);
|
||||
|
||||
gdk_gl_context_make_current (self->gl_context);
|
||||
|
||||
self->render_items = g_array_new (FALSE, FALSE, sizeof (RenderItem));
|
||||
@ -813,7 +819,7 @@ gsk_gl_renderer_validate_tree (GskGLRenderer *self,
|
||||
gsk_gl_driver_begin_frame (self->gl_driver);
|
||||
|
||||
GSK_NOTE (OPENGL, g_print ("RenderNode -> RenderItem\n"));
|
||||
gsk_gl_renderer_add_render_item (self, projection, self->render_items, root, NULL);
|
||||
gsk_gl_renderer_add_render_item (self, projection, &identity, self->render_items, root, NULL);
|
||||
|
||||
GSK_NOTE (OPENGL, g_print ("Total render items: %d\n",
|
||||
self->render_items->len));
|
||||
|
@ -112,7 +112,6 @@ gsk_render_node_new (const GskRenderNodeClass *node_class)
|
||||
self->mag_filter = GSK_SCALING_FILTER_NEAREST;
|
||||
|
||||
self->is_mutable = TRUE;
|
||||
self->needs_world_matrix_update = TRUE;
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -304,11 +303,9 @@ gsk_render_node_insert_child_internal (GskRenderNode *node,
|
||||
|
||||
child->parent = node;
|
||||
child->age = 0;
|
||||
child->needs_world_matrix_update = TRUE;
|
||||
|
||||
node->n_children += 1;
|
||||
node->age += 1;
|
||||
node->needs_world_matrix_update = TRUE;
|
||||
|
||||
if (child->prev_sibling == NULL)
|
||||
node->first_child = child;
|
||||
@ -517,8 +514,6 @@ gsk_render_node_set_transform (GskRenderNode *node,
|
||||
graphene_matrix_init_identity (&node->transform);
|
||||
else
|
||||
graphene_matrix_init_from_matrix (&node->transform, transform);
|
||||
|
||||
node->transform_set = !graphene_matrix_is_identity (&node->transform);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -634,57 +629,6 @@ gsk_render_node_get_toplevel (GskRenderNode *node)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gsk_render_node_update_world_matrix:
|
||||
* @node: a #GskRenderNode
|
||||
* @force: %TRUE if the update should be forced
|
||||
*
|
||||
* Updates the cached world matrix of @node and its children, if needed.
|
||||
*/
|
||||
void
|
||||
gsk_render_node_update_world_matrix (GskRenderNode *node,
|
||||
gboolean force)
|
||||
{
|
||||
GskRenderNode *child;
|
||||
|
||||
if (force || node->needs_world_matrix_update)
|
||||
{
|
||||
GSK_NOTE (RENDER_NODE, g_print ("Updating cached world matrix on node %p [parent=%p, t_set=%s]\n",
|
||||
node,
|
||||
node->parent != NULL ? node->parent : 0,
|
||||
node->transform_set ? "y" : "n"));
|
||||
|
||||
if (node->parent == NULL)
|
||||
{
|
||||
if (node->transform_set)
|
||||
graphene_matrix_init_from_matrix (&node->world_matrix, &node->transform);
|
||||
else
|
||||
graphene_matrix_init_identity (&node->world_matrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
GskRenderNode *parent = node->parent;
|
||||
graphene_matrix_t tmp;
|
||||
|
||||
graphene_matrix_init_identity (&tmp);
|
||||
|
||||
if (node->transform_set)
|
||||
graphene_matrix_multiply (&tmp, &node->transform, &tmp);
|
||||
|
||||
graphene_matrix_multiply (&tmp, &parent->world_matrix, &node->world_matrix);
|
||||
}
|
||||
|
||||
node->needs_world_matrix_update = FALSE;
|
||||
}
|
||||
|
||||
for (child = gsk_render_node_get_first_child (node);
|
||||
child != NULL;
|
||||
child = gsk_render_node_get_next_sibling (child))
|
||||
{
|
||||
gsk_render_node_update_world_matrix (child, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gsk_render_node_set_scaling_filters (GskRenderNode *node,
|
||||
GskScalingFilter min_filter,
|
||||
@ -698,33 +642,6 @@ gsk_render_node_set_scaling_filters (GskRenderNode *node,
|
||||
node->mag_filter = mag_filter;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gsk_render_node_get_world_matrix:
|
||||
* @node: a #GskRenderNode
|
||||
* @mv: (out caller-allocates): return location for the modelview matrix
|
||||
* in world-relative coordinates
|
||||
*
|
||||
* Retrieves the modelview matrix in world-relative coordinates.
|
||||
*/
|
||||
void
|
||||
gsk_render_node_get_world_matrix (GskRenderNode *node,
|
||||
graphene_matrix_t *mv)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_RENDER_NODE (node));
|
||||
g_return_if_fail (mv != NULL);
|
||||
|
||||
if (node->needs_world_matrix_update)
|
||||
{
|
||||
GskRenderNode *tmp = gsk_render_node_get_toplevel (node);
|
||||
|
||||
gsk_render_node_update_world_matrix (tmp, TRUE);
|
||||
|
||||
g_assert (!node->needs_world_matrix_update);
|
||||
}
|
||||
|
||||
*mv = node->world_matrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_render_node_set_name:
|
||||
* @node: a #GskRenderNode
|
||||
|
@ -41,16 +41,11 @@ struct _GskRenderNode
|
||||
GskScalingFilter min_filter;
|
||||
GskScalingFilter mag_filter;
|
||||
|
||||
/* Transformations relative to the root of the scene */
|
||||
graphene_matrix_t world_matrix;
|
||||
|
||||
/* Transformations applied to the node */
|
||||
graphene_matrix_t transform;
|
||||
|
||||
/* Bit fields; leave at the end */
|
||||
gboolean is_mutable : 1;
|
||||
gboolean transform_set : 1;
|
||||
gboolean needs_world_matrix_update : 1;
|
||||
};
|
||||
|
||||
struct _GskRenderNodeClass
|
||||
@ -82,12 +77,6 @@ GskBlendMode gsk_render_node_get_blend_mode (GskRenderNode *node);
|
||||
|
||||
GskRenderNode *gsk_render_node_get_toplevel (GskRenderNode *node);
|
||||
|
||||
void gsk_render_node_update_world_matrix (GskRenderNode *node,
|
||||
gboolean force);
|
||||
|
||||
void gsk_render_node_get_world_matrix (GskRenderNode *node,
|
||||
graphene_matrix_t *mv);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_RENDER_NODE_PRIVATE_H__ */
|
||||
|
@ -274,12 +274,12 @@ gsk_vulkan_render_pass_reserve_descriptor_sets (GskVulkanRenderPass *self,
|
||||
void
|
||||
gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
||||
GskVulkanRender *render,
|
||||
const graphene_matrix_t *root_mvp,
|
||||
const graphene_matrix_t *parent_mvp,
|
||||
GskVulkanPipeline *pipeline,
|
||||
VkCommandBuffer command_buffer)
|
||||
{
|
||||
GskVulkanRenderOp *op;
|
||||
graphene_matrix_t world, mvp;
|
||||
graphene_matrix_t transform, mvp;
|
||||
float float_matrix[16];
|
||||
guint i;
|
||||
|
||||
@ -298,8 +298,8 @@ gsk_vulkan_render_pass_draw (GskVulkanRenderPass *self,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
gsk_render_node_get_world_matrix (op->node, &world);
|
||||
graphene_matrix_multiply (&world, root_mvp, &mvp);
|
||||
gsk_render_node_get_transform (op->node, &transform);
|
||||
graphene_matrix_multiply (&transform, parent_mvp, &mvp);
|
||||
graphene_matrix_to_float (&mvp, float_matrix);
|
||||
|
||||
vkCmdPushConstants (command_buffer,
|
||||
|
Loading…
Reference in New Issue
Block a user