From 3b6dfef24501acbfaac100bf0dba8c0e897ca17f Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Tue, 24 Jul 2012 22:18:38 +1200 Subject: [PATCH] Bug 764125; pass around the size of a gfxASurface when creating a DrawTarget. r=Bas --- gfx/2d/2D.h | 2 +- gfx/2d/DrawTargetCairo.cpp | 7 ++++--- gfx/2d/DrawTargetCairo.h | 3 ++- gfx/2d/Factory.cpp | 4 ++-- gfx/thebes/gfxPlatform.cpp | 6 +++--- gfx/thebes/gfxPlatform.h | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index 73b17888cf0..093481e85ca 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -802,7 +802,7 @@ class GFX2D_API Factory public: static bool HasSSE2(); - static TemporaryRef CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface); + static TemporaryRef CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize); static TemporaryRef CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFormat aFormat); diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index 9a136d4117c..9400d27c458 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -250,7 +250,7 @@ DrawTargetCairo::~DrawTargetCairo() IntSize DrawTargetCairo::GetSize() { - return IntSize(); + return mSize; } TemporaryRef @@ -712,7 +712,7 @@ DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFo if (!cairo_surface_status(similar)) { RefPtr target = new DrawTargetCairo(); - target->Init(similar); + target->Init(similar, aSize); return target; } @@ -720,9 +720,10 @@ DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFo } bool -DrawTargetCairo::Init(cairo_surface_t* aSurface) +DrawTargetCairo::Init(cairo_surface_t* aSurface, const IntSize& aSize) { mContext = cairo_create(aSurface); + mSize = aSize; return true; } diff --git a/gfx/2d/DrawTargetCairo.h b/gfx/2d/DrawTargetCairo.h index 8d409bb4416..5b7a4a5a9a6 100644 --- a/gfx/2d/DrawTargetCairo.h +++ b/gfx/2d/DrawTargetCairo.h @@ -123,7 +123,7 @@ public: virtual void *GetNativeSurface(NativeSurfaceType aType); - bool Init(cairo_surface_t* aSurface); + bool Init(cairo_surface_t* aSurface, const IntSize& aSize); void SetPathObserver(CairoPathContext* aPathObserver); @@ -157,6 +157,7 @@ private: // methods private: // data cairo_t* mContext; + IntSize mSize; std::vector mSnapshots; mutable RefPtr mPathObserver; }; diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index 1ca3e0c9984..9a46e8d87cf 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -365,11 +365,11 @@ Factory::GetD2DVRAMUsageSourceSurface() #endif // XP_WIN TemporaryRef -Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface) +Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSize& aSize) { #ifdef USE_CAIRO RefPtr newTarget = new DrawTargetCairo(); - if (newTarget->Init(aSurface)) { + if (newTarget->Init(aSurface, aSize)) { return newTarget; } diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 064b928fc96..65e9347f76c 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -473,9 +473,9 @@ gfxPlatform::OptimizeImage(gfxImageSurface *aSurface, cairo_user_data_key_t kDrawTarget; RefPtr -gfxPlatform::CreateDrawTargetForSurface(gfxASurface *aSurface) +gfxPlatform::CreateDrawTargetForSurface(gfxASurface *aSurface, const IntSize& aSize) { - RefPtr drawTarget = Factory::CreateDrawTargetForCairoSurface(aSurface->CairoSurface()); + RefPtr drawTarget = Factory::CreateDrawTargetForCairoSurface(aSurface->CairoSurface(), aSize); aSurface->SetData(&kDrawTarget, drawTarget, NULL); return drawTarget; } @@ -691,7 +691,7 @@ gfxPlatform::CreateOffscreenDrawTarget(const IntSize& aSize, SurfaceFormat aForm nsRefPtr surf = CreateOffscreenSurface(ThebesIntSize(aSize), ContentForFormat(aFormat)); - return CreateDrawTargetForSurface(surf); + return CreateDrawTargetForSurface(surf, aSize); } else { return Factory::CreateDrawTarget(backend, aSize, aFormat); } diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 37fc8c30a98..251ec19fd52 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -172,7 +172,7 @@ public: gfxASurface::gfxImageFormat format); virtual mozilla::RefPtr - CreateDrawTargetForSurface(gfxASurface *aSurface); + CreateDrawTargetForSurface(gfxASurface *aSurface, const mozilla::gfx::IntSize& aSize); /* * Creates a SourceSurface for a gfxASurface. This surface should -not- be