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)
This commit is contained in:
Vladimir Vukicevic 2006-02-17 23:37:54 -08:00 committed by Vladimir Vukicevic
parent 2d784815ff
commit 1a14419126

View file

@ -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;