mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1343341. Only call AnimationState::SetDiscarded on the main thread. r=aosmond
Image::OnSurfaceDiscarded can be called on any thread. But AnimationState is a main thread only object.
This commit is contained in:
parent
edb96ff7d7
commit
63ad0ad7f3
@ -445,13 +445,38 @@ RasterImage::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey)
|
||||
{
|
||||
MOZ_ASSERT(mProgressTracker);
|
||||
|
||||
if (mAnimationState && aSurfaceKey.Playback() == PlaybackType::eAnimated) {
|
||||
bool animatedFramesDiscarded =
|
||||
mAnimationState && aSurfaceKey.Playback() == PlaybackType::eAnimated;
|
||||
|
||||
if (animatedFramesDiscarded && NS_IsMainThread()) {
|
||||
MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable());
|
||||
mAnimationState->SetDiscarded(true);
|
||||
// We don't need OnSurfaceDiscardedInternal to handle the animated frames
|
||||
// being discarded because we just did.
|
||||
animatedFramesDiscarded = false;
|
||||
}
|
||||
|
||||
RefPtr<RasterImage> image = this;
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction(
|
||||
"RasterImage::OnSurfaceDiscarded",
|
||||
[=]() -> void {
|
||||
image->OnSurfaceDiscardedInternal(animatedFramesDiscarded);
|
||||
}));
|
||||
}
|
||||
|
||||
void
|
||||
RasterImage::OnSurfaceDiscardedInternal(bool aAnimatedFramesDiscarded)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aAnimatedFramesDiscarded && mAnimationState) {
|
||||
MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable());
|
||||
mAnimationState->SetDiscarded(true);
|
||||
}
|
||||
|
||||
NS_DispatchToMainThread(NewRunnableMethod("ProgressTracker::OnDiscard",
|
||||
mProgressTracker, &ProgressTracker::OnDiscard));
|
||||
if (mProgressTracker) {
|
||||
mProgressTracker->OnDiscard();
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
|
@ -379,6 +379,8 @@ private:
|
||||
*/
|
||||
void RecoverFromInvalidFrames(const nsIntSize& aSize, uint32_t aFlags);
|
||||
|
||||
void OnSurfaceDiscardedInternal(bool aAnimatedFramesDiscarded);
|
||||
|
||||
private: // data
|
||||
nsIntSize mSize;
|
||||
nsTArray<nsIntSize> mNativeSizes;
|
||||
|
Loading…
x
Reference in New Issue
Block a user