author | Kaku Kuo <kaku@mozilla.com> |
Fri, 10 Mar 2017 16:52:03 +0800 | |
changeset 347419 | af2fd441e1b2e96ffa38ff7b3a194be9cd67c1cd |
parent 347418 | caaa45f70bb7a7fd8077bdad3fe3b660aa4ca460 |
child 347420 | a42487bf567a382db80ffe2116324dd76daa7735 |
push id | 31496 |
push user | cbook@mozilla.com |
push date | Tue, 14 Mar 2017 13:21:57 +0000 |
treeherder | mozilla-central@9a26ed658fdc [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jwwang |
bugs | 1346498 |
milestone | 55.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
dom/media/MediaDecoder.cpp | file | annotate | diff | comparison | revisions | |
dom/media/MediaDecoder.h | file | annotate | diff | comparison | revisions |
--- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -1305,32 +1305,56 @@ MediaDecoder::NotifyCompositor() } } void MediaDecoder::SetElementVisibility(bool aIsVisible) { MOZ_ASSERT(NS_IsMainThread()); mElementVisible = aIsVisible; - mIsVisible = !mForcedHidden && mElementVisible; + UpdateVideoDecodeMode(); } void MediaDecoder::SetForcedHidden(bool aForcedHidden) { MOZ_ASSERT(NS_IsMainThread()); mForcedHidden = aForcedHidden; - SetElementVisibility(mElementVisible); + UpdateVideoDecodeMode(); } void MediaDecoder::SetSuspendTaint(bool aTainted) { MOZ_ASSERT(NS_IsMainThread()); mHasSuspendTaint = aTainted; + UpdateVideoDecodeMode(); +} + +void +MediaDecoder::UpdateVideoDecodeMode() +{ + // The MDSM may yet be set. + if (!mDecoderStateMachine) { + return; + } + + // If mHasSuspendTaint is set, never suspend the video decoder. + if (mHasSuspendTaint) { + mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Normal); + return; + } + + // If mForcedHidden is set, suspend the video decoder anyway. + // Otherwise, depends on the owner's visibility state. + if (!mForcedHidden && mElementVisible) { + mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Normal); + } else { + mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Suspend); + } } bool MediaDecoder::HasSuspendTaint() const { MOZ_ASSERT(NS_IsMainThread()); return mHasSuspendTaint; } @@ -1499,16 +1523,17 @@ MediaDecoder::DisconnectMirrors() void MediaDecoder::SetStateMachine(MediaDecoderStateMachine* aStateMachine) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT_IF(aStateMachine, !mDecoderStateMachine); mDecoderStateMachine = aStateMachine; if (aStateMachine) { ConnectMirrors(aStateMachine); + UpdateVideoDecodeMode(); } else { DisconnectMirrors(); } } ImageContainer* MediaDecoder::GetImageContainer() {
--- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -378,16 +378,18 @@ private: void SetForcedHidden(bool aForcedHidden); // Mark the decoder as tainted, meaning suspend-video-decoder is disabled. void SetSuspendTaint(bool aTaint); // Returns true if the decoder can't participate in suspend-video-decoder. bool HasSuspendTaint() const; + void UpdateVideoDecodeMode(); + /****** * The following methods must only be called on the main * thread. ******/ // Change to a new play state. This updates the mState variable and // notifies any thread blocking on this object's monitor of the // change. Call on the main thread only.