mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 14:38:13 +02:00
[cairo-ps-surface] Tidy return from _analyze_image_transparency().
_analyze_image_transparency() only returned SUCCESS, so use the return parameter to pass back the transparency type instead of using an out parameter.
This commit is contained in:
parent
bc83e028b8
commit
2eb03b8cf2
1 changed files with 13 additions and 24 deletions
|
|
@ -1346,43 +1346,38 @@ color_is_gray (double red, double green, double blue)
|
|||
fabs (red - blue) < epsilon);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_analyze_image_transparency (cairo_image_surface_t *image,
|
||||
cairo_image_transparency_t *transparency)
|
||||
static cairo_image_transparency_t
|
||||
_analyze_image_transparency (cairo_image_surface_t *image)
|
||||
{
|
||||
int x, y;
|
||||
cairo_image_transparency_t transparency;
|
||||
|
||||
if (image->format == CAIRO_FORMAT_RGB24) {
|
||||
*transparency = CAIRO_IMAGE_IS_OPAQUE;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
if (image->format == CAIRO_FORMAT_RGB24)
|
||||
return CAIRO_IMAGE_IS_OPAQUE;
|
||||
|
||||
if (image->format != CAIRO_FORMAT_ARGB32) {
|
||||
/* If the PS surface does not support the image format, assume
|
||||
* that it does have alpha. The image will be converted to
|
||||
* rgb24 when the PS surface blends the image into the page
|
||||
* color to remove the transparency. */
|
||||
*transparency = CAIRO_IMAGE_HAS_ALPHA;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
return CAIRO_IMAGE_HAS_ALPHA;
|
||||
}
|
||||
|
||||
*transparency = CAIRO_IMAGE_IS_OPAQUE;
|
||||
transparency = CAIRO_IMAGE_IS_OPAQUE;
|
||||
for (y = 0; y < image->height; y++) {
|
||||
int a;
|
||||
uint32_t *pixel = (uint32_t *) (image->data + y * image->stride);
|
||||
|
||||
for (x = 0; x < image->width; x++, pixel++) {
|
||||
a = (*pixel & 0xff000000) >> 24;
|
||||
int a = (*pixel & 0xff000000) >> 24;
|
||||
if (a > 0 && a < 255) {
|
||||
*transparency = CAIRO_IMAGE_HAS_ALPHA;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
return CAIRO_IMAGE_HAS_ALPHA;
|
||||
} else if (a == 0) {
|
||||
*transparency = CAIRO_IMAGE_HAS_BILEVEL_ALPHA;
|
||||
transparency = CAIRO_IMAGE_HAS_BILEVEL_ALPHA;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
return transparency;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
|
|
@ -1403,10 +1398,7 @@ _cairo_ps_surface_analyze_surface_pattern_transparency (cairo_ps_surface_t
|
|||
if (image->base.status)
|
||||
return image->base.status;
|
||||
|
||||
status = _analyze_image_transparency (image, &transparency);
|
||||
if (status)
|
||||
goto RELEASE_SOURCE;
|
||||
|
||||
transparency = _analyze_image_transparency (image);
|
||||
switch (transparency) {
|
||||
case CAIRO_IMAGE_IS_OPAQUE:
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
|
|
@ -1426,7 +1418,6 @@ _cairo_ps_surface_analyze_surface_pattern_transparency (cairo_ps_surface_t
|
|||
break;
|
||||
}
|
||||
|
||||
RELEASE_SOURCE:
|
||||
_cairo_surface_release_source_image (pattern->surface, image, image_extra);
|
||||
|
||||
return status;
|
||||
|
|
@ -1853,9 +1844,7 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface,
|
|||
if (image->base.status)
|
||||
return image->base.status;
|
||||
|
||||
status = _analyze_image_transparency (image, &transparency);
|
||||
if (status)
|
||||
return status;
|
||||
transparency = _analyze_image_transparency (image);
|
||||
|
||||
/* PostScript can not represent the alpha channel, so we blend the
|
||||
current image over a white (or black for CONTENT_COLOR
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue