gfx/cairo/win32-avoid-extend-pad-fallback.patch

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/cairo/win32-avoid-extend-pad-fallback.patch	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     1.4 +diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
     1.5 +--- a/gfx/cairo/cairo/src/cairo-win32-surface.c
     1.6 ++++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
     1.7 +@@ -1114,17 +1114,17 @@ static cairo_int_status_t
     1.8 +     cairo_win32_surface_t *dst = abstract_dst;
     1.9 +     cairo_win32_surface_t *src;
    1.10 +     cairo_surface_pattern_t *src_surface_pattern;
    1.11 +     int alpha;
    1.12 +     double scalex, scaley;
    1.13 +     cairo_fixed_t x0_fixed, y0_fixed;
    1.14 +     cairo_int_status_t status;
    1.15 + 
    1.16 +-    cairo_bool_t needs_alpha, needs_scale, needs_repeat;
    1.17 ++    cairo_bool_t needs_alpha, needs_scale, needs_repeat, needs_pad;
    1.18 +     cairo_image_surface_t *src_image = NULL;
    1.19 + 
    1.20 +     cairo_format_t src_format;
    1.21 +     cairo_rectangle_int_t src_extents;
    1.22 + 
    1.23 +     cairo_rectangle_int_t src_r = { src_x, src_y, width, height };
    1.24 +     cairo_rectangle_int_t dst_r = { dst_x, dst_y, width, height };
    1.25 + 
    1.26 +@@ -1145,17 +1145,18 @@ static cairo_int_status_t
    1.27 +     {
    1.28 + 	goto UNSUPPORTED;
    1.29 +     }
    1.30 + 
    1.31 +     if (pattern->type != CAIRO_PATTERN_TYPE_SURFACE)
    1.32 + 	goto UNSUPPORTED;
    1.33 + 
    1.34 +     if (pattern->extend != CAIRO_EXTEND_NONE &&
    1.35 +-	pattern->extend != CAIRO_EXTEND_REPEAT)
    1.36 ++	pattern->extend != CAIRO_EXTEND_REPEAT &&
    1.37 ++	pattern->extend != CAIRO_EXTEND_PAD)
    1.38 + 	goto UNSUPPORTED;
    1.39 + 
    1.40 +     if (mask_pattern) {
    1.41 + 	/* FIXME: When we fully support RENDER style 4-channel
    1.42 + 	 * masks we need to check r/g/b != 1.0.
    1.43 + 	 */
    1.44 + 	if (mask_pattern->type != CAIRO_PATTERN_TYPE_SOLID)
    1.45 + 	    return CAIRO_INT_STATUS_UNSUPPORTED;
    1.46 +@@ -1252,16 +1253,17 @@ static cairo_int_status_t
    1.47 + 
    1.48 +     /* If the src rectangle doesn't wholly lie within the src extents,
    1.49 +      * fudge things.  We really need to do fixup on the unpainted
    1.50 +      * region -- e.g. the SOURCE operator is broken for areas outside
    1.51 +      * of the extents, because it won't clear that area to transparent
    1.52 +      * black.
    1.53 +      */
    1.54 + 
    1.55 ++    needs_pad = FALSE;
    1.56 +     if (pattern->extend != CAIRO_EXTEND_REPEAT) {
    1.57 + 	needs_repeat = FALSE;
    1.58 + 
    1.59 + 	/* If the src rect and the extents of the source image don't overlap at all,
    1.60 + 	 * we can't do anything useful here.
    1.61 + 	 */
    1.62 + 	if (src_r.x > src_extents.width || src_r.y > src_extents.height ||
    1.63 + 	    (src_r.x + src_r.width) < 0 || (src_r.y + src_r.height) < 0)
    1.64 +@@ -1273,40 +1275,48 @@ static cairo_int_status_t
    1.65 + 
    1.66 + 	if (src_r.x < 0) {
    1.67 + 	    src_r.width += src_r.x;
    1.68 + 
    1.69 + 	    dst_r.width += src_r.x;
    1.70 + 	    dst_r.x -= src_r.x;
    1.71 + 
    1.72 +             src_r.x = 0;
    1.73 ++            needs_pad = TRUE;
    1.74 + 	}
    1.75 + 
    1.76 + 	if (src_r.y < 0) {
    1.77 + 	    src_r.height += src_r.y;
    1.78 + 
    1.79 + 	    dst_r.height += src_r.y;
    1.80 + 	    dst_r.y -= src_r.y;
    1.81 + 	    
    1.82 +             src_r.y = 0;
    1.83 ++            needs_pad = TRUE;
    1.84 + 	}
    1.85 + 
    1.86 + 	if (src_r.x + src_r.width > src_extents.width) {
    1.87 + 	    src_r.width = src_extents.width - src_r.x;
    1.88 + 	    dst_r.width = src_r.width;
    1.89 ++            needs_pad = TRUE;
    1.90 + 	}
    1.91 + 
    1.92 + 	if (src_r.y + src_r.height > src_extents.height) {
    1.93 + 	    src_r.height = src_extents.height - src_r.y;
    1.94 + 	    dst_r.height = src_r.height;
    1.95 ++            needs_pad = TRUE;
    1.96 + 	}
    1.97 +     } else {
    1.98 + 	needs_repeat = TRUE;
    1.99 +     }
   1.100 + 
   1.101 ++    if (pattern->extend == CAIRO_EXTEND_PAD && needs_pad) {
   1.102 ++        goto UNSUPPORTED;
   1.103 ++    }
   1.104 ++
   1.105 +     /*
   1.106 +      * Operations that we can do:
   1.107 +      *
   1.108 +      * AlphaBlend uses the following formula for alpha when not use the per-pixel alpha (AlphaFormat = 0)
   1.109 +      *   Dst.Alpha = Src.Alpha * (SCA/255.0) + Dst.Alpha * (1.0 - (SCA/255.0))
   1.110 +      * This turns into Dst.Alpha = Src.Alpha when SCA = 255.
   1.111 +      * (http://msdn.microsoft.com/en-us/library/aa921335.aspx)
   1.112 +      *

mercurial