summaryrefslogtreecommitdiff
path: root/test/pdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-08-22 23:09:13 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-08-26 23:01:30 +0100
commit08ea9d1f2a2210a1f333f3425eb141c2f5f1399c (patch)
tree671d42ca17f220e6c3dd97aeaf097d27f4ee5d6b /test/pdiff
parent590ccb900605f9bdf30f02f76b7dd622acb9a27d (diff)
downloadcairo-08ea9d1f2a2210a1f333f3425eb141c2f5f1399c.tar.gz
[pdiff] Get the surface data pointer once.
Don't call cairo_image_surface_get_data() for every single component of the two surfaces to compare.
Diffstat (limited to 'test/pdiff')
-rw-r--r--test/pdiff/pdiff.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/test/pdiff/pdiff.c b/test/pdiff/pdiff.c
index 3f472f3b9..c4f7d5310 100644
--- a/test/pdiff/pdiff.c
+++ b/test/pdiff/pdiff.c
@@ -175,24 +175,19 @@ XYZToLAB (float x, float y, float z, float *L, float *A, float *B)
}
static uint32_t
-_get_pixel (cairo_surface_t *surface, int i)
+_get_pixel (const uint32_t *data, int i)
{
- uint32_t *data;
-
- data = (uint32_t *) cairo_image_surface_get_data (surface);
return data[i];
}
static unsigned char
-_get_red (cairo_surface_t *surface, int i)
+_get_red (const uint32_t *data, int i)
{
uint32_t pixel;
uint8_t alpha;
- pixel = _get_pixel (surface, i);
-
+ pixel = _get_pixel (data, i);
alpha = (pixel & 0xff000000) >> 24;
-
if (alpha == 0)
return 0;
else
@@ -200,15 +195,13 @@ _get_red (cairo_surface_t *surface, int i)
}
static unsigned char
-_get_green (cairo_surface_t *surface, int i)
+_get_green (const uint32_t *data, int i)
{
uint32_t pixel;
uint8_t alpha;
- pixel = _get_pixel (surface, i);
-
+ pixel = _get_pixel (data, i);
alpha = (pixel & 0xff000000) >> 24;
-
if (alpha == 0)
return 0;
else
@@ -216,15 +209,13 @@ _get_green (cairo_surface_t *surface, int i)
}
static unsigned char
-_get_blue (cairo_surface_t *surface, int i)
+_get_blue (const uint32_t *data, int i)
{
uint32_t pixel;
uint8_t alpha;
- pixel = _get_pixel (surface, i);
-
+ pixel = _get_pixel (data, i);
alpha = (pixel & 0xff000000) >> 24;
-
if (alpha == 0)
return 0;
else
@@ -281,6 +272,7 @@ pdiff_compare (cairo_surface_t *surface_a,
float cpd[MAX_PYR_LEVELS];
float F_freq[MAX_PYR_LEVELS - 2];
float csf_max;
+ const uint32_t *data_a, *data_b;
unsigned int pixels_failed;
@@ -303,19 +295,21 @@ pdiff_compare (cairo_surface_t *surface_a,
aB = xmalloc (dim * sizeof (float));
bB = xmalloc (dim * sizeof (float));
+ data_a = (uint32_t *) cairo_image_surface_get_data (surface_a);
+ data_b = (uint32_t *) cairo_image_surface_get_data (surface_b);
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
float r, g, b, l;
i = x + y * w;
- r = powf(_get_red (surface_a, i) / 255.0f, gamma);
- g = powf(_get_green (surface_a, i) / 255.0f, gamma);
- b = powf(_get_blue (surface_a, i) / 255.0f, gamma);
+ r = powf(_get_red (data_a, i) / 255.0f, gamma);
+ g = powf(_get_green (data_a, i) / 255.0f, gamma);
+ b = powf(_get_blue (data_a, i) / 255.0f, gamma);
AdobeRGBToXYZ(r,g,b,&aX[i],&aY[i],&aZ[i]);
XYZToLAB(aX[i], aY[i], aZ[i], &l, &aA[i], &aB[i]);
- r = powf(_get_red (surface_b, i) / 255.0f, gamma);
- g = powf(_get_green (surface_b, i) / 255.0f, gamma);
- b = powf(_get_blue (surface_b, i) / 255.0f, gamma);
+ r = powf(_get_red (data_b, i) / 255.0f, gamma);
+ g = powf(_get_green (data_b, i) / 255.0f, gamma);
+ b = powf(_get_blue (data_b, i) / 255.0f, gamma);
AdobeRGBToXYZ(r,g,b,&bX[i],&bY[i],&bZ[i]);
XYZToLAB(bX[i], bY[i], bZ[i], &l, &bA[i], &bB[i]);