зеркало из https://github.com/mozilla/gecko-dev.git
Bug 579985. Part 3.1: Pass cairo_content_t parameter when creating CGLayer surfaces. r=jrmuizel,a=blocking
This commit is contained in:
Родитель
cc373a3edf
Коммит
55d56898d6
|
@ -148,6 +148,8 @@ quartz-fix-PAD.patch: Treat PAD like NONE instead of REPEAT
|
|||
|
||||
quartz-mask-non-OVER.patch: Don't use CGContextSetAlpha to optimize alpha masking for non-OVER operators
|
||||
|
||||
quartz-layers-content.patch: Store cairo content type in CGLayer surfaces
|
||||
|
||||
==== pixman patches ====
|
||||
|
||||
pixman-android-cpu-detect.patch: Add CPU detection support for Android, where we can't reliably access /proc/self/auxv.
|
||||
|
|
|
@ -2047,7 +2047,8 @@ _cairo_quartz_surface_create_similar (void *abstract_surface,
|
|||
cairo_format_t format;
|
||||
|
||||
if (surface->cgLayer)
|
||||
return cairo_quartz_surface_create_cg_layer (abstract_surface, width, height);
|
||||
return cairo_quartz_surface_create_cg_layer (abstract_surface, content,
|
||||
width, height);
|
||||
|
||||
if (content == CAIRO_CONTENT_COLOR_ALPHA)
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
|
@ -2967,13 +2968,13 @@ cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext,
|
|||
* cairo_quartz_cglayer_surface_create_similar
|
||||
* @surface: The returned surface can be efficiently drawn into this
|
||||
* destination surface (if tiling is not used)."
|
||||
* @content: the content type of the surface
|
||||
* @width: width of the surface, in pixels
|
||||
* @height: height of the surface, in pixels
|
||||
*
|
||||
* Creates a Quartz surface backed by a CGLayer, if the given surface
|
||||
* is a Quartz surface; the CGLayer is created to match the surface's
|
||||
* Quartz context. Otherwise just calls cairo_surface_create_similar
|
||||
* with CAIRO_CONTENT_COLOR_ALPHA.
|
||||
* Quartz context. Otherwise just calls cairo_surface_create_similar.
|
||||
* The returned surface can be efficiently blitted to the given surface,
|
||||
* but tiling and 'extend' modes other than NONE are not so efficient.
|
||||
*
|
||||
|
@ -2983,6 +2984,7 @@ cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext,
|
|||
**/
|
||||
cairo_surface_t *
|
||||
cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface,
|
||||
cairo_content_t content,
|
||||
unsigned int width,
|
||||
unsigned int height)
|
||||
{
|
||||
|
@ -2993,7 +2995,7 @@ cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface,
|
|||
|
||||
cgContext = cairo_quartz_surface_get_cg_context (surface);
|
||||
if (!cgContext)
|
||||
return cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
return cairo_surface_create_similar (surface, content,
|
||||
width, height);
|
||||
|
||||
if (!_cairo_quartz_verify_surface_size(width, height))
|
||||
|
@ -3004,7 +3006,7 @@ cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface,
|
|||
*/
|
||||
if (width == 0 || height == 0) {
|
||||
return (cairo_surface_t*)
|
||||
_cairo_quartz_surface_create_internal (NULL, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
_cairo_quartz_surface_create_internal (NULL, content,
|
||||
width, height);
|
||||
}
|
||||
|
||||
|
@ -3023,8 +3025,8 @@ cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface,
|
|||
CGContextScaleCTM (ctx, 1, -1);
|
||||
|
||||
CGContextRetain (ctx);
|
||||
surf = _cairo_quartz_surface_create_internal (ctx, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
width, height);
|
||||
surf = _cairo_quartz_surface_create_internal (ctx, content,
|
||||
width, height);
|
||||
if (surf->base.status) {
|
||||
CGLayerRelease (layer);
|
||||
// create_internal will have set an error
|
||||
|
|
|
@ -51,6 +51,7 @@ cairo_quartz_surface_create (cairo_format_t format,
|
|||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface,
|
||||
cairo_content_t content,
|
||||
unsigned int width,
|
||||
unsigned int height);
|
||||
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
|
||||
--- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
|
||||
+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
|
||||
@@ -2040,17 +2040,18 @@ _cairo_quartz_surface_create_similar (vo
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface;
|
||||
cairo_format_t format;
|
||||
|
||||
if (surface->cgLayer)
|
||||
- return cairo_quartz_surface_create_cg_layer (abstract_surface, width, height);
|
||||
+ return cairo_quartz_surface_create_cg_layer (abstract_surface, content,
|
||||
+ width, height);
|
||||
|
||||
if (content == CAIRO_CONTENT_COLOR_ALPHA)
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
else if (content == CAIRO_CONTENT_COLOR)
|
||||
format = CAIRO_FORMAT_RGB24;
|
||||
else if (content == CAIRO_CONTENT_ALPHA)
|
||||
format = CAIRO_FORMAT_A8;
|
||||
else
|
||||
@@ -2960,54 +2961,55 @@ cairo_quartz_surface_create_for_cg_conte
|
||||
|
||||
return (cairo_surface_t *) surf;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_quartz_cglayer_surface_create_similar
|
||||
* @surface: The returned surface can be efficiently drawn into this
|
||||
* destination surface (if tiling is not used)."
|
||||
+ * @content: the content type of the surface
|
||||
* @width: width of the surface, in pixels
|
||||
* @height: height of the surface, in pixels
|
||||
*
|
||||
* Creates a Quartz surface backed by a CGLayer, if the given surface
|
||||
* is a Quartz surface; the CGLayer is created to match the surface's
|
||||
- * Quartz context. Otherwise just calls cairo_surface_create_similar
|
||||
- * with CAIRO_CONTENT_COLOR_ALPHA.
|
||||
+ * Quartz context. Otherwise just calls cairo_surface_create_similar.
|
||||
* The returned surface can be efficiently blitted to the given surface,
|
||||
* but tiling and 'extend' modes other than NONE are not so efficient.
|
||||
*
|
||||
* Return value: the newly created surface.
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
cairo_surface_t *
|
||||
cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface,
|
||||
+ cairo_content_t content,
|
||||
unsigned int width,
|
||||
unsigned int height)
|
||||
{
|
||||
cairo_quartz_surface_t *surf;
|
||||
CGLayerRef layer;
|
||||
CGContextRef ctx;
|
||||
CGContextRef cgContext;
|
||||
|
||||
cgContext = cairo_quartz_surface_get_cg_context (surface);
|
||||
if (!cgContext)
|
||||
- return cairo_surface_create_similar (surface, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
+ return cairo_surface_create_similar (surface, content,
|
||||
width, height);
|
||||
|
||||
if (!_cairo_quartz_verify_surface_size(width, height))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
|
||||
|
||||
/* If we pass zero width or height into CGLayerCreateWithContext below,
|
||||
* it will fail.
|
||||
*/
|
||||
if (width == 0 || height == 0) {
|
||||
return (cairo_surface_t*)
|
||||
- _cairo_quartz_surface_create_internal (NULL, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
+ _cairo_quartz_surface_create_internal (NULL, content,
|
||||
width, height);
|
||||
}
|
||||
|
||||
layer = CGLayerCreateWithContext (cgContext,
|
||||
CGSizeMake (width, height),
|
||||
NULL);
|
||||
if (!layer)
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
@@ -3016,18 +3018,18 @@ cairo_quartz_surface_create_cg_layer (ca
|
||||
/* Flip it when we draw into it, so that when we finally composite it
|
||||
* to a flipped target, the directions match and Quartz will optimize
|
||||
* the composition properly
|
||||
*/
|
||||
CGContextTranslateCTM (ctx, 0, height);
|
||||
CGContextScaleCTM (ctx, 1, -1);
|
||||
|
||||
CGContextRetain (ctx);
|
||||
- surf = _cairo_quartz_surface_create_internal (ctx, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
- width, height);
|
||||
+ surf = _cairo_quartz_surface_create_internal (ctx, content,
|
||||
+ width, height);
|
||||
if (surf->base.status) {
|
||||
CGLayerRelease (layer);
|
||||
// create_internal will have set an error
|
||||
return (cairo_surface_t*) surf;
|
||||
}
|
||||
surf->cgLayer = layer;
|
||||
|
||||
return (cairo_surface_t *) surf;
|
||||
diff --git a/gfx/cairo/cairo/src/cairo-quartz.h b/gfx/cairo/cairo/src/cairo-quartz.h
|
||||
--- a/gfx/cairo/cairo/src/cairo-quartz.h
|
||||
+++ b/gfx/cairo/cairo/src/cairo-quartz.h
|
||||
@@ -46,16 +46,17 @@ CAIRO_BEGIN_DECLS
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_quartz_surface_create (cairo_format_t format,
|
||||
unsigned int width,
|
||||
unsigned int height);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface,
|
||||
+ cairo_content_t content,
|
||||
unsigned int width,
|
||||
unsigned int height);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext,
|
||||
unsigned int width,
|
||||
unsigned int height);
|
||||
|
|
@ -92,7 +92,8 @@ gfxQuartzSurface::CreateSimilarSurface(gfxContentType aType,
|
|||
const gfxIntSize& aSize)
|
||||
{
|
||||
cairo_surface_t *surface =
|
||||
cairo_quartz_surface_create_cg_layer(mSurface, aSize.width, aSize.height);
|
||||
cairo_quartz_surface_create_cg_layer(mSurface, (cairo_content_t)aType,
|
||||
aSize.width, aSize.height);
|
||||
if (cairo_surface_status(surface)) {
|
||||
cairo_surface_destroy(surface);
|
||||
return nsnull;
|
||||
|
|
Загрузка…
Ссылка в новой задаче