Bug 1201796 (Part 2) - Add GetFrameAtSize() to support downscale-during-decode for GetFrame() use cases. r=tn

This commit is contained in:
Seth Fowler
2015-09-19 13:34:09 -07:00
parent 79db930145
commit cb59972471
12 changed files with 127 additions and 31 deletions

View File

@@ -168,10 +168,18 @@ DynamicImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags)
{
gfxIntSize size(mDrawable->Size());
return GetFrameAtSize(IntSize(size.width, size.height),
aWhichFrame,
aFlags);
}
NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
DynamicImage::GetFrameAtSize(const IntSize& aSize,
uint32_t aWhichFrame,
uint32_t aFlags)
{
RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(IntSize(size.width, size.height),
SurfaceFormat::B8G8R8A8);
CreateOffscreenContentDrawTarget(aSize, SurfaceFormat::B8G8R8A8);
if (!dt) {
gfxWarning() <<
"DynamicImage::GetFrame failed in CreateOffscreenContentDrawTarget";
@@ -179,7 +187,7 @@ DynamicImage::GetFrame(uint32_t aWhichFrame,
}
nsRefPtr<gfxContext> context = new gfxContext(dt);
auto result = Draw(context, size, ImageRegion::Create(size),
auto result = Draw(context, aSize, ImageRegion::Create(aSize),
aWhichFrame, GraphicsFilter::FILTER_NEAREST,
Nothing(), aFlags);