[cairo] [PATCH 2/3] Support a different pixel format for HDC

Uli Schlachter psychon at znc.in
Thu Apr 17 02:48:55 PDT 2014


On 17.04.2014 11:06, LRN wrote:
> Add cairo API to set up a Win32 surface for an HDC with an alpha channel.

This adds alpha support to cairo-win32, but doesn't add support for this to the
test suite. IMO this should also contain the necessary changes to boilerplate/
and contain some information about the test suite results (and compare it to
cairo-win32-without-alpha?).

> Signed-off-by: Bas Schouten <bas.schouten at live.nl>

I just noticed that your three patches are all signed off by different persons.
None of these is you. What's up with this? Are we really sure that the original
authors are OK with submitting this code to cairo? Why didn't they do so
themselves? Where did you find the patches?

> ---
>  src/cairo-win32.h                       |  3 ++
>  src/win32/cairo-win32-display-surface.c | 64 ++++++++++++++++++++++-----------
>  2 files changed, 47 insertions(+), 21 deletions(-)
> 
> diff --git a/src/cairo-win32.h b/src/cairo-win32.h
> index 3d2e1c6..2dd8934 100644
> --- a/src/cairo-win32.h
> +++ b/src/cairo-win32.h
> @@ -49,6 +49,9 @@ cairo_public cairo_surface_t *
>  cairo_win32_surface_create (HDC hdc);
> 
>  cairo_public cairo_surface_t *
> +cairo_win32_surface_create_with_alpha (HDC hdc);
> +
> +cairo_public cairo_surface_t *
>  cairo_win32_printing_surface_create (HDC hdc);
> 
>  cairo_public cairo_surface_t *
> diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
> index 965f2c4..d002ce2 100644
> --- a/src/win32/cairo-win32-display-surface.c
> +++ b/src/win32/cairo-win32-display-surface.c
> @@ -916,33 +916,14 @@ static const cairo_surface_backend_t cairo_win32_display_surface_backend = {
>   *              multiplied by all the src components.
>   */
> 
> -/**
> - * cairo_win32_surface_create:
> - * @hdc: the DC to create a surface for
> - *
> - * Creates a cairo surface that targets the given DC.  The DC will be
> - * queried for its initial clip extents, and this will be used as the
> - * size of the cairo surface.  The resulting surface will always be of
> - * format %CAIRO_FORMAT_RGB24; should you need another surface format,
> - * you will need to create one through
> - * cairo_win32_surface_create_with_dib().
> - *
> - * Return value: the newly created surface
> - *
> - * Since: 1.0
> - **/
> -cairo_surface_t *
> -cairo_win32_surface_create (HDC hdc)
> +static cairo_surface_t *
> +cairo_win32_surface_create_internal (HDC hdc, cairo_format_t format)
>  {
>      cairo_win32_display_surface_t *surface;
> 
> -    cairo_format_t format;
>      cairo_status_t status;
>      cairo_device_t *device;
> 
> -    /* Assume that everything coming in as a HDC is RGB24 */
> -    format = CAIRO_FORMAT_RGB24;
> -
>      surface = malloc (sizeof (*surface));
>      if (surface == NULL)
>  	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
> @@ -977,6 +958,48 @@ cairo_win32_surface_create (HDC hdc)
>  }
> 
>  /**
> + * cairo_win32_surface_create:
> + * @hdc: the DC to create a surface for
> + *
> + * Creates a cairo surface that targets the given DC.  The DC will be
> + * queried for its initial clip extents, and this will be used as the
> + * size of the cairo surface.  The resulting surface will always be of
> + * format %CAIRO_FORMAT_RGB24; should you need another surface format,
> + * you will need to create one through
> + * cairo_win32_surface_create_with_dib() or call
> + * cairo_win32_surface_create_with_alpha().
> + *
> + * Return value: the newly created surface
> + *
> + * Since: 1.0
> + **/
> +cairo_surface_t *
> +cairo_win32_surface_create (HDC hdc)
> +{
> +    return cairo_win32_surface_create_internal(hdc, CAIRO_FORMAT_RGB24);
> +}
> +
> +/**
> + * cairo_win32_surface_create_with_alpha:
> + * @hdc: the DC to create a surface for
> + *
> + * Creates a cairo surface that targets the given DC.  The DC will be
> + * queried for its initial clip extents, and this will be used as the
> + * size of the cairo surface.  The resulting surface will always be of
> + * format %CAIRO_FORMAT_ARGB32 (as supported for transparent windows with
> + * Windows Vista and up).
> + *
> + * Return value: the newly created surface
> + *
> + * Since: 1.12
> + **/
> +cairo_surface_t *
> +cairo_win32_surface_create_with_alpha (HDC hdc)
> +{
> +    return cairo_win32_surface_create_internal(hdc, CAIRO_FORMAT_ARGB32);
> +}
> +
> +/**
>   * cairo_win32_surface_create_with_dib:
>   * @format: format of pixels in the surface to create
>   * @width: width of the surface, in pixels
> 

Uli
-- 
99 little bugs in the code
99 little bugs in the code
Take one down, patch it around
117 little bugs in the code
  -- @irqed


More information about the cairo mailing list