mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-04-20 07:10:46 +02:00
Win32: expose win32 DIB (image) surface creation function, and DC getter
Adds cairo_win32_surface_create_dib() for creating a win32 DIB-backed surface with a particular format. Also exposes cairo_win32_surface_get_dc() to obtain the DC of a win32 surface. (cherry picked from 0813a1b9b6f35d786fe8cb0d4748771023956cde commit)
This commit is contained in:
parent
f4b34df6b6
commit
0fe8a93d95
4 changed files with 37 additions and 9 deletions
|
|
@ -1159,7 +1159,7 @@ _cairo_win32_scaled_font_show_glyphs (void *abstract_font,
|
|||
cairo_surface_pattern_t mask;
|
||||
RECT r;
|
||||
|
||||
tmp_surface = (cairo_win32_surface_t *)_cairo_win32_surface_create_dib (CAIRO_FORMAT_ARGB32, width, height);
|
||||
tmp_surface = (cairo_win32_surface_t *)cairo_win32_surface_create_dib (CAIRO_FORMAT_ARGB32, width, height);
|
||||
if (tmp_surface->base.status)
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
|
||||
|
|
|
|||
|
|
@ -70,11 +70,6 @@ typedef struct _cairo_win32_surface {
|
|||
cairo_status_t
|
||||
_cairo_win32_print_gdi_error (const char *context);
|
||||
|
||||
cairo_surface_t *
|
||||
_cairo_win32_surface_create_dib (cairo_format_t format,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_surface_is_win32 (cairo_surface_t *surface);
|
||||
|
||||
|
|
|
|||
|
|
@ -330,9 +330,9 @@ _cairo_win32_surface_create_similar (void *abstract_src,
|
|||
* be created (probably because of lack of memory)
|
||||
**/
|
||||
cairo_surface_t *
|
||||
_cairo_win32_surface_create_dib (cairo_format_t format,
|
||||
int width,
|
||||
int height)
|
||||
cairo_win32_surface_create_dib (cairo_format_t format,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
return _cairo_win32_surface_create_for_dc (NULL, format, width, height);
|
||||
}
|
||||
|
|
@ -1007,6 +1007,31 @@ _cairo_surface_is_win32 (cairo_surface_t *surface)
|
|||
return surface->backend == &cairo_win32_surface_backend;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_win32_surface_get_dc
|
||||
* @surface: a #cairo_surface_t
|
||||
*
|
||||
* Returns the HDC associated with this surface, or NULL if none.
|
||||
* Also returns NULL if the surface is not a win32 surface.
|
||||
*
|
||||
* Return value: HDC or NULL if no HDC available.
|
||||
**/
|
||||
HDC
|
||||
cairo_win32_surface_get_dc (cairo_surface_t *surface)
|
||||
{
|
||||
cairo_win32_surface_t *winsurf;
|
||||
|
||||
if (surface == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!_cairo_surface_is_win32(surface))
|
||||
return NULL;
|
||||
|
||||
winsurf = (cairo_win32_surface_t *) surface;
|
||||
|
||||
return winsurf->dc;
|
||||
}
|
||||
|
||||
static const cairo_surface_backend_t cairo_win32_surface_backend = {
|
||||
_cairo_win32_surface_create_similar,
|
||||
_cairo_win32_surface_finish,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,14 @@ CAIRO_BEGIN_DECLS
|
|||
cairo_public cairo_surface_t *
|
||||
cairo_win32_surface_create (HDC hdc);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_win32_surface_create_dib (cairo_format_t format,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
cairo_public HDC
|
||||
cairo_win32_surface_get_dc (cairo_surface_t *surface);
|
||||
|
||||
cairo_public cairo_font_face_t *
|
||||
cairo_win32_font_face_create_for_logfontw (LOGFONTW *logfont);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue