summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-09-29 22:07:30 -0400
committerMatthias Clasen <mclasen@redhat.com>2017-09-29 22:12:25 -0400
commit538e7c79821c754196e89de33162e0bd9a2cb62f (patch)
tree5962db37ef44692c350cd8cfeba11a19e8eb8423
parente91051a5626d5594ac79289de6ac6d054329df76 (diff)
downloadgtk+-538e7c79821c754196e89de33162e0bd9a2cb62f.tar.gz
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.
-rw-r--r--gsk/gskvulkanblendpipeline.c11
-rw-r--r--gsk/gskvulkanblendpipelineprivate.h3
-rw-r--r--gsk/gskvulkanrenderpass.c1
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;
}