summaryrefslogtreecommitdiffstats
path: root/external/cairo/pixman
diff options
context:
space:
mode:
Diffstat (limited to 'external/cairo/pixman')
-rw-r--r--external/cairo/pixman/pixman-0.24.4.patch91
-rw-r--r--external/cairo/pixman/pixman-ubsan.patch85
-rw-r--r--external/cairo/pixman/pixman-wasm.patch108
3 files changed, 284 insertions, 0 deletions
diff --git a/external/cairo/pixman/pixman-0.24.4.patch b/external/cairo/pixman/pixman-0.24.4.patch
new file mode 100644
index 0000000000..a5d32f88f8
--- /dev/null
+++ b/external/cairo/pixman/pixman-0.24.4.patch
@@ -0,0 +1,91 @@
+--- misc/pixman-0.24.4/Makefile.in 2011-11-06 22:11:25.000000000 +0100
++++ misc/build/pixman-0.24.4/Makefile.in 2011-12-16 09:06:45.317211035 +0100
+@@ -385,7 +385,7 @@
+ top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+-SUBDIRS = pixman demos test
++SUBDIRS = pixman
+ pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = pixman-1.pc
+ GPGKEY = 3892336E
+--- misc/pixman-0.24.4/pixman/pixman-utils.c
++++ misc/build/pixman-0.24.4/pixman/pixman-utils.c
+@@ -27,6 +27,7 @@
+ #endif
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <limits.h>
+
+ #include "pixman-private.h"
+
+--- misc/pixman-0.24.4/pixman/pixman-glyph.c 2015-06-30 05:48:31.000000000 -0400
++++ misc/build/pixman-0.24.4/pixman/pixman-glyph.c 2017-11-25 13:26:33.075558418 -0500
+@@ -38,6 +38,7 @@
+
+ /* XXX: These numbers are arbitrary---we've never done any measurements.
+ */
++#define N_PIXELS_HIGH_WATER (4 * 1024 * 1024)
+ #define N_GLYPHS_HIGH_WATER (16384)
+ #define N_GLYPHS_LOW_WATER (8192)
+ #define HASH_SIZE (2 * N_GLYPHS_HIGH_WATER)
+@@ -58,6 +59,7 @@
+ int n_glyphs;
+ int n_tombstones;
+ int freeze_count;
++ long n_pixels;
+ pixman_list_t mru;
+ glyph_t * glyphs[HASH_SIZE];
+ };
+@@ -133,6 +135,7 @@
+ if (*loc == TOMBSTONE)
+ cache->n_tombstones--;
+ cache->n_glyphs++;
++ cache->n_pixels += glyph->image->bits.width * glyph->image->bits.height;
+
+ *loc = glyph;
+ }
+@@ -150,6 +153,7 @@
+ cache->glyphs[idx & HASH_MASK] = TOMBSTONE;
+ cache->n_tombstones++;
+ cache->n_glyphs--;
++ cache->n_pixels -= glyph->image->bits.width * glyph->image->bits.height;
+
+ /* Eliminate tombstones if possible */
+ if (cache->glyphs[(idx + 1) & HASH_MASK] == NULL)
+@@ -180,6 +184,7 @@
+
+ cache->n_glyphs = 0;
+ cache->n_tombstones = 0;
++ cache->n_pixels = 0;
+ }
+
+ PIXMAN_EXPORT pixman_glyph_cache_t *
+@@ -194,6 +199,7 @@
+ cache->n_glyphs = 0;
+ cache->n_tombstones = 0;
+ cache->freeze_count = 0;
++ cache->n_pixels = 0;
+
+ pixman_list_init (&cache->mru);
+
+@@ -220,9 +226,9 @@
+ pixman_glyph_cache_thaw (pixman_glyph_cache_t *cache)
+ {
+ if (--cache->freeze_count == 0 &&
+- cache->n_glyphs + cache->n_tombstones > N_GLYPHS_HIGH_WATER)
++ (cache->n_glyphs + cache->n_tombstones > N_GLYPHS_HIGH_WATER || cache->n_pixels > N_PIXELS_HIGH_WATER))
+ {
+- if (cache->n_tombstones > N_GLYPHS_HIGH_WATER)
++ if (cache->n_tombstones > N_GLYPHS_LOW_WATER)
+ {
+ /* More than half the entries are
+ * tombstones. Just dump the whole table.
+@@ -230,7 +236,7 @@
+ clear_table (cache);
+ }
+
+- while (cache->n_glyphs > N_GLYPHS_LOW_WATER)
++ while (cache->n_glyphs > N_GLYPHS_LOW_WATER || cache->n_pixels > N_PIXELS_HIGH_WATER)
+ {
+ glyph_t *glyph = CONTAINER_OF (glyph_t, mru_link, cache->mru.tail);
diff --git a/external/cairo/pixman/pixman-ubsan.patch b/external/cairo/pixman/pixman-ubsan.patch
new file mode 100644
index 0000000000..b4b1d43adb
--- /dev/null
+++ b/external/cairo/pixman/pixman-ubsan.patch
@@ -0,0 +1,85 @@
+diff -ru pixman-0.42.2.orig/pixman/pixman-bits-image.c pixman-0.42.2/pixman/pixman-bits-image.c
+--- misc/pixman-0.42.2.orig/pixman/pixman-bits-image.c 2022-11-03 02:25:48.000000000 +0900
++++ misc/build/pixman-0.42.2/pixman/pixman-bits-image.c 2022-11-28 21:35:25.896969126 +0900
+@@ -351,8 +351,8 @@
+ * positioned relative to a particular phase (and not relative to whatever
+ * exact fraction we happen to get here).
+ */
+- x = ((x >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1);
+- y = ((y >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1);
++ x = ((uint32_t)(x >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1);
++ y = ((uint32_t)(y >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1);
+
+ px = (x & 0xffff) >> x_phase_shift;
+ py = (y & 0xffff) >> y_phase_shift;
+diff -ru pixman-0.42.2.orig/pixman/pixman-combine32.c pixman-0.42.2/pixman/pixman-combine32.c
+--- misc/pixman-0.42.2.orig/pixman/pixman-combine32.c 2022-02-02 05:51:25.000000000 +0900
++++ misc/build/pixman-0.42.2/pixman/pixman-combine32.c 2022-11-28 21:38:48.226968594 +0900
+@@ -589,7 +589,7 @@
+ rg = DIV_ONE_UN8 (rg); \
+ rb = DIV_ONE_UN8 (rb); \
+ \
+- *(dest + i) = ra << 24 | rr << 16 | rg << 8 | rb; \
++ *(dest + i) = (uint32_t)ra << 24 | rr << 16 | rg << 8 | rb; \
+ } \
+ } \
+ \
+diff -ru pixman-0.42.2.orig/pixman/pixman-fast-path.c pixman-0.42.2/pixman/pixman-fast-path.c
+--- misc/pixman-0.42.2.orig/pixman/pixman-fast-path.c 2022-10-18 02:47:42.000000000 +0900
++++ misc/build/pixman-0.42.2/pixman/pixman-fast-path.c 2022-11-28 21:53:12.596963317 +0900
+@@ -2758,8 +2758,8 @@
+ * positioned relative to a particular phase (and not relative to whatever
+ * exact fraction we happen to get here).
+ */
+- x = ((vx >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1);
+- y = ((vy >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1);
++ x = ((uint32_t)(vx >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1);
++ y = ((uint32_t)(vy >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1);
+
+ px = (x & 0xffff) >> x_phase_shift;
+ py = (y & 0xffff) >> y_phase_shift;
+@@ -2837,9 +2837,9 @@
+ sbtot = CLIP (sbtot, 0, 0xff);
+
+ #ifdef WORDS_BIGENDIAN
+- buffer[k] = (satot << 0) | (srtot << 8) | (sgtot << 16) | (sbtot << 24);
++ buffer[k] = (satot << 0) | (srtot << 8) | (sgtot << 16) | ((uint32_t)sbtot << 24);
+ #else
+- buffer[k] = (satot << 24) | (srtot << 16) | (sgtot << 8) | (sbtot << 0);
++ buffer[k] = ((uint32_t)satot << 24) | (srtot << 16) | (sgtot << 8) | (sbtot << 0);
+ #endif
+
+ next:
+diff -ru pixman-0.42.2.orig/pixman/pixman-sse2.c pixman-0.42.2/pixman/pixman-sse2.c
+--- misc/pixman-0.42.2/pixman/pixman-sse2.c 2022-02-02 05:51:25.000000000 +0900
++++ misc/build/pixman-0.42.2/pixman/pixman-sse2.c 2022-11-28 22:11:19.276969466 +0900
+@@ -516,7 +516,7 @@
+ }
+
+ static force_inline uint32_t
+-combine1 (const uint32_t *ps, const uint32_t *pm)
++combine1 (const void *ps, const uint32_t *pm)
+ {
+ uint32_t s;
+ memcpy(&s, ps, sizeof(uint32_t));
+@@ -3345,7 +3345,7 @@
+
+ b = filler & 0xff;
+ w = (b << 8) | b;
+- filler = (w << 16) | w;
++ filler = ((uint32_t)w << 16) | w;
+ }
+ else if (bpp == 16)
+ {
+diff -ru pixman-0.42.2.orig/pixman/pixman-utils.c pixman-0.42.2/pixman/pixman-utils.c
+--- misc/pixman-0.42.2.orig/pixman/pixman-utils.c 2022-02-02 05:51:25.000000000 +0900
++++ misc/build/pixman-0.42.2/pixman/pixman-utils.c 2022-11-28 21:55:44.196964912 +0900
+@@ -213,7 +213,7 @@
+ g = float_to_unorm (src[i].g, 8);
+ b = float_to_unorm (src[i].b, 8);
+
+- dst[i] = (a << 24) | (r << 16) | (g << 8) | (b << 0);
++ dst[i] = ((uint32_t)a << 24) | (r << 16) | (g << 8) | (b << 0);
+ }
+ }
+
diff --git a/external/cairo/pixman/pixman-wasm.patch b/external/cairo/pixman/pixman-wasm.patch
new file mode 100644
index 0000000000..a04aa7ccca
--- /dev/null
+++ b/external/cairo/pixman/pixman-wasm.patch
@@ -0,0 +1,108 @@
+--- a/pixman/pixman/pixman-x86.c
++++ b/pixman/pixman/pixman-x86.c
+@@ -77,13 +77,20 @@
+
+ #else
+
+-#define _PIXMAN_X86_64 \
+- (defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64))
++#if (defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64))
++#define _PIXMAN_X86_64 1
++#else
++#define _PIXMAN_X86_64 0
++#endif
+
+ static pixman_bool_t
+ have_cpuid (void)
+ {
+-#if _PIXMAN_X86_64 || defined (_MSC_VER)
++#if defined(__EMSCRIPTEN__)
++
++ return FALSE;
++
++#elif _PIXMAN_X86_64 || defined (_MSC_VER)
+
+ return TRUE;
+
+@@ -109,6 +109,8 @@
+ #endif
+ }
+
++#if !defined(__EMSCRIPTEN__)
++
+ static void
+ pixman_cpuid (uint32_t feature,
+ uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d)
+@@ -156,10 +156,17 @@
+ #error Unknown compiler
+ #endif
+ }
++
++#endif // !__EMSCRIPTEN__
+
+ static cpu_features_t
+ detect_cpu_features (void)
+ {
++#if defined(__EMSCRIPTEN__)
++
++ return X86_MMX | X86_MMX_EXTENSIONS | X86_SSE | X86_SSE2 | X86_SSSE3;
++
++#else
+ uint32_t a, b, c, d;
+ cpu_features_t features = 0;
+
+@@ -202,6 +202,8 @@
+ }
+
+ return features;
++
++#endif // !__EMSCRIPTEN__
+ }
+
+ #endif
+--- a/pixman/pixman/pixman-ssse3.c
++++ b/pixman/pixman/pixman-ssse3.c
+@@ -28,7 +28,9 @@
+ #endif
+
+ #include <stdlib.h>
++#if !defined(__EMSCRIPTEN__)
+ #include <mmintrin.h>
++#endif
+ #include <xmmintrin.h>
+ #include <emmintrin.h>
+ #include <tmmintrin.h>
+--- a/pixman/configure
++++ b/pixman/configure
+@@ -14207,7 +14207,11 @@
+ #if defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
+ #error "Need GCC >= 3.4 for MMX intrinsics"
+ #endif
++#if !defined(__EMSCRIPTEN__)
+ #include <mmintrin.h>
++#else
++#include <xmmintrin.h>
++#endif
+ #include <stdint.h>
+
+ /* Check support for block expressions */
+@@ -14308,7 +14308,9 @@
+ # error "Need GCC >= 4.2 for SSE2 intrinsics on x86"
+ # endif
+ #endif
++#if !defined(__EMSCRIPTEN__)
+ #include <mmintrin.h>
++#endif
+ #include <xmmintrin.h>
+ #include <emmintrin.h>
+ int param;
+@@ -14380,7 +14380,9 @@
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++#if !defined(__EMSCRIPTEN__)
+ #include <mmintrin.h>
++#endif
+ #include <xmmintrin.h>
+ #include <emmintrin.h>
+ #include <tmmintrin.h>