summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Vukicevic <vladimir@pobox.com>2006-02-17 23:37:54 -0800
committerBehdad Esfahbod <behdad@home.(none)>2006-03-15 11:53:43 -0500
commit9acc981e440bdf370aee25cc5ea2b836db0886b1 (patch)
tree0fbe530b93f12c6deff9e322d1420e67cbb51e2f
parentec4b006c162292ea3b2719dc18a4a3bd40a971ab (diff)
downloadcairo-9acc981e440bdf370aee25cc5ea2b836db0886b1.tar.gz
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) (cherry picked from 1a1441912604c89e2912ec764fe26b7a9db995a3 commit)
-rw-r--r--src/cairo-win32-surface.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 84105e53b..b00251c97 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -385,8 +385,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;
@@ -601,6 +611,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;
@@ -934,7 +946,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;