summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <soren.sandmann@gmail.com>2015-09-19 07:38:51 -0400
committerSøren Sandmann Pedersen <soren.sandmann@gmail.com>2015-09-19 07:38:51 -0400
commit4d2d6ce7c10b728ea3771cfbfa49260dd22cb0f6 (patch)
treea0e59af09e27110ae4208fcf5b119d46d26cdc49
parent73e586efb3ee149f76f15d9e549bffa15d8e30ec (diff)
Get rid of fetch_pixel() routinesno_pixels
Replace all instances of fetch_pixel() with fetch_scanline() with a width of 1.
-rw-r--r--pixman/pixman-access.c276
-rw-r--r--pixman/pixman-bits-image.c16
-rw-r--r--pixman/pixman-noop.c9
-rw-r--r--pixman/pixman-private.h10
4 files changed, 51 insertions, 260 deletions
diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c
index 4f0642d7..7770ad8a 100644
--- a/pixman/pixman-access.c
+++ b/pixman/pixman-access.c
@@ -453,18 +453,6 @@ convert_and_store_pixel (bits_image_t * image,
} \
} \
\
- static uint32_t \
- fetch_pixel_ ## format (bits_image_t *image, \
- int offset, \
- int line) \
- { \
- uint8_t *bits = \
- (uint8_t *)(image->bits + line * image->rowstride); \
- \
- return fetch_and_convert_pixel ( \
- image, bits, offset, PIXMAN_ ## format); \
- } \
- \
static const void *const __dummy__ ## format
MAKE_ACCESSORS(a8r8g8b8);
@@ -803,163 +791,6 @@ fetch_scanline_yv12 (bits_image_t *image,
}
}
-/**************************** Pixel wise fetching *****************************/
-
-static argb_t
-fetch_pixel_x2r10g10b10_float (bits_image_t *image,
- int offset,
- int line)
-{
- uint32_t *bits = image->bits + line * image->rowstride;
- uint32_t p = READ (image, bits + offset);
- uint64_t r = (p >> 20) & 0x3ff;
- uint64_t g = (p >> 10) & 0x3ff;
- uint64_t b = p & 0x3ff;
- argb_t argb;
-
- argb.a = 1.0;
- argb.r = pixman_unorm_to_float (r, 10);
- argb.g = pixman_unorm_to_float (g, 10);
- argb.b = pixman_unorm_to_float (b, 10);
-
- return argb;
-}
-
-static argb_t
-fetch_pixel_a2r10g10b10_float (bits_image_t *image,
- int offset,
- int line)
-{
- uint32_t *bits = image->bits + line * image->rowstride;
- uint32_t p = READ (image, bits + offset);
- uint64_t a = p >> 30;
- uint64_t r = (p >> 20) & 0x3ff;
- uint64_t g = (p >> 10) & 0x3ff;
- uint64_t b = p & 0x3ff;
- argb_t argb;
-
- argb.a = pixman_unorm_to_float (a, 2);
- argb.r = pixman_unorm_to_float (r, 10);
- argb.g = pixman_unorm_to_float (g, 10);
- argb.b = pixman_unorm_to_float (b, 10);
-
- return argb;
-}
-
-static argb_t
-fetch_pixel_a2b10g10r10_float (bits_image_t *image,
- int offset,
- int line)
-{
- uint32_t *bits = image->bits + line * image->rowstride;
- uint32_t p = READ (image, bits + offset);
- uint64_t a = p >> 30;
- uint64_t b = (p >> 20) & 0x3ff;
- uint64_t g = (p >> 10) & 0x3ff;
- uint64_t r = p & 0x3ff;
- argb_t argb;
-
- argb.a = pixman_unorm_to_float (a, 2);
- argb.r = pixman_unorm_to_float (r, 10);
- argb.g = pixman_unorm_to_float (g, 10);
- argb.b = pixman_unorm_to_float (b, 10);
-
- return argb;
-}
-
-static argb_t
-fetch_pixel_x2b10g10r10_float (bits_image_t *image,
- int offset,
- int line)
-{
- uint32_t *bits = image->bits + line * image->rowstride;
- uint32_t p = READ (image, bits + offset);
- uint64_t b = (p >> 20) & 0x3ff;
- uint64_t g = (p >> 10) & 0x3ff;
- uint64_t r = p & 0x3ff;
- argb_t argb;
-
- argb.a = 1.0;
- argb.r = pixman_unorm_to_float (r, 10);
- argb.g = pixman_unorm_to_float (g, 10);
- argb.b = pixman_unorm_to_float (b, 10);
-
- return argb;
-}
-
-static argb_t
-fetch_pixel_a8r8g8b8_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 = pixman_unorm_to_float ((p >> 24) & 0xff, 8);
-
- 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,
- int line)
-{
- const uint32_t *bits = image->bits + image->rowstride * line;
-
- int16_t y, u, v;
- int32_t r, g, b;
-
- y = ((uint8_t *) bits)[offset << 1] - 16;
- u = ((uint8_t *) bits)[((offset << 1) & - 4) + 1] - 128;
- v = ((uint8_t *) bits)[((offset << 1) & - 4) + 3] - 128;
-
- /* R = 1.164(Y - 16) + 1.596(V - 128) */
- r = 0x012b27 * y + 0x019a2e * v;
-
- /* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) */
- g = 0x012b27 * y - 0x00d0f2 * v - 0x00647e * u;
-
- /* B = 1.164(Y - 16) + 2.018(U - 128) */
- b = 0x012b27 * y + 0x0206a2 * u;
-
- return 0xff000000 |
- (r >= 0 ? r < 0x1000000 ? r & 0xff0000 : 0xff0000 : 0) |
- (g >= 0 ? g < 0x1000000 ? (g >> 8) & 0x00ff00 : 0x00ff00 : 0) |
- (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0);
-}
-
-static uint32_t
-fetch_pixel_yv12 (bits_image_t *image,
- int offset,
- int line)
-{
- YV12_SETUP (image);
- int16_t y = YV12_Y (line)[offset] - 16;
- int16_t u = YV12_U (line)[offset >> 1] - 128;
- int16_t v = YV12_V (line)[offset >> 1] - 128;
- int32_t r, g, b;
-
- /* R = 1.164(Y - 16) + 1.596(V - 128) */
- r = 0x012b27 * y + 0x019a2e * v;
-
- /* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) */
- g = 0x012b27 * y - 0x00d0f2 * v - 0x00647e * u;
-
- /* B = 1.164(Y - 16) + 2.018(U - 128) */
- b = 0x012b27 * y + 0x0206a2 * u;
-
- return 0xff000000 |
- (r >= 0 ? r < 0x1000000 ? r & 0xff0000 : 0xff0000 : 0) |
- (g >= 0 ? g < 0x1000000 ? (g >> 8) & 0x00ff00 : 0x00ff00 : 0) |
- (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0);
-}
-
/*********************************** Store ************************************/
static void
@@ -1133,9 +964,38 @@ fetch_scanline_generic_float (bits_image_t * image,
pixman_expand_to_float ((argb_t *)buffer, buffer, image->format, width);
}
+/*
+ * XXX: The transformed fetch path only works at 32-bpp so far. When all
+ * paths have wide versions, this can be removed.
+ *
+ * WARNING: This function loses precision!
+ */
+static void
+fetch_scanline_generic_lossy_32 (bits_image_t * image,
+ int x,
+ int y,
+ int width,
+ uint32_t * buffer,
+ const uint32_t *mask)
+{
+ argb_t *float_pixels;
+
+ float_pixels = pixman_malloc_ab (width, sizeof(argb_t));
+ if (!float_pixels)
+ return;
+
+ image->fetch_scanline_float (
+ image, x, y, width, (uint32_t *)float_pixels, NULL);
+
+ pixman_contract_from_float (buffer, float_pixels, width);
+
+ free (float_pixels);
+}
+
/* The 32_sRGB paths should be deleted after narrow processing
* is no longer invoked for formats that are considered wide.
- * (Also see fetch_pixel_generic_lossy_32) */
+ * (Also see fetch_scanline_generic_lossy_32)
+ */
static void
fetch_scanline_a8r8g8b8_32_sRGB (bits_image_t *image,
int x,
@@ -1168,27 +1028,6 @@ fetch_scanline_a8r8g8b8_32_sRGB (bits_image_t *image,
}
}
-static uint32_t
-fetch_pixel_a8r8g8b8_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 a, r, g, b;
-
- a = (tmp >> 24) & 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,
@@ -1221,45 +1060,11 @@ store_scanline_a8r8g8b8_32_sRGB (bits_image_t *image,
}
}
-static argb_t
-fetch_pixel_generic_float (bits_image_t *image,
- int offset,
- int line)
-{
- uint32_t pixel32 = image->fetch_pixel_32 (image, offset, line);
- argb_t f;
-
- pixman_expand_to_float (&f, &pixel32, image->format, 1);
-
- return f;
-}
-
-/*
- * XXX: The transformed fetch path only works at 32-bpp so far. When all
- * paths have wide versions, this can be removed.
- *
- * WARNING: This function loses precision!
- */
-static uint32_t
-fetch_pixel_generic_lossy_32 (bits_image_t *image,
- int offset,
- int line)
-{
- argb_t pixel64 = image->fetch_pixel_float (image, offset, line);
- uint32_t result;
-
- pixman_contract_from_float (&result, &pixel64, 1);
-
- return result;
-}
-
typedef struct
{
pixman_format_code_t format;
fetch_scanline_t fetch_scanline_32;
fetch_scanline_t fetch_scanline_float;
- fetch_pixel_32_t fetch_pixel_32;
- fetch_pixel_float_t fetch_pixel_float;
store_scanline_t store_scanline_32;
store_scanline_t store_scanline_float;
} format_info_t;
@@ -1269,8 +1074,6 @@ typedef struct
PIXMAN_ ## format, \
fetch_scanline_ ## format, \
fetch_scanline_generic_float, \
- fetch_pixel_ ## format, \
- fetch_pixel_generic_float, \
store_scanline_ ## format, \
store_scanline_generic_float \
}
@@ -1291,7 +1094,6 @@ static const format_info_t accessors[] =
/* sRGB formats */
{ PIXMAN_a8r8g8b8_sRGB,
fetch_scanline_a8r8g8b8_32_sRGB, fetch_scanline_a8r8g8b8_sRGB_float,
- fetch_pixel_a8r8g8b8_32_sRGB, fetch_pixel_a8r8g8b8_sRGB_float,
store_scanline_a8r8g8b8_32_sRGB, store_scanline_a8r8g8b8_sRGB_float,
},
@@ -1324,12 +1126,10 @@ static const format_info_t accessors[] =
FORMAT_INFO (g8),
#define fetch_scanline_x4c4 fetch_scanline_c8
-#define fetch_pixel_x4c4 fetch_pixel_c8
#define store_scanline_x4c4 store_scanline_c8
FORMAT_INFO (x4c4),
#define fetch_scanline_x4g4 fetch_scanline_g8
-#define fetch_pixel_x4g4 fetch_pixel_g8
#define store_scanline_x4g4 store_scanline_g8
FORMAT_INFO (x4g4),
@@ -1353,34 +1153,28 @@ static const format_info_t accessors[] =
/* Wide formats */
{ PIXMAN_a2r10g10b10,
- NULL, fetch_scanline_a2r10g10b10_float,
- fetch_pixel_generic_lossy_32, fetch_pixel_a2r10g10b10_float,
+ fetch_scanline_generic_lossy_32, fetch_scanline_a2r10g10b10_float,
NULL, store_scanline_a2r10g10b10_float },
{ PIXMAN_x2r10g10b10,
- NULL, fetch_scanline_x2r10g10b10_float,
- fetch_pixel_generic_lossy_32, fetch_pixel_x2r10g10b10_float,
+ fetch_scanline_generic_lossy_32, fetch_scanline_x2r10g10b10_float,
NULL, store_scanline_x2r10g10b10_float },
{ PIXMAN_a2b10g10r10,
- NULL, fetch_scanline_a2b10g10r10_float,
- fetch_pixel_generic_lossy_32, fetch_pixel_a2b10g10r10_float,
+ fetch_scanline_generic_lossy_32, fetch_scanline_a2b10g10r10_float,
NULL, store_scanline_a2b10g10r10_float },
{ PIXMAN_x2b10g10r10,
- NULL, fetch_scanline_x2b10g10r10_float,
- fetch_pixel_generic_lossy_32, fetch_pixel_x2b10g10r10_float,
+ fetch_scanline_generic_lossy_32, fetch_scanline_x2b10g10r10_float,
NULL, store_scanline_x2b10g10r10_float },
/* YUV formats */
{ PIXMAN_yuy2,
fetch_scanline_yuy2, fetch_scanline_generic_float,
- fetch_pixel_yuy2, fetch_pixel_generic_float,
NULL, NULL },
{ PIXMAN_yv12,
fetch_scanline_yv12, fetch_scanline_generic_float,
- fetch_pixel_yv12, fetch_pixel_generic_float,
NULL, NULL },
{ PIXMAN_null },
@@ -1397,8 +1191,6 @@ setup_accessors (bits_image_t *image)
{
image->fetch_scanline_32 = info->fetch_scanline_32;
image->fetch_scanline_float = info->fetch_scanline_float;
- image->fetch_pixel_32 = info->fetch_pixel_32;
- image->fetch_pixel_float = info->fetch_pixel_float;
image->store_scanline_32 = info->store_scanline_32;
image->store_scanline_float = info->store_scanline_float;
diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index dcdcc699..b4016acf 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -56,13 +56,17 @@ static force_inline uint32_t
fetch_pixel_no_alpha (bits_image_t *image,
int x, int y, pixman_bool_t check_bounds)
{
+ uint32_t result;
+
if (check_bounds &&
(x < 0 || x >= image->width || y < 0 || y >= image->height))
{
return 0;
}
- return image->fetch_pixel_32 (image, x, y);
+ image->fetch_scanline_32 (image, x, y, 1, &result, NULL);
+
+ return result;
}
typedef uint32_t (* get_pixel_t) (bits_image_t *image,
@@ -407,7 +411,7 @@ fetch_pixel_general (bits_image_t *image, int x, int y, pixman_bool_t check_boun
return 0;
}
- pixel = image->fetch_pixel_32 (image, x, y);
+ image->fetch_scanline_32 (image, x, y, 1, &pixel, NULL);
if (image->common.alpha_map)
{
@@ -423,8 +427,8 @@ fetch_pixel_general (bits_image_t *image, int x, int y, pixman_bool_t check_boun
}
else
{
- pixel_a = image->common.alpha_map->fetch_pixel_32 (
- image->common.alpha_map, x, y);
+ image->common.alpha_map->fetch_scanline_32 (
+ image->common.alpha_map, x, y, 1, &pixel_a, NULL);
pixel_a = ALPHA_8 (pixel_a);
}
@@ -515,7 +519,7 @@ replicate_pixel_32 (bits_image_t * bits,
uint32_t color;
uint32_t *end;
- color = bits->fetch_pixel_32 (bits, x, y);
+ bits->fetch_scanline_32 (bits, x, y, 1, &color, NULL);
end = buffer + width;
while (buffer < end)
@@ -533,7 +537,7 @@ replicate_pixel_float (bits_image_t * bits,
argb_t *buffer = (argb_t *)b;
argb_t *end;
- color = bits->fetch_pixel_float (bits, x, y);
+ bits->fetch_scanline_float (bits, x, y, 1, (uint32_t *)&color, NULL);
end = buffer + width;
while (buffer < end)
diff --git a/pixman/pixman-noop.c b/pixman/pixman-noop.c
index e5989049..1ed5c688 100644
--- a/pixman/pixman-noop.c
+++ b/pixman/pixman-noop.c
@@ -59,7 +59,7 @@ noop_init_solid_narrow (pixman_iter_t *iter,
if (iter->image->type == SOLID)
color = image->solid.color_32;
else
- color = image->bits.fetch_pixel_32 (&image->bits, 0, 0);
+ image->bits.fetch_scanline_32 (&image->bits, 0, 0, 1, &color, NULL);
while (buffer < end)
*(buffer++) = color;
@@ -75,9 +75,14 @@ noop_init_solid_wide (pixman_iter_t *iter,
argb_t color;
if (iter->image->type == SOLID)
+ {
color = image->solid.color_float;
+ }
else
- color = image->bits.fetch_pixel_float (&image->bits, 0, 0);
+ {
+ image->bits.fetch_scanline_float (
+ &image->bits, 0, 0, 1, (uint32_t *)&color, NULL);
+ }
while (buffer < end)
*(buffer++) = color;
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 73108a01..f06d9fd9 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -64,14 +64,6 @@ typedef void (*fetch_scanline_t) (bits_image_t *image,
uint32_t *buffer,
const uint32_t *mask);
-typedef uint32_t (*fetch_pixel_32_t) (bits_image_t *image,
- int x,
- int y);
-
-typedef argb_t (*fetch_pixel_float_t) (bits_image_t *image,
- int x,
- int y);
-
typedef void (*store_scanline_t) (bits_image_t * image,
int x,
int y,
@@ -182,11 +174,9 @@ struct bits_image
int rowstride; /* in number of uint32_t's */
fetch_scanline_t fetch_scanline_32;
- fetch_pixel_32_t fetch_pixel_32;
store_scanline_t store_scanline_32;
fetch_scanline_t fetch_scanline_float;
- fetch_pixel_float_t fetch_pixel_float;
store_scanline_t store_scanline_float;
/* Used for indirect access to the bits */