Bug 1462355 - Part 9. Lock animated imgFrame objects at creation rather than deferring. r=tnikkel

This commit is contained in:
Andrew Osmond 2018-05-29 08:36:13 -04:00
parent d76ab26901
commit 14b23692e6
3 changed files with 7 additions and 26 deletions

View File

@ -356,8 +356,6 @@ Decoder::AllocateFrameInternal(const gfx::IntSize& aOutputSize,
if (frameNum == 1) {
MOZ_ASSERT(aPreviousFrame, "Must provide a previous frame when animated");
aPreviousFrame->SetRawAccessOnly();
// If we dispose of the first frame by clearing it, then the first frame's
// refresh area is all of itself.
// RESTORE_PREVIOUS is invalid (assumed to be DISPOSE_CLEAR).
@ -370,8 +368,6 @@ Decoder::AllocateFrameInternal(const gfx::IntSize& aOutputSize,
}
if (frameNum > 0) {
ref->SetRawAccessOnly();
// Some GIFs are huge but only have a small area that they animate. We only
// need to refresh that small area when frame 0 comes around again.
mFirstFrameRefreshArea.UnionRect(mFirstFrameRefreshArea, frame->GetRect());

View File

@ -314,6 +314,13 @@ imgFrame::InitForDecoder(const nsIntSize& aImageSize,
}
}
if (aAnimParams) {
// We never want to unlock animated frames because we need the raw frame
// buffer for blending with future frames. Adding an extra unmatched lock
// here will guarantee that.
++mLockCount;
}
return NS_OK;
}
@ -500,16 +507,6 @@ imgFrame::RawAccessRef(bool aOnlyFinished /*= false*/)
return RawAccessFrameRef(this, aOnlyFinished);
}
void
imgFrame::SetRawAccessOnly()
{
AssertImageDataLocked();
// Lock our data and throw away the key.
LockImageData(false);
}
imgFrame::SurfaceWithFormat
imgFrame::SurfaceForDrawing(bool aDoPartialDecode,
bool aDoTile,

View File

@ -103,18 +103,6 @@ public:
*/
RawAccessFrameRef RawAccessRef(bool aOnlyFinished = false);
/**
* Make this imgFrame permanently available for raw access.
*
* This is irrevocable, and should be avoided whenever possible, since it
* prevents this imgFrame from being optimized and makes it impossible for its
* volatile buffer to be freed.
*
* It is an error to call this without already holding a RawAccessFrameRef to
* this imgFrame.
*/
void SetRawAccessOnly();
bool Draw(gfxContext* aContext, const ImageRegion& aRegion,
SamplingFilter aSamplingFilter, uint32_t aImageFlags,
float aOpacity);