gfx/cairo/quartz-layers-content.patch

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/cairo/quartz-layers-content.patch	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,125 @@
     1.4 +diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
     1.5 +--- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
     1.6 ++++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
     1.7 +@@ -2040,17 +2040,18 @@ _cairo_quartz_surface_create_similar (vo
     1.8 + 				       cairo_content_t content,
     1.9 + 				       int width,
    1.10 + 				       int height)
    1.11 + {
    1.12 +     cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface;
    1.13 +     cairo_format_t format;
    1.14 + 
    1.15 +     if (surface->cgLayer)
    1.16 +-        return cairo_quartz_surface_create_cg_layer (abstract_surface, width, height);
    1.17 ++        return cairo_quartz_surface_create_cg_layer (abstract_surface, content,
    1.18 ++                                                     width, height);
    1.19 + 
    1.20 +     if (content == CAIRO_CONTENT_COLOR_ALPHA)
    1.21 + 	format = CAIRO_FORMAT_ARGB32;
    1.22 +     else if (content == CAIRO_CONTENT_COLOR)
    1.23 + 	format = CAIRO_FORMAT_RGB24;
    1.24 +     else if (content == CAIRO_CONTENT_ALPHA)
    1.25 + 	format = CAIRO_FORMAT_A8;
    1.26 +     else
    1.27 +@@ -2960,54 +2961,55 @@ cairo_quartz_surface_create_for_cg_conte
    1.28 + 
    1.29 +     return (cairo_surface_t *) surf;
    1.30 + }
    1.31 + 
    1.32 + /**
    1.33 +  * cairo_quartz_cglayer_surface_create_similar
    1.34 +  * @surface: The returned surface can be efficiently drawn into this
    1.35 +  * destination surface (if tiling is not used)."
    1.36 ++ * @content: the content type of the surface
    1.37 +  * @width: width of the surface, in pixels
    1.38 +  * @height: height of the surface, in pixels
    1.39 +  *
    1.40 +  * Creates a Quartz surface backed by a CGLayer, if the given surface
    1.41 +  * is a Quartz surface; the CGLayer is created to match the surface's
    1.42 +- * Quartz context. Otherwise just calls cairo_surface_create_similar
    1.43 +- * with CAIRO_CONTENT_COLOR_ALPHA.
    1.44 ++ * Quartz context. Otherwise just calls cairo_surface_create_similar.
    1.45 +  * The returned surface can be efficiently blitted to the given surface,
    1.46 +  * but tiling and 'extend' modes other than NONE are not so efficient.
    1.47 +  *
    1.48 +  * Return value: the newly created surface.
    1.49 +  *
    1.50 +  * Since: 1.10
    1.51 +  **/
    1.52 + cairo_surface_t *
    1.53 + cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface,
    1.54 ++                                      cairo_content_t content,
    1.55 +                                       unsigned int width,
    1.56 +                                       unsigned int height)
    1.57 + {
    1.58 +     cairo_quartz_surface_t *surf;
    1.59 +     CGLayerRef layer;
    1.60 +     CGContextRef ctx;
    1.61 +     CGContextRef cgContext;
    1.62 + 
    1.63 +     cgContext = cairo_quartz_surface_get_cg_context (surface);
    1.64 +     if (!cgContext)
    1.65 +-        return cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA,
    1.66 ++        return cairo_surface_create_similar (surface, content,
    1.67 +                                              width, height);
    1.68 + 
    1.69 +     if (!_cairo_quartz_verify_surface_size(width, height))
    1.70 +         return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
    1.71 + 
    1.72 +     /* If we pass zero width or height into CGLayerCreateWithContext below,
    1.73 +      * it will fail.
    1.74 +      */
    1.75 +     if (width == 0 || height == 0) {
    1.76 +         return (cairo_surface_t*)
    1.77 +-            _cairo_quartz_surface_create_internal (NULL, CAIRO_CONTENT_COLOR_ALPHA,
    1.78 ++            _cairo_quartz_surface_create_internal (NULL, content,
    1.79 +                                                    width, height);
    1.80 +     }
    1.81 + 
    1.82 +     layer = CGLayerCreateWithContext (cgContext,
    1.83 +                                       CGSizeMake (width, height),
    1.84 +                                       NULL);
    1.85 +     if (!layer)
    1.86 +       return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
    1.87 +@@ -3016,18 +3018,18 @@ cairo_quartz_surface_create_cg_layer (ca
    1.88 +     /* Flip it when we draw into it, so that when we finally composite it
    1.89 +      * to a flipped target, the directions match and Quartz will optimize
    1.90 +      * the composition properly
    1.91 +      */
    1.92 +     CGContextTranslateCTM (ctx, 0, height);
    1.93 +     CGContextScaleCTM (ctx, 1, -1);
    1.94 + 
    1.95 +     CGContextRetain (ctx);
    1.96 +-    surf = _cairo_quartz_surface_create_internal (ctx, CAIRO_CONTENT_COLOR_ALPHA,
    1.97 +-              width, height);
    1.98 ++    surf = _cairo_quartz_surface_create_internal (ctx, content,
    1.99 ++                                                  width, height);
   1.100 +     if (surf->base.status) {
   1.101 +         CGLayerRelease (layer);
   1.102 +         // create_internal will have set an error
   1.103 +         return (cairo_surface_t*) surf;
   1.104 +     }
   1.105 +     surf->cgLayer = layer;
   1.106 + 
   1.107 +     return (cairo_surface_t *) surf;
   1.108 +diff --git a/gfx/cairo/cairo/src/cairo-quartz.h b/gfx/cairo/cairo/src/cairo-quartz.h
   1.109 +--- a/gfx/cairo/cairo/src/cairo-quartz.h
   1.110 ++++ b/gfx/cairo/cairo/src/cairo-quartz.h
   1.111 +@@ -46,16 +46,17 @@ CAIRO_BEGIN_DECLS
   1.112 + 
   1.113 + cairo_public cairo_surface_t *
   1.114 + cairo_quartz_surface_create (cairo_format_t format,
   1.115 +                              unsigned int width,
   1.116 +                              unsigned int height);
   1.117 + 
   1.118 + cairo_public cairo_surface_t *
   1.119 + cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface,
   1.120 ++                                      cairo_content_t content,
   1.121 +                                       unsigned int width,
   1.122 +                                       unsigned int height);
   1.123 + 
   1.124 + cairo_public cairo_surface_t *
   1.125 + cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext,
   1.126 +                                             unsigned int width,
   1.127 +                                             unsigned int height);
   1.128 + 

mercurial