vulkan: Make clip type an enum
authorBenjamin Otte <otte@redhat.com>
Sat, 15 Jul 2023 10:47:35 +0000 (12:47 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 16 Jul 2023 11:16:43 +0000 (13:16 +0200)
and add gsk_vulkan_shader_op_alloc() that sets it properly.

31 files changed:
gsk/vulkan/gskvulkanblendmodeop.c
gsk/vulkan/gskvulkanblendmodeopprivate.h
gsk/vulkan/gskvulkanblurop.c
gsk/vulkan/gskvulkanbluropprivate.h
gsk/vulkan/gskvulkanborderop.c
gsk/vulkan/gskvulkanborderopprivate.h
gsk/vulkan/gskvulkanclip.c
gsk/vulkan/gskvulkanclipprivate.h
gsk/vulkan/gskvulkancolormatrixop.c
gsk/vulkan/gskvulkancolormatrixopprivate.h
gsk/vulkan/gskvulkancolorop.c
gsk/vulkan/gskvulkancoloropprivate.h
gsk/vulkan/gskvulkancrossfadeop.c
gsk/vulkan/gskvulkancrossfadeopprivate.h
gsk/vulkan/gskvulkanglyphop.c
gsk/vulkan/gskvulkanglyphopprivate.h
gsk/vulkan/gskvulkaninsetshadowop.c
gsk/vulkan/gskvulkaninsetshadowopprivate.h
gsk/vulkan/gskvulkanlineargradientop.c
gsk/vulkan/gskvulkanlineargradientopprivate.h
gsk/vulkan/gskvulkanmaskop.c
gsk/vulkan/gskvulkanmaskopprivate.h
gsk/vulkan/gskvulkanoutsetshadowop.c
gsk/vulkan/gskvulkanoutsetshadowopprivate.h
gsk/vulkan/gskvulkanrender.c
gsk/vulkan/gskvulkanrenderpass.c
gsk/vulkan/gskvulkanrenderprivate.h
gsk/vulkan/gskvulkanshaderop.c
gsk/vulkan/gskvulkanshaderopprivate.h
gsk/vulkan/gskvulkantextureop.c
gsk/vulkan/gskvulkantextureopprivate.h

index 81df72c6a33f879b4d83c7f134478dc875a37f37..21407a1f66595b9830a8b7ddf902393ca6d772f6 100644 (file)
@@ -95,7 +95,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_BLEND_MODE_OP_CLASS = {
 
 void
 gsk_vulkan_blend_mode_op (GskVulkanRender        *render,
-                          const char             *clip_type,
+                          GskVulkanShaderClip     clip,
                           const graphene_rect_t  *bounds,
                           const graphene_point_t *offset,
                           GskBlendMode            blend_mode,
@@ -108,9 +108,8 @@ gsk_vulkan_blend_mode_op (GskVulkanRender        *render,
 {
   GskVulkanBlendModeOp *self;
 
-  self = (GskVulkanBlendModeOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_BLEND_MODE_OP_CLASS.parent_class);
+  self = (GskVulkanBlendModeOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_BLEND_MODE_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   graphene_rect_offset_r (bounds, offset->x, offset->y, &self->bounds);
   self->blend_mode = blend_mode;
 
index 418c5f2649714fb5245760900cdc8a9918a52af5..c90d756dbf76a9dbd7422ab645cf810a94a6d937 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_blend_mode_op                        (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          const graphene_rect_t          *bounds,
                                                                          const graphene_point_t         *offset,
                                                                          GskBlendMode                    blend_mode,
index 76719ccbafb78e7015330d1d79ca5bd640b2b4dc..910c9a2fe2cf132235c3e34f14b3b3f9dceb46a7 100644 (file)
@@ -84,7 +84,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_BLUR_OP_CLASS = {
 
 void
 gsk_vulkan_blur_op (GskVulkanRender         *render,
-                    const char              *clip_type,
+                    GskVulkanShaderClip      clip,
                     GskVulkanImage          *image,
                     const graphene_rect_t   *rect,
                     const graphene_point_t  *offset,
@@ -95,9 +95,8 @@ gsk_vulkan_blur_op (GskVulkanRender         *render,
 
   g_assert (radius > 0);
 
-  self = (GskVulkanBlurOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_BLUR_OP_CLASS.parent_class);
+  self = (GskVulkanBlurOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_BLUR_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   self->image = g_object_ref (image);
   graphene_rect_offset_r (rect, offset->x, offset->y, &self->rect);
   gsk_vulkan_normalize_tex_coords (&self->tex_rect, rect, tex_rect);
index 24a90a71951ffe63da7409c693b3d7ee6a6782a0..681cc3e8cb055ca2b590f748599b114b9b10165c 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_blur_op                              (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          GskVulkanImage                 *image,
                                                                          const graphene_rect_t          *rect,
                                                                          const graphene_point_t         *offset,
index 2d157aea362eea64ec28f2e674cbb96a0899213b..3015820fce5687e55556fd656fac2880571b8093 100644 (file)
@@ -100,7 +100,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_BORDER_OP_CLASS = {
 
 void
 gsk_vulkan_border_op (GskVulkanRender         *render,
-                      const char              *clip_type,
+                      GskVulkanShaderClip      clip,
                       const GskRoundedRect    *outline,
                       const graphene_point_t  *offset,
                       const float              widths[4],
@@ -109,9 +109,8 @@ gsk_vulkan_border_op (GskVulkanRender         *render,
   GskVulkanBorderOp *self;
   guint i;
 
-  self = (GskVulkanBorderOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_BORDER_OP_CLASS.parent_class);
+  self = (GskVulkanBorderOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_BORDER_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   self->outline = *outline;
   gsk_rounded_rect_offset (&self->outline, offset->x, offset->y);
   for (i = 0; i < 4; i++)
index 85985e4a7af51a5c310ed579ee418faa05d0e68c..cc3a2b3e204961854f709cc45fff415bdcdea4ef 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_border_op                            (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          const GskRoundedRect           *outline,
                                                                          const graphene_point_t         *offset,
                                                                          const float                     widths[4],
index 4d066ada42094ea79766888458e7da5de1054668..d9a300011fce1f29880c2dd3ecb37e8a9db491e0 100644 (file)
@@ -285,16 +285,16 @@ gsk_vulkan_clip_contains_rect (const GskVulkanClip    *self,
     }
 }
 
-const char *
-gsk_vulkan_clip_get_clip_type (const GskVulkanClip    *self,
-                               const graphene_point_t *offset,
-                               const graphene_rect_t  *rect)
+GskVulkanShaderClip
+gsk_vulkan_clip_get_shader_clip (const GskVulkanClip    *self,
+                                 const graphene_point_t *offset,
+                                 const graphene_rect_t  *rect)
 {
   if (gsk_vulkan_clip_contains_rect (self, offset, rect))
-    return "";
+    return GSK_VULKAN_SHADER_CLIP_NONE;
   else if (self->type == GSK_VULKAN_CLIP_RECT)
-    return "-clip";
+    return GSK_VULKAN_SHADER_CLIP_RECT;
   else
-    return "-clip-rounded";
+    return GSK_VULKAN_SHADER_CLIP_ROUNDED;
 }
 
index 1fc592809a03cafd01ad84522dd645c484f078c0..1813497f1d4e58de2a8885a60909a9d06193a86f 100644 (file)
@@ -6,6 +6,12 @@
 
 G_BEGIN_DECLS
 
+typedef enum {
+  GSK_VULKAN_SHADER_CLIP_NONE,
+  GSK_VULKAN_SHADER_CLIP_RECT,
+  GSK_VULKAN_SHADER_CLIP_ROUNDED
+} GskVulkanShaderClip;
+
 typedef enum {
   /* The whole area is clipped, no drawing is necessary.
    * This can't be handled by return values because for return
@@ -58,7 +64,7 @@ gboolean                gsk_vulkan_clip_contains_rect                   (const G
 gboolean                gsk_vulkan_clip_may_intersect_rect              (const GskVulkanClip    *self,
                                                                          const graphene_point_t *offset,
                                                                          const graphene_rect_t  *rect) G_GNUC_WARN_UNUSED_RESULT;
-const char *            gsk_vulkan_clip_get_clip_type                   (const GskVulkanClip    *self,
+GskVulkanShaderClip     gsk_vulkan_clip_get_shader_clip                 (const GskVulkanClip    *self,
                                                                          const graphene_point_t *offset,
                                                                          const graphene_rect_t  *rect);
 
index f007ddfd4f5c0f25813131886068a40a9ad0c061..88ae643b44138d05a445adb85761a755c10c20f0 100644 (file)
@@ -91,7 +91,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_COLOR_MATRIX_OP_CLASS = {
 
 void
 gsk_vulkan_color_matrix_op (GskVulkanRender         *render,
-                            const char              *clip_type,
+                            GskVulkanShaderClip      clip,
                             GskVulkanImage          *image,
                             const graphene_rect_t   *rect,
                             const graphene_point_t  *offset,
@@ -101,9 +101,8 @@ gsk_vulkan_color_matrix_op (GskVulkanRender         *render,
 {
   GskVulkanColorMatrixOp *self;
 
-  self = (GskVulkanColorMatrixOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_COLOR_MATRIX_OP_CLASS.parent_class);
+  self = (GskVulkanColorMatrixOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_COLOR_MATRIX_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   self->image = g_object_ref (image);
   graphene_rect_offset_r (rect, offset->x, offset->y, &self->rect);
   gsk_vulkan_normalize_tex_coords (&self->tex_rect, rect, tex_rect);
@@ -113,7 +112,7 @@ gsk_vulkan_color_matrix_op (GskVulkanRender         *render,
 
 void
 gsk_vulkan_color_matrix_op_opacity (GskVulkanRender        *render,
-                                    const char             *clip_type,
+                                    GskVulkanShaderClip     clip,
                                     GskVulkanImage         *image,
                                     const graphene_rect_t  *rect,
                                     const graphene_point_t *offset,
@@ -133,7 +132,7 @@ gsk_vulkan_color_matrix_op_opacity (GskVulkanRender        *render,
   graphene_vec4_init (&color_offset, 0.0, 0.0, 0.0, 0.0);
 
   gsk_vulkan_color_matrix_op (render,
-                              clip_type,
+                              clip,
                               image,
                               rect,
                               offset,
index e50cdbf10b4d0a13b4de8e2e4dcc0668746213dd..b2a490b0050d49cf5c7d0c6ebe155c4641303f4f 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_color_matrix_op                      (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          GskVulkanImage                 *image,
                                                                          const graphene_rect_t          *rect,
                                                                          const graphene_point_t         *offset,
@@ -14,7 +14,7 @@ void                    gsk_vulkan_color_matrix_op                      (GskVulk
                                                                          const graphene_vec4_t          *color_offset);
 
 void                    gsk_vulkan_color_matrix_op_opacity              (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          GskVulkanImage                 *image,
                                                                          const graphene_rect_t          *rect,
                                                                          const graphene_point_t         *offset,
index e5b5c2178056897d1bfe1801ba4f91c1bb6ae5a8..1caa47d63f56f446a38b2f06e9ed9758e2435957 100644 (file)
@@ -76,16 +76,15 @@ static const GskVulkanShaderOpClass GSK_VULKAN_COLOR_OP_CLASS = {
 
 void
 gsk_vulkan_color_op (GskVulkanRender        *render,
-                     const char             *clip_type,
+                     GskVulkanShaderClip     clip,
                      const graphene_rect_t  *rect,
                      const graphene_point_t *offset,
                      const GdkRGBA          *color)
 {
   GskVulkanColorOp *self;
 
-  self = (GskVulkanColorOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_COLOR_OP_CLASS.parent_class);
+  self = (GskVulkanColorOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_COLOR_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   graphene_rect_offset_r (rect, offset->x, offset->y, &self->rect);
   self->color = *color;
 }
index 904141b61220e1b2d5c8563f058bf150f04bb791..4b6e3442ff4c59edf9bdf21cd9404e4a21351c4b 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_color_op                             (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          const graphene_rect_t          *rect,
                                                                          const graphene_point_t         *offset,
                                                                          const GdkRGBA                  *color);
index e563f57dba69717dbfeee5e35dd45886b5ff8f03..4a7df63b5fd1e1005cfebbe68034021e252d1da8 100644 (file)
@@ -95,7 +95,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_CROSS_FADE_OP_CLASS = {
 
 void
 gsk_vulkan_cross_fade_op (GskVulkanRender        *render,
-                          const char             *clip_type,
+                          GskVulkanShaderClip     clip,
                           const graphene_rect_t  *bounds,
                           const graphene_point_t *offset,
                           float                   progress,
@@ -108,9 +108,8 @@ gsk_vulkan_cross_fade_op (GskVulkanRender        *render,
 {
   GskVulkanCrossFadeOp *self;
 
-  self = (GskVulkanCrossFadeOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_CROSS_FADE_OP_CLASS.parent_class);
+  self = (GskVulkanCrossFadeOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_CROSS_FADE_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   graphene_rect_offset_r (bounds, offset->x, offset->y, &self->bounds);
   self->progress = progress;
 
index ec7e1d92603a58f1383aab1d11b340620af20f4f..92f2a78f8a26664aee40038a47e615f88c58789d 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_cross_fade_op                        (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          const graphene_rect_t          *bounds,
                                                                          const graphene_point_t         *offset,
                                                                          float                           progress,
index 2794491933b365f0c56d53d9412f241589c0f3b3..1edc4d1dbfff8cc7881618985afee9c7a69cbde3 100644 (file)
@@ -82,7 +82,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_GLYPH_OP_CLASS = {
 
 void
 gsk_vulkan_glyph_op (GskVulkanRender        *render,
-                     const char             *clip_type,
+                     GskVulkanShaderClip     clip,
                      GskVulkanImage         *image,
                      const graphene_rect_t  *rect,
                      const graphene_point_t *offset,
@@ -91,9 +91,8 @@ gsk_vulkan_glyph_op (GskVulkanRender        *render,
 {
   GskVulkanGlyphOp *self;
 
-  self = (GskVulkanGlyphOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_GLYPH_OP_CLASS.parent_class);
+  self = (GskVulkanGlyphOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_GLYPH_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   self->image = g_object_ref (image);
   graphene_rect_offset_r (rect, offset->x, offset->y, &self->rect);
   gsk_vulkan_normalize_tex_coords (&self->tex_rect, rect, tex_rect);
index 74f38832e6a17f9df618d8a076e0884fac9d3dde..3c40cdbaa3cad69adc415617e7a4432f4834dd3a 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_glyph_op                             (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          GskVulkanImage                 *image,
                                                                          const graphene_rect_t          *rect,
                                                                          const graphene_point_t         *offset,
index 6f8481a61205ff43760290ba93677734c8ce70fd..95ce8d894e515d696edf323eb73028e98d482850 100644 (file)
@@ -78,7 +78,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_INSET_SHADOW_OP_CLASS = {
 
 void
 gsk_vulkan_inset_shadow_op (GskVulkanRender         *render,
-                            const char              *clip_type,
+                            GskVulkanShaderClip      clip,
                             const GskRoundedRect    *outline,
                             const graphene_point_t  *offset,
                             const GdkRGBA           *color,
@@ -88,9 +88,8 @@ gsk_vulkan_inset_shadow_op (GskVulkanRender         *render,
 {
   GskVulkanInsetShadowOp *self;
 
-  self = (GskVulkanInsetShadowOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_INSET_SHADOW_OP_CLASS.parent_class);
+  self = (GskVulkanInsetShadowOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_INSET_SHADOW_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   self->outline = *outline;
   gsk_rounded_rect_offset (&self->outline, offset->x, offset->y);
   self->color = *color;
index eef7a16cca1128df1b2924fbf602b4ed02de0043..664e0e667a9b7b13d4e025147b4098d09a537934 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_inset_shadow_op                      (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          const GskRoundedRect           *outline,
                                                                          const graphene_point_t         *offset,
                                                                          const GdkRGBA                  *color,
index 2d9a1cfd57c6b93322bbad92b7a7db0a59b75386..61afebf0e0f19e36d5cd679e95b472dd2bdfffa3 100644 (file)
@@ -90,7 +90,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_LINEAR_GRADIENT_OP_CLASS = {
 
 void
 gsk_vulkan_linear_gradient_op (GskVulkanRender        *render,
-                               const char             *clip_type,
+                               GskVulkanShaderClip     clip,
                                const graphene_rect_t  *rect,
                                const graphene_point_t *offset,
                                const graphene_point_t *start,
@@ -101,9 +101,8 @@ gsk_vulkan_linear_gradient_op (GskVulkanRender        *render,
 {
   GskVulkanLinearGradientOp *self;
 
-  self = (GskVulkanLinearGradientOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_LINEAR_GRADIENT_OP_CLASS.parent_class);
+  self = (GskVulkanLinearGradientOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_LINEAR_GRADIENT_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   graphene_rect_offset_r (rect, offset->x, offset->y, &self->rect);
   self->start = GRAPHENE_POINT_INIT (start->x + offset->x, start->y + offset->y);
   self->end = GRAPHENE_POINT_INIT (end->x + offset->x, end->y + offset->y);
index ce26f4cf85932fe9abcf418d958ac6d1a677b46f..6cc3c821d1584c7f9c863bf31f53337dc04d76c9 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_linear_gradient_op                   (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          const graphene_rect_t          *rect,
                                                                          const graphene_point_t         *offset,
                                                                          const graphene_point_t         *start,
index b422ea01c2a1b5de21574441dce8ed77336140f2..7b6f9772402eedb224484892d803234f2b05df15 100644 (file)
@@ -106,7 +106,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_COLOR_MASK_OP_CLASS = {
 
 void
 gsk_vulkan_mask_op (GskVulkanRender        *render,
-                    const char             *clip_type,
+                    GskVulkanShaderClip     clip,
                     const graphene_point_t *offset,
                     GskVulkanImage         *source,
                     const graphene_rect_t  *source_rect,
@@ -118,9 +118,8 @@ gsk_vulkan_mask_op (GskVulkanRender        *render,
 {
   GskVulkanMaskOp *self;
 
-  self = (GskVulkanMaskOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_COLOR_MASK_OP_CLASS.parent_class);
+  self = (GskVulkanMaskOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_COLOR_MASK_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   self->source.image = g_object_ref (source);
   graphene_rect_offset_r (source_rect, offset->x, offset->y, &self->source.rect);
   gsk_vulkan_normalize_tex_coords (&self->source.tex_rect, source_rect, source_tex_rect);
index 520b3c2daaaa13a64d1913a14acc264d694b1779..268bc4756476effb03cf50e49815efb3de8e2a4a 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_mask_op                              (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          const graphene_point_t         *offset,
                                                                          GskVulkanImage                 *source,
                                                                          const graphene_rect_t          *source_rect,
index 0358ce3d4dfb0925d346e0fa298da867624782a1..dcfd4281991d9f80736f4057d156686f412bf0a4 100644 (file)
@@ -78,7 +78,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_OUTSET_SHADOW_OP_CLASS = {
 
 void
 gsk_vulkan_outset_shadow_op (GskVulkanRender         *render,
-                             const char              *clip_type,
+                             GskVulkanShaderClip      clip,
                              const GskRoundedRect    *outline,
                              const graphene_point_t  *offset,
                              const GdkRGBA           *color,
@@ -88,9 +88,8 @@ gsk_vulkan_outset_shadow_op (GskVulkanRender         *render,
 {
   GskVulkanOutsetShadowOp *self;
 
-  self = (GskVulkanOutsetShadowOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_OUTSET_SHADOW_OP_CLASS.parent_class);
+  self = (GskVulkanOutsetShadowOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_OUTSET_SHADOW_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   self->outline = *outline;
   gsk_rounded_rect_offset (&self->outline, offset->x, offset->y);
   self->color = *color;
index 4ff2b6c51b568715d60cd637bda9c8acf7ecaea5..b60069c31b9aae8ace22c3ed1a0ac3915b6c6f8d 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_outset_shadow_op                     (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          const GskRoundedRect           *outline,
                                                                          const graphene_point_t         *offset,
                                                                          const GdkRGBA                  *color,
index 0ef3c98d7d4de227b64f1e740b8411f91a8bfdb1..4f57fdedf2a78be89c039db36d61a6a0864f0e57 100644 (file)
@@ -87,7 +87,7 @@ typedef struct _RenderPassCacheKey RenderPassCacheKey;
 struct _PipelineCacheKey
 {
   const GskVulkanOpClass *op_class;
-  const /* interned */ char *clip_type;
+  GskVulkanShaderClip clip;
   VkFormat format;
 };
 
@@ -104,8 +104,8 @@ pipeline_cache_key_hash (gconstpointer data)
   const PipelineCacheKey *key = data;
 
   return GPOINTER_TO_UINT (key->op_class) ^
-         GPOINTER_TO_UINT (key->clip_type) ^
-         key->format;
+         key->clip ^
+         (key->format << 2);
 }
 
 static gboolean
@@ -116,7 +116,7 @@ pipeline_cache_key_equal (gconstpointer a,
   const PipelineCacheKey *keyb = b;
 
   return keya->op_class == keyb->op_class &&
-         keya->clip_type == keyb->clip_type &&
+         keya->clip == keyb->clip &&
          keya->format == keyb->format;
 }
 
@@ -522,10 +522,11 @@ gsk_vulkan_render_get_pipeline_layout (GskVulkanRender *self)
 VkPipeline
 gsk_vulkan_render_get_pipeline (GskVulkanRender        *self,
                                 const GskVulkanOpClass *op_class,
-                                const char             *clip_type,
+                                GskVulkanShaderClip     clip,
                                 VkRenderPass            render_pass)
 {
   const GskVulkanShaderOpClass *shader_op_class = (const GskVulkanShaderOpClass *) op_class;
+  static const char *clip_names[] = { "", "-clip", "-clip-rounded" };
   PipelineCacheKey cache_key;
   VkPipeline pipeline;
   GdkDisplay *display;
@@ -533,7 +534,7 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender        *self,
 
   cache_key = (PipelineCacheKey) {
     .op_class = op_class,
-    .clip_type = clip_type,
+    .clip = clip,
     .format = gsk_vulkan_image_get_vk_format (self->target)
   };
   pipeline = g_hash_table_lookup (self->pipeline_cache, &cache_key);
@@ -541,8 +542,8 @@ gsk_vulkan_render_get_pipeline (GskVulkanRender        *self,
     return pipeline;
 
   display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (self->vulkan));
-  vertex_shader_name = g_strconcat ("/org/gtk/libgsk/vulkan/", shader_op_class->shader_name, clip_type, ".vert.spv", NULL);
-  fragment_shader_name = g_strconcat ("/org/gtk/libgsk/vulkan/", shader_op_class->shader_name, clip_type, ".frag.spv", NULL);
+  vertex_shader_name = g_strconcat ("/org/gtk/libgsk/vulkan/", shader_op_class->shader_name, clip_names[clip], ".vert.spv", NULL);
+  fragment_shader_name = g_strconcat ("/org/gtk/libgsk/vulkan/", shader_op_class->shader_name, clip_names[clip], ".frag.spv", NULL);
 
   GSK_VK_CHECK (vkCreateGraphicsPipelines, gdk_vulkan_context_get_device (self->vulkan),
                                            gdk_vulkan_context_get_pipeline_cache (self->vulkan),
index 1c951a604e3a6cc590f3966c88dbef5613f363bf..59f338568d1ef70d0bb1c84b2beda5f0bf71be5e 100644 (file)
@@ -275,7 +275,7 @@ gsk_vulkan_render_pass_add_fallback_node (GskVulkanRenderPass       *self,
                                       &clipped);
 
   gsk_vulkan_texture_op (render,
-                         gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                         gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                          image,
                          GSK_VULKAN_SAMPLER_DEFAULT,
                          &node->bounds,
@@ -351,13 +351,13 @@ gsk_vulkan_render_pass_add_color_node (GskVulkanRenderPass       *self,
       if (state->clip.type == GSK_VULKAN_CLIP_ROUNDED)
         {
           graphene_rect_t cover;
-          const char *clip_type;
+          GskVulkanShaderClip shader_clip;
           float scale_x = graphene_vec2_get_x (&state->scale);
           float scale_y = graphene_vec2_get_y (&state->scale);
           clipped = GRAPHENE_RECT_INIT (int_clipped.x / scale_x, int_clipped.y / scale_y,
                                         int_clipped.width / scale_x, int_clipped.height / scale_y);
-          clip_type = gsk_vulkan_clip_get_clip_type (&state->clip, graphene_point_zero(), &clipped);
-          if (clip_type[0] != '\0')
+          shader_clip = gsk_vulkan_clip_get_shader_clip (&state->clip, graphene_point_zero(), &clipped);
+          if (shader_clip != GSK_VULKAN_SHADER_CLIP_NONE)
             {
               gsk_rounded_rect_get_largest_cover (&state->clip.rect, &clipped, &cover);
               int_clipped.x = ceil (cover.origin.x * scale_x);
@@ -367,7 +367,7 @@ gsk_vulkan_render_pass_add_color_node (GskVulkanRenderPass       *self,
               if (int_clipped.width == 0 || int_clipped.height == 0)
                 {
                   gsk_vulkan_color_op (render,
-                                       clip_type,
+                                       shader_clip,
                                        &clipped,
                                        graphene_point_zero (),
                                        color);
@@ -377,19 +377,19 @@ gsk_vulkan_render_pass_add_color_node (GskVulkanRenderPass       *self,
                                           int_clipped.width / scale_x, int_clipped.height / scale_y);
               if (clipped.origin.x != cover.origin.x)
                 gsk_vulkan_color_op (render,
-                                     clip_type,
+                                     shader_clip,
                                      &GRAPHENE_RECT_INIT (clipped.origin.x, clipped.origin.y, cover.origin.x - clipped.origin.x, clipped.size.height),
                                      graphene_point_zero (),
                                      color);
               if (clipped.origin.y != cover.origin.y)
                 gsk_vulkan_color_op (render,
-                                     clip_type,
+                                     shader_clip,
                                      &GRAPHENE_RECT_INIT (clipped.origin.x, clipped.origin.y, clipped.size.width, cover.origin.y - clipped.origin.y),
                                      graphene_point_zero (),
                                      color);
               if (clipped.origin.x + clipped.size.width != cover.origin.x + cover.size.width)
                 gsk_vulkan_color_op (render,
-                                     clip_type,
+                                     shader_clip,
                                      &GRAPHENE_RECT_INIT (cover.origin.x + cover.size.width,
                                                           clipped.origin.y,
                                                           clipped.origin.x + clipped.size.width - cover.origin.x - cover.size.width,
@@ -398,7 +398,7 @@ gsk_vulkan_render_pass_add_color_node (GskVulkanRenderPass       *self,
                                      color);
               if (clipped.origin.y + clipped.size.height != cover.origin.y + cover.size.height)
                 gsk_vulkan_color_op (render,
-                                     clip_type,
+                                     shader_clip,
                                      &GRAPHENE_RECT_INIT (clipped.origin.x,
                                                           cover.origin.y + cover.size.height,
                                                           clipped.size.width,
@@ -415,7 +415,7 @@ gsk_vulkan_render_pass_add_color_node (GskVulkanRenderPass       *self,
     }
 
   gsk_vulkan_color_op (render,
-                       gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                       gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                        &rect,
                        graphene_point_zero (),
                        color);
@@ -430,7 +430,7 @@ gsk_vulkan_render_pass_add_linear_gradient_node (GskVulkanRenderPass       *self
                                                  GskRenderNode             *node)
 {
   gsk_vulkan_linear_gradient_op (render,
-                                 gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                                 gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                                  &node->bounds,
                                  &state->offset,
                                  gsk_linear_gradient_node_get_start (node),
@@ -448,7 +448,7 @@ gsk_vulkan_render_pass_add_border_node (GskVulkanRenderPass       *self,
                                         GskRenderNode             *node)
 {
   gsk_vulkan_border_op (render,
-                        gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                        gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                         gsk_border_node_get_outline (node),
                         &state->offset,
                         gsk_border_node_get_widths (node),
@@ -476,7 +476,7 @@ gsk_vulkan_render_pass_add_texture_node (GskVulkanRenderPass       *self,
     }
 
   gsk_vulkan_texture_op (render,
-                         gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                         gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                          image,
                          GSK_VULKAN_SAMPLER_DEFAULT,
                          &node->bounds,
@@ -519,7 +519,7 @@ gsk_vulkan_render_pass_add_texture_scale_node (GskVulkanRenderPass       *self,
     }
 
   gsk_vulkan_texture_op (render,
-                         gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                         gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                          image,
                          sampler,
                          &node->bounds,
@@ -539,7 +539,7 @@ gsk_vulkan_render_pass_add_inset_shadow_node (GskVulkanRenderPass       *self,
     FALLBACK ("Blur support not implemented for inset shadows");
 
   gsk_vulkan_inset_shadow_op (render,
-                              gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                              gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                               gsk_inset_shadow_node_get_outline (node),
                               &state->offset,
                               gsk_inset_shadow_node_get_color (node),
@@ -561,7 +561,7 @@ gsk_vulkan_render_pass_add_outset_shadow_node (GskVulkanRenderPass       *self,
     FALLBACK ("Blur support not implemented for outset shadows");
 
   gsk_vulkan_outset_shadow_op (render,
-                               gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                               gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                                gsk_outset_shadow_node_get_outline (node),
                                &state->offset,
                                gsk_outset_shadow_node_get_color (node),
@@ -745,7 +745,7 @@ gsk_vulkan_render_pass_add_opacity_node (GskVulkanRenderPass       *self,
     return TRUE;
 
   gsk_vulkan_color_matrix_op_opacity (render,
-                                      gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                                      gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                                       image,
                                       &node->bounds,
                                       &state->offset,
@@ -773,7 +773,7 @@ gsk_vulkan_render_pass_add_color_matrix_node (GskVulkanRenderPass       *self,
     return TRUE;
 
   gsk_vulkan_color_matrix_op (render,
-                              gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                              gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                               image,
                               &node->bounds,
                               &state->offset,
@@ -907,7 +907,7 @@ gsk_vulkan_render_pass_add_repeat_node (GskVulkanRenderPass       *self,
                                                gsk_repeat_node_get_child (node));
 
   gsk_vulkan_texture_op (render,
-                         gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                         gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                          image,
                          GSK_VULKAN_SAMPLER_REPEAT,
                          &node->bounds,
@@ -954,7 +954,7 @@ gsk_vulkan_render_pass_add_blend_node (GskVulkanRenderPass       *self,
     }
 
   gsk_vulkan_blend_mode_op (render,
-                            gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                            gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                             &node->bounds,
                             &state->offset,
                             gsk_blend_node_get_blend_mode (node),
@@ -998,7 +998,7 @@ gsk_vulkan_render_pass_add_cross_fade_node (GskVulkanRenderPass       *self,
         return TRUE;
 
       gsk_vulkan_color_matrix_op_opacity (render,
-                                          gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &end_child->bounds),
+                                          gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &end_child->bounds),
                                           end_image,
                                           &node->bounds,
                                           &state->offset,
@@ -1010,7 +1010,7 @@ gsk_vulkan_render_pass_add_cross_fade_node (GskVulkanRenderPass       *self,
   else if (end_image == NULL)
     {
       gsk_vulkan_color_matrix_op_opacity (render,
-                                          gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &start_child->bounds),
+                                          gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &start_child->bounds),
                                           start_image,
                                           &node->bounds,
                                           &state->offset,
@@ -1020,7 +1020,7 @@ gsk_vulkan_render_pass_add_cross_fade_node (GskVulkanRenderPass       *self,
     }
 
   gsk_vulkan_cross_fade_op (render,
-                            gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                            gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                             &node->bounds,
                             &state->offset,
                             progress,
@@ -1083,7 +1083,7 @@ gsk_vulkan_render_pass_add_text_node (GskVulkanRenderPass       *self,
                           glyph->draw_height / glyph->th);
       if (gsk_text_node_has_color_glyphs (node))
         gsk_vulkan_texture_op (render,
-                               gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &glyph_bounds),
+                               gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &glyph_bounds),
                                glyph->atlas_image,
                                GSK_VULKAN_SAMPLER_DEFAULT,
                                &glyph_bounds,
@@ -1091,7 +1091,7 @@ gsk_vulkan_render_pass_add_text_node (GskVulkanRenderPass       *self,
                                &glyph_tex_rect);
       else
         gsk_vulkan_glyph_op (render,
-                             gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &glyph_bounds),
+                             gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &glyph_bounds),
                              glyph->atlas_image,
                              &glyph_bounds,
                              &state->offset,
@@ -1130,7 +1130,7 @@ gsk_vulkan_render_pass_add_blur_node (GskVulkanRenderPass       *self,
     return TRUE;
 
   gsk_vulkan_blur_op (render,
-                      gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                      gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                       image,
                       &node->bounds,
                       &state->offset,
@@ -1174,7 +1174,7 @@ gsk_vulkan_render_pass_add_mask_node (GskVulkanRenderPass       *self,
       graphene_rect_t bounds;
       if (graphene_rect_intersection (&source->bounds, &mask->bounds, &bounds))
         gsk_vulkan_glyph_op (render,
-                             gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &bounds),
+                             gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &bounds),
                              mask_image,
                              &bounds,
                              &state->offset,
@@ -1192,7 +1192,7 @@ gsk_vulkan_render_pass_add_mask_node (GskVulkanRenderPass       *self,
     return TRUE;
 
   gsk_vulkan_mask_op (render,
-                      gsk_vulkan_clip_get_clip_type (&state->clip, &state->offset, &node->bounds),
+                      gsk_vulkan_clip_get_shader_clip (&state->clip, &state->offset, &node->bounds),
                       &state->offset,
                       source_image,
                       &source->bounds,
index 8342231e0df1950690a3eeb26356df09005eaa2e..84a2939361d7ff8cde721d464264b670c97af520 100644 (file)
@@ -3,6 +3,7 @@
 #include <gdk/gdk.h>
 #include <gsk/gskrendernode.h>
 
+#include "gskvulkanclipprivate.h"
 #include "gskvulkanimageprivate.h"
 #include "gskvulkanprivate.h"
 #include "gskvulkanrenderpassprivate.h"
@@ -44,7 +45,7 @@ gpointer                gsk_vulkan_render_alloc_op                      (GskVulk
 VkPipelineLayout        gsk_vulkan_render_get_pipeline_layout           (GskVulkanRender        *self);
 VkPipeline              gsk_vulkan_render_get_pipeline                  (GskVulkanRender        *self,
                                                                          const GskVulkanOpClass *op_class,
-                                                                         const char             *clip_type,
+                                                                         GskVulkanShaderClip     clip,
                                                                          VkRenderPass            render_pass);
 VkRenderPass            gsk_vulkan_render_get_render_pass               (GskVulkanRender        *self,
                                                                          VkFormat                format,
index 141271eccaf24fd44f88946d5548f2e067c2024f..3364a387a00c698d410d0f46a2257ce1c8c6d5b8 100644 (file)
@@ -52,7 +52,7 @@ gsk_vulkan_shader_op_command_n (GskVulkanOp      *op,
                      VK_PIPELINE_BIND_POINT_GRAPHICS,
                      gsk_vulkan_render_get_pipeline (render,
                                                      op->op_class,
-                                                     self->clip_type,
+                                                     self->clip,
                                                      render_pass));
 
   vkCmdDraw (command_buffer,
@@ -71,3 +71,16 @@ gsk_vulkan_shader_op_command (GskVulkanOp      *op,
   return gsk_vulkan_shader_op_command_n (op, render, render_pass, command_buffer, 1);
 }
 
+GskVulkanShaderOp *
+gsk_vulkan_shader_op_alloc (GskVulkanRender              *render,
+                            const GskVulkanShaderOpClass *op_class,
+                            GskVulkanShaderClip           clip)
+{
+  GskVulkanShaderOp *self;
+
+  self = (GskVulkanShaderOp *) gsk_vulkan_op_alloc (render, &op_class->parent_class);
+
+  self->clip = clip;
+
+  return self;
+}
index e9f29bb90c6819e5f9bdd952ef5196a811397da1..77f111981bc13614fc695d415c2e58668d5b78d3 100644 (file)
@@ -2,6 +2,8 @@
 
 #include "gskvulkanopprivate.h"
 
+#include "gskvulkanclipprivate.h"
+
 G_BEGIN_DECLS
 
 typedef struct _GskVulkanShaderOp GskVulkanShaderOp;
@@ -11,7 +13,7 @@ struct _GskVulkanShaderOp
 {
   GskVulkanOp parent_op;
 
-  const /* interned */ char *clip_type;
+  GskVulkanShaderClip clip;
   gsize vertex_offset;
 };
 
@@ -23,6 +25,10 @@ struct _GskVulkanShaderOpClass
   const VkPipelineVertexInputStateCreateInfo *vertex_input_state;
 };
 
+GskVulkanShaderOp *     gsk_vulkan_shader_op_alloc                      (GskVulkanRender        *render,
+                                                                         const GskVulkanShaderOpClass *op_class,
+                                                                         GskVulkanShaderClip     clip);
+
 gsize                   gsk_vulkan_shader_op_count_vertex_data          (GskVulkanOp            *op,
                                                                          gsize                   n_bytes);
 GskVulkanOp *           gsk_vulkan_shader_op_command_n                  (GskVulkanOp            *op,
index d0df51d4209fed42fe51f7ff20e307c635f07565..806ca8dbfaee08a0e50507b9f3b2213af11a3fc1 100644 (file)
@@ -87,7 +87,7 @@ static const GskVulkanShaderOpClass GSK_VULKAN_TEXTURE_OP_CLASS = {
 
 void
 gsk_vulkan_texture_op (GskVulkanRender        *render,
-                       const char             *clip_type,
+                       GskVulkanShaderClip     clip,
                        GskVulkanImage         *image,
                        GskVulkanRenderSampler  sampler,
                        const graphene_rect_t  *rect,
@@ -96,9 +96,8 @@ gsk_vulkan_texture_op (GskVulkanRender        *render,
 {
   GskVulkanTextureOp *self;
 
-  self = (GskVulkanTextureOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_TEXTURE_OP_CLASS.parent_class);
+  self = (GskVulkanTextureOp *) gsk_vulkan_shader_op_alloc (render, &GSK_VULKAN_TEXTURE_OP_CLASS, clip);
 
-  ((GskVulkanShaderOp *) self)->clip_type = g_intern_string (clip_type);
   self->image = g_object_ref (image);
   self->sampler = sampler;
   graphene_rect_offset_r (rect, offset->x, offset->y, &self->rect);
index f67795cfb0f645998bedac4433009cb95de6eb4a..480943616c4a910bff1336be8f38e70c1f681266 100644 (file)
@@ -5,7 +5,7 @@
 G_BEGIN_DECLS
 
 void                    gsk_vulkan_texture_op                           (GskVulkanRender                *render,
-                                                                         const char                     *clip_type,
+                                                                         GskVulkanShaderClip             clip,
                                                                          GskVulkanImage                 *image,
                                                                          GskVulkanRenderSampler          sampler,
                                                                          const graphene_rect_t          *rect,