From 1a1441912604c89e2912ec764fe26b7a9db995a3 Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Fri, 17 Feb 2006 23:37:54 -0800 Subject: [PATCH] Win32: Handle BitBlt in get_image failure and AlphaBlend not being supported If the BitBlt in get_image fails, we pretty much can't do anything -- so fill the destination with white and hope for the best. This enables somewhat accurate printing of complex operations. Also, check the destination device caps before calling AlphaBlend; return UNSUPPORTED if the destination DC can't do AlphaBlend. (cherry picked from 9831de538e347a624af5b0ca38242b198b64bd45 commit) --- src/cairo-win32-surface.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c index d27185d19..c7f45556e 100644 --- a/src/cairo-win32-surface.c +++ b/src/cairo-win32-surface.c @@ -364,8 +364,18 @@ _cairo_win32_surface_get_subimage (cairo_win32_surface_t *surface, width, height, surface->dc, x, y, - SRCCOPY)) - goto FAIL; + SRCCOPY)) { + /* If we fail to BitBlt here, most likely the source is a printer. + * You can't reliably get bits from a printer DC, so just fill in + * the surface as white (common case for printing). + */ + + RECT r; + r.left = r.top = 0; + r.right = width; + r.bottom = height; + FillRect(local->dc, &r, (HBRUSH)GetStockObject(WHITE_BRUSH)); + } *local_out = local; @@ -580,6 +590,8 @@ _composite_alpha_blend (cairo_win32_surface_t *dst, if (alpha_blend == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; + if (GetDeviceCaps(dst->dc, SHADEBLENDCAPS) == SB_NONE) + return CAIRO_INT_STATUS_UNSUPPORTED; blend_function.BlendOp = AC_SRC_OVER; blend_function.BlendFlags = 0; @@ -913,7 +925,7 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface, return CAIRO_STATUS_NO_MEMORY; /* Combine the new region with the original clip */ - + if (surface->saved_clip) { if (CombineRgn (gdi_region, gdi_region, surface->saved_clip, RGN_AND) == ERROR) goto FAIL;