summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2012-09-29 02:30:07 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-09-29 02:30:07 -0400
commit93ebc61f61da2724a7ac2b38d1f780f7305e2095 (patch)
treee9417a9a9a8d2294a7bcdae1503c09a350c36770
parent50c47176f921cddbca0eb15f90a0e2476e875fbd (diff)
Support for x8b8g8r8_sRGBsRGB_x8r8g8b8
-rw-r--r--pixman/pixman-access.c159
-rw-r--r--pixman/pixman-image.c4
-rw-r--r--pixman/pixman-private.h3
-rw-r--r--pixman/pixman.c1
-rw-r--r--pixman/pixman.h2
5 files changed, 166 insertions, 3 deletions
diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index 3bdfd967..88b45bba 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -212,6 +212,7 @@ get_shifts (pixman_format_code_t format,
case PIXMAN_TYPE_ARGB:
case PIXMAN_TYPE_ARGB_SRGB:
+ case PIXMAN_TYPE_ABGR_SRGB:
*b = 0;
*g = *b + PIXMAN_FORMAT_B (format);
*r = *g + PIXMAN_FORMAT_G (format);
@@ -638,6 +639,34 @@ fetch_scanline_x8r8g8b8_sRGB_float (pixman_image_t *image,
}
}
+static void
+fetch_scanline_x8b8g8r8_sRGB_float (pixman_image_t *image,
+ int x,
+ int y,
+ int width,
+ uint32_t * b,
+ const uint32_t *mask)
+{
+ const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+ const uint32_t *pixel = bits + x;
+ const uint32_t *end = pixel + width;
+ argb_t *buffer = (argb_t *)b;
+
+ while (pixel < end)
+ {
+ uint32_t p = READ (image, pixel++);
+ argb_t *argb = buffer;
+
+ argb->a = 1.0;
+
+ argb->b = to_linear [(p >> 16) & 0xff];
+ argb->g = to_linear [(p >> 8) & 0xff];
+ argb->r = to_linear [(p >> 0) & 0xff];
+
+ buffer++;
+ }
+}
+
/* Expects a float buffer */
static void
fetch_scanline_a2r10g10b10_float (pixman_image_t *image,
@@ -950,6 +979,23 @@ fetch_pixel_x8r8g8b8_sRGB_float (bits_image_t *image,
return argb;
}
+static argb_t
+fetch_pixel_x8b8g8r8_sRGB_float (bits_image_t *image,
+ int offset,
+ int line)
+{
+ uint32_t *bits = image->bits + line * image->rowstride;
+ uint32_t p = READ (image, bits + offset);
+ argb_t argb;
+
+ argb.a = 1.0;
+ argb.r = to_linear [(p >> 0) & 0xff];
+ argb.g = to_linear [(p >> 8) & 0xff];
+ argb.b = to_linear [(p >> 16) & 0xff];
+
+ return argb;
+}
+
static uint32_t
fetch_pixel_yuy2 (bits_image_t *image,
int offset,
@@ -1160,6 +1206,31 @@ store_scanline_x8r8g8b8_sRGB_float (bits_image_t * image,
}
}
+static void
+store_scanline_x8b8g8r8_sRGB_float (bits_image_t * image,
+ int x,
+ int y,
+ int width,
+ const uint32_t *v)
+{
+ uint32_t *bits = image->bits + image->rowstride * y;
+ uint32_t *pixel = bits + x;
+ argb_t *values = (argb_t *)v;
+ int i;
+
+ for (i = 0; i < width; ++i)
+ {
+ uint8_t r, g, b;
+
+ r = to_srgb (values[i].r);
+ g = to_srgb (values[i].g);
+ b = to_srgb (values[i].b);
+
+ WRITE (image, pixel++,
+ (b << 16) | (g << 8) | r);
+ }
+}
+
/*
* 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
@@ -1269,6 +1340,37 @@ fetch_scanline_x8r8g8b8_32_sRGB (pixman_image_t *image,
}
}
+static void
+fetch_scanline_x8b8g8r8_32_sRGB (pixman_image_t *image,
+ int x,
+ int y,
+ int width,
+ uint32_t *buffer,
+ const uint32_t *mask)
+{
+ const uint32_t *bits = image->bits.bits + y * image->bits.rowstride;
+ const uint32_t *pixel = (uint32_t *)bits + x;
+ const uint32_t *end = pixel + width;
+ uint32_t tmp;
+
+ while (pixel < end)
+ {
+ uint8_t r, g, b;
+
+ tmp = READ (image, pixel++);
+
+ 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++ = (0xff000000) | (b << 16) | (g << 8) | (r << 0);
+ }
+}
+
static uint32_t
fetch_pixel_a8r8g8b8_32_sRGB (bits_image_t *image,
int offset,
@@ -1310,6 +1412,26 @@ fetch_pixel_x8r8g8b8_32_sRGB (bits_image_t *image,
return 0xff000000 | (r << 16) | (g << 8) | (b << 0);
}
+static uint32_t
+fetch_pixel_x8b8g8r8_32_sRGB (bits_image_t *image,
+ int offset,
+ int line)
+{
+ uint32_t *bits = image->bits + line * image->rowstride;
+ uint32_t tmp = READ (image, bits + offset);
+ uint8_t r, g, b;
+
+ 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 0xff000000 | (b << 16) | (g << 8) | (r << 0);
+}
+
static void
store_scanline_a8r8g8b8_32_sRGB (bits_image_t *image,
int x,
@@ -1373,6 +1495,37 @@ store_scanline_x8r8g8b8_32_sRGB (bits_image_t *image,
}
}
+static void
+store_scanline_x8b8g8r8_32_sRGB (bits_image_t *image,
+ int x,
+ int y,
+ int width,
+ const uint32_t *v)
+{
+ uint32_t *bits = image->bits + image->rowstride * y;
+ uint64_t *values = (uint64_t *)v;
+ uint32_t *pixel = bits + x;
+ uint64_t tmp;
+ int i;
+
+ for (i = 0; i < width; ++i)
+ {
+ uint8_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));
+
+ WRITE (image, pixel++, (b << 16) | (g << 8) | (r << 0));
+ }
+}
+
static argb_t
fetch_pixel_generic_float (bits_image_t *image,
int offset,
@@ -1453,6 +1606,12 @@ static const format_info_t accessors[] =
store_scanline_x8r8g8b8_32_sRGB, store_scanline_x8r8g8b8_sRGB_float,
},
+ { PIXMAN_x8b8g8r8_sRGB,
+ fetch_scanline_x8b8g8r8_32_sRGB, fetch_scanline_x8b8g8r8_sRGB_float,
+ fetch_pixel_x8b8g8r8_32_sRGB, fetch_pixel_x8b8g8r8_sRGB_float,
+ store_scanline_x8b8g8r8_32_sRGB, store_scanline_x8b8g8r8_sRGB_float,
+ },
+
/* 24bpp formats */
FORMAT_INFO (r8g8b8),
FORMAT_INFO (b8g8r8),
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index d9c30344..baa093d6 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -909,8 +909,8 @@ _pixman_image_get_solid (pixman_implementation_t *imp,
}
/* If necessary, convert RGB <--> BGR. */
- if (PIXMAN_FORMAT_TYPE (format) != PIXMAN_TYPE_ARGB
- && PIXMAN_FORMAT_TYPE (format) != PIXMAN_TYPE_ARGB_SRGB)
+ if (PIXMAN_FORMAT_TYPE (format) != PIXMAN_TYPE_ARGB &&
+ PIXMAN_FORMAT_TYPE (format) != PIXMAN_TYPE_ARGB_SRGB)
{
result = (((result & 0xff000000) >> 0) |
((result & 0x00ff0000) >> 16) |
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index dd03a939..f223d8f5 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -904,7 +904,8 @@ pixman_list_move_to_front (pixman_list_t *list, pixman_link_t *link)
PIXMAN_FORMAT_R (f) > 8 || \
PIXMAN_FORMAT_G (f) > 8 || \
PIXMAN_FORMAT_B (f) > 8 || \
- PIXMAN_FORMAT_TYPE (f) == PIXMAN_TYPE_ARGB_SRGB)
+ PIXMAN_FORMAT_TYPE (f) == PIXMAN_TYPE_ARGB_SRGB || \
+ PIXMAN_FORMAT_TYPE (f) == PIXMAN_TYPE_ABGR_SRGB)
#ifdef WORDS_BIGENDIAN
# define SCREEN_SHIFT_LEFT(x,n) ((x) << (n))
diff --git a/pixman/pixman.c b/pixman/pixman.c
index 810bf7d4..8ea25814 100644
--- a/pixman/pixman.c
+++ b/pixman/pixman.c
@@ -1019,6 +1019,7 @@ pixman_format_supported_source (pixman_format_code_t format)
case PIXMAN_a8r8g8b8:
case PIXMAN_a8r8g8b8_sRGB:
case PIXMAN_x8r8g8b8_sRGB:
+ case PIXMAN_x8b8g8r8_sRGB:
case PIXMAN_x8r8g8b8:
case PIXMAN_a8b8g8r8:
case PIXMAN_x8b8g8r8:
diff --git a/pixman/pixman.h b/pixman/pixman.h
index e74276bd..dcf7bbf2 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -654,6 +654,7 @@ struct pixman_indexed
#define PIXMAN_TYPE_BGRA 8
#define PIXMAN_TYPE_RGBA 9
#define PIXMAN_TYPE_ARGB_SRGB 10
+#define PIXMAN_TYPE_ABGR_SRGB 11
#define PIXMAN_FORMAT_COLOR(f) \
(PIXMAN_FORMAT_TYPE(f) == PIXMAN_TYPE_ARGB || \
@@ -680,6 +681,7 @@ typedef enum {
/* sRGB formats */
PIXMAN_a8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,8,8,8,8),
PIXMAN_x8r8g8b8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB_SRGB,0,8,8,8),
+ PIXMAN_x8b8g8r8_sRGB = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR_SRGB,0,8,8,8),
/* 24bpp formats */
PIXMAN_r8g8b8 = PIXMAN_FORMAT(24,PIXMAN_TYPE_ARGB,0,8,8,8),