Bug 1201796 (Part 2) - Add GetFrameAtSize() to support downscale-during-decode for GetFrame() use cases. r=tn
This commit is contained in:
@@ -668,19 +668,8 @@ VectorImage::IsOpaque()
|
||||
/* [noscript] SourceSurface getFrame(in uint32_t aWhichFrame,
|
||||
* in uint32_t aFlags; */
|
||||
NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
|
||||
VectorImage::GetFrame(uint32_t aWhichFrame,
|
||||
uint32_t aFlags)
|
||||
VectorImage::GetFrame(uint32_t aWhichFrame, uint32_t aFlags)
|
||||
{
|
||||
MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE);
|
||||
|
||||
if (aWhichFrame > FRAME_MAX_VALUE) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (mError || !mIsFullyLoaded) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Look up height & width
|
||||
// ----------------------
|
||||
SVGSVGElement* svgElem = mSVGDocumentWrapper->GetRootSVGElem();
|
||||
@@ -695,12 +684,32 @@ VectorImage::GetFrame(uint32_t aWhichFrame,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GetFrameAtSize(imageIntSize, aWhichFrame, aFlags);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
|
||||
VectorImage::GetFrameAtSize(const IntSize& aSize,
|
||||
uint32_t aWhichFrame,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE);
|
||||
|
||||
if (aSize.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (aWhichFrame > FRAME_MAX_VALUE) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (mError || !mIsFullyLoaded) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Make our surface the size of what will ultimately be drawn to it.
|
||||
// (either the full image size, or the restricted region)
|
||||
RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->
|
||||
CreateOffscreenContentDrawTarget(IntSize(imageIntSize.width,
|
||||
imageIntSize.height),
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
CreateOffscreenContentDrawTarget(aSize, SurfaceFormat::B8G8R8A8);
|
||||
if (!dt) {
|
||||
NS_ERROR("Could not create a DrawTarget");
|
||||
return nullptr;
|
||||
@@ -708,8 +717,8 @@ VectorImage::GetFrame(uint32_t aWhichFrame,
|
||||
|
||||
nsRefPtr<gfxContext> context = new gfxContext(dt);
|
||||
|
||||
auto result = Draw(context, imageIntSize,
|
||||
ImageRegion::Create(imageIntSize),
|
||||
auto result = Draw(context, aSize,
|
||||
ImageRegion::Create(aSize),
|
||||
aWhichFrame, GraphicsFilter::FILTER_NEAREST,
|
||||
Nothing(), aFlags);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user