Bug 739096 - Remove support for CGLayer-backed cairo quartz surface. r=jrmuizel

This was a performance optimization that we no longer care about.
Removing it will avoid the need to merge the additions into the new
cairo-quartz-surface code from upstream.

Differential Revision: https://phabricator.services.mozilla.com/D112556
This commit is contained in:
Jonathan Kew 2021-04-29 14:33:29 +00:00
Родитель 836cfc1c1f
Коммит 3f563bce7e
7 изменённых файлов: 1 добавлений и 168 удалений

Просмотреть файл

@ -1749,13 +1749,6 @@ already_AddRefed<DrawTarget> DrawTargetCairo::CreateSimilarDrawTarget(
similar = cairo_win32_surface_create_with_dib(
GfxFormatToCairoFormat(aFormat), aSize.width, aSize.height);
break;
#endif
#ifdef CAIRO_HAS_QUARTZ_SURFACE
case CAIRO_SURFACE_TYPE_QUARTZ:
similar = cairo_quartz_surface_create_cg_layer(
mSurface, GfxFormatToCairoContent(aFormat), aSize.width,
aSize.height);
break;
#endif
default:
similar = cairo_surface_create_similar(mSurface,

Просмотреть файл

@ -71,11 +71,6 @@ typedef struct cairo_quartz_surface {
*/
CGImageRef bitmapContextImage;
/**
* If non-null, this is the CGLayer for the surface.
*/
CGLayerRef cgLayer;
cairo_rectangle_int_t extents;
cairo_bool_t ownsData;

Просмотреть файл

@ -1643,17 +1643,6 @@ _cairo_quartz_setup_surface_source (cairo_quartz_surface_t *surface,
cairo_matrix_invert(&m);
_cairo_quartz_cairo_matrix_to_quartz (&m, &state->transform);
/* Draw nonrepeating CGLayer surface using DO_LAYER */
if (!repeat && cairo_surface_get_type (pat_surf) == CAIRO_SURFACE_TYPE_QUARTZ) {
cairo_quartz_surface_t *quartz_surf = (cairo_quartz_surface_t *) pat_surf;
if (quartz_surf->cgLayer) {
state->imageRect = CGRectMake (0, 0, quartz_surf->extents.width, quartz_surf->extents.height);
state->layer = quartz_surf->cgLayer;
state->action = DO_LAYER;
return;
}
}
status = _cairo_surface_to_cgimage (pat_surf, &img);
if (status) {
state->action = DO_UNSUPPORTED;
@ -2055,10 +2044,6 @@ _cairo_quartz_surface_finish (void *abstract_surface)
surface->imageData = NULL;
if (surface->cgLayer) {
CGLayerRelease (surface->cgLayer);
}
return CAIRO_STATUS_SUCCESS;
}
@ -2076,38 +2061,6 @@ _cairo_quartz_surface_acquire_image (void *abstract_surface,
status = _cairo_quartz_get_image (surface, image_out);
if (status == CAIRO_INT_STATUS_UNSUPPORTED && surface->cgLayer) {
/* copy the layer into a Quartz bitmap context so we can get the data */
cairo_surface_t *tmp =
cairo_quartz_surface_create (CAIRO_FORMAT_ARGB32,
surface->extents.width,
surface->extents.height);
cairo_quartz_surface_t *tmp_surface = (cairo_quartz_surface_t *) tmp;
/* if surface creation failed, we won't have a Quartz surface here */
if (cairo_surface_get_type (tmp) == CAIRO_SURFACE_TYPE_QUARTZ &&
tmp_surface->imageSurfaceEquiv) {
CGContextSaveGState (tmp_surface->cgContext);
CGContextTranslateCTM (tmp_surface->cgContext, 0, surface->extents.height);
CGContextScaleCTM (tmp_surface->cgContext, 1, -1);
/* Note that according to Apple docs it's completely legal
* to draw a CGLayer to any CGContext, even one it wasn't
* created for.
*/
CGContextDrawLayerAtPoint (tmp_surface->cgContext,
CGPointMake (0.0, 0.0),
surface->cgLayer);
CGContextRestoreGState (tmp_surface->cgContext);
*image_out = (cairo_image_surface_t*)
cairo_surface_reference(tmp_surface->imageSurfaceEquiv);
*image_extra = tmp;
status = CAIRO_STATUS_SUCCESS;
} else {
cairo_surface_destroy (tmp);
}
}
if (status)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -2190,10 +2143,6 @@ _cairo_quartz_surface_create_similar (void *abstract_surface,
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, content,
width, height);
if (content == CAIRO_CONTENT_COLOR_ALPHA)
format = CAIRO_FORMAT_ARGB32;
else if (content == CAIRO_CONTENT_COLOR)
@ -3288,7 +3237,6 @@ _cairo_quartz_surface_create_internal (CGContextRef cgContext,
surface->imageData = NULL;
surface->imageSurfaceEquiv = NULL;
surface->bitmapContextImage = NULL;
surface->cgLayer = NULL;
surface->ownsData = TRUE;
return surface;
@ -3341,79 +3289,6 @@ cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext,
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.
* 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, 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, content,
width, height);
}
layer = CGLayerCreateWithContext (cgContext,
CGSizeMake (width, height),
NULL);
if (!layer)
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
ctx = CGLayerGetContext (layer);
/* 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, 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;
}
/**
* cairo_quartz_surface_create
* @format: format of pixels in the surface to create

Просмотреть файл

@ -1,6 +1,6 @@
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2006, 2007 Mozilla Corporation
* Copyright <EFBFBD> 2006, 2007 Mozilla Corporation
*
* This library is free software; you can redistribute it and/or
* modify it either under the terms of the GNU Lesser General Public
@ -62,12 +62,6 @@ cairo_quartz_surface_create_for_data (unsigned char *data,
unsigned int height,
unsigned int stride);
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,

Просмотреть файл

@ -106,13 +106,6 @@ already_AddRefed<DrawTarget> PrintTarget::GetReferenceDrawTarget() {
CairoContentToCairoFormat(cairo_surface_get_content(mCairoSurface)),
size.width, size.height);
break;
#endif
#ifdef CAIRO_HAS_QUARTZ_SURFACE
case CAIRO_SURFACE_TYPE_QUARTZ:
similar = cairo_quartz_surface_create_cg_layer(
mCairoSurface, cairo_surface_get_content(mCairoSurface), size.width,
size.height);
break;
#endif
default:
similar = cairo_surface_create_similar(

Просмотреть файл

@ -82,20 +82,6 @@ gfxQuartzSurface::gfxQuartzSurface(unsigned char* data,
}
}
already_AddRefed<gfxASurface> gfxQuartzSurface::CreateSimilarSurface(
gfxContentType aType, const mozilla::gfx::IntSize& aSize) {
cairo_surface_t* surface = 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 nullptr;
}
RefPtr<gfxASurface> result = Wrap(surface, aSize);
cairo_surface_destroy(surface);
return result.forget();
}
already_AddRefed<gfxImageSurface> gfxQuartzSurface::GetAsImageSurface() {
cairo_surface_t* surface = cairo_quartz_surface_get_image(mSurface);
if (!surface || cairo_surface_status(surface)) return nullptr;

Просмотреть файл

@ -25,9 +25,6 @@ class gfxQuartzSurface : public gfxASurface {
virtual ~gfxQuartzSurface();
virtual already_AddRefed<gfxASurface> CreateSimilarSurface(
gfxContentType aType, const mozilla::gfx::IntSize& aSize);
virtual const mozilla::gfx::IntSize GetSize() const {
return mozilla::gfx::IntSize(mSize.width, mSize.height);
}