mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-20 04:40:07 +01:00
Win32: Avoid checking the last error for GDI functions that don't set it
Most GDI functions do not set the last error, so GetLastError() returns unrelated error codes. There are some exceptions, however, like BitBlt and CreateDIBSection. Whether a GDI function sets the last error is stated in the reference documentation on MSDN.
This commit is contained in:
parent
f289bea1d2
commit
85f308f690
6 changed files with 124 additions and 103 deletions
|
|
@ -36,36 +36,6 @@
|
|||
|
||||
#include <windows.h>
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_win32_print_gdi_error (const char *context)
|
||||
{
|
||||
void *lpMsgBuf;
|
||||
DWORD last_error = GetLastError ();
|
||||
|
||||
if (!FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
last_error,
|
||||
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPWSTR) &lpMsgBuf,
|
||||
0, NULL)) {
|
||||
fprintf (stderr, "%s: Unknown GDI error", context);
|
||||
} else {
|
||||
fprintf (stderr, "%s: %S", context, (wchar_t *)lpMsgBuf);
|
||||
|
||||
LocalFree (lpMsgBuf);
|
||||
}
|
||||
|
||||
fflush (stderr);
|
||||
|
||||
/* We should switch off of last_status, but we'd either return
|
||||
* CAIRO_STATUS_NO_MEMORY or CAIRO_STATUS_UNKNOWN_ERROR and there
|
||||
* is no CAIRO_STATUS_UNKNOWN_ERROR.
|
||||
*/
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
static cairo_user_data_key_t win32_closure_key;
|
||||
|
||||
typedef struct _win32_target_closure {
|
||||
|
|
@ -159,7 +129,7 @@ create_printer_dc (win32_target_closure_t *ptc)
|
|||
xform.eDx = 0;
|
||||
xform.eDy = printable_height - ptc->height*y_dpi/72.0;
|
||||
if (!SetWorldTransform (ptc->dc, &xform)) {
|
||||
_cairo_win32_print_gdi_error ("cairo-boilerplate-win32-printing:SetWorldTransform");
|
||||
fprintf (stderr, "%s:%s\n", "cairo-boilerplate-win32-printing", "SetWorldTransform");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,8 +95,6 @@ _create_dc_and_bitmap (cairo_win32_display_surface_t *surface,
|
|||
unsigned char **bits_out,
|
||||
int *rowstride_out)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
BITMAPINFO *bitmap_info = NULL;
|
||||
struct {
|
||||
BITMAPINFOHEADER bmiHeader;
|
||||
|
|
@ -201,16 +199,20 @@ _create_dc_and_bitmap (cairo_win32_display_surface_t *surface,
|
|||
}
|
||||
|
||||
surface->win32.dc = CreateCompatibleDC (original_dc);
|
||||
if (!surface->win32.dc)
|
||||
if (!surface->win32.dc) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "CreateCompatibleDC");
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
surface->bitmap = CreateDIBSection (surface->win32.dc,
|
||||
bitmap_info,
|
||||
DIB_RGB_COLORS,
|
||||
&bits,
|
||||
NULL, 0);
|
||||
if (!surface->bitmap)
|
||||
if (!surface->bitmap) {
|
||||
_cairo_win32_print_gdi_error ("_create_dc_and_bitmap:CreateDIBSection");
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
surface->is_dib = TRUE;
|
||||
|
||||
|
|
@ -218,8 +220,10 @@ _create_dc_and_bitmap (cairo_win32_display_surface_t *surface,
|
|||
|
||||
surface->saved_dc_bitmap = SelectObject (surface->win32.dc,
|
||||
surface->bitmap);
|
||||
if (!surface->saved_dc_bitmap)
|
||||
if (!surface->saved_dc_bitmap) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SelectObject");
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
if (bitmap_info && num_palette > 2)
|
||||
free (bitmap_info);
|
||||
|
|
@ -256,8 +260,6 @@ _create_dc_and_bitmap (cairo_win32_display_surface_t *surface,
|
|||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
FAIL:
|
||||
status = _cairo_win32_print_gdi_error (__FUNCTION__);
|
||||
|
||||
if (bitmap_info && num_palette > 2)
|
||||
free (bitmap_info);
|
||||
|
||||
|
|
@ -276,7 +278,7 @@ _create_dc_and_bitmap (cairo_win32_display_surface_t *surface,
|
|||
surface->win32.dc = NULL;
|
||||
}
|
||||
|
||||
return status;
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
|
|
@ -547,7 +549,7 @@ _cairo_win32_display_surface_flush (void *abstract_surface, unsigned flags)
|
|||
fallback->win32.dc,
|
||||
surface->win32.extents.x, surface->win32.extents.y,
|
||||
SRCCOPY))
|
||||
status = _cairo_win32_print_gdi_error (__FUNCTION__);
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_display_surface_flush:BitBlt");
|
||||
} else if (damage->region) {
|
||||
int n = cairo_region_num_rectangles (damage->region), i;
|
||||
for (i = 0; i < n; i++) {
|
||||
|
|
@ -564,7 +566,7 @@ _cairo_win32_display_surface_flush (void *abstract_surface, unsigned flags)
|
|||
fallback->win32.dc,
|
||||
rect.x, rect.y,
|
||||
SRCCOPY)) {
|
||||
status = _cairo_win32_print_gdi_error (__FUNCTION__);
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_display_surface_flush:BitBlt");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -615,7 +617,7 @@ _cairo_win32_save_initial_clip (HDC hdc, cairo_win32_display_surface_t *surface)
|
|||
|
||||
clipBoxType = GetClipBox (hdc, &rect);
|
||||
if (clipBoxType == ERROR) {
|
||||
_cairo_win32_print_gdi_error (__FUNCTION__);
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetClipBox");
|
||||
SetGraphicsMode (hdc, gm);
|
||||
/* XXX: Can we make a more reasonable guess at the error cause here? */
|
||||
return _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
|
||||
|
|
@ -748,8 +750,10 @@ _cairo_win32_display_surface_set_clip (cairo_win32_display_surface_t *surface,
|
|||
|
||||
/* AND the new region into our DC */
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
if (ExtSelectClipRgn (surface->win32.dc, gdi_region, RGN_AND) == ERROR)
|
||||
status = _cairo_win32_print_gdi_error (__FUNCTION__);
|
||||
if (ExtSelectClipRgn (surface->win32.dc, gdi_region, RGN_AND) == ERROR) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "ExtSelectClipRgn");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
DeleteObject (gdi_region);
|
||||
|
||||
|
|
|
|||
|
|
@ -159,12 +159,12 @@ _get_global_font_dc (void)
|
|||
if (!hdc) {
|
||||
hdc = CreateCompatibleDC (NULL);
|
||||
if (!hdc) {
|
||||
_cairo_win32_print_gdi_error ("_get_global_font_dc");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "CreateCompatibleDC");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!SetGraphicsMode (hdc, GM_ADVANCED)) {
|
||||
_cairo_win32_print_gdi_error ("_get_global_font_dc");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SetGraphicsMode");
|
||||
DeleteDC (hdc);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -409,8 +409,10 @@ _win32_scaled_font_set_world_transform (cairo_win32_scaled_font_t *scaled_font,
|
|||
|
||||
_cairo_matrix_to_win32_xform (&scaled_font->logical_to_device, &xform);
|
||||
|
||||
if (!SetWorldTransform (hdc, &xform))
|
||||
return _cairo_win32_print_gdi_error ("_win32_scaled_font_set_world_transform");
|
||||
if (!SetWorldTransform (hdc, &xform)) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SetWorldTransform");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
@ -418,8 +420,10 @@ _win32_scaled_font_set_world_transform (cairo_win32_scaled_font_t *scaled_font,
|
|||
static cairo_status_t
|
||||
_win32_scaled_font_set_identity_transform (HDC hdc)
|
||||
{
|
||||
if (!ModifyWorldTransform (hdc, NULL, MWT_IDENTITY))
|
||||
return _cairo_win32_print_gdi_error ("_win32_scaled_font_set_identity_transform");
|
||||
if (!ModifyWorldTransform (hdc, NULL, MWT_IDENTITY)) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "ModifyWorldTransform");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
@ -437,8 +441,10 @@ _win32_scaled_font_get_scaled_hfont (cairo_win32_scaled_font_t *scaled_font,
|
|||
logfont.lfQuality = scaled_font->quality;
|
||||
|
||||
scaled_font->scaled_hfont = CreateFontIndirectW (&logfont);
|
||||
if (!scaled_font->scaled_hfont)
|
||||
return _cairo_win32_print_gdi_error ("_win32_scaled_font_get_scaled_hfont");
|
||||
if (!scaled_font->scaled_hfont) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "CreateFontIndirect");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
*hfont_out = scaled_font->scaled_hfont;
|
||||
|
|
@ -462,25 +468,30 @@ _win32_scaled_font_get_unscaled_hfont (cairo_win32_scaled_font_t *scaled_font,
|
|||
if (status)
|
||||
return status;
|
||||
|
||||
if (! SelectObject (hdc, scaled_hfont))
|
||||
return _cairo_win32_print_gdi_error ("_win32_scaled_font_get_unscaled_hfont:SelectObject");
|
||||
if (! SelectObject (hdc, scaled_hfont)) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SelectObject");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
otm_size = GetOutlineTextMetrics (hdc, 0, NULL);
|
||||
if (! otm_size)
|
||||
return _cairo_win32_print_gdi_error ("_win32_scaled_font_get_unscaled_hfont:GetOutlineTextMetrics");
|
||||
if (! otm_size) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetOutlineTextMetrics");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
otm = _cairo_malloc (otm_size);
|
||||
if (otm == NULL)
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
if (! GetOutlineTextMetrics (hdc, otm_size, otm)) {
|
||||
status = _cairo_win32_print_gdi_error ("_win32_scaled_font_get_unscaled_hfont:GetOutlineTextMetrics");
|
||||
free (otm);
|
||||
return status;
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetOutlineTextMetrics");
|
||||
free (otm);
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
scaled_font->em_square = otm->otmEMSquare;
|
||||
free (otm);
|
||||
otm = NULL;
|
||||
|
||||
logfont = scaled_font->logfont;
|
||||
logfont.lfHeight = -scaled_font->em_square;
|
||||
|
|
@ -490,8 +501,10 @@ _win32_scaled_font_get_unscaled_hfont (cairo_win32_scaled_font_t *scaled_font,
|
|||
logfont.lfQuality = scaled_font->quality;
|
||||
|
||||
scaled_font->unscaled_hfont = CreateFontIndirectW (&logfont);
|
||||
if (! scaled_font->unscaled_hfont)
|
||||
return _cairo_win32_print_gdi_error ("_win32_scaled_font_get_unscaled_hfont:CreateIndirect");
|
||||
if (! scaled_font->unscaled_hfont) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "CreateFontIndirect");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
*hfont_out = scaled_font->unscaled_hfont;
|
||||
|
|
@ -511,8 +524,10 @@ _cairo_win32_scaled_font_select_unscaled_font (cairo_scaled_font_t *scaled_font,
|
|||
return status;
|
||||
|
||||
old_hfont = SelectObject (hdc, hfont);
|
||||
if (!old_hfont)
|
||||
return _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_select_unscaled_font");
|
||||
if (!old_hfont) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "CreateSolidBrush");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
status = _win32_scaled_font_set_identity_transform (hdc);
|
||||
if (status) {
|
||||
|
|
@ -651,7 +666,7 @@ _cairo_win32_scaled_font_ucs4_to_index (void *abstract_font,
|
|||
unicode[0] = ucs4;
|
||||
unicode[1] = 0;
|
||||
if (GetGlyphIndicesW (hdc, unicode, 1, &glyph_index, 0) == GDI_ERROR) {
|
||||
_cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_ucs4_to_index:GetGlyphIndicesW");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetGlyphIndices");
|
||||
glyph_index = 0;
|
||||
}
|
||||
|
||||
|
|
@ -681,7 +696,8 @@ _cairo_win32_scaled_font_set_metrics (cairo_win32_scaled_font_t *scaled_font)
|
|||
return status;
|
||||
|
||||
if (!GetTextMetrics (hdc, &metrics)) {
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_set_metrics:GetTextMetrics");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetTextMetrics");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
cairo_win32_scaled_font_done_font (&scaled_font->base);
|
||||
|
|
@ -766,7 +782,8 @@ _cairo_win32_scaled_font_init_glyph_metrics (cairo_win32_scaled_font_t *scaled_f
|
|||
return status;
|
||||
|
||||
if (!GetCharWidth32(hdc, charIndex, charIndex, &width)) {
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_init_glyph_metrics:GetCharWidth32");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetCharWidth32");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
width = 0;
|
||||
}
|
||||
cairo_win32_scaled_font_done_font (&scaled_font->base);
|
||||
|
|
@ -965,7 +982,8 @@ _flush_glyphs (cairo_glyph_state_t *state)
|
|||
elements,
|
||||
state->glyphs.num_elements,
|
||||
dx_elements)) {
|
||||
return _cairo_win32_print_gdi_error ("_flush_glyphs");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "CreateSolidBrush");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
_cairo_array_truncate (&state->glyphs, 0);
|
||||
|
|
@ -1045,8 +1063,10 @@ _draw_glyphs_on_surface (cairo_win32_surface_t *surface,
|
|||
cairo_status_t status, status2;
|
||||
int i;
|
||||
|
||||
if (!SaveDC (surface->dc))
|
||||
return _cairo_win32_print_gdi_error ("_draw_glyphs_on_surface:SaveDC");
|
||||
if (!SaveDC (surface->dc)) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SaveDC");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
status = cairo_win32_scaled_font_select_font (&scaled_font->base, surface->dc);
|
||||
if (status)
|
||||
|
|
@ -1167,8 +1187,8 @@ _cairo_win32_scaled_font_index_to_ucs4 (void *abstract_font,
|
|||
|
||||
res = GetFontUnicodeRanges(hdc, NULL);
|
||||
if (res == 0) {
|
||||
status = _cairo_win32_print_gdi_error (
|
||||
"_cairo_win32_scaled_font_index_to_ucs4:GetFontUnicodeRanges");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetFontUnicodeRanges");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto exit1;
|
||||
}
|
||||
|
||||
|
|
@ -1180,8 +1200,8 @@ _cairo_win32_scaled_font_index_to_ucs4 (void *abstract_font,
|
|||
|
||||
res = GetFontUnicodeRanges(hdc, glyph_set);
|
||||
if (res == 0) {
|
||||
status = _cairo_win32_print_gdi_error (
|
||||
"_cairo_win32_scaled_font_index_to_ucs4:GetFontUnicodeRanges");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetFontUnicodeRanges");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto exit1;
|
||||
}
|
||||
|
||||
|
|
@ -1206,8 +1226,8 @@ _cairo_win32_scaled_font_index_to_ucs4 (void *abstract_font,
|
|||
utf16[j] = 0;
|
||||
|
||||
if (GetGlyphIndicesW (hdc, utf16, num_glyphs, glyph_indices, 0) == GDI_ERROR) {
|
||||
status = _cairo_win32_print_gdi_error (
|
||||
"_cairo_win32_scaled_font_index_to_ucs4:GetGlyphIndicesW");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetGlyphIndices");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto exit2;
|
||||
}
|
||||
|
||||
|
|
@ -1476,7 +1496,8 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font
|
|||
&metrics, 0, NULL, &matrix);
|
||||
|
||||
if (bytesGlyph == GDI_ERROR) {
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_glyph_path");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetGlyphOutline");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto CLEANUP_FONT;
|
||||
}
|
||||
|
||||
|
|
@ -1489,7 +1510,8 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font
|
|||
if (GetGlyphOutlineW (hdc, _cairo_scaled_glyph_index (scaled_glyph),
|
||||
GGO_NATIVE | GGO_GLYPH_INDEX,
|
||||
&metrics, bytesGlyph, buffer, &matrix) == GDI_ERROR) {
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_glyph_path");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GetGlyphOutline");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto CLEANUP_BUFFER;
|
||||
}
|
||||
|
||||
|
|
@ -1987,14 +2009,16 @@ cairo_win32_scaled_font_select_font (cairo_scaled_font_t *scaled_font,
|
|||
return status;
|
||||
|
||||
old_hfont = SelectObject (hdc, hfont);
|
||||
if (!old_hfont)
|
||||
return _cairo_win32_print_gdi_error ("cairo_win32_scaled_font_select_font:SelectObject");
|
||||
if (!old_hfont) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SelectObject");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
old_mode = SetGraphicsMode (hdc, GM_ADVANCED);
|
||||
if (!old_mode) {
|
||||
status = _cairo_win32_print_gdi_error ("cairo_win32_scaled_font_select_font:SetGraphicsMode");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SetGraphicsMode");
|
||||
SelectObject (hdc, old_hfont);
|
||||
return status;
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
status = _win32_scaled_font_set_world_transform ((cairo_win32_scaled_font_t *)scaled_font, hdc);
|
||||
|
|
|
|||
|
|
@ -166,8 +166,10 @@ fill_boxes (cairo_win32_display_surface_t *dst,
|
|||
|
||||
fb.dc = dst->win32.dc;
|
||||
fb.brush = CreateSolidBrush (color_to_rgb(color));
|
||||
if (!fb.brush)
|
||||
return _cairo_win32_print_gdi_error (__FUNCTION__);
|
||||
if (!fb.brush) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "CreateSolidBrush");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
if (! _cairo_boxes_for_each_box (boxes, fill_box, &fb))
|
||||
status = CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
|
|
|||
|
|
@ -477,8 +477,10 @@ _cairo_win32_printing_surface_select_solid_brush (cairo_win32_printing_surface_t
|
|||
color = _cairo_win32_printing_surface_flatten_transparency (surface,
|
||||
&pattern->color);
|
||||
surface->brush = CreateSolidBrush (color);
|
||||
if (!surface->brush)
|
||||
return _cairo_win32_print_gdi_error ("_cairo_win32_surface_select_solid_brush(CreateSolidBrush)");
|
||||
if (!surface->brush) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "CreateSolidBrush");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
surface->old_brush = SelectObject (surface->win32.dc, surface->brush);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
|
@ -501,13 +503,17 @@ _cairo_win32_printing_surface_get_ctm_clip_box (cairo_win32_printing_surface_t *
|
|||
XFORM xform;
|
||||
|
||||
_cairo_matrix_to_win32_xform (&surface->ctm, &xform);
|
||||
if (!ModifyWorldTransform (surface->win32.dc, &xform, MWT_LEFTMULTIPLY))
|
||||
return _cairo_win32_print_gdi_error ("_cairo_win32_printing_surface_get_clip_box:ModifyWorldTransform");
|
||||
if (!ModifyWorldTransform (surface->win32.dc, &xform, MWT_LEFTMULTIPLY)) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "ModifyWorldTransform");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
GetClipBox (surface->win32.dc, clip);
|
||||
|
||||
_cairo_matrix_to_win32_xform (&surface->gdi_ctm, &xform);
|
||||
if (!SetWorldTransform (surface->win32.dc, &xform))
|
||||
return _cairo_win32_print_gdi_error ("_cairo_win32_printing_surface_get_clip_box:SetWorldTransform");
|
||||
if (!SetWorldTransform (surface->win32.dc, &xform)) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SetWorldTransform");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
@ -887,7 +893,8 @@ _cairo_win32_printing_surface_paint_image_pattern (cairo_win32_printing_surface_
|
|||
_cairo_matrix_to_win32_xform (&m, &xform);
|
||||
|
||||
if (! SetWorldTransform (surface->win32.dc, &xform)) {
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_printing_surface_paint_image_pattern");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SetWorldTransform");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto CLEANUP_OPAQUE_IMAGE;
|
||||
}
|
||||
|
||||
|
|
@ -922,7 +929,8 @@ _cairo_win32_printing_surface_paint_image_pattern (cairo_win32_printing_surface_
|
|||
DIB_RGB_COLORS,
|
||||
SRCCOPY))
|
||||
{
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_printing_surface_paint(StretchDIBits)");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "StretchDIBits");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto CLEANUP_OPAQUE_IMAGE;
|
||||
}
|
||||
}
|
||||
|
|
@ -996,8 +1004,10 @@ _cairo_win32_printing_surface_paint_linear_pattern (cairo_win32_printing_surface
|
|||
|
||||
_cairo_matrix_to_win32_xform (&mat, &xform);
|
||||
|
||||
if (!SetWorldTransform (surface->win32.dc, &xform))
|
||||
return _cairo_win32_print_gdi_error ("_win32_printing_surface_paint_linear_pattern:SetWorldTransform2");
|
||||
if (!SetWorldTransform (surface->win32.dc, &xform)) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SetWorldTransform");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
GetClipBox (surface->win32.dc, &clip);
|
||||
|
||||
|
|
@ -1086,7 +1096,10 @@ _cairo_win32_printing_surface_paint_linear_pattern (cairo_win32_printing_surface
|
|||
vert, total_verts,
|
||||
rect, total_rects,
|
||||
GRADIENT_FILL_RECT_H))
|
||||
return _cairo_win32_print_gdi_error ("_win32_printing_surface_paint_linear_pattern:GradientFill");
|
||||
{
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "GradientFill");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
|
||||
free (rect);
|
||||
free (vert);
|
||||
|
|
@ -1556,13 +1569,15 @@ _cairo_win32_printing_surface_stroke (void *abstract_surface,
|
|||
style->num_dashes,
|
||||
dash_array);
|
||||
if (pen == NULL) {
|
||||
status = _cairo_win32_print_gdi_error ("_win32_surface_stroke:ExtCreatePen");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "ExtCreatePen");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto cleanup_composite;
|
||||
}
|
||||
|
||||
obj = SelectObject (surface->win32.dc, pen);
|
||||
if (obj == NULL) {
|
||||
status = _cairo_win32_print_gdi_error ("_win32_surface_stroke:SelectObject");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SelectObject");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto cleanup_composite;
|
||||
}
|
||||
|
||||
|
|
@ -1582,7 +1597,8 @@ _cairo_win32_printing_surface_stroke (void *abstract_surface,
|
|||
xform.eDy = 0.0f;
|
||||
|
||||
if (!ModifyWorldTransform (surface->win32.dc, &xform, MWT_LEFTMULTIPLY)) {
|
||||
status = _cairo_win32_print_gdi_error ("_win32_surface_stroke:SetWorldTransform");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "ModifyWorldTransform");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto cleanup_composite;
|
||||
}
|
||||
|
||||
|
|
@ -1590,18 +1606,21 @@ _cairo_win32_printing_surface_stroke (void *abstract_surface,
|
|||
StrokePath (surface->win32.dc);
|
||||
} else {
|
||||
if (!WidenPath (surface->win32.dc)) {
|
||||
status = _cairo_win32_print_gdi_error ("_win32_surface_stroke:WidenPath");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "WidenPath");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto cleanup_composite;
|
||||
}
|
||||
if (!SelectClipPath (surface->win32.dc, RGN_AND)) {
|
||||
status = _cairo_win32_print_gdi_error ("_win32_surface_stroke:SelectClipPath");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SelectClipPath");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto cleanup_composite;
|
||||
}
|
||||
|
||||
/* Return to device space to paint the pattern */
|
||||
_cairo_matrix_to_win32_xform (&surface->gdi_ctm, &xform);
|
||||
if (!SetWorldTransform (surface->win32.dc, &xform)) {
|
||||
status = _cairo_win32_print_gdi_error ("_win32_surface_stroke:ModifyWorldTransform");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "SetWorldTransform");
|
||||
status = _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
goto cleanup_composite;
|
||||
}
|
||||
status = _cairo_win32_printing_surface_paint_pattern (surface, source, &extents.bounded);
|
||||
|
|
@ -2102,8 +2121,10 @@ _cairo_win32_printing_surface_start_page (void *abstract_surface)
|
|||
surface->ctm.x0 = xform.eDx;
|
||||
surface->ctm.y0 = xform.eDy;
|
||||
cairo_matrix_init_identity (&surface->gdi_ctm);
|
||||
if (!ModifyWorldTransform (surface->win32.dc, NULL, MWT_IDENTITY))
|
||||
return _cairo_win32_print_gdi_error ("_cairo_win32_printing_surface_start_page:ModifyWorldTransform");
|
||||
if (!ModifyWorldTransform (surface->win32.dc, NULL, MWT_IDENTITY)) {
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "ModifyWorldTransform");
|
||||
return _cairo_error (CAIRO_STATUS_WIN32_GDI_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
surface->has_ctm = !_cairo_matrix_is_identity (&surface->ctm);
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ _cairo_win32_surface_emit_glyphs (cairo_win32_surface_t *dst,
|
|||
num_glyphs,
|
||||
dxy_buf);
|
||||
if (!win_result) {
|
||||
_cairo_win32_print_gdi_error("_cairo_win32_surface_show_glyphs(ExtTextOutW failed)");
|
||||
fprintf (stderr, "%s:%s\n", __FUNCTION__, "ExtTextOut");
|
||||
}
|
||||
|
||||
RestoreDC(dst->dc, -1);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue