[gegl/wip/Jehan/fix-ctx-on-win32] gegl: update ctx library.




commit a85e87c7f982534252a2388f82e4bbaeccad6ddc
Author: Jehan <jehan girinstud io>
Date:   Sun Jul 4 23:31:00 2021 +0200

    gegl: update ctx library.
    
    Cf. my latest commits on ctx:
    - ctx: do not use PATH_MAX.
    - src: improve conditional code contents.
    - Better macro defaults for Windows.
    
    This fixes the GEGL build on Windows, which broke since ctx got
    introduced. With these changes, ctx still works fine in GEGL (tested
    both on Linux and Windows builds), i.e. in particular gegl:fill-path
    operation still works fine.

 gegl/ctx/ctx.c |  9 ++++++++-
 gegl/ctx/ctx.h | 46 +++++++++++++++++++++++++++-------------------
 2 files changed, 35 insertions(+), 20 deletions(-)
---
diff --git a/gegl/ctx/ctx.c b/gegl/ctx/ctx.c
index e9debe8b8..fa297c405 100644
--- a/gegl/ctx/ctx.c
+++ b/gegl/ctx/ctx.c
@@ -1,12 +1,15 @@
 #include <stdint.h>
-#include <termios.h>
 #include <unistd.h>
 
 #include <babl/babl.h>
 
 #define CTX_PARSER               1
 #define CTX_FORMATTER            1
+#ifdef _WIN32
+#define CTX_EVENTS               0
+#else
 #define CTX_EVENTS               1
+#endif
 #define CTX_BITPACK_PACKER       0 // turned of due to asan report
 #define CTX_GRADIENT_CACHE       1
 #define CTX_ENABLE_CMYK          1
@@ -17,7 +20,11 @@
                                        // variable size for each save|restore
 #define CTX_SHAPE_CACHE          0 // when used per gegl op perhsp
                                   // useful when rendering lots of text initially?
+#ifdef _WIN32
+#define CTX_IMPLEMENTATION 0
+#else
 #define CTX_IMPLEMENTATION 1
+#endif
 #define CTX_RASTERIZER     1
 
 #include "ctx.h"
diff --git a/gegl/ctx/ctx.h b/gegl/ctx/ctx.h
index 708065a39..385419d2e 100644
--- a/gegl/ctx/ctx.h
+++ b/gegl/ctx/ctx.h
@@ -5367,8 +5367,10 @@ static inline char *ctx_strstr (const char *h, const char *n)
 #include <stdio.h>
 #include <unistd.h>
 #include <math.h>
+#if CTX_EVENTS
 #include <sys/select.h> 
 #endif
+#endif
 
 #define CTX_BRANCH_HINTS  1
 
@@ -6754,8 +6756,8 @@ int    ctx_pcm_queue             (Ctx *ctx, const int8_t *data, int frames);
 #include <pthread.h>
 #if CTX_ALSA_AUDIO
 #include <alsa/asoundlib.h>
-#endif
 #include <alloca.h>
+#endif
 
 #endif
 
@@ -21804,6 +21806,13 @@ int ctx_renderer_is_ctx (Ctx *ctx)
   return 0;
 }
 
+#else
+
+int ctx_renderer_is_ctx (Ctx *ctx)
+{
+  return 0;
+}
+
 #endif
 
 #if CTX_TILED
@@ -28243,20 +28252,20 @@ ctx_string_append_callback (void *contents, size_t size, size_t nmemb, void *use
 
 #endif
 
+#endif /* CTX_EVENTS */
+
 int
 ctx_get_contents (const char     *uri,
                   unsigned char **contents,
                   long           *length)
 {
-  char temp_uri[PATH_MAX]; // XXX XXX breaks with data uri's
+  char *temp_uri = NULL; // XXX XXX breaks with data uri's
+  int   success  = -1;
+
   if (uri[0] == '/')
   {
-    snprintf (temp_uri, sizeof (temp_uri)-1, "file://%s", uri);
-    uri = temp_uri;
-  }
-  else
-  {
-    snprintf (temp_uri, sizeof (temp_uri)-1, uri);
+    temp_uri = (char*) malloc (strlen (uri) + 8);
+    sprintf (temp_uri, "file://%s", uri);
     uri = temp_uri;
   }
 
@@ -28271,6 +28280,7 @@ ctx_get_contents (const char     *uri,
       contents = malloc (c->length+1);
       contents[c->length]=0;
       if (length) *length = c->length;
+      free (temp_uri);
       return 0;
     }
   }
@@ -28282,7 +28292,7 @@ ctx_get_contents (const char     *uri,
   }
 
   if (!strncmp (uri, "file://", 7))
-    return __ctx_file_get_contents (uri + 7, contents, length);
+    success = __ctx_file_get_contents (uri + 7, contents, length);
   else
   {
 #ifndef NO_LIBCURL
@@ -28312,18 +28322,16 @@ ctx_get_contents (const char     *uri,
      *length = string->length;
      ctx_string_free (string, 0);
      curl_easy_cleanup (curl);
-     return 0;
+     success = 0;
   }
 #else
-    return __ctx_file_get_contents (uri, contents, length);
+    success = __ctx_file_get_contents (uri, contents, length);
 #endif
   }
-  return -1;
+  free (temp_uri);
+  return success;
 }
 
-
-#endif
-
 #endif // CTX_IMPLEMENTATION
 
 #if CTX_COMPOSITE
@@ -32058,14 +32066,14 @@ ctx_float_porter_duff(RGBAF, 4,image,           ctx_fragment_image_RGBAF,
 
 #if CTX_GRADIENTS
 #define ctx_float_porter_duff_blend(comp_name, components, blend_mode, blend_name)\
-ctx_float_porter_duff(comp_name, components,color_##blend_name,            NULL,                             
  blend_mode)\
+ctx_float_porter_duff(comp_name, components,color_##blend_name,            rasterizer->fragment,             
                  blend_mode)\
 ctx_float_porter_duff(comp_name, components,generic_##blend_name,          rasterizer->fragment,             
  blend_mode)\
 ctx_float_porter_duff(comp_name, components,linear_gradient_##blend_name,  
ctx_fragment_linear_gradient_RGBA8, blend_mode)\
 ctx_float_porter_duff(comp_name, components,radial_gradient_##blend_name,  
ctx_fragment_radial_gradient_RGBA8, blend_mode)\
 ctx_float_porter_duff(comp_name, components,image_##blend_name,            ctx_fragment_image_RGBAF,         
  blend_mode)
 #else
 #define ctx_float_porter_duff_blend(comp_name, components, blend_mode, blend_name)\
-ctx_float_porter_duff(comp_name, components,color_##blend_name,            NULL,                             
  blend_mode)\
+ctx_float_porter_duff(comp_name, components,color_##blend_name,            rasterizer->fragment,             
                  blend_mode)\
 ctx_float_porter_duff(comp_name, components,generic_##blend_name,          rasterizer->fragment,             
  blend_mode)\
 ctx_float_porter_duff(comp_name, components,image_##blend_name,            ctx_fragment_image_RGBAF,         
  blend_mode)
 #endif
@@ -33198,12 +33206,12 @@ static CtxFragment ctx_rasterizer_get_fragment_GRAYA8 (CtxRasterizer *rasterizer
   return ctx_fragment_color_GRAYA8;
 }
 
-ctx_u8_porter_duff(GRAYA8, 2,color,   NULL,                 rasterizer->state->gstate.blend_mode)
+ctx_u8_porter_duff(GRAYA8, 2,color,   rasterizer->fragment, rasterizer->state->gstate.blend_mode)
 ctx_u8_porter_duff(GRAYA8, 2,generic, rasterizer->fragment, rasterizer->state->gstate.blend_mode)
 
 #if CTX_INLINED_NORMAL
 
-ctx_u8_porter_duff(GRAYA8, 2,color_normal,   NULL,                 CTX_BLEND_NORMAL)
+ctx_u8_porter_duff(GRAYA8, 2,color_normal,   rasterizer->fragment, CTX_BLEND_NORMAL)
 ctx_u8_porter_duff(GRAYA8, 2,generic_normal, rasterizer->fragment, CTX_BLEND_NORMAL)
 
 static void


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