From 9ad44524fe912b011a7096794d42f74b46065330 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Wed, 2 Oct 2013 16:05:34 +1300 Subject: [PATCH] Bug 886219 - Force an invalidation when an async video finishes. r=nical --- content/media/MediaDecoder.cpp | 8 ++++++++ content/media/MediaDecoder.h | 1 + content/media/VideoFrameContainer.cpp | 4 ++-- content/media/VideoFrameContainer.h | 7 ++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/content/media/MediaDecoder.cpp b/content/media/MediaDecoder.cpp index b25b26cc819..84518fc152b 100644 --- a/content/media/MediaDecoder.cpp +++ b/content/media/MediaDecoder.cpp @@ -901,6 +901,7 @@ void MediaDecoder::PlaybackEnded() PlaybackPositionChanged(); ChangeState(PLAY_STATE_ENDED); + InvalidateWithFlags(VideoFrameContainer::INVALIDATE_FORCE); UpdateReadyStateForData(); if (mOwner) { @@ -1466,6 +1467,13 @@ ImageContainer* MediaDecoder::GetImageContainer() return mVideoFrameContainer ? mVideoFrameContainer->GetImageContainer() : nullptr; } +void MediaDecoder::InvalidateWithFlags(uint32_t aFlags) +{ + if (mVideoFrameContainer) { + mVideoFrameContainer->InvalidateWithFlags(aFlags); + } +} + void MediaDecoder::Invalidate() { if (mVideoFrameContainer) { diff --git a/content/media/MediaDecoder.h b/content/media/MediaDecoder.h index e03eb093d26..52a566b757f 100644 --- a/content/media/MediaDecoder.h +++ b/content/media/MediaDecoder.h @@ -533,6 +533,7 @@ public: // Invalidate the frame. void Invalidate(); + void InvalidateWithFlags(uint32_t aFlags); // Suspend any media downloads that are in progress. Called by the // media element when it is sent to the bfcache, or when we need diff --git a/content/media/VideoFrameContainer.cpp b/content/media/VideoFrameContainer.cpp index 83ba71cf77d..89ec8f55120 100644 --- a/content/media/VideoFrameContainer.cpp +++ b/content/media/VideoFrameContainer.cpp @@ -106,11 +106,11 @@ double VideoFrameContainer::GetFrameDelay() return mPaintDelay.ToSeconds(); } -void VideoFrameContainer::Invalidate() +void VideoFrameContainer::InvalidateWithFlags(uint32_t aFlags) { NS_ASSERTION(NS_IsMainThread(), "Must call on main thread"); - if (!mNeedInvalidation) { + if (!mNeedInvalidation && !(aFlags & INVALIDATE_FORCE)) { return; } diff --git a/content/media/VideoFrameContainer.h b/content/media/VideoFrameContainer.h index 00d8db35e75..29f6844e70c 100644 --- a/content/media/VideoFrameContainer.h +++ b/content/media/VideoFrameContainer.h @@ -55,7 +55,12 @@ public: // but was actually painted at t+n, this returns n in seconds. Threadsafe. double GetFrameDelay(); // Call on main thread - void Invalidate(); + enum { + INVALIDATE_DEFAULT, + INVALIDATE_FORCE + }; + void Invalidate() { InvalidateWithFlags(INVALIDATE_DEFAULT); } + void InvalidateWithFlags(uint32_t aFlags); ImageContainer* GetImageContainer(); void ForgetElement() { mElement = nullptr; }