third_party/cairo/src/win32/cairo-win32-display-surface.c
cairo_surface_t *
cairo_win32_surface_create_with_format (HDC hdc, cairo_format_t format)
{
    cairo_win32_display_surface_t *surface;

    cairo_status_t status;
    cairo_device_t *device;

    switch (format) {
    default:
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
    case CAIRO_FORMAT_ARGB32:
    case CAIRO_FORMAT_RGB24:
	break;
    }

    surface = _cairo_malloc (sizeof (*surface));
    if (surface == NULL)
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));

    status = _cairo_win32_save_initial_clip (hdc, surface);
    if (status) {
	free (surface);
	return _cairo_surface_create_in_error (status);
    }

    surface->image = NULL;
    surface->fallback = NULL;
    surface->win32.format = format;

    surface->win32.dc = hdc;
    surface->bitmap = NULL;
    surface->is_dib = FALSE;
    surface->saved_dc_bitmap = NULL;

    surface->win32.flags = _cairo_win32_flags_for_dc (surface->win32.dc, format);

    device = _cairo_win32_device_get ();

    _cairo_surface_init (&surface->win32.base,
			 &cairo_win32_display_surface_backend,
			 device,
			 _cairo_content_from_format (format),
			 FALSE); /* is_vector */

    cairo_device_destroy (device);

    return &surface->win32.base;
}
/**
 * cairo_win32_surface_create_with_format:
 * @hdc: the DC to create a surface for
 * @format: format of pixels in the surface to create
 *
 * 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.
 *
 * Supported formats are:
 * %CAIRO_FORMAT_ARGB32
 * %CAIRO_FORMAT_RGB24
 *
 * Note: @format only tells cairo how to draw on the surface, not what
 * the format of the surface is. Namely, cairo does not (and cannot)
 * check that @hdc actually supports alpha-transparency.
 *
 * Return value: the newly created surface, NULL on failure
 *
 * Since: 1.14
 **/
@hdc: the DC to create a surface for
@format: format of pixels in the surface to create

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.



@format only tells cairo how to draw on the surface, not what
the format of the surface is. Namely, cairo does not (and cannot)
check that @hdc actually supports alpha-transparency.

Return value: the newly created surface, NULL on failure


@hdc : the DC to create a surface for @format : format of pixels in the surface to create 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 . @format only tells cairo how to draw on the surface not what the format of the surface is . Namely cairo does not ( and cannot ) check that @hdc actually supports alpha - transparency . Return value : the newly created surface NULL on failure
cairo_surface_t *
cairo_win32_surface_create_with_format (HDC hdc, cairo_format_t format)
{
    cairo_win32_display_surface_t *surface;
    cairo_status_t status;
    cairo_device_t *device;
    switch (format) {
    default:
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
    case CAIRO_FORMAT_ARGB32:
    case CAIRO_FORMAT_RGB24:
	break;
    }
    surface = _cairo_malloc (sizeof (*surface));
    if (surface == NULL)
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
    status = _cairo_win32_save_initial_clip (hdc, surface);
    if (status) {
	free (surface);
	return _cairo_surface_create_in_error (status);
    }
    surface->image = NULL;
    surface->fallback = NULL;
    surface->win32.format = format;
    surface->win32.dc = hdc;
    surface->bitmap = NULL;
    surface->is_dib = FALSE;
    surface->saved_dc_bitmap = NULL;
    surface->win32.flags = _cairo_win32_flags_for_dc (surface->win32.dc, format);
    device = _cairo_win32_device_get ();
    _cairo_surface_init (&surface->win32.base,
			 &cairo_win32_display_surface_backend,
			 device,
			 _cairo_content_from_format (format),
			 FALSE); 
    cairo_device_destroy (device);
    return &surface->win32.base;
}
cairo_surface_t * cairo_win32_surface_create_with_format ( HDC hdc , cairo_format_t format ) { cairo_win32_display_surface_t * surface ; cairo_status_t status ; cairo_device_t * device ; switch ( format ) { default : return _cairo_surface_create_in_error ( _cairo_error ( CAIRO_STATUS_INVALID_FORMAT ) ) ; case CAIRO_FORMAT_ARGB32 : case CAIRO_FORMAT_RGB24 : break ; } surface = _cairo_malloc ( sizeof ( * surface ) ) ; if ( surface == NULL ) return _cairo_surface_create_in_error ( _cairo_error ( CAIRO_STATUS_NO_MEMORY ) ) ; status = _cairo_win32_save_initial_clip ( hdc , surface ) ; if ( status ) { free ( surface ) ; return _cairo_surface_create_in_error ( status ) ; } surface -> image = NULL ; surface -> fallback = NULL ; surface -> win32 . format = format ; surface -> win32 . dc = hdc ; surface -> bitmap = NULL ; surface -> is_dib = FALSE ; surface -> saved_dc_bitmap = NULL ; surface -> win32 . flags = _cairo_win32_flags_for_dc ( surface -> win32 . dc , format ) ; device = _cairo_win32_device_get ( ) ; _cairo_surface_init ( & surface -> win32 . base , & cairo_win32_display_surface_backend , device , _cairo_content_from_format ( format ) , FALSE ) ; cairo_device_destroy ( device ) ; return & surface -> win32 . base ; }
cairo_win32_surface_create_with_format:
 @hdc: the DC to create a surface for
 @format: format of pixels in the surface to create
cairo_win32_surface_create_with_format : @hdc : the DC to create a surface for @format : format of pixels in the surface to create
/* is_vector */