Bug 1278424 - Remove some code from gfxQuartzSurface. r=eflores

--HG--
extra : rebase_source : b382286844a47ef6e5ffdf83435cd0c36b767f31
This commit is contained in:
Jonathan Watt 2016-05-30 16:26:30 +01:00
parent 4501364d03
commit 27d64c914e
4 changed files with 11 additions and 68 deletions

View File

@ -16,12 +16,11 @@ gfxQuartzSurface::MakeInvalid()
mSize = mozilla::gfx::IntSize(-1, -1);
}
gfxQuartzSurface::gfxQuartzSurface(const gfxSize& desiredSize, gfxImageFormat format)
gfxQuartzSurface::gfxQuartzSurface(const mozilla::gfx::IntSize& desiredSize,
gfxImageFormat format)
: mCGContext(nullptr), mSize(desiredSize)
{
mozilla::gfx::IntSize size((unsigned int) floor(desiredSize.width),
(unsigned int) floor(desiredSize.height));
if (!CheckSurfaceSize(size))
if (!CheckSurfaceSize(desiredSize))
MakeInvalid();
unsigned int width = static_cast<unsigned int>(mSize.width);
@ -40,30 +39,6 @@ gfxQuartzSurface::gfxQuartzSurface(const gfxSize& desiredSize, gfxImageFormat fo
}
}
gfxQuartzSurface::gfxQuartzSurface(CGContextRef context,
const gfxSize& desiredSize)
: mCGContext(context), mSize(desiredSize)
{
mozilla::gfx::IntSize size((unsigned int) floor(desiredSize.width),
(unsigned int) floor(desiredSize.height));
if (!CheckSurfaceSize(size))
MakeInvalid();
unsigned int width = static_cast<unsigned int>(mSize.width);
unsigned int height = static_cast<unsigned int>(mSize.height);
cairo_surface_t *surf =
cairo_quartz_surface_create_for_cg_context(context,
width, height);
CGContextRetain(mCGContext);
Init(surf);
if (mSurfaceValid) {
RecordMemoryUsed(mSize.height * 4 + sizeof(gfxQuartzSurface));
}
}
gfxQuartzSurface::gfxQuartzSurface(CGContextRef context,
const mozilla::gfx::IntSize& size)
: mCGContext(context), mSize(size)
@ -96,34 +71,6 @@ gfxQuartzSurface::gfxQuartzSurface(cairo_surface_t *csurf,
Init(csurf, true);
}
gfxQuartzSurface::gfxQuartzSurface(unsigned char *data,
const gfxSize& desiredSize,
long stride,
gfxImageFormat format)
: mCGContext(nullptr), mSize(desiredSize)
{
mozilla::gfx::IntSize size((unsigned int) floor(desiredSize.width),
(unsigned int) floor(desiredSize.height));
if (!CheckSurfaceSize(size))
MakeInvalid();
unsigned int width = static_cast<unsigned int>(mSize.width);
unsigned int height = static_cast<unsigned int>(mSize.height);
cairo_format_t cformat = GfxFormatToCairoFormat(format);
cairo_surface_t *surf = cairo_quartz_surface_create_for_data
(data, cformat, width, height, stride);
mCGContext = cairo_quartz_surface_get_cg_context (surf);
CGContextRetain(mCGContext);
Init(surf);
if (mSurfaceValid) {
RecordMemoryUsed(mSize.height * stride + sizeof(gfxQuartzSurface));
}
}
gfxQuartzSurface::gfxQuartzSurface(unsigned char *data,
const mozilla::gfx::IntSize& aSize,
long stride,

View File

@ -17,11 +17,9 @@ class gfxImageSurface;
class gfxQuartzSurface : public gfxASurface {
public:
gfxQuartzSurface(const gfxSize& size, gfxImageFormat format);
gfxQuartzSurface(CGContextRef context, const gfxSize& size);
gfxQuartzSurface(const mozilla::gfx::IntSize&, gfxImageFormat format);
gfxQuartzSurface(CGContextRef context, const mozilla::gfx::IntSize& size);
gfxQuartzSurface(cairo_surface_t *csurf, const mozilla::gfx::IntSize& aSize);
gfxQuartzSurface(unsigned char *data, const gfxSize& size, long stride, gfxImageFormat format);
gfxQuartzSurface(unsigned char *data, const mozilla::gfx::IntSize& size, long stride, gfxImageFormat format);
virtual ~gfxQuartzSurface();
@ -39,7 +37,7 @@ protected:
void MakeInvalid();
CGContextRef mCGContext;
gfxSize mSize;
mozilla::gfx::IntSize mSize;
};
#endif /* GFX_QUARTZSURFACE_H */

View File

@ -144,6 +144,7 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetSurfaceForPrinter(gfxASurface **surface)
GetPaperRect(&top, &left, &bottom, &right);
const double width = right - left;
const double height = bottom - top;
IntSize size(floor(width), floor(height));
CGContextRef context;
::PMSessionGetCGGraphicsContext(mPrintSession, &context);
@ -155,9 +156,9 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetSurfaceForPrinter(gfxASurface **surface)
// Here, we translate it to top-left corner of the paper.
CGContextTranslateCTM(context, 0, height);
CGContextScaleCTM(context, 1.0, -1.0);
newSurface = new gfxQuartzSurface(context, gfxSize(width, height));
newSurface = new gfxQuartzSurface(context, size);
} else {
newSurface = new gfxQuartzSurface(gfxSize((int32_t)width, (int32_t)height), SurfaceFormat::A8R8G8B8_UINT32);
newSurface = new gfxQuartzSurface(size, SurfaceFormat::A8R8G8B8_UINT32);
}
if (!newSurface)

View File

@ -340,7 +340,7 @@ private:
CGContextScaleCTM(aContext, 1.0 / scale, 1.0 / scale);
CGSize viewSize = [self bounds].size;
nsIntSize backingSize(viewSize.width * scale, viewSize.height * scale);
gfx::IntSize backingSize(viewSize.width * scale, viewSize.height * scale);
CGContextSaveGState(aContext);
@ -356,9 +356,7 @@ private:
RefPtr<gfxContext> targetContext;
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(gfx::BackendType::COREGRAPHICS)) {
RefPtr<gfx::DrawTarget> dt =
gfx::Factory::CreateDrawTargetForCairoCGContext(aContext,
gfx::IntSize(backingSize.width,
backingSize.height));
gfx::Factory::CreateDrawTargetForCairoCGContext(aContext, backingSize);
if (!dt || !dt->IsValid()) {
gfxDevCrash(mozilla::gfx::LogReason::InvalidContext) << "Window context problem 1 " << backingSize;
return;
@ -372,8 +370,7 @@ private:
targetSurface->SetAllowUseAsSource(false);
RefPtr<gfx::DrawTarget> dt =
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(targetSurface,
gfx::IntSize(backingSize.width,
backingSize.height));
backingSize);
if (!dt || !dt->IsValid()) {
gfxDevCrash(mozilla::gfx::LogReason::InvalidContext) << "Window context problem 2 " << backingSize;
return;