From 860c82d57648a1c64a178ab30c6d1ffcf07b5055 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 10 May 2023 00:08:24 +0200 Subject: vulkan: Handle empty child bounds in repeat node Also add test to the testsuite for it. --- gsk/vulkan/gskvulkanimage.c | 2 ++ gsk/vulkan/gskvulkanrenderpass.c | 3 +++ .../gsk/compare/repeat-empty-child-bounds.node | 24 +++++++++++++++++++++ .../gsk/compare/repeat-empty-child-bounds.png | Bin 0 -> 119 bytes testsuite/gsk/meson.build | 1 + 5 files changed, 30 insertions(+) create mode 100644 testsuite/gsk/compare/repeat-empty-child-bounds.node create mode 100644 testsuite/gsk/compare/repeat-empty-child-bounds.png diff --git a/gsk/vulkan/gskvulkanimage.c b/gsk/vulkan/gskvulkanimage.c index b6b44ecc8c..5888cb0a23 100644 --- a/gsk/vulkan/gskvulkanimage.c +++ b/gsk/vulkan/gskvulkanimage.c @@ -209,6 +209,8 @@ gsk_vulkan_image_new (GdkVulkanContext *context, VkMemoryRequirements requirements; GskVulkanImage *self; + g_assert (width > 0 && height > 0); + self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL); self->vulkan = g_object_ref (context); diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c index 556502af7a..0b1d431161 100644 --- a/gsk/vulkan/gskvulkanrenderpass.c +++ b/gsk/vulkan/gskvulkanrenderpass.c @@ -725,6 +725,9 @@ gsk_vulkan_render_pass_add_repeat_node (GskVulkanRenderPass *self, .render.node = node }; + if (graphene_rect_get_area (gsk_repeat_node_get_child_bounds (node)) == 0) + return TRUE; + if (gsk_vulkan_clip_contains_rect (&constants->clip, &node->bounds)) pipeline_type = GSK_VULKAN_PIPELINE_TEXTURE; else if (constants->clip.type == GSK_VULKAN_CLIP_RECT) diff --git a/testsuite/gsk/compare/repeat-empty-child-bounds.node b/testsuite/gsk/compare/repeat-empty-child-bounds.node new file mode 100644 index 0000000000..b2dee849f3 --- /dev/null +++ b/testsuite/gsk/compare/repeat-empty-child-bounds.node @@ -0,0 +1,24 @@ +repeat { + bounds: 0 0 100 100; + child-bounds: 0 0 0 0; + child: color { + bounds: 0 0 20 20; + color: rgb(255,0,0); + } +} +repeat { + bounds: 0 0 100 100; + child-bounds: 0 0 20 0; + child: color { + bounds: 0 0 20 20; + color: rgb(0,128,0); + } +} +repeat { + bounds: 0 0 100 100; + child-bounds: 0 0 0 20; + child: color { + bounds: 0 0 20 20; + color: rgb(0,0,255); + } +} diff --git a/testsuite/gsk/compare/repeat-empty-child-bounds.png b/testsuite/gsk/compare/repeat-empty-child-bounds.png new file mode 100644 index 0000000000..1cf45d8688 Binary files /dev/null and b/testsuite/gsk/compare/repeat-empty-child-bounds.png differ diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index 263d13cf29..df493d9332 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -77,6 +77,7 @@ compare_render_tests = [ 'outset_shadow_simple', 'repeat', 'repeat-no-repeat', + 'repeat-empty-child-bounds', 'repeat-negative-coords', 'repeat-texture', 'scale-textures-negative-ngl', -- cgit v1.2.1