зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1346498 part 9 - move all policy codes into MediaDecoder::UpdateVideoDecodeMode(); r=jwwang
Make HTMLMediaElement no longer has logic of deciding visibility, it just passes all information into MediaDecoder. MozReview-Commit-ID: ApVcEQfboO --HG-- extra : rebase_source : 88c70b0cf1933d9cf814359909463a811be2ab9f extra : source : 669d1340d3c93d3e0eab55ce87693f842cf40247
This commit is contained in:
Родитель
fbcb4f2d6f
Коммит
7e43b9cace
|
@ -7400,12 +7400,9 @@ HTMLMediaElement::GetEMEInfo(nsString& aEMEInfo)
|
||||||
void
|
void
|
||||||
HTMLMediaElement::NotifyDecoderActivityChanges() const
|
HTMLMediaElement::NotifyDecoderActivityChanges() const
|
||||||
{
|
{
|
||||||
// A element is visible only if its document is visible and the element
|
|
||||||
// itself is visible.
|
|
||||||
const bool visible = !IsHidden() &&
|
|
||||||
mVisibilityState == Visibility::APPROXIMATELY_VISIBLE;
|
|
||||||
if (mDecoder) {
|
if (mDecoder) {
|
||||||
mDecoder->NotifyOwnerActivityChanged(visible);
|
mDecoder->NotifyOwnerActivityChanged(!IsHidden(),
|
||||||
|
mVisibilityState == Visibility::APPROXIMATELY_VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,11 +297,12 @@ MediaDecoder::ResourceCallback::NotifyBytesConsumed(int64_t aBytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaDecoder::NotifyOwnerActivityChanged(bool aIsVisible)
|
MediaDecoder::NotifyOwnerActivityChanged(bool aIsDocumentVisible,
|
||||||
|
bool aIsElementVisible)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
|
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
|
||||||
SetElementVisibility(aIsVisible);
|
SetElementVisibility(aIsDocumentVisible, aIsElementVisible);
|
||||||
|
|
||||||
NotifyCompositor();
|
NotifyCompositor();
|
||||||
}
|
}
|
||||||
|
@ -394,7 +395,8 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner)
|
||||||
, mMinimizePreroll(false)
|
, mMinimizePreroll(false)
|
||||||
, mMediaTracksConstructed(false)
|
, mMediaTracksConstructed(false)
|
||||||
, mFiredMetadataLoaded(false)
|
, mFiredMetadataLoaded(false)
|
||||||
, mElementVisible(!aOwner->IsHidden())
|
, mIsDocumentVisible(!aOwner->IsHidden())
|
||||||
|
, mIsElementVisible(!aOwner->IsHidden())
|
||||||
, mForcedHidden(false)
|
, mForcedHidden(false)
|
||||||
, mHasSuspendTaint(false)
|
, mHasSuspendTaint(false)
|
||||||
, INIT_MIRROR(mStateMachineIsShutdown, true)
|
, INIT_MIRROR(mStateMachineIsShutdown, true)
|
||||||
|
@ -1305,10 +1307,12 @@ MediaDecoder::NotifyCompositor()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaDecoder::SetElementVisibility(bool aIsVisible)
|
MediaDecoder::SetElementVisibility(bool aIsDocumentVisible,
|
||||||
|
bool aIsElementVisible)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
mElementVisible = aIsVisible;
|
mIsDocumentVisible = aIsDocumentVisible;
|
||||||
|
mIsElementVisible = aIsElementVisible;
|
||||||
UpdateVideoDecodeMode();
|
UpdateVideoDecodeMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1343,8 +1347,15 @@ MediaDecoder::UpdateVideoDecodeMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If mForcedHidden is set, suspend the video decoder anyway.
|
// If mForcedHidden is set, suspend the video decoder anyway.
|
||||||
|
if (mForcedHidden) {
|
||||||
|
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Suspend);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Otherwise, depends on the owner's visibility state.
|
// Otherwise, depends on the owner's visibility state.
|
||||||
if (!mForcedHidden && mElementVisible) {
|
// A element is visible only if its document is visible and the element
|
||||||
|
// itself is visible.
|
||||||
|
if (mIsDocumentVisible && mIsElementVisible) {
|
||||||
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Normal);
|
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Normal);
|
||||||
} else {
|
} else {
|
||||||
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Suspend);
|
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Suspend);
|
||||||
|
|
|
@ -189,7 +189,8 @@ public:
|
||||||
virtual nsresult Play();
|
virtual nsresult Play();
|
||||||
|
|
||||||
// Notify activity of the decoder owner is changed.
|
// Notify activity of the decoder owner is changed.
|
||||||
virtual void NotifyOwnerActivityChanged(bool aIsVisible);
|
virtual void NotifyOwnerActivityChanged(bool aIsDocumentVisible,
|
||||||
|
bool aIsElementVisible);
|
||||||
|
|
||||||
// Pause video playback.
|
// Pause video playback.
|
||||||
virtual void Pause();
|
virtual void Pause();
|
||||||
|
@ -371,7 +372,8 @@ private:
|
||||||
dom::AudioChannel GetAudioChannel() { return mAudioChannel; }
|
dom::AudioChannel GetAudioChannel() { return mAudioChannel; }
|
||||||
|
|
||||||
// Called from HTMLMediaElement when owner document activity changes
|
// Called from HTMLMediaElement when owner document activity changes
|
||||||
virtual void SetElementVisibility(bool aIsVisible);
|
virtual void SetElementVisibility(bool aIsDocumentVisible,
|
||||||
|
bool aIsElementVisible);
|
||||||
|
|
||||||
// Force override the visible state to hidden.
|
// Force override the visible state to hidden.
|
||||||
// Called from HTMLMediaElement when testing of video decode suspend from mochitests.
|
// Called from HTMLMediaElement when testing of video decode suspend from mochitests.
|
||||||
|
@ -716,8 +718,11 @@ protected:
|
||||||
// only be accessed from main thread.
|
// only be accessed from main thread.
|
||||||
nsAutoPtr<MediaInfo> mInfo;
|
nsAutoPtr<MediaInfo> mInfo;
|
||||||
|
|
||||||
// Tracks the visiblity status from HTMLMediaElement
|
// Tracks the visibility status of owner element's document.
|
||||||
bool mElementVisible;
|
bool mIsDocumentVisible;
|
||||||
|
|
||||||
|
// Tracks the visibliity status of owner element.
|
||||||
|
bool mIsElementVisible;
|
||||||
|
|
||||||
// If true, forces the decoder to be considered hidden.
|
// If true, forces the decoder to be considered hidden.
|
||||||
bool mForcedHidden;
|
bool mForcedHidden;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче