[cairo] [PATCH, pixman] Implement get_scanline_64() correctly for solid fill images.
Soeren Sandmann
sandmann at daimi.au.dk
Fri Jan 22 17:46:43 PST 2010
Previously they would be evaluated at 8 bits and then expanded.
Soren
---
pixman/pixman-image.c | 2 +-
pixman/pixman-private.h | 5 ++++-
pixman/pixman-solid-fill.c | 35 ++++++++++++++++++++++++++++++++---
3 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index a4df4e5..c035eca 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -591,7 +591,7 @@ _pixman_image_is_opaque (pixman_image_t *image)
break;
case SOLID:
- if (ALPHA_8 (image->solid.color) != 0xff)
+ if (image->solid.color.alpha != 0xffff)
return FALSE;
break;
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index c99f2a2..40388aa 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -114,7 +114,10 @@ struct source_image
struct solid_fill
{
source_image_t common;
- uint32_t color; /* FIXME: shouldn't this be a pixman_color_t? */
+ pixman_color_t color;
+
+ uint32_t color_32;
+ uint64_t color_64;
};
struct gradient
diff --git a/pixman/pixman-solid-fill.c b/pixman/pixman-solid-fill.c
index 38675dc..48c999a 100644
--- a/pixman/pixman-solid-fill.c
+++ b/pixman/pixman-solid-fill.c
@@ -36,7 +36,7 @@ solid_fill_get_scanline_32 (pixman_image_t *image,
uint32_t mask_bits)
{
uint32_t *end = buffer + width;
- register uint32_t color = ((solid_fill_t *)image)->color;
+ uint32_t color = image->solid.color_32;
while (buffer < end)
*(buffer++) = color;
@@ -44,6 +44,23 @@ solid_fill_get_scanline_32 (pixman_image_t *image,
return;
}
+static void
+solid_fill_get_scanline_64 (pixman_image_t *image,
+ int x,
+ int y,
+ int width,
+ uint32_t * buffer,
+ const uint32_t *mask,
+ uint32_t mask_bits)
+{
+ uint64_t *b = (uint64_t *)buffer;
+ uint64_t *e = b + width;
+ uint64_t color = image->solid.color_64;
+
+ while (b < e)
+ *(b++) = color;
+}
+
static source_image_class_t
solid_fill_classify (pixman_image_t *image,
int x,
@@ -58,7 +75,7 @@ static void
solid_fill_property_changed (pixman_image_t *image)
{
image->common.get_scanline_32 = solid_fill_get_scanline_32;
- image->common.get_scanline_64 = _pixman_image_get_scanline_generic_64;
+ image->common.get_scanline_64 = solid_fill_get_scanline_64;
}
static uint32_t
@@ -71,6 +88,16 @@ color_to_uint32 (const pixman_color_t *color)
(color->blue >> 8);
}
+static uint64_t
+color_to_uint64 (const pixman_color_t *color)
+{
+ return
+ ((uint64_t)color->alpha << 48) |
+ ((uint64_t)color->red << 32) |
+ ((uint64_t)color->green << 16) |
+ ((uint64_t)color->blue);
+}
+
PIXMAN_EXPORT pixman_image_t *
pixman_image_create_solid_fill (pixman_color_t *color)
{
@@ -80,7 +107,9 @@ pixman_image_create_solid_fill (pixman_color_t *color)
return NULL;
img->type = SOLID;
- img->solid.color = color_to_uint32 (color);
+ img->solid.color = *color;
+ img->solid.color_32 = color_to_uint32 (color);
+ img->solid.color_64 = color_to_uint64 (color);
img->source.class = SOURCE_IMAGE_CLASS_UNKNOWN;
img->common.classify = solid_fill_classify;
--
1.6.5.2
More information about the cairo
mailing list