mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
vulkan: Track offset in the renderpass
This avoids emitting lots of push constant updates as most of the transforms we have are simple translations to adjust drawing for the next widget.
This commit is contained in:
parent
5de6f12e88
commit
d8b9c3ae96
@ -766,13 +766,14 @@ gsk_rounded_rect_path (const GskRoundedRect *self,
|
||||
* only look at the last vec4 if they have to.
|
||||
*/
|
||||
void
|
||||
gsk_rounded_rect_to_float (const GskRoundedRect *self,
|
||||
float rect[12])
|
||||
gsk_rounded_rect_to_float (const GskRoundedRect *self,
|
||||
const graphene_point_t *offset,
|
||||
float rect[12])
|
||||
{
|
||||
guint i;
|
||||
|
||||
rect[0] = self->bounds.origin.x;
|
||||
rect[1] = self->bounds.origin.y;
|
||||
rect[0] = self->bounds.origin.x + offset->x;
|
||||
rect[1] = self->bounds.origin.y + offset->y;
|
||||
rect[2] = self->bounds.size.width;
|
||||
rect[3] = self->bounds.size.height;
|
||||
|
||||
|
@ -28,6 +28,7 @@ gboolean gsk_rounded_rect_is_circular (const GskRounde
|
||||
void gsk_rounded_rect_path (const GskRoundedRect *self,
|
||||
cairo_t *cr);
|
||||
void gsk_rounded_rect_to_float (const GskRoundedRect *self,
|
||||
const graphene_point_t *offset,
|
||||
float rect[12]);
|
||||
|
||||
gboolean gsk_rounded_rect_equal (gconstpointer rect1,
|
||||
|
@ -106,16 +106,17 @@ gsk_vulkan_blend_mode_pipeline_count_vertex_data (GskVulkanBlendModePipeline *pi
|
||||
|
||||
void
|
||||
gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GskVulkanBlendModePipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_tex_rect,
|
||||
const graphene_rect_t *end_tex_rect,
|
||||
GskBlendMode blend_mode)
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_tex_rect,
|
||||
const graphene_rect_t *end_tex_rect,
|
||||
GskBlendMode blend_mode)
|
||||
{
|
||||
GskVulkanBlendModeInstance *instance = (GskVulkanBlendModeInstance *) data;
|
||||
|
||||
instance->rect[0] = bounds->origin.x;
|
||||
instance->rect[1] = bounds->origin.y;
|
||||
instance->rect[0] = bounds->origin.x + offset->x;
|
||||
instance->rect[1] = bounds->origin.y + offset->y;
|
||||
instance->rect[2] = bounds->size.width;
|
||||
instance->rect[3] = bounds->size.height;
|
||||
|
||||
|
@ -21,6 +21,7 @@ GskVulkanPipeline * gsk_vulkan_blend_mode_pipeline_new (GdkVulka
|
||||
gsize gsk_vulkan_blend_mode_pipeline_count_vertex_data (GskVulkanBlendModePipeline *pipeline);
|
||||
void gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GskVulkanBlendModePipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_bounds,
|
||||
const graphene_rect_t *end_bounds,
|
||||
|
@ -98,16 +98,17 @@ gsk_vulkan_blur_pipeline_count_vertex_data (GskVulkanBlurPipeline *pipeline)
|
||||
}
|
||||
|
||||
void
|
||||
gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
double blur_radius)
|
||||
gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
double blur_radius)
|
||||
{
|
||||
GskVulkanBlurInstance *instance = (GskVulkanBlurInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->tex_rect[0] = tex_rect->origin.x;
|
||||
|
@ -20,6 +20,7 @@ GskVulkanPipeline * gsk_vulkan_blur_pipeline_new (GdkVulka
|
||||
gsize gsk_vulkan_blur_pipeline_count_vertex_data (GskVulkanBlurPipeline *pipeline);
|
||||
void gsk_vulkan_blur_pipeline_collect_vertex_data (GskVulkanBlurPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
double radius);
|
||||
|
@ -132,6 +132,7 @@ gsk_vulkan_border_pipeline_count_vertex_data (GskVulkanBorderPipeline *pipeline)
|
||||
void
|
||||
gsk_vulkan_border_pipeline_collect_vertex_data (GskVulkanBorderPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const GskRoundedRect *rect,
|
||||
const float widths[4],
|
||||
const GdkRGBA colors[4])
|
||||
@ -139,7 +140,7 @@ gsk_vulkan_border_pipeline_collect_vertex_data (GskVulkanBorderPipeline *pipelin
|
||||
GskVulkanBorderInstance *instance = (GskVulkanBorderInstance *) data;
|
||||
guint i;
|
||||
|
||||
gsk_rounded_rect_to_float (rect, instance->rect);
|
||||
gsk_rounded_rect_to_float (rect, offset, instance->rect);
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
instance->widths[i] = widths[i];
|
||||
|
@ -21,6 +21,7 @@ GskVulkanPipeline * gsk_vulkan_border_pipeline_new (GdkVulk
|
||||
gsize gsk_vulkan_border_pipeline_count_vertex_data (GskVulkanBorderPipeline *pipeline);
|
||||
void gsk_vulkan_border_pipeline_collect_vertex_data (GskVulkanBorderPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const GskRoundedRect *rect,
|
||||
const float widths[4],
|
||||
const GdkRGBA colors[4]);
|
||||
|
@ -128,6 +128,7 @@ gsk_vulkan_box_shadow_pipeline_count_vertex_data (GskVulkanBoxShadowPipeline *pi
|
||||
void
|
||||
gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GskVulkanBoxShadowPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const GskRoundedRect *outline,
|
||||
const GdkRGBA *color,
|
||||
float dx,
|
||||
@ -137,7 +138,7 @@ gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GskVulkanBoxShadowPipeline *
|
||||
{
|
||||
GskVulkanBoxShadowInstance *instance = (GskVulkanBoxShadowInstance *) data;
|
||||
|
||||
gsk_rounded_rect_to_float (outline, instance->outline);
|
||||
gsk_rounded_rect_to_float (outline, offset, instance->outline);
|
||||
instance->color[0] = color->red;
|
||||
instance->color[1] = color->green;
|
||||
instance->color[2] = color->blue;
|
||||
|
@ -21,6 +21,7 @@ GskVulkanPipeline * gsk_vulkan_box_shadow_pipeline_new (GdkVulk
|
||||
gsize gsk_vulkan_box_shadow_pipeline_count_vertex_data (GskVulkanBoxShadowPipeline *pipeline);
|
||||
void gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GskVulkanBoxShadowPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const GskRoundedRect *outline,
|
||||
const GdkRGBA *color,
|
||||
float dx,
|
||||
|
@ -93,13 +93,14 @@ gsk_vulkan_color_pipeline_count_vertex_data (GskVulkanColorPipeline *pipeline)
|
||||
void
|
||||
gsk_vulkan_color_pipeline_collect_vertex_data (GskVulkanColorPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
GskVulkanColorInstance *instance = (GskVulkanColorInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->color[0] = color->red;
|
||||
|
@ -20,6 +20,7 @@ GskVulkanPipeline * gsk_vulkan_color_pipeline_new (GdkVulk
|
||||
gsize gsk_vulkan_color_pipeline_count_vertex_data (GskVulkanColorPipeline *pipeline);
|
||||
void gsk_vulkan_color_pipeline_collect_vertex_data (GskVulkanColorPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const GdkRGBA *color);
|
||||
gsize gsk_vulkan_color_pipeline_draw (GskVulkanColorPipeline *pipeline,
|
||||
|
@ -106,16 +106,17 @@ gsk_vulkan_cross_fade_pipeline_count_vertex_data (GskVulkanCrossFadePipeline *pi
|
||||
|
||||
void
|
||||
gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_tex_rect,
|
||||
const graphene_rect_t *end_tex_rect,
|
||||
double progress)
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_tex_rect,
|
||||
const graphene_rect_t *end_tex_rect,
|
||||
double progress)
|
||||
{
|
||||
GskVulkanCrossFadeInstance *instance = (GskVulkanCrossFadeInstance *) data;
|
||||
|
||||
instance->rect[0] = bounds->origin.x;
|
||||
instance->rect[1] = bounds->origin.y;
|
||||
instance->rect[0] = bounds->origin.x + offset->x;
|
||||
instance->rect[1] = bounds->origin.y + offset->y;
|
||||
instance->rect[2] = bounds->size.width;
|
||||
instance->rect[3] = bounds->size.height;
|
||||
|
||||
|
@ -20,6 +20,7 @@ GskVulkanPipeline * gsk_vulkan_cross_fade_pipeline_new (GdkVulka
|
||||
gsize gsk_vulkan_cross_fade_pipeline_count_vertex_data (GskVulkanCrossFadePipeline *pipeline);
|
||||
void gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GskVulkanCrossFadePipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *bounds,
|
||||
const graphene_rect_t *start_bounds,
|
||||
const graphene_rect_t *end_bounds,
|
||||
|
@ -125,6 +125,7 @@ gsk_vulkan_effect_pipeline_count_vertex_data (GskVulkanEffectPipeline *pipeline)
|
||||
void
|
||||
gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
const graphene_matrix_t *color_matrix,
|
||||
@ -132,8 +133,8 @@ gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipelin
|
||||
{
|
||||
GskVulkanEffectInstance *instance = (GskVulkanEffectInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->tex_rect[0] = tex_rect->origin.x;
|
||||
|
@ -20,6 +20,7 @@ GskVulkanPipeline * gsk_vulkan_effect_pipeline_new (GdkVulk
|
||||
gsize gsk_vulkan_effect_pipeline_count_vertex_data (GskVulkanEffectPipeline *pipeline);
|
||||
void gsk_vulkan_effect_pipeline_collect_vertex_data (GskVulkanEffectPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect,
|
||||
const graphene_matrix_t *color_matrix,
|
||||
|
@ -176,6 +176,7 @@ gsk_vulkan_linear_gradient_pipeline_count_vertex_data (GskVulkanLinearGradientPi
|
||||
void
|
||||
gsk_vulkan_linear_gradient_pipeline_collect_vertex_data (GskVulkanLinearGradientPipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_point_t *start,
|
||||
const graphene_point_t *end,
|
||||
@ -191,14 +192,14 @@ gsk_vulkan_linear_gradient_pipeline_collect_vertex_data (GskVulkanLinearGradient
|
||||
g_warning ("Only %u color stops supported.", GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS);
|
||||
n_stops = GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS;
|
||||
}
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->start[0] = start->x;
|
||||
instance->start[1] = start->y;
|
||||
instance->end[0] = end->x;
|
||||
instance->end[1] = end->y;
|
||||
instance->start[0] = start->x + offset->x;
|
||||
instance->start[1] = start->y + offset->y;
|
||||
instance->end[0] = end->x + offset->x;
|
||||
instance->end[1] = end->y + offset->y;
|
||||
instance->repeating = repeating;
|
||||
instance->stop_count = n_stops;
|
||||
for (i = 0; i < n_stops; i++)
|
||||
|
@ -25,6 +25,7 @@ gsize gsk_vulkan_linear_gradient_pipeline_count_vertex_data
|
||||
void gsk_vulkan_linear_gradient_pipeline_collect_vertex_data
|
||||
(GskVulkanLinearGradientPipeline*pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_point_t *start,
|
||||
const graphene_point_t *end,
|
||||
|
@ -78,7 +78,7 @@ gsk_vulkan_push_constants_wire_init (GskVulkanPushConstantsWire *wire,
|
||||
const GskVulkanPushConstants *self)
|
||||
{
|
||||
graphene_matrix_to_float (&self->mvp, wire->common.mvp);
|
||||
gsk_rounded_rect_to_float (&self->clip.rect, wire->common.clip);
|
||||
gsk_rounded_rect_to_float (&self->clip.rect, graphene_point_zero (), wire->common.clip);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -63,6 +63,7 @@ struct _GskVulkanOpRender
|
||||
{
|
||||
GskVulkanOpType type;
|
||||
GskRenderNode *node; /* node that's the source of this op */
|
||||
graphene_point_t offset; /* offset of the node */
|
||||
GskVulkanPipeline *pipeline; /* pipeline to use */
|
||||
GskRoundedRect clip; /* clip rect (or random memory if not relevant) */
|
||||
GskVulkanImage *source; /* source image to render */
|
||||
@ -79,6 +80,7 @@ struct _GskVulkanOpText
|
||||
{
|
||||
GskVulkanOpType type;
|
||||
GskRenderNode *node; /* node that's the source of this op */
|
||||
graphene_point_t offset; /* offset of the node */
|
||||
GskVulkanPipeline *pipeline; /* pipeline to use */
|
||||
GskRoundedRect clip; /* clip rect (or random memory if not relevant) */
|
||||
GskVulkanImage *source; /* source image to render */
|
||||
@ -117,6 +119,7 @@ struct _GskVulkanRenderPass
|
||||
cairo_region_t *clip;
|
||||
|
||||
graphene_vec2_t scale;
|
||||
graphene_point_t offset;
|
||||
|
||||
VkRenderPass render_pass;
|
||||
VkSemaphore signal_semaphore;
|
||||
@ -247,7 +250,8 @@ gsk_vulkan_render_pass_add_fallback_node (GskVulkanRenderPass *self,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
switch (constants->clip.type)
|
||||
@ -321,7 +325,8 @@ gsk_vulkan_render_pass_add_color_node (GskVulkanRenderPass *self,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
|
||||
@ -349,7 +354,8 @@ gsk_vulkan_render_pass_add_repeating_linear_gradient_node (GskVulkanRenderPass
|
||||
{
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
if (gsk_linear_gradient_node_get_n_color_stops (node) > GSK_VULKAN_LINEAR_GRADIENT_PIPELINE_MAX_COLOR_STOPS)
|
||||
@ -381,7 +387,8 @@ gsk_vulkan_render_pass_add_border_node (GskVulkanRenderPass *self,
|
||||
{
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
||||
@ -408,7 +415,8 @@ gsk_vulkan_render_pass_add_texture_node (GskVulkanRenderPass *self,
|
||||
{
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
||||
@ -435,7 +443,8 @@ gsk_vulkan_render_pass_add_inset_shadow_node (GskVulkanRenderPass *self
|
||||
{
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
if (gsk_inset_shadow_node_get_blur_radius (node) > 0)
|
||||
@ -464,7 +473,8 @@ gsk_vulkan_render_pass_add_outset_shadow_node (GskVulkanRenderPass *sel
|
||||
{
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
if (gsk_outset_shadow_node_get_blur_radius (node) > 0)
|
||||
@ -492,11 +502,13 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
GskRenderNode *child;
|
||||
GskTransform *transform;
|
||||
graphene_vec2_t old_scale;
|
||||
graphene_point_t old_offset;
|
||||
float scale_x;
|
||||
float scale_y;
|
||||
graphene_vec2_t scale;
|
||||
@ -506,14 +518,23 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self,
|
||||
FALLBACK ("Transform nodes can't deal with clip type %u\n", clip->type);
|
||||
#endif
|
||||
|
||||
child = gsk_transform_node_get_child (node);
|
||||
transform = gsk_transform_node_get_transform (node);
|
||||
|
||||
switch (gsk_transform_get_category (transform))
|
||||
{
|
||||
case GSK_TRANSFORM_CATEGORY_IDENTITY:
|
||||
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
|
||||
scale_x = scale_y = 1;
|
||||
break;
|
||||
{
|
||||
float dx, dy;
|
||||
gsk_transform_to_translate (transform, &dx, &dy);
|
||||
self->offset.x += dx;
|
||||
self->offset.y += dy;
|
||||
gsk_vulkan_render_pass_add_node (self, render, constants, child);
|
||||
self->offset.x -= dx;
|
||||
self->offset.y -= dy;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
|
||||
{
|
||||
@ -562,13 +583,16 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self,
|
||||
break;
|
||||
}
|
||||
|
||||
child = gsk_transform_node_get_child (node);
|
||||
transform = gsk_transform_transform (gsk_transform_translate (NULL, &self->offset),
|
||||
transform);
|
||||
if (!gsk_vulkan_push_constants_transform (&op.constants.constants, constants, transform, &child->bounds))
|
||||
FALLBACK ("Transform nodes can't deal with clip type %u", constants->clip.type);
|
||||
|
||||
op.type = GSK_VULKAN_OP_PUSH_VERTEX_CONSTANTS;
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
old_offset = self->offset;
|
||||
self->offset = *graphene_point_zero ();
|
||||
graphene_vec2_init_from_vec2 (&old_scale, &self->scale);
|
||||
graphene_vec2_init (&scale, fabs (scale_x), fabs (scale_y));
|
||||
graphene_vec2_multiply (&self->scale, &scale, &self->scale);
|
||||
@ -579,6 +603,9 @@ gsk_vulkan_render_pass_add_transform_node (GskVulkanRenderPass *self,
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
graphene_vec2_init_from_vec2 (&self->scale, &old_scale);
|
||||
self->offset = old_offset;
|
||||
|
||||
gsk_transform_unref (transform);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -591,7 +618,8 @@ gsk_vulkan_render_pass_add_opacity_node (GskVulkanRenderPass *self,
|
||||
{
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
||||
@ -618,7 +646,8 @@ gsk_vulkan_render_pass_add_color_matrix_node (GskVulkanRenderPass *self
|
||||
{
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
||||
@ -644,10 +673,16 @@ gsk_vulkan_render_pass_add_clip_node (GskVulkanRenderPass *self,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
graphene_rect_t clip;
|
||||
|
||||
if (!gsk_vulkan_push_constants_intersect_rect (&op.constants.constants, constants, gsk_clip_node_get_clip (node)))
|
||||
graphene_rect_offset_r (gsk_clip_node_get_clip (node),
|
||||
self->offset.x, self->offset.y,
|
||||
&clip);
|
||||
|
||||
if (!gsk_vulkan_push_constants_intersect_rect (&op.constants.constants, constants, &clip))
|
||||
FALLBACK ("Failed to find intersection between clip of type %u and rectangle", constants->clip.type);
|
||||
|
||||
if (op.constants.constants.clip.type == GSK_VULKAN_CLIP_ALL_CLIPPED)
|
||||
@ -671,12 +706,15 @@ gsk_vulkan_render_pass_add_rounded_clip_node (GskVulkanRenderPass *self
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
GskRoundedRect clip;
|
||||
|
||||
if (!gsk_vulkan_push_constants_intersect_rounded (&op.constants.constants,
|
||||
constants,
|
||||
gsk_rounded_clip_node_get_clip (node)))
|
||||
clip = *gsk_rounded_clip_node_get_clip (node);
|
||||
gsk_rounded_rect_offset (&clip, self->offset.x, self->offset.y);
|
||||
|
||||
if (!gsk_vulkan_push_constants_intersect_rounded (&op.constants.constants, constants, &clip))
|
||||
FALLBACK ("Failed to find intersection between clip of type %u and rounded rectangle", constants->clip.type);
|
||||
|
||||
if (op.constants.constants.clip.type == GSK_VULKAN_CLIP_ALL_CLIPPED)
|
||||
@ -701,7 +739,8 @@ gsk_vulkan_render_pass_add_repeat_node (GskVulkanRenderPass *self,
|
||||
{
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
if (graphene_rect_get_area (gsk_repeat_node_get_child_bounds (node)) == 0)
|
||||
@ -731,7 +770,8 @@ gsk_vulkan_render_pass_add_blend_node (GskVulkanRenderPass *self,
|
||||
{
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
||||
@ -757,7 +797,8 @@ gsk_vulkan_render_pass_add_cross_fade_node (GskVulkanRenderPass *self,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
|
||||
@ -784,7 +825,8 @@ gsk_vulkan_render_pass_add_text_node (GskVulkanRenderPass *self,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
const PangoGlyphInfo *glyphs;
|
||||
@ -877,7 +919,8 @@ gsk_vulkan_render_pass_add_blur_node (GskVulkanRenderPass *self,
|
||||
{
|
||||
GskVulkanPipelineType pipeline_type;
|
||||
GskVulkanOp op = {
|
||||
.render.node = node
|
||||
.render.node = node,
|
||||
.render.offset = self->offset,
|
||||
};
|
||||
|
||||
if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds))
|
||||
@ -1001,6 +1044,8 @@ gsk_vulkan_render_pass_add (GskVulkanRenderPass *self,
|
||||
g_array_append_val (self->render_ops, op);
|
||||
|
||||
gsk_vulkan_render_pass_add_node (self, render, &op.constants.constants, node);
|
||||
|
||||
self->offset = GRAPHENE_POINT_INIT (0, 0);
|
||||
}
|
||||
|
||||
static GskVulkanImage *
|
||||
@ -1207,13 +1252,17 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderPass *self,
|
||||
if (op->type == GSK_VULKAN_OP_FALLBACK_CLIP)
|
||||
{
|
||||
cairo_rectangle (cr,
|
||||
op->clip.bounds.origin.x, op->clip.bounds.origin.y,
|
||||
op->clip.bounds.size.width, op->clip.bounds.size.height);
|
||||
op->clip.bounds.origin.x - op->offset.x,
|
||||
op->clip.bounds.origin.y - op->offset.y,
|
||||
op->clip.bounds.size.width,
|
||||
op->clip.bounds.size.height);
|
||||
cairo_clip (cr);
|
||||
}
|
||||
else if (op->type == GSK_VULKAN_OP_FALLBACK_ROUNDED_CLIP)
|
||||
{
|
||||
cairo_translate (cr, - op->offset.x, - op->offset.y);
|
||||
gsk_rounded_rect_path (&op->clip, cr);
|
||||
cairo_translate (cr, op->offset.x, op->offset.y);
|
||||
cairo_clip (cr);
|
||||
}
|
||||
else
|
||||
@ -1227,8 +1276,10 @@ gsk_vulkan_render_pass_upload_fallback (GskVulkanRenderPass *self,
|
||||
if (GSK_RENDERER_DEBUG_CHECK (gsk_vulkan_render_get_renderer (render), FALLBACK))
|
||||
{
|
||||
cairo_rectangle (cr,
|
||||
op->clip.bounds.origin.x, op->clip.bounds.origin.y,
|
||||
op->clip.bounds.size.width, op->clip.bounds.size.height);
|
||||
op->clip.bounds.origin.x - op->offset.x,
|
||||
op->clip.bounds.origin.y - op->offset.y,
|
||||
op->clip.bounds.size.width,
|
||||
op->clip.bounds.size.height);
|
||||
if (gsk_render_node_get_node_type (node) == GSK_CAIRO_NODE)
|
||||
cairo_set_source_rgba (cr, 0.3, 0, 1, 0.25);
|
||||
else
|
||||
@ -1579,6 +1630,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_texture_pipeline_collect_vertex_data (GSK_VULKAN_TEXTURE_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
&op->render.node->bounds,
|
||||
&op->render.source_rect);
|
||||
n_bytes += op->render.vertex_count;
|
||||
@ -1590,6 +1642,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_texture_pipeline_collect_vertex_data (GSK_VULKAN_TEXTURE_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
&op->render.node->bounds,
|
||||
&op->render.source_rect);
|
||||
n_bytes += op->render.vertex_count;
|
||||
@ -1607,7 +1660,10 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
gsk_text_node_get_num_glyphs (op->text.node),
|
||||
gsk_text_node_get_glyphs (op->text.node, NULL),
|
||||
gsk_text_node_get_color (op->text.node),
|
||||
gsk_text_node_get_offset (op->text.node),
|
||||
&GRAPHENE_POINT_INIT (
|
||||
gsk_text_node_get_offset (op->text.node)->x + op->render.offset.x,
|
||||
gsk_text_node_get_offset (op->text.node)->y + op->render.offset.y
|
||||
),
|
||||
op->text.start_glyph,
|
||||
op->text.num_glyphs,
|
||||
op->text.scale);
|
||||
@ -1625,7 +1681,10 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
(PangoFont *)gsk_text_node_get_font (op->text.node),
|
||||
gsk_text_node_get_num_glyphs (op->text.node),
|
||||
gsk_text_node_get_glyphs (op->text.node, NULL),
|
||||
gsk_text_node_get_offset (op->text.node),
|
||||
&GRAPHENE_POINT_INIT (
|
||||
gsk_text_node_get_offset (op->text.node)->x + op->render.offset.x,
|
||||
gsk_text_node_get_offset (op->text.node)->y + op->render.offset.y
|
||||
),
|
||||
op->text.start_glyph,
|
||||
op->text.num_glyphs,
|
||||
op->text.scale);
|
||||
@ -1638,6 +1697,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_color_pipeline_collect_vertex_data (GSK_VULKAN_COLOR_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
&op->render.node->bounds,
|
||||
gsk_color_node_get_color (op->render.node));
|
||||
n_bytes += op->render.vertex_count;
|
||||
@ -1649,6 +1709,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_linear_gradient_pipeline_collect_vertex_data (GSK_VULKAN_LINEAR_GRADIENT_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
&op->render.node->bounds,
|
||||
gsk_linear_gradient_node_get_start (op->render.node),
|
||||
gsk_linear_gradient_node_get_end (op->render.node),
|
||||
@ -1676,6 +1737,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
|
||||
gsk_vulkan_effect_pipeline_collect_vertex_data (GSK_VULKAN_EFFECT_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
&op->render.node->bounds,
|
||||
&op->render.source_rect,
|
||||
&color_matrix,
|
||||
@ -1689,6 +1751,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_blur_pipeline_collect_vertex_data (GSK_VULKAN_BLUR_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
&op->render.node->bounds,
|
||||
&op->render.source_rect,
|
||||
gsk_blur_node_get_radius (op->render.node));
|
||||
@ -1701,6 +1764,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_effect_pipeline_collect_vertex_data (GSK_VULKAN_EFFECT_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
&op->render.node->bounds,
|
||||
&op->render.source_rect,
|
||||
gsk_color_matrix_node_get_color_matrix (op->render.node),
|
||||
@ -1714,6 +1778,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_border_pipeline_collect_vertex_data (GSK_VULKAN_BORDER_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
gsk_border_node_get_outline (op->render.node),
|
||||
gsk_border_node_get_widths (op->render.node),
|
||||
gsk_border_node_get_colors (op->render.node));
|
||||
@ -1726,6 +1791,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GSK_VULKAN_BOX_SHADOW_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
gsk_inset_shadow_node_get_outline (op->render.node),
|
||||
gsk_inset_shadow_node_get_color (op->render.node),
|
||||
gsk_inset_shadow_node_get_dx (op->render.node),
|
||||
@ -1741,6 +1807,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_box_shadow_pipeline_collect_vertex_data (GSK_VULKAN_BOX_SHADOW_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
gsk_outset_shadow_node_get_outline (op->render.node),
|
||||
gsk_outset_shadow_node_get_color (op->render.node),
|
||||
gsk_outset_shadow_node_get_dx (op->render.node),
|
||||
@ -1756,6 +1823,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_cross_fade_pipeline_collect_vertex_data (GSK_VULKAN_CROSS_FADE_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
&op->render.node->bounds,
|
||||
&op->render.source_rect,
|
||||
&op->render.source2_rect,
|
||||
@ -1769,6 +1837,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self,
|
||||
op->render.vertex_offset = offset + n_bytes;
|
||||
gsk_vulkan_blend_mode_pipeline_collect_vertex_data (GSK_VULKAN_BLEND_MODE_PIPELINE (op->render.pipeline),
|
||||
data + n_bytes + offset,
|
||||
&op->render.offset,
|
||||
&op->render.node->bounds,
|
||||
&op->render.source_rect,
|
||||
&op->render.source2_rect,
|
||||
|
@ -21,21 +21,21 @@ GskVulkanPipeline * gsk_vulkan_text_pipeline_new (GdkVulka
|
||||
gsize gsk_vulkan_text_pipeline_count_vertex_data (GskVulkanTextPipeline *pipeline,
|
||||
int num_instances);
|
||||
void gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
|
||||
guchar *data,
|
||||
GskVulkanRenderer *renderer,
|
||||
const graphene_rect_t *rect,
|
||||
PangoFont *font,
|
||||
guint total_glyphs,
|
||||
const PangoGlyphInfo *glyphs,
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset,
|
||||
guint start_glyph,
|
||||
guint num_glyphs,
|
||||
float scale);
|
||||
guchar *data,
|
||||
GskVulkanRenderer *renderer,
|
||||
const graphene_rect_t *rect,
|
||||
PangoFont *font,
|
||||
guint total_glyphs,
|
||||
const PangoGlyphInfo *glyphs,
|
||||
const GdkRGBA *color,
|
||||
const graphene_point_t *offset,
|
||||
guint start_glyph,
|
||||
guint num_glyphs,
|
||||
float scale);
|
||||
gsize gsk_vulkan_text_pipeline_draw (GskVulkanTextPipeline *pipeline,
|
||||
VkCommandBuffer command_buffer,
|
||||
gsize offset,
|
||||
gsize n_commands);
|
||||
VkCommandBuffer command_buffer,
|
||||
gsize offset,
|
||||
gsize n_commands);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -93,13 +93,14 @@ gsk_vulkan_texture_pipeline_count_vertex_data (GskVulkanTexturePipeline *pipelin
|
||||
void
|
||||
gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect)
|
||||
{
|
||||
GskVulkanTextureInstance *instance = (GskVulkanTextureInstance *) data;
|
||||
|
||||
instance->rect[0] = rect->origin.x;
|
||||
instance->rect[1] = rect->origin.y;
|
||||
instance->rect[0] = rect->origin.x + offset->x;
|
||||
instance->rect[1] = rect->origin.y + offset->y;
|
||||
instance->rect[2] = rect->size.width;
|
||||
instance->rect[3] = rect->size.height;
|
||||
instance->tex_rect[0] = tex_rect->origin.x;
|
||||
|
@ -20,6 +20,7 @@ GskVulkanPipeline * gsk_vulkan_texture_pipeline_new (GdkVulk
|
||||
gsize gsk_vulkan_texture_pipeline_count_vertex_data (GskVulkanTexturePipeline *pipeline);
|
||||
void gsk_vulkan_texture_pipeline_collect_vertex_data (GskVulkanTexturePipeline *pipeline,
|
||||
guchar *data,
|
||||
const graphene_point_t *offset,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_rect_t *tex_rect);
|
||||
gsize gsk_vulkan_texture_pipeline_draw (GskVulkanTexturePipeline *pipeline,
|
||||
|
@ -1267,7 +1267,7 @@ populate_render_node_properties (GListStore *store,
|
||||
float radius = gsk_outset_shadow_node_get_blur_radius (node);
|
||||
float rect[12];
|
||||
|
||||
gsk_rounded_rect_to_float (outline, rect);
|
||||
gsk_rounded_rect_to_float (outline, graphene_point_zero (), rect);
|
||||
tmp = g_strdup_printf ("%.2f x %.2f + %.2f + %.2f",
|
||||
rect[2], rect[3], rect[0], rect[1]);
|
||||
add_text_row (store, "Outline", tmp);
|
||||
|
@ -152,12 +152,19 @@ test_to_float (void)
|
||||
&GRAPHENE_SIZE_INIT (8, 9),
|
||||
&GRAPHENE_SIZE_INIT (10, 11));
|
||||
|
||||
gsk_rounded_rect_to_float (&rect, flt);
|
||||
gsk_rounded_rect_to_float (&rect, &GRAPHENE_POINT_INIT(0, 0), flt);
|
||||
g_assert_true (flt[0] == 0. && flt[1] == 11. && flt[2] == 22. && flt[3] == 33.);
|
||||
g_assert_true (flt[4] == 4. && flt[5] == 6.);
|
||||
g_assert_true (flt[6] == 8. && flt[7] == 10.);
|
||||
g_assert_true (flt[8] == 5. && flt[9] == 7.);
|
||||
g_assert_true (flt[10] == 9. && flt[11] == 11.);
|
||||
|
||||
gsk_rounded_rect_to_float (&rect, &GRAPHENE_POINT_INIT(100, 200), flt);
|
||||
g_assert_true (flt[0] == 100. && flt[1] == 211. && flt[2] == 22. && flt[3] == 33.);
|
||||
g_assert_true (flt[4] == 4. && flt[5] == 6.);
|
||||
g_assert_true (flt[6] == 8. && flt[7] == 10.);
|
||||
g_assert_true (flt[8] == 5. && flt[9] == 7.);
|
||||
g_assert_true (flt[10] == 9. && flt[11] == 11.);
|
||||
}
|
||||
|
||||
#define ROUNDED_RECT_INIT_FULL(x,y,w,h,w0,h0,w1,h1,w2,h2,w3,h3) \
|
||||
|
Loading…
Reference in New Issue
Block a user