Bug 948221 - Part 4: Add a gfxSurfaceDrawable constructor that takes a SourceSurface. r=roc

This commit is contained in:
Matt Woodrow 2013-11-27 14:05:03 +13:00
parent 6133167fe4
commit 0cfc75c3ec
2 changed files with 15 additions and 1 deletions

View File

@ -33,6 +33,15 @@ gfxSurfaceDrawable::gfxSurfaceDrawable(DrawTarget* aDrawTarget,
{
}
gfxSurfaceDrawable::gfxSurfaceDrawable(SourceSurface* aSurface,
const gfxIntSize aSize,
const gfxMatrix aTransform)
: gfxDrawable(aSize)
, mSourceSurface(aSurface)
, mTransform(aTransform)
{
}
static gfxMatrix
DeviceToImageTransform(gfxContext* aContext,
const gfxMatrix& aUserSpaceToImageSpace)
@ -127,6 +136,8 @@ gfxSurfaceDrawable::Draw(gfxContext* aContext,
RefPtr<SourceSurface> source = mDrawTarget->Snapshot();
pattern = new gfxPattern(source, Matrix());
}
} else if (mSourceSurface) {
pattern = new gfxPattern(mSourceSurface, Matrix());
} else {
pattern = new gfxPattern(mSurface);
}
@ -160,7 +171,7 @@ gfxSurfaceDrawable::Draw(gfxContext* aContext,
already_AddRefed<gfxImageSurface>
gfxSurfaceDrawable::GetAsImageSurface()
{
if (mDrawTarget) {
if (mDrawTarget || mSourceSurface) {
// TODO: Find a way to implement this. The caller really wants a 'sub-image' of
// the original, without having to do a copy. GetDataSurface() might just copy,
// which isn't useful.

View File

@ -58,6 +58,8 @@ public:
const gfxMatrix aTransform = gfxMatrix());
gfxSurfaceDrawable(mozilla::gfx::DrawTarget* aDT, const gfxIntSize aSize,
const gfxMatrix aTransform = gfxMatrix());
gfxSurfaceDrawable(mozilla::gfx::SourceSurface* aSurface, const gfxIntSize aSize,
const gfxMatrix aTransform = gfxMatrix());
virtual ~gfxSurfaceDrawable() {}
virtual bool Draw(gfxContext* aContext,
@ -71,6 +73,7 @@ public:
protected:
nsRefPtr<gfxASurface> mSurface;
mozilla::RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
mozilla::RefPtr<mozilla::gfx::SourceSurface> mSourceSurface;
const gfxMatrix mTransform;
};