summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Vukicevic <vladimir@pobox.com>2006-02-17 23:24:06 -0800
committerBehdad Esfahbod <behdad@home.(none)>2006-03-15 11:53:14 -0500
commitd7b280a3add4ec84670e56a85b2a256225b21d0d (patch)
tree4cebccbb97abf18447e66e42a6bb5904eff1a2c1
parentb07f042861602812ca02e01f566026256ba075db (diff)
downloadcairo-d7b280a3add4ec84670e56a85b2a256225b21d0d.tar.gz
Win32: Fix up src coords before calling AlphaBlend/BitBlt to avoid invalid calls
Fixes up src coords and width/height before calling AlphaBlend/BitBlt; it's an error to try to use a region that extents outside of the source surface as a source DC. Doesn't repair the extra region relative to the operator -- e.g. regions outside of an ARGB source surface with SOURCE operator should be cleared to fully transparent black in the destination. (cherry picked from bc19c5b64b0e38e9d20045907d7b47d79f6afc60 commit) (cherry picked from 68ed40b6da242816a43cd68cc2c7feb779cf0acf commit)
-rw-r--r--src/cairo-win32-surface.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index df7ec413f..66fc1c48d 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -664,6 +664,33 @@ _cairo_win32_surface_composite (cairo_operator_t operator,
if (!integer_transform)
return CAIRO_INT_STATUS_UNSUPPORTED;
+ /* Fix up src coordinates; the src coords and size must be within the
+ * bounds of the source surface.
+ * XXX the region not covered should be appropriately rendered!
+ * - for OVER/SOURCE with RGB24 source -> opaque black
+ * - for SOURCE with ARGB32 source -> 100% transparent black
+ */
+ src_x += itx;
+ src_y += ity;
+
+ if (src_x < 0) {
+ width += src_x;
+ dst_x -= src_x;
+ src_x = 0;
+ }
+
+ if (src_y < 0) {
+ height += src_y;
+ dst_y -= src_y;
+ src_y = 0;
+ }
+
+ if (src_x + width > src->extents.width)
+ width = src->extents.width - src_x;
+
+ if (src_y + height > src->extents.height)
+ height = src->extents.height - src_y;
+
if (alpha == 255 &&
src->format == dst->format &&
(operator == CAIRO_OPERATOR_SOURCE ||
@@ -673,7 +700,7 @@ _cairo_win32_surface_composite (cairo_operator_t operator,
dst_x, dst_y,
width, height,
src->dc,
- src_x + itx, src_y + ity,
+ src_x, src_y,
SRCCOPY))
return _cairo_win32_print_gdi_error ("_cairo_win32_surface_composite");
@@ -685,7 +712,7 @@ _cairo_win32_surface_composite (cairo_operator_t operator,
operator == CAIRO_OPERATOR_OVER) {
return _composite_alpha_blend (dst, src, alpha,
- src_x + itx, src_y + ity,
+ src_x, src_y,
dst_x, dst_y, width, height);
}