Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[xsrc/trunk]: xsrc/external/mit/pixman/include merge pixman 0.42.2.
details: https://anonhg.NetBSD.org/xsrc/rev/e93e5269ec25
branches: trunk
changeset: 7252:e93e5269ec25
user: mrg <mrg%NetBSD.org@localhost>
date: Sat Nov 12 03:35:25 2022 +0000
description:
merge pixman 0.42.2.
this reverts a local change to pixman.h as upstream have fixed it
in a different way.
diffstat:
external/mit/pixman/dist/pixman/pixman-arm.c | 31 +
external/mit/pixman/dist/pixman/pixman-bits-image.c | 185 +++++++-
external/mit/pixman/dist/pixman/pixman-inlines.h | 2 +-
external/mit/pixman/dist/pixman/pixman-mmx.c | 14 +-
external/mit/pixman/dist/pixman/pixman-ppc.c | 18 +
external/mit/pixman/dist/pixman/pixman-private.h | 12 +
external/mit/pixman/dist/pixman/pixman-x86.c | 1 +
external/mit/pixman/dist/pixman/pixman.h | 463 ++++++++++++++++---
external/mit/pixman/include/config.h | 6 +-
9 files changed, 618 insertions(+), 114 deletions(-)
diffs (truncated from 1412 to 300 lines):
diff -r ac42e7940cca -r e93e5269ec25 external/mit/pixman/dist/pixman/pixman-arm.c
--- a/external/mit/pixman/dist/pixman/pixman-arm.c Sat Nov 12 03:24:10 2022 +0000
+++ b/external/mit/pixman/dist/pixman/pixman-arm.c Sat Nov 12 03:35:25 2022 +0000
@@ -176,6 +176,31 @@
return features;
}
+#elif defined (_3DS) /* 3DS homebrew (devkitARM) */
+
+static arm_cpu_features_t
+detect_cpu_features (void)
+{
+ arm_cpu_features_t features = 0;
+
+ features |= ARM_V6;
+
+ return features;
+}
+
+#elif defined (PSP2) || defined (__SWITCH__)
+/* Vita (VitaSDK) or Switch (devkitA64) homebrew */
+
+static arm_cpu_features_t
+detect_cpu_features (void)
+{
+ arm_cpu_features_t features = 0;
+
+ features |= ARM_NEON;
+
+ return features;
+}
+
#elif defined (__NetBSD__) /* NetBSD */
#include <sys/sysctl.h>
@@ -254,5 +279,11 @@
imp = _pixman_implementation_create_arm_neon (imp);
#endif
+#ifdef USE_ARM_A64_NEON
+ /* neon is a part of aarch64 */
+ if (!_pixman_disabled ("arm-neon"))
+ imp = _pixman_implementation_create_arm_neon (imp);
+#endif
+
return imp;
}
diff -r ac42e7940cca -r e93e5269ec25 external/mit/pixman/dist/pixman/pixman-bits-image.c
--- a/external/mit/pixman/dist/pixman/pixman-bits-image.c Sat Nov 12 03:24:10 2022 +0000
+++ b/external/mit/pixman/dist/pixman/pixman-bits-image.c Sat Nov 12 03:35:25 2022 +0000
@@ -35,6 +35,7 @@
#include "pixman-private.h"
#include "pixman-combine32.h"
#include "pixman-inlines.h"
+#include "dither/blue-noise-64x64.h"
/* Fetch functions */
@@ -190,8 +191,8 @@
*ret = bilinear_interpolation_float (tl, tr, bl, br, distx, disty);
}
-static force_inline void accum_32(int *satot, int *srtot,
- int *sgtot, int *sbtot,
+static force_inline void accum_32(unsigned int *satot, unsigned int *srtot,
+ unsigned int *sgtot, unsigned int *sbtot,
const void *p, pixman_fixed_t f)
{
uint32_t pixel = *(uint32_t *)p;
@@ -202,8 +203,9 @@
*satot += (int)ALPHA_8 (pixel) * f;
}
-static force_inline void reduce_32(int satot, int srtot,
- int sgtot, int sbtot, void *p)
+static force_inline void reduce_32(unsigned int satot, unsigned int srtot,
+ unsigned int sgtot, unsigned int sbtot,
+ void *p)
{
uint32_t *ret = p;
@@ -220,8 +222,8 @@
*ret = ((satot << 24) | (srtot << 16) | (sgtot << 8) | (sbtot));
}
-static force_inline void accum_float(int *satot, int *srtot,
- int *sgtot, int *sbtot,
+static force_inline void accum_float(unsigned int *satot, unsigned int *srtot,
+ unsigned int *sgtot, unsigned int *sbtot,
const void *p, pixman_fixed_t f)
{
const argb_t *pixel = p;
@@ -232,8 +234,8 @@
*sbtot += pixel->b * f;
}
-static force_inline void reduce_float(int satot, int srtot,
- int sgtot, int sbtot,
+static force_inline void reduce_float(unsigned int satot, unsigned int srtot,
+ unsigned int sgtot, unsigned int sbtot,
void *p)
{
argb_t *ret = p;
@@ -244,12 +246,13 @@
ret->b = CLIP (sbtot / 65536.f, 0.f, 1.f);
}
-typedef void (* accumulate_pixel_t) (int *satot, int *srtot,
- int *sgtot, int *sbtot,
+typedef void (* accumulate_pixel_t) (unsigned int *satot, unsigned int *srtot,
+ unsigned int *sgtot, unsigned int *sbtot,
const void *pixel, pixman_fixed_t f);
-typedef void (* reduce_pixel_t) (int satot, int srtot,
- int sgtot, int sbtot, void *out);
+typedef void (* reduce_pixel_t) (unsigned int satot, unsigned int srtot,
+ unsigned int sgtot, unsigned int sbtot,
+ void *out);
static force_inline void
bits_image_fetch_pixel_convolution (bits_image_t *image,
@@ -269,7 +272,7 @@
pixman_repeat_t repeat_mode = image->common.repeat;
int width = image->width;
int height = image->height;
- int srtot, sgtot, sbtot, satot;
+ unsigned int srtot, sgtot, sbtot, satot;
params += 2;
@@ -338,7 +341,7 @@
int x_off = ((cwidth << 16) - pixman_fixed_1) >> 1;
int y_off = ((cheight << 16) - pixman_fixed_1) >> 1;
pixman_fixed_t *y_params;
- int srtot, sgtot, sbtot, satot;
+ unsigned int srtot, sgtot, sbtot, satot;
int32_t x1, x2, y1, y2;
int32_t px, py;
int i, j;
@@ -432,29 +435,38 @@
case PIXMAN_FILTER_CONVOLUTION:
if (wide)
+ {
bits_image_fetch_pixel_convolution (image, x, y,
get_pixel, out,
accum_float,
reduce_float);
+ }
else
+ {
bits_image_fetch_pixel_convolution (image, x, y,
get_pixel, out,
accum_32, reduce_32);
+ }
break;
case PIXMAN_FILTER_SEPARABLE_CONVOLUTION:
if (wide)
+ {
bits_image_fetch_pixel_separable_convolution (image, x, y,
get_pixel, out,
accum_float,
reduce_float);
+ }
else
+ {
bits_image_fetch_pixel_separable_convolution (image, x, y,
get_pixel, out,
accum_32, reduce_32);
+ }
break;
default:
+ assert (0);
break;
}
}
@@ -470,6 +482,7 @@
int width = iter->width;
uint32_t * buffer = iter->buffer;
+ const uint32_t wide_zero[4] = {0};
pixman_fixed_t x, y;
pixman_fixed_t ux, uy;
pixman_vector_t v;
@@ -501,7 +514,8 @@
for (i = 0; i < width; ++i)
{
- if (!mask || mask[i])
+ if (!mask || (!wide && mask[i]) ||
+ (wide && memcmp(&mask[4 * i], wide_zero, 16) != 0))
{
bits_image_fetch_pixel_filtered (
&image->bits, wide, x, y, get_pixel, buffer);
@@ -624,6 +638,7 @@
get_pixel_t get_pixel =
wide ? fetch_pixel_general_float : fetch_pixel_general_32;
+ const uint32_t wide_zero[4] = {0};
pixman_fixed_t x, y, w;
pixman_fixed_t ux, uy, uw;
pixman_vector_t v;
@@ -658,12 +673,13 @@
{
pixman_fixed_t x0, y0;
- if (!mask || mask[i])
+ if (!mask || (!wide && mask[i]) ||
+ (wide && memcmp(&mask[4 * i], wide_zero, 16) != 0))
{
if (w != 0)
{
- x0 = ((pixman_fixed_48_16_t)x << 16) / w;
- y0 = ((pixman_fixed_48_16_t)y << 16) / w;
+ x0 = ((uint64_t)x << 16) / w;
+ y0 = ((uint64_t)y << 16) / w;
}
else
{
@@ -1039,6 +1055,119 @@
iter->y++;
}
+static float
+dither_factor_blue_noise_64 (int x, int y)
+{
+ float m = dither_blue_noise_64x64[((y & 0x3f) << 6) | (x & 0x3f)];
+ return m * (1. / 4096.f) + (1. / 8192.f);
+}
+
+static float
+dither_factor_bayer_8 (int x, int y)
+{
+ uint32_t m;
+
+ y ^= x;
+
+ /* Compute reverse(interleave(xor(x mod n, y mod n), x mod n))
+ * Here n = 8 and `mod n` is the bottom 3 bits.
+ */
+ m = ((y & 0x1) << 5) | ((x & 0x1) << 4) |
+ ((y & 0x2) << 2) | ((x & 0x2) << 1) |
+ ((y & 0x4) >> 1) | ((x & 0x4) >> 2);
+
+ /* m is in range [0, 63]. We scale it to [0, 63.0f/64.0f], then
+ * shift it to to [1.0f/128.0f, 127.0f/128.0f] so that 0 < d < 1.
+ * This ensures exact values are not changed by dithering.
+ */
+ return (float)(m) * (1 / 64.0f) + (1.0f / 128.0f);
+}
+
+typedef float (* dither_factor_t)(int x, int y);
+
+static force_inline float
+dither_apply_channel (float f, float d, float s)
+{
+ /* float_to_unorm splits the [0, 1] segment in (1 << n_bits)
+ * subsections of equal length; however unorm_to_float does not
+ * map to the center of those sections. In fact, pixel value u is
+ * mapped to:
+ *
+ * u u u 1
+ * -------------- = ---------- + -------------- * ----------
+ * 2^n_bits - 1 2^n_bits 2^n_bits - 1 2^n_bits
+ *
+ * Hence if f = u / (2^n_bits - 1) is exactly representable on a
+ * n_bits palette, all the numbers between
+ *
+ * u
+ * ---------- = f - f * 2^n_bits = f + (0 - f) * 2^n_bits
+ * 2^n_bits
+ *
+ * and
+ *
+ * u + 1
+ * ---------- = f - (f - 1) * 2^n_bits = f + (1 - f) * 2^n_bits
+ * 2^n_bits
+ *
+ * are also mapped back to u.
+ *
+ * Hence the following calculation ensures that we add as much
+ * noise as possible without perturbing values which are exactly
+ * representable in the target colorspace. Note that this corresponds to
+ * mixing the original color with noise with a ratio of `1 / 2^n_bits`.
+ */
+ return f + (d - f) * s;
+}
+
+static force_inline float
+dither_compute_scale (int n_bits)
+{
+ // No dithering for wide formats
+ if (n_bits == 0 || n_bits >= 32)
+ return 0.f;
+
+ return 1.f / (float)(1 << n_bits);
+}
+
Home |
Main Index |
Thread Index |
Old Index