[gegl] vector-fill: handle CMYK colors



commit f167b07229e987c1e7bc888fa87824b03a8f248f
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Jul 1 06:03:54 2021 +0200

    vector-fill: handle CMYK colors
    
    Both RGB and CMYK are now using floating point encodingings, color
    management is still missing.

 gegl/ctx/ctx.h                    |  4 +++-
 operations/external/vector-fill.c | 26 ++++++++++----------------
 2 files changed, 13 insertions(+), 17 deletions(-)
---
diff --git a/gegl/ctx/ctx.h b/gegl/ctx/ctx.h
index 0eb6f3098..4b7fba24a 100644
--- a/gegl/ctx/ctx.h
+++ b/gegl/ctx/ctx.h
@@ -32553,6 +32553,7 @@ ctx_setup_CMYKAF (CtxRasterizer *rasterizer)
   if (gstate->source_fill.type == CTX_SOURCE_COLOR)
     {
       rasterizer->comp_op = ctx_CMYKAF_porter_duff_color;
+      rasterizer->comp_op = ctx_CMYKAF_porter_duff_generic;
  //     rasterizer->fragment = NULL;
       ctx_color_get_cmyka (rasterizer->state, &gstate->source_fill.color, (float*)rasterizer->color);
       if (gstate->global_alpha_u8 != 255)
@@ -32563,10 +32564,10 @@ ctx_setup_CMYKAF (CtxRasterizer *rasterizer)
     rasterizer->comp_op = ctx_CMYKAF_porter_duff_generic;
   }
 
-
 #if CTX_INLINED_NORMAL
   if (gstate->compositing_mode == CTX_COMPOSITE_CLEAR)
     rasterizer->comp_op = ctx_CMYKAF_clear_normal;
+#if 0
   else
     switch (gstate->blend_mode)
     {
@@ -32618,6 +32619,7 @@ ctx_setup_CMYKAF (CtxRasterizer *rasterizer)
         break;
     }
 #endif
+#endif
 }
 
 #endif
diff --git a/operations/external/vector-fill.c b/operations/external/vector-fill.c
index db0b1aea3..76cd3b68b 100644
--- a/operations/external/vector-fill.c
+++ b/operations/external/vector-fill.c
@@ -87,7 +87,7 @@ prepare (GeglOperation *operation)
   }
   else
   {
-    gegl_operation_set_format (operation, "output", babl_format ("R'aG'aB'aA float"));
+    gegl_operation_set_format (operation, "output", babl_format ("RaGaBaA float"));
   }
 
   if (o->transform && o->transform[0] != '\0')
@@ -136,18 +136,8 @@ process (GeglOperation       *operation,
   gboolean need_fill = FALSE;
   const Babl *format =  gegl_operation_get_format (operation, "output");
   gdouble color[5] = {0, 0, 0, 0, 0};
-  const Babl *formats[4] = {NULL, NULL, NULL, NULL};
   int is_cmyk = babl_get_model_flags (format) & BABL_MODEL_FLAG_CMYK ? 1 : 0;
 
-  if (is_cmyk)
-  {
-    formats[0]=babl_format ("camayakaA float");
-  }
-  else
-  {
-    formats[0]=babl_format ("RaGaBaA float");
-  }
-
   if (input)
     {
       gegl_buffer_copy (input, result, GEGL_ABYSS_NONE, output, result);
@@ -161,7 +151,7 @@ process (GeglOperation       *operation,
     {
       if (is_cmyk)
       {
-        gegl_color_get_pixel (o->color, babl_format ("cmykA double"), color);
+        gegl_color_get_pixel (o->color, babl_format ("CMYKA double"), color);
         color[4] *= o->opacity;
         if (color[4] > 0.001)
           need_fill=TRUE;
@@ -181,12 +171,16 @@ process (GeglOperation       *operation,
 
       g_mutex_lock (&mutex);
 
-      for (int i = 0; formats[i]; i++)
       {
         guchar *data = gegl_buffer_linear_open (output, result, NULL,
-                                                formats[i]);
-        Ctx *ctx = ctx_new_for_framebuffer (data, result->width, result->height,
-                                            result->width * 4 * 4, CTX_FORMAT_RGBAF);
+                                                format);
+        Ctx *ctx;
+        if (is_cmyk)
+          ctx = ctx_new_for_framebuffer (data, result->width, result->height,
+                                         result->width * 5 * 4, CTX_FORMAT_CMYKAF);
+        else
+          ctx = ctx_new_for_framebuffer (data, result->width, result->height,
+                                         result->width * 4 * 4, CTX_FORMAT_RGBAF);
 
         ctx_translate (ctx, -result->x, -result->y);
         if (g_str_equal (o->fill_rule, "evenodd"))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]