зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1731956: Make NativeLayerRootCA fullscreen and mouse move accessors thread safe. r=mstange
In addition to adding locks around the accessors, this also removes the call to `CommitToScreen` from the fullscreen accessor, which was probably redundant and definitely made the main thread call `Commit` which introduces possible concurrency errors. Differential Revision: https://phabricator.services.mozilla.com/D129425
This commit is contained in:
Родитель
b0068bfe22
Коммит
63e3c22a38
|
@ -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 <typename F>
|
||||
void ForAllRepresentations(F aFn);
|
||||
|
||||
void UpdateMouseMovedRecently();
|
||||
void UpdateMouseMovedRecently(const MutexAutoLock& aProofOfLock);
|
||||
|
||||
Mutex mMutex; // protects all other fields
|
||||
Representation mOnscreenRepresentation;
|
||||
|
|
|
@ -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 =
|
||||
|
|
Загрузка…
Ссылка в новой задаче