Bug 1440555 - P1: Allow setVisible to take effect before decoder creation. r=cpearce

MozReview-Commit-ID: GSNM6esm0fW

--HG--
extra : rebase_source : 89a9836a48a93f7dfc5ce78bc6fd8b2c11da9c0e
This commit is contained in:
Dan Glastonbury 2018-02-27 14:33:41 +10:00
Родитель 0b070afeaf
Коммит 80cd024fd7
3 изменённых файлов: 16 добавлений и 9 удалений

Просмотреть файл

@ -1645,11 +1645,10 @@ HTMLMediaElement::MozDumpDebugInfo()
void
HTMLMediaElement::SetVisible(bool aVisible)
{
if (!mDecoder) {
return;
}
mForcedHidden = !aVisible;
if (mDecoder) {
mDecoder->SetForcedHidden(!aVisible);
}
}
already_AddRefed<layers::Image>
@ -3880,6 +3879,7 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
mFirstFrameLoaded(false),
mDefaultPlaybackStartPosition(0.0),
mHasSuspendTaint(false),
mForcedHidden(false),
mMediaTracksConstructed(false),
mVisibilityState(Visibility::UNTRACKED),
mErrorSink(new ErrorSink(this)),
@ -7331,6 +7331,9 @@ HTMLMediaElement::SetDecoder(MediaDecoder* aDecoder)
}
mDecoder = aDecoder;
DDLINKCHILD("decoder", mDecoder.get());
if (mDecoder && mForcedHidden) {
mDecoder->SetForcedHidden(mForcedHidden);
}
}
float

Просмотреть файл

@ -1821,6 +1821,10 @@ private:
// participate in video decoder suspending.
bool mHasSuspendTaint;
// True if media element has been forced into being considered 'hidden'.
// For use by mochitests. Enabling pref "media.test.video-suspend"
bool mForcedHidden;
// True if audio tracks and video tracks are constructed and added into the
// track list, false if all tracks are removed from the track list.
bool mMediaTracksConstructed;

Просмотреть файл

@ -3080,6 +3080,11 @@ void MediaDecoderStateMachine::SetVideoDecodeModeInternal(VideoDecodeMode aMode)
{
MOZ_ASSERT(OnTaskQueue());
LOG("SetVideoDecodeModeInternal(), VideoDecodeMode=(%s->%s), mVideoDecodeSuspended=%c",
mVideoDecodeMode == VideoDecodeMode::Normal ? "Normal" : "Suspend",
aMode == VideoDecodeMode::Normal ? "Normal" : "Suspend",
mVideoDecodeSuspended ? 'T' : 'F');
// Should not suspend decoding if we don't turn on the pref.
if (!MediaPrefs::MDSMSuspendBackgroundVideoEnabled() &&
aMode == VideoDecodeMode::Suspend) {
@ -3092,11 +3097,6 @@ void MediaDecoderStateMachine::SetVideoDecodeModeInternal(VideoDecodeMode aMode)
return;
}
LOG("SetVideoDecodeModeInternal(), VideoDecodeMode=(%s->%s), mVideoDecodeSuspended=%c",
mVideoDecodeMode == VideoDecodeMode::Normal ? "Normal" : "Suspend",
aMode == VideoDecodeMode::Normal ? "Normal" : "Suspend",
mVideoDecodeSuspended ? 'T' : 'F');
// Set new video decode mode.
mVideoDecodeMode = aMode;