pixman: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 3 12:54:07 UTC 2022


 pixman/pixman-access.c |  156 +++++++++++++++++++++++++++++++++++++++++++++++++
 pixman/pixman.c        |    1 
 pixman/pixman.h        |    1 
 test/composite.c       |    1 
 test/stress-test.c     |    1 
 test/utils.c           |    1 
 6 files changed, 161 insertions(+)

New commits:
commit 40d6c9b256ed4a5805c9296392e7af0d9e329455
Author: Claude Heiland-Allen <claude at mathr.co.uk>
Date:   Sun Mar 7 23:38:57 2021 +0000

    add r8g8b8 sRGB to test suite
    
    Signed-off-by: Claude Heiland-Allen <claude at mathr.co.uk>

diff --git a/test/composite.c b/test/composite.c
index 594c697..8d95046 100644
--- a/test/composite.c
+++ b/test/composite.c
@@ -92,6 +92,7 @@ static const pixman_format_code_t formats[] =
     
     /* sRGB formats */
     PIXMAN_a8r8g8b8_sRGB,
+    PIXMAN_r8g8b8_sRGB,
 
     /* 24 bpp formats */
     PIXMAN_r8g8b8,
diff --git a/test/stress-test.c b/test/stress-test.c
index 13d9979..8ee1896 100644
--- a/test/stress-test.c
+++ b/test/stress-test.c
@@ -28,6 +28,7 @@ static const pixman_format_code_t image_formats[] =
     PIXMAN_r8g8b8,
     PIXMAN_b8g8r8,
     PIXMAN_a8r8g8b8_sRGB,
+    PIXMAN_r8g8b8_sRGB,
     PIXMAN_r5g6b5,
     PIXMAN_b5g6r5,
     PIXMAN_x2r10g10b10,
diff --git a/test/utils.c b/test/utils.c
index 1c64cee..23bf019 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -1249,6 +1249,7 @@ static const format_entry_t format_list[] =
 
 /* sRGB formats */
     ENTRY (a8r8g8b8_sRGB),
+    ENTRY (r8g8b8_sRGB),
 
 /* 24bpp formats */
     ENTRY (r8g8b8),
commit 83ba0244838217714d387834cf2ea4eef04a3206
Author: Claude Heiland-Allen <claude at mathr.co.uk>
Date:   Thu Mar 11 13:14:49 2021 +0000

    implement r8g8b8 sRGB (without alpha)
    
    Signed-off-by: Claude Heiland-Allen <claude at mathr.co.uk>

diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index 7c5ce78..54b0f31 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -610,6 +610,32 @@ fetch_scanline_a8r8g8b8_sRGB_float (bits_image_t *  image,
     }
 }
 
+static void
+fetch_scanline_r8g8b8_sRGB_float (bits_image_t *  image,
+				  int             x,
+				  int             y,
+				  int             width,
+				  uint32_t *      b,
+				  const uint32_t *mask)
+{
+    const uint8_t *bits = (uint8_t *)(image->bits + y * image->rowstride);
+    argb_t *buffer = (argb_t *)b;
+    int i;
+    for (i = x; i < width; ++i)
+    {
+	uint32_t p = FETCH_24 (image, bits, i);
+	argb_t *argb = buffer;
+
+	argb->a = 1.0f;
+
+	argb->r = to_linear[(p >> 16) & 0xff];
+	argb->g = to_linear[(p >>  8) & 0xff];
+	argb->b = to_linear[(p >>  0) & 0xff];
+
+	buffer++;
+    }
+}
+
 /* Expects a float buffer */
 static void
 fetch_scanline_a2r10g10b10_float (bits_image_t *  image,
@@ -981,6 +1007,24 @@ fetch_pixel_a8r8g8b8_sRGB_float (bits_image_t *image,
     return argb;
 }
 
+static argb_t
+fetch_pixel_r8g8b8_sRGB_float (bits_image_t *image,
+			       int	     offset,
+			       int           line)
+{
+    uint8_t *bits = (uint8_t *)(image->bits + line * image->rowstride);
+    uint32_t p = FETCH_24 (image, bits, offset);
+    argb_t argb;
+
+    argb.a = 1.0f;
+
+    argb.r = to_linear[(p >> 16) & 0xff];
+    argb.g = to_linear[(p >>  8) & 0xff];
+    argb.b = to_linear[(p >>  0) & 0xff];
+
+    return argb;
+}
+
 static uint32_t
 fetch_pixel_yuy2 (bits_image_t *image,
 		  int           offset,
@@ -1205,6 +1249,31 @@ store_scanline_a8r8g8b8_sRGB_float (bits_image_t *  image,
     }
 }
 
+static void
+store_scanline_r8g8b8_sRGB_float (bits_image_t *  image,
+				  int             x,
+				  int             y,
+				  int             width,
+				  const uint32_t *v)
+{
+    uint8_t *bits = (uint8_t *)(image->bits + image->rowstride * y) + 3 * x;
+    argb_t *values = (argb_t *)v;
+    int i;
+
+    for (i = 0; i < width; ++i)
+    {
+	uint32_t r, g, b, rgb;
+
+	r = to_srgb (values[i].r);
+	g = to_srgb (values[i].g);
+	b = to_srgb (values[i].b);
+
+	rgb = (r << 16) | (g << 8) | b;
+
+	STORE_24 (image, bits, i, rgb);
+    }
+}
+
 /*
  * Contracts a floating point image to 32bpp and then stores it using a
  * regular 32-bit store proc. Despite the type, this function expects an
@@ -1283,6 +1352,37 @@ fetch_scanline_a8r8g8b8_32_sRGB (bits_image_t   *image,
     }
 }
 
+static void
+fetch_scanline_r8g8b8_32_sRGB (bits_image_t   *image,
+                               int             x,
+                               int             y,
+                               int             width,
+                               uint32_t       *buffer,
+                               const uint32_t *mask)
+{
+    const uint8_t *bits = (uint8_t *)(image->bits + y * image->rowstride) + 3 * x;
+    uint32_t tmp;
+    int i;
+
+    for (i = 0; i < width; ++i)
+    {
+	uint32_t a, r, g, b;
+
+	tmp = FETCH_24 (image, bits, i);
+
+	a = 0xff;
+	r = (tmp >> 16) & 0xff;
+	g = (tmp >> 8) & 0xff;
+	b = (tmp >> 0) & 0xff;
+
+	r = to_linear[r] * 255.0f + 0.5f;
+	g = to_linear[g] * 255.0f + 0.5f;
+	b = to_linear[b] * 255.0f + 0.5f;
+
+	*buffer++ = (a << 24) | (r << 16) | (g << 8) | (b << 0);
+    }
+}
+
 static uint32_t
 fetch_pixel_a8r8g8b8_32_sRGB (bits_image_t *image,
 			      int           offset,
@@ -1304,6 +1404,27 @@ fetch_pixel_a8r8g8b8_32_sRGB (bits_image_t *image,
     return (a << 24) | (r << 16) | (g << 8) | (b << 0);
 }
 
+static uint32_t
+fetch_pixel_r8g8b8_32_sRGB (bits_image_t *image,
+			    int           offset,
+			    int           line)
+{
+    uint8_t *bits = (uint8_t *)(image->bits + line * image->rowstride);
+    uint32_t tmp = FETCH_24 (image, bits, offset);
+    uint32_t a, r, g, b;
+
+    a = 0xff;
+    r = (tmp >> 16) & 0xff;
+    g = (tmp >> 8) & 0xff;
+    b = (tmp >> 0) & 0xff;
+
+    r = to_linear[r] * 255.0f + 0.5f;
+    g = to_linear[g] * 255.0f + 0.5f;
+    b = to_linear[b] * 255.0f + 0.5f;
+
+    return (a << 24) | (r << 16) | (g << 8) | (b << 0);
+}
+
 static void
 store_scanline_a8r8g8b8_32_sRGB (bits_image_t   *image,
                                  int             x,
@@ -1336,6 +1457,36 @@ store_scanline_a8r8g8b8_32_sRGB (bits_image_t   *image,
     }
 }
 
+static void
+store_scanline_r8g8b8_32_sRGB (bits_image_t   *image,
+			       int             x,
+                               int             y,
+                               int             width,
+                               const uint32_t *v)
+{
+    uint8_t *bits = (uint8_t *)(image->bits + image->rowstride * y) + 3 * x;
+    uint64_t *values = (uint64_t *)v;
+    uint64_t tmp;
+    int i;
+
+    for (i = 0; i < width; ++i)
+    {
+	uint32_t r, g, b;
+
+	tmp = values[i];
+
+	r = (tmp >> 16) & 0xff;
+	g = (tmp >> 8) & 0xff;
+	b = (tmp >> 0) & 0xff;
+
+	r = to_srgb (r * (1/255.0f));
+	g = to_srgb (g * (1/255.0f));
+	b = to_srgb (b * (1/255.0f));
+
+	STORE_24 (image, bits, i, (r << 16) | (g << 8) | (b << 0));
+    }
+}
+
 static argb_t
 fetch_pixel_generic_float (bits_image_t *image,
 			   int		 offset,
@@ -1409,6 +1560,11 @@ static const format_info_t accessors[] =
     fetch_pixel_a8r8g8b8_32_sRGB, fetch_pixel_a8r8g8b8_sRGB_float,
     store_scanline_a8r8g8b8_32_sRGB, store_scanline_a8r8g8b8_sRGB_float,
   },
+  { PIXMAN_r8g8b8_sRGB,
+    fetch_scanline_r8g8b8_32_sRGB, fetch_scanline_r8g8b8_sRGB_float,
+    fetch_pixel_r8g8b8_32_sRGB, fetch_pixel_r8g8b8_sRGB_float,
+    store_scanline_r8g8b8_32_sRGB, store_scanline_r8g8b8_sRGB_float,
+  },
 
 /* 24bpp formats */
     FORMAT_INFO (r8g8b8),
diff --git a/pixman/pixman.c b/pixman/pixman.c
index c09b528..1a3cba0 100644
--- a/pixman/pixman.c
+++ b/pixman/pixman.c
@@ -1020,6 +1020,7 @@ pixman_format_supported_source (pixman_format_code_t format)
     case PIXMAN_x2r10g10b10:
     case PIXMAN_a8r8g8b8:
     case PIXMAN_a8r8g8b8_sRGB:
+    case PIXMAN_r8g8b8_sRGB:
     case PIXMAN_x8r8g8b8:
     case PIXMAN_a8b8g8r8:
     case PIXMAN_x8b8g8r8:
diff --git a/pixman/pixman.h b/pixman/pixman.h
index 0070340..2cd875b 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -891,6 +891,7 @@ typedef enum {
 
 /* sRGB formats */
     PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8),
+    PIXMAN_r8g8b8_sRGB = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB_SRGB,0,8,8,8),
 
 /* 24bpp formats */
     PIXMAN_r8g8b8 =	 PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8),


More information about the xorg-commit mailing list