vulkan: Handle empty child bounds in repeat node
authorBenjamin Otte <otte@redhat.com>
Tue, 9 May 2023 22:08:24 +0000 (00:08 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 4 Jun 2023 17:42:01 +0000 (19:42 +0200)
Also add test to the testsuite for it.

gsk/vulkan/gskvulkanimage.c
gsk/vulkan/gskvulkanrenderpass.c
testsuite/gsk/compare/repeat-empty-child-bounds.node [new file with mode: 0644]
testsuite/gsk/compare/repeat-empty-child-bounds.png [new file with mode: 0644]
testsuite/gsk/meson.build

index b6b44ecc8c60a7ce9dafa408dfa7712639d8b4ce..5888cb0a233cc9fdf13c89550dc82b7735ebd580 100644 (file)
@@ -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);
index 556502af7a9c89f8cf84650fe65cb3b02e71dea0..0b1d431161dd46654e5b29f2e64446376716a24d 100644 (file)
@@ -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 (file)
index 0000000..b2dee84
--- /dev/null
@@ -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 (file)
index 0000000..1cf45d8
Binary files /dev/null and b/testsuite/gsk/compare/repeat-empty-child-bounds.png differ
index 263d13cf2954bef1c55befd75787878f5e301a76..df493d9332c6ec1d43c362c9581d98bd30a51f87 100644 (file)
@@ -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',