[cairo] [PATCH 3/3] Adjust assertions and checks to handle more pixel formats

Uli Schlachter psychon at znc.in
Thu Apr 17 02:46:15 PDT 2014


On 17.04.2014 11:07, LRN wrote:
> Now that ARGB32 format is available, allow it to be used, and use it
> where appropriate.

I would squash this into the previous commit. Without this, the previous commit
just adds some really broken API.

Also, why is this patch correct? Are you sure that all of this code really
handles the ARGB32 format correctly?

> Signed-off-by: Руслан Ижбулатов <lrn1986 at gmail.com>
> ---
>  src/win32/cairo-win32-display-surface.c | 4 ++--
>  src/win32/cairo-win32-surface.c         | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
> index d002ce2..5c01721 100644
> --- a/src/win32/cairo-win32-display-surface.c
> +++ b/src/win32/cairo-win32-display-surface.c
> @@ -372,7 +372,7 @@ _cairo_win32_display_surface_create_similar (void	    *abstract_src,
>       */
>      if (!(src->is_dib || content & CAIRO_CONTENT_ALPHA)) {
>  	/* try to create a ddb */
> -	new_surf = cairo_win32_surface_create_with_ddb (src->win32.dc, CAIRO_FORMAT_RGB24, width, height);
> +	new_surf = cairo_win32_surface_create_with_ddb (src->win32.dc, CAIRO_FORMAT_ARGB32, width, height);

I don't like this. It should only use ARGB32 when really necessary, not always.
Since this was using RGB24 before, there must be cases when it is still enough
to use RGB24.

>  	if (new_surf->status)
>  	    new_surf = NULL;
> @@ -1049,7 +1049,7 @@ cairo_win32_surface_create_with_ddb (HDC hdc,
>      HDC screen_dc, ddb_dc;
>      HBITMAP saved_dc_bitmap;
> 
> -    if (format != CAIRO_FORMAT_RGB24)
> +    if (format != CAIRO_FORMAT_RGB24 && format != CAIRO_FORMAT_ARGB32)
>  	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
>  /* XXX handle these eventually
>  	format != CAIRO_FORMAT_A8 ||
> diff --git a/src/win32/cairo-win32-surface.c b/src/win32/cairo-win32-surface.c
> index 7cd46fc..081eeab 100644
> --- a/src/win32/cairo-win32-surface.c
> +++ b/src/win32/cairo-win32-surface.c
> @@ -227,7 +227,7 @@ _cairo_win32_surface_emit_glyphs (cairo_win32_surface_t *dst,
> 
>      /* We can only handle opaque solid color sources and destinations */
>      assert (_cairo_pattern_is_opaque_solid(source));
> -    assert (dst->format == CAIRO_FORMAT_RGB24);
> +    assert (dst->format == CAIRO_FORMAT_RGB24 || dst->format == CAIRO_FORMAT_ARGB32);
> 
>      solid_pattern = (cairo_solid_pattern_t *)source;
>      color = RGB(((int)solid_pattern->color.red_short) >> 8,
> 

Uli
-- 
“Cold. Cold. Cold. Cold. Cold. Cold. Cold. Cold. Cold. Cold.” – Anna


More information about the cairo mailing list