Don't cache DrawTargetCaptures in nsCanvasFrame. (bug 1395478 part 10, r=mattwoodrow)

--HG--
extra : rebase_source : fc0746099e910f1e46842f292f60b2f00ee25f38
This commit is contained in:
David Anderson 2017-10-31 12:02:32 -07:00
parent 3bc0066b70
commit 997c7019bc
4 changed files with 24 additions and 3 deletions

View File

@ -1273,6 +1273,18 @@ public:
return CreateSimilarDrawTarget(aSize, aFormat);
}
/**
* Create a similar draw target, but if the draw target is not backed by a
* raster backend (for example, it is capturing or recording), force it to
* create a raster target instead. This is intended for code that wants to
* cache pixels, and would have no effect if it were caching a recording.
*/
virtual RefPtr<DrawTarget>
CreateSimilarRasterTarget(const IntSize& aSize, SurfaceFormat aFormat) const
{
return CreateSimilarDrawTarget(aSize, aFormat);
}
/**
* Create a path builder with the specified fillmode.
*

View File

@ -405,5 +405,12 @@ DrawTargetCaptureImpl::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceForm
return MakeAndAddRef<DrawTargetCaptureImpl>(GetBackendType(), aSize, aFormat);
}
RefPtr<DrawTarget>
DrawTargetCaptureImpl::CreateSimilarRasterTarget(const IntSize& aSize, SurfaceFormat aFormat) const
{
MOZ_ASSERT(!mRefDT->IsCaptureDT());
return mRefDT->CreateSimilarDrawTarget(aSize, aFormat);
}
} // namespace gfx
} // namespace mozilla

View File

@ -128,6 +128,8 @@ public:
virtual already_AddRefed<DrawTarget>
CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override;
virtual RefPtr<DrawTarget>
CreateSimilarRasterTarget(const IntSize& aSize, SurfaceFormat aFormat) const override;
virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override
{

View File

@ -383,9 +383,9 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
return;
}
dt = destDT->CreateSimilarDrawTarget(IntSize::Ceil(destRect.width,
destRect.height),
SurfaceFormat::B8G8R8A8);
dt = destDT->CreateSimilarRasterTarget(IntSize::Ceil(destRect.width,
destRect.height),
SurfaceFormat::B8G8R8A8);
if (dt && dt->IsValid()) {
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(ctx); // already checked draw target above