diff --git a/gfx/layers/NativeLayerCA.h b/gfx/layers/NativeLayerCA.h index 2579ec0baed3..5b881aaba306 100644 --- a/gfx/layers/NativeLayerCA.h +++ b/gfx/layers/NativeLayerCA.h @@ -120,7 +120,6 @@ class NativeLayerRootCA : public NativeLayerRoot { bool aIsOpaque) override; void SetWindowIsFullscreen(bool aFullscreen); - void NoteMouseMove(); void NoteMouseMoveAtTime(const TimeStamp& aTime); protected: @@ -145,7 +144,7 @@ class NativeLayerRootCA : public NativeLayerRoot { template void ForAllRepresentations(F aFn); - void UpdateMouseMovedRecently(); + void UpdateMouseMovedRecently(const MutexAutoLock& aProofOfLock); Mutex mMutex; // protects all other fields Representation mOnscreenRepresentation; diff --git a/gfx/layers/NativeLayerCA.mm b/gfx/layers/NativeLayerCA.mm index a4914d116739..bfd3d9d497de 100644 --- a/gfx/layers/NativeLayerCA.mm +++ b/gfx/layers/NativeLayerCA.mm @@ -135,7 +135,7 @@ NativeLayerRootCA::NativeLayerRootCA(CALayer* aLayer) : mMutex("NativeLayerRootCA"), mOnscreenRepresentation(aLayer), mOffscreenRepresentation(MakeOffscreenRootCALayer()) { - NoteMouseMove(); + mLastMouseMoveTime = TimeStamp::NowLoRes(); } NativeLayerRootCA::~NativeLayerRootCA() { @@ -240,7 +240,7 @@ bool NativeLayerRootCA::CommitToScreen() { return false; } - UpdateMouseMovedRecently(); + UpdateMouseMovedRecently(lock); mOnscreenRepresentation.Commit(WhichRepresentation::ONSCREEN, mSublayers, mWindowIsFullscreen, mMouseMovedRecently); @@ -533,26 +533,26 @@ void NativeLayerRootCA::DumpLayerTreeToFile(const char* aPath) { } void NativeLayerRootCA::SetWindowIsFullscreen(bool aFullscreen) { + MutexAutoLock lock(mMutex); + if (mWindowIsFullscreen != aFullscreen) { mWindowIsFullscreen = aFullscreen; for (auto layer : mSublayers) { layer->SetRootWindowIsFullscreen(mWindowIsFullscreen); } - - // Treat this as a mouse move, for purposes of resetting our timer. - NoteMouseMove(); - - PrepareForCommit(); - CommitToScreen(); } + + // Treat this as a mouse move, for purposes of resetting our timer. + mLastMouseMoveTime = TimeStamp::NowLoRes(); } -void NativeLayerRootCA::NoteMouseMove() { mLastMouseMoveTime = TimeStamp::NowLoRes(); } +void NativeLayerRootCA::NoteMouseMoveAtTime(const TimeStamp& aTime) { + MutexAutoLock lock(mMutex); + mLastMouseMoveTime = aTime; +} -void NativeLayerRootCA::NoteMouseMoveAtTime(const TimeStamp& aTime) { mLastMouseMoveTime = aTime; } - -void NativeLayerRootCA::UpdateMouseMovedRecently() { +void NativeLayerRootCA::UpdateMouseMovedRecently(const MutexAutoLock& aProofOfLock) { static const double SECONDS_TO_WAIT = 2.0; bool newMouseMovedRecently =