[babl] cairo: add fast paths for u8 and u16 gray gamma
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] cairo: add fast paths for u8 and u16 gray gamma
- Date: Thu, 15 Dec 2016 20:02:00 +0000 (UTC)
commit 57045014253643f4afd35c322a146ee1d1517a46
Author: Øyvind Kolås <pippin gimp org>
Date: Thu Dec 15 21:01:45 2016 +0100
cairo: add fast paths for u8 and u16 gray gamma
extensions/cairo.c | 43 +++++++++++++++++++++++++++++++++++++++++++
tools/babl-verify.sh | 4 ----
2 files changed, 43 insertions(+), 4 deletions(-)
---
diff --git a/extensions/cairo.c b/extensions/cairo.c
index a8247f6..2d807cb 100644
--- a/extensions/cairo.c
+++ b/extensions/cairo.c
@@ -125,6 +125,9 @@ conv_rgbA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
return samples;
}
+
+
+
static inline long
conv_yA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
{
@@ -163,6 +166,40 @@ conv_yA16_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
return samples;
}
+static inline long
+conv_y8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+{
+ long n = samples;
+ while (n--)
+ {
+ unsigned char val = *src++;
+ *dst++ = val;
+ *dst++ = val;
+ *dst++ = val;
+ *dst++ = 0xff;
+ }
+ return samples;
+}
+
+static inline long
+conv_y16_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+{
+ long n = samples;
+ uint16_t *s16 = (void*)src;
+ while (n--)
+ {
+#define div_257(a) ((((a)+128)-(((a)+128)>>8))>>8)
+ uint16_t v16 = *s16++;
+ unsigned char val = div_257(v16);
+#undef dib_257
+ *dst++ = val;
+ *dst++ = val;
+ *dst++ = val;
+ *dst++ = 0xff;
+ }
+ return samples;
+}
+
static long
conv_rgbA_gamma_float_cairo32_le (unsigned char *src,
unsigned char *dst,
@@ -273,6 +310,12 @@ init (void)
babl_conversion_new (babl_format ("Y'A u16"), f32, "linear",
conv_yA16_cairo32_le, NULL);
+
+ babl_conversion_new (babl_format ("Y' u8"), f32, "linear",
+ conv_y8_cairo32_le, NULL);
+ babl_conversion_new (babl_format ("Y' u16"), f32, "linear",
+ conv_y16_cairo32_le, NULL);
+
babl_conversion_new (babl_format ("RGBA float"), f32, "linear",
conv_rgbafloat_cairo32_le, NULL);
diff --git a/tools/babl-verify.sh b/tools/babl-verify.sh
index bde6aa0..5d917bb 100755
--- a/tools/babl-verify.sh
+++ b/tools/babl-verify.sh
@@ -28,8 +28,6 @@ $base_path/tools/babl-verify "$format" "RGBA float" "x"
$base_path/tools/babl-verify "RGBA float" "$format" "x"
$base_path/tools/babl-verify "$format" "R'G'B'A float" "x"
$base_path/tools/babl-verify "R'G'B'A float" "$format" "x"
-$base_path/tools/babl-verify "$format" "CIE Lab float" "x"
-$base_path/tools/babl-verify "CIE Lab float" "$format" "x"
$base_path/tools/babl-verify "$format" "cairo-ARGB32"
$base_path/tools/babl-verify "$format" "RaGaBaA float"
@@ -38,6 +36,4 @@ $base_path/tools/babl-verify "$format" "RGBA float"
$base_path/tools/babl-verify "RGBA float" "$format"
$base_path/tools/babl-verify "$format" "R'G'B'A float"
$base_path/tools/babl-verify "R'G'B'A float" "$format"
-$base_path/tools/babl-verify "$format" "CIE Lab float"
-$base_path/tools/babl-verify "CIE Lab float" "$format"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]