mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 04:08:13 +02:00
pdiff: convert RGB24 image values to ARGB32 on read
To avoid reading a potentially garbage alpha channel when users of pdiff_compare pass in RGB24 images, if the format is RGB24, force the alpha channel to be 0xff. This commit also updates CI to adjust for the new tests that have started/stopped failing. New failures often are cases where the reference image has alpha transparency, but the test output does not; new passing tests may indicate that the unused alpha channel of an RGB24 image was garbage, but now is ignored.
This commit is contained in:
parent
a8012953ed
commit
0490607584
14 changed files with 72 additions and 26 deletions
|
|
@ -18,3 +18,4 @@ text-antialias-subpixel-vrgb
|
|||
text-pattern
|
||||
text-rotate
|
||||
text-unhinted-metrics
|
||||
user-font-mask
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
bug-source-cu
|
||||
clip-text
|
||||
culled-glyphs
|
||||
dash-zero-length
|
||||
degenerate-path
|
||||
extended-blend-alpha-mask
|
||||
fill-and-stroke
|
||||
fill-missed-stop
|
||||
finer-grained-fallbacks
|
||||
ft-show-glyphs-positioning
|
||||
ft-text-vertical-layout-type1
|
||||
ft-text-vertical-layout-type3
|
||||
gradient-alpha
|
||||
gradient-constant-alpha
|
||||
halo-transform
|
||||
new-sub-path
|
||||
overlapping-glyphs
|
||||
record1414x-select-font-face
|
||||
record1414x-text-transform
|
||||
rel-path
|
||||
shifted-operator
|
||||
show-glyphs-advance
|
||||
subsurface
|
||||
|
|
@ -20,3 +30,4 @@ text-antialias-subpixel-vrgb
|
|||
text-pattern
|
||||
text-rotate
|
||||
text-unhinted-metrics
|
||||
user-font-mask
|
||||
|
|
|
|||
|
|
@ -2,17 +2,18 @@ bug-361
|
|||
bug-431
|
||||
bug-448
|
||||
bug-image-compositor
|
||||
bug-source-cu
|
||||
coverage-rhombus
|
||||
culled-glyphs
|
||||
extended-blend
|
||||
extended-blend-alpha
|
||||
extended-blend-alpha-mask
|
||||
extended-blend-mask
|
||||
extended-blend-solid
|
||||
extended-blend-solid-alpha
|
||||
fill-missed-stop
|
||||
ft-show-glyphs-positioning
|
||||
ft-text-vertical-layout-type1
|
||||
ft-text-vertical-layout-type3
|
||||
gradient-alpha
|
||||
negative-stride-image
|
||||
operator-www
|
||||
radial-gradient
|
||||
|
|
@ -41,6 +42,8 @@ record-replay-extend-reflect
|
|||
record-replay-extend-repeat
|
||||
record-select-font-face
|
||||
record-text-transform
|
||||
rel-path
|
||||
set-source
|
||||
shifted-operator
|
||||
simple-edge
|
||||
subsurface
|
||||
|
|
|
|||
|
|
@ -3,12 +3,19 @@ clear-source
|
|||
clip-text
|
||||
coverage-rectangles
|
||||
culled-glyphs
|
||||
dash-zero-length
|
||||
degenerate-path
|
||||
extended-blend-alpha-mask
|
||||
fill-and-stroke
|
||||
fill-missed-stop
|
||||
finer-grained-fallbacks
|
||||
ft-show-glyphs-positioning
|
||||
ft-text-vertical-layout-type1
|
||||
ft-text-vertical-layout-type3
|
||||
gradient-alpha
|
||||
gradient-constant-alpha
|
||||
halo-transform
|
||||
new-sub-path
|
||||
overlapping-glyphs
|
||||
pthread-same-source
|
||||
record1414x-fill-alpha
|
||||
|
|
@ -22,6 +29,7 @@ recording-surface-extend-reflect
|
|||
recording-surface-extend-repeat
|
||||
recording-surface-over
|
||||
recording-surface-source
|
||||
rel-path
|
||||
scale-offset-similar
|
||||
show-glyphs-advance
|
||||
subsurface
|
||||
|
|
|
|||
|
|
@ -1,15 +1,21 @@
|
|||
clip-text
|
||||
coverage-intersecting-triangles
|
||||
culled-glyphs
|
||||
dash-zero-length
|
||||
degenerate-path
|
||||
extended-blend-alpha-mask
|
||||
fallback
|
||||
fill-missed-stop
|
||||
ft-show-glyphs-positioning
|
||||
ft-text-vertical-layout-type1
|
||||
ft-text-vertical-layout-type3
|
||||
halo-transform
|
||||
new-sub-path
|
||||
overlapping-glyphs
|
||||
record1414x-select-font-face
|
||||
record1414x-text-transform
|
||||
record-replay-extend-pad
|
||||
rel-path
|
||||
show-glyphs-advance
|
||||
subsurface
|
||||
subsurface-scale
|
||||
|
|
|
|||
|
|
@ -8,11 +8,15 @@ clip-stroke-unbounded
|
|||
clip-twice
|
||||
coverage-intersecting-triangles
|
||||
culled-glyphs
|
||||
dash-zero-length
|
||||
degenerate-path
|
||||
extended-blend-alpha-mask
|
||||
fallback
|
||||
fill-missed-stop
|
||||
ft-text-vertical-layout-type1
|
||||
hatchings
|
||||
mask
|
||||
new-sub-path
|
||||
operator-source
|
||||
radial-gradient
|
||||
radial-gradient-mask
|
||||
|
|
@ -25,8 +29,10 @@ recording-surface-extend-none
|
|||
recording-surface-over
|
||||
record-neg-extents-bounded
|
||||
record-paint-alpha-solid-clip
|
||||
record-replay-extend-pad
|
||||
record-replay-extend-reflect
|
||||
record-replay-extend-repeat
|
||||
rel-path
|
||||
rotated-clip
|
||||
text-antialias-subpixel
|
||||
text-antialias-subpixel-bgr
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ arc-looping-dash
|
|||
bug-51910
|
||||
bug-84115
|
||||
bug-image-compositor
|
||||
bug-source-cu
|
||||
bug-spline
|
||||
caps-05
|
||||
caps-1
|
||||
|
|
@ -54,8 +53,6 @@ partial-clip-text-bottom
|
|||
partial-clip-text-left
|
||||
partial-coverage-reference
|
||||
partial-coverage-three-quarter-reference
|
||||
push-group
|
||||
push-group-color
|
||||
radial-gradient
|
||||
radial-gradient-mask
|
||||
radial-gradient-mask-source
|
||||
|
|
@ -115,6 +112,7 @@ text-antialias-subpixel-rgb
|
|||
text-antialias-subpixel-vbgr
|
||||
text-antialias-subpixel-vrgb
|
||||
text-glyph-range
|
||||
text-pattern
|
||||
text-rotate
|
||||
text-transform
|
||||
tighten-bounds
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@ partial-clip-text-bottom
|
|||
partial-clip-text-left
|
||||
partial-coverage-reference
|
||||
partial-coverage-three-quarter-reference
|
||||
push-group
|
||||
push-group-color
|
||||
radial-outer-focus
|
||||
record1414x-fill-alpha
|
||||
record1414x-self-intersecting
|
||||
|
|
@ -102,6 +100,7 @@ text-antialias-subpixel-rgb
|
|||
text-antialias-subpixel-vbgr
|
||||
text-antialias-subpixel-vrgb
|
||||
text-glyph-range
|
||||
text-pattern
|
||||
text-rotate
|
||||
text-transform
|
||||
tighten-bounds
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ text-antialias-subpixel-rgb
|
|||
text-antialias-subpixel-vbgr
|
||||
text-antialias-subpixel-vrgb
|
||||
text-glyph-range
|
||||
text-pattern
|
||||
text-rotate
|
||||
text-transform
|
||||
tighten-bounds
|
||||
|
|
|
|||
|
|
@ -28,10 +28,12 @@ dash-infinite-loop
|
|||
dash-scale
|
||||
dash-zero-length
|
||||
degenerate-curve-to
|
||||
degenerate-path
|
||||
degenerate-pen
|
||||
degenerate-rel-curve-to
|
||||
extended-blend-alpha-mask
|
||||
fallback
|
||||
fill-missed-stop
|
||||
filter-bilinear-extents
|
||||
finer-grained-fallbacks
|
||||
font-matrix-translation
|
||||
|
|
@ -52,6 +54,7 @@ line-width-tolerance
|
|||
long-dashed-lines
|
||||
mask-transformed-image
|
||||
mask-transformed-similar
|
||||
new-sub-path
|
||||
operator-alpha-alpha
|
||||
over-above-source
|
||||
over-around-source
|
||||
|
|
@ -71,6 +74,7 @@ recording-surface-extend-none
|
|||
recording-surface-over
|
||||
rectilinear-miter-limit
|
||||
reflected-stroke
|
||||
rel-path
|
||||
select-font-face
|
||||
self-copy
|
||||
shifted-operator
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@ clip-text
|
|||
coverage-intersecting-triangles
|
||||
culled-glyphs
|
||||
curve-to-as-line-to
|
||||
dash-zero-length
|
||||
degenerate-path
|
||||
extended-blend-alpha-mask
|
||||
fallback
|
||||
fill-and-stroke
|
||||
fill-and-stroke-alpha
|
||||
fill-and-stroke-alpha-add
|
||||
fill-missed-stop
|
||||
finer-grained-fallbacks
|
||||
ft-show-glyphs-positioning
|
||||
ft-text-vertical-layout-type1
|
||||
|
|
@ -22,6 +25,7 @@ infinite-join
|
|||
large-twin-antialias-mixed
|
||||
leaky-polygon
|
||||
mask
|
||||
new-sub-path
|
||||
operator-clear
|
||||
operator-source
|
||||
overlapping-glyphs
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ bug-51910
|
|||
bug-84115
|
||||
bug-extents
|
||||
bug-image-compositor
|
||||
bug-source-cu
|
||||
bug-spline
|
||||
caps-joins-05
|
||||
caps-joins-curve
|
||||
|
|
@ -76,8 +75,6 @@ partial-coverage-reference
|
|||
partial-coverage-three-quarter-reference
|
||||
path-stroke-twice
|
||||
pthread-show-text
|
||||
push-group
|
||||
push-group-color
|
||||
radial-gradient
|
||||
radial-gradient-mask
|
||||
radial-gradient-mask-source
|
||||
|
|
|
|||
|
|
@ -73,8 +73,6 @@ partial-coverage-reference
|
|||
partial-coverage-three-quarter-reference
|
||||
path-stroke-twice
|
||||
pthread-show-text
|
||||
push-group
|
||||
push-group-color
|
||||
radial-outer-focus
|
||||
record1414x-fill-alpha
|
||||
record1414x-select-font-face
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include "lpyramid.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -171,18 +172,21 @@ XYZToLAB (float x, float y, float z, float *L, float *A, float *B)
|
|||
}
|
||||
|
||||
static uint32_t
|
||||
_get_pixel (const uint32_t *data, int i)
|
||||
_get_pixel (const uint32_t *data, int i, cairo_format_t format)
|
||||
{
|
||||
return data[i];
|
||||
if (format == CAIRO_FORMAT_ARGB32)
|
||||
return data[i];
|
||||
else
|
||||
return data[i] | 0xff000000;
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
_get_red (const uint32_t *data, int i)
|
||||
_get_red (const uint32_t *data, int i, cairo_format_t format)
|
||||
{
|
||||
uint32_t pixel;
|
||||
uint8_t alpha;
|
||||
|
||||
pixel = _get_pixel (data, i);
|
||||
pixel = _get_pixel (data, i, format);
|
||||
alpha = (pixel & 0xff000000) >> 24;
|
||||
if (alpha == 0)
|
||||
return 0;
|
||||
|
|
@ -191,12 +195,12 @@ _get_red (const uint32_t *data, int i)
|
|||
}
|
||||
|
||||
static unsigned char
|
||||
_get_green (const uint32_t *data, int i)
|
||||
_get_green (const uint32_t *data, int i, cairo_format_t format)
|
||||
{
|
||||
uint32_t pixel;
|
||||
uint8_t alpha;
|
||||
|
||||
pixel = _get_pixel (data, i);
|
||||
pixel = _get_pixel (data, i, format);
|
||||
alpha = (pixel & 0xff000000) >> 24;
|
||||
if (alpha == 0)
|
||||
return 0;
|
||||
|
|
@ -205,12 +209,12 @@ _get_green (const uint32_t *data, int i)
|
|||
}
|
||||
|
||||
static unsigned char
|
||||
_get_blue (const uint32_t *data, int i)
|
||||
_get_blue (const uint32_t *data, int i, cairo_format_t format)
|
||||
{
|
||||
uint32_t pixel;
|
||||
uint8_t alpha;
|
||||
|
||||
pixel = _get_pixel (data, i);
|
||||
pixel = _get_pixel (data, i, format);
|
||||
alpha = (pixel & 0xff000000) >> 24;
|
||||
if (alpha == 0)
|
||||
return 0;
|
||||
|
|
@ -269,6 +273,7 @@ pdiff_compare (cairo_surface_t *surface_a,
|
|||
float F_freq[MAX_PYR_LEVELS - 2];
|
||||
float csf_max;
|
||||
const uint32_t *data_a, *data_b;
|
||||
cairo_format_t format_a, format_b;
|
||||
|
||||
unsigned int pixels_failed;
|
||||
|
||||
|
|
@ -277,6 +282,11 @@ pdiff_compare (cairo_surface_t *surface_a,
|
|||
if (w < 3 || h < 3) /* too small for the Laplacian convolution */
|
||||
return -1;
|
||||
|
||||
format_a = cairo_image_surface_get_format (surface_a);
|
||||
format_b = cairo_image_surface_get_format (surface_b);
|
||||
assert (format_a == CAIRO_FORMAT_RGB24 || format_a == CAIRO_FORMAT_ARGB32);
|
||||
assert (format_b == CAIRO_FORMAT_RGB24 || format_b == CAIRO_FORMAT_ARGB32);
|
||||
|
||||
aX = xmalloc (dim * sizeof (float));
|
||||
aY = xmalloc (dim * sizeof (float));
|
||||
aZ = xmalloc (dim * sizeof (float));
|
||||
|
|
@ -297,15 +307,15 @@ pdiff_compare (cairo_surface_t *surface_a,
|
|||
for (x = 0; x < w; x++) {
|
||||
float r, g, b, l;
|
||||
i = x + y * w;
|
||||
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);
|
||||
r = powf(_get_red (data_a, i, format_a) / 255.0f, gamma);
|
||||
g = powf(_get_green (data_a, i, format_a) / 255.0f, gamma);
|
||||
b = powf(_get_blue (data_a, i, format_a) / 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 (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);
|
||||
r = powf(_get_red (data_b, i, format_b) / 255.0f, gamma);
|
||||
g = powf(_get_green (data_b, i, format_b) / 255.0f, gamma);
|
||||
b = powf(_get_blue (data_b, i, format_b) / 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]);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue