From 538e7c79821c754196e89de33162e0bd9a2cb62f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 29 Sep 2017 22:07:30 -0400 Subject: [PATCH] vulkan: Allow to control scaling in the blend pipeline Pass in a second rect that defines the size of the texture. Update the sole caller to pass in the same rect, for unchanged behavior. --- gsk/gskvulkanblendpipeline.c | 11 ++++++----- gsk/gskvulkanblendpipelineprivate.h | 3 ++- gsk/gskvulkanrenderpass.c | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gsk/gskvulkanblendpipeline.c b/gsk/gskvulkanblendpipeline.c index 6d939ca296..2bcd5491fa 100644 --- a/gsk/gskvulkanblendpipeline.c +++ b/gsk/gskvulkanblendpipeline.c @@ -93,7 +93,8 @@ gsk_vulkan_blend_pipeline_count_vertex_data (GskVulkanBlendPipeline *pipeline) void gsk_vulkan_blend_pipeline_collect_vertex_data (GskVulkanBlendPipeline *pipeline, guchar *data, - const graphene_rect_t *rect) + const graphene_rect_t *rect, + const graphene_rect_t *tex_rect) { GskVulkanBlendInstance *instance = (GskVulkanBlendInstance *) data; @@ -101,10 +102,10 @@ gsk_vulkan_blend_pipeline_collect_vertex_data (GskVulkanBlendPipeline *pipeline, instance->rect[1] = rect->origin.y; instance->rect[2] = rect->size.width; instance->rect[3] = rect->size.height; - instance->tex_rect[0] = 0.0; - instance->tex_rect[1] = 0.0; - instance->tex_rect[2] = 1.0; - instance->tex_rect[3] = 1.0; + instance->tex_rect[0] = (rect->origin.x - tex_rect->origin.x)/tex_rect->size.width; + instance->tex_rect[1] = (rect->origin.y - tex_rect->origin.y)/tex_rect->size.height; + instance->tex_rect[2] = (rect->size.width + rect->origin.x - tex_rect->origin.x)/tex_rect->size.width; + instance->tex_rect[3] = (rect->size.height + rect->origin.y - tex_rect->origin.y)/tex_rect->size.height; } gsize diff --git a/gsk/gskvulkanblendpipelineprivate.h b/gsk/gskvulkanblendpipelineprivate.h index eb471981b8..678db008a6 100644 --- a/gsk/gskvulkanblendpipelineprivate.h +++ b/gsk/gskvulkanblendpipelineprivate.h @@ -21,7 +21,8 @@ GskVulkanPipeline * gsk_vulkan_blend_pipeline_new (GdkVulk gsize gsk_vulkan_blend_pipeline_count_vertex_data (GskVulkanBlendPipeline *pipeline); void gsk_vulkan_blend_pipeline_collect_vertex_data (GskVulkanBlendPipeline *pipeline, guchar *data, - const graphene_rect_t *rect); + const graphene_rect_t *rect, + const graphene_rect_t *tex_rect); gsize gsk_vulkan_blend_pipeline_draw (GskVulkanBlendPipeline *pipeline, VkCommandBuffer command_buffer, gsize offset, diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c index b222b9cd52..77f4fcd0e6 100644 --- a/gsk/gskvulkanrenderpass.c +++ b/gsk/gskvulkanrenderpass.c @@ -1055,6 +1055,7 @@ gsk_vulkan_render_pass_collect_vertex_data (GskVulkanRenderPass *self, op->render.vertex_offset = offset + n_bytes; gsk_vulkan_blend_pipeline_collect_vertex_data (GSK_VULKAN_BLEND_PIPELINE (op->render.pipeline), data + n_bytes + offset, + &op->render.node->bounds, &op->render.node->bounds); n_bytes += op->render.vertex_count; }