зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1741799 - Remove SupportsThreadSafeWeakPtr from WinWindowOcclusionTracker r=nical,gfx-reviewers
SupportsThreadSafeWeakPtr is not necessary for current WinWindowOcclusionTracker. Differential Revision: https://phabricator.services.mozilla.com/D131469
This commit is contained in:
Родитель
2dc3b69cde
Коммит
79ce913ffa
|
@ -86,16 +86,16 @@ class OcclusionUpdateRunnable : public CancelableRunnable {
|
||||||
|
|
||||||
class UpdateOcclusionStateRunnable : public Runnable {
|
class UpdateOcclusionStateRunnable : public Runnable {
|
||||||
public:
|
public:
|
||||||
UpdateOcclusionStateRunnable(
|
UpdateOcclusionStateRunnable(std::unordered_map<HWND, OcclusionState>* aMap,
|
||||||
ThreadSafeWeakPtr<WinWindowOcclusionTracker> aOcclusionTracker,
|
bool aShowAllWindows)
|
||||||
std::unordered_map<HWND, OcclusionState>* aMap, bool aShowAllWindows)
|
|
||||||
: Runnable("UpdateOcclusionStateRunnable"),
|
: Runnable("UpdateOcclusionStateRunnable"),
|
||||||
mOcclusionTracker(aOcclusionTracker),
|
|
||||||
mMap(aMap),
|
mMap(aMap),
|
||||||
mShowAllWindows(aShowAllWindows) {}
|
mShowAllWindows(aShowAllWindows) {}
|
||||||
|
|
||||||
NS_IMETHOD Run() override {
|
NS_IMETHOD Run() override {
|
||||||
auto tracker = RefPtr<WinWindowOcclusionTracker>(mOcclusionTracker);
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
|
auto* tracker = WinWindowOcclusionTracker::Get();
|
||||||
if (tracker) {
|
if (tracker) {
|
||||||
tracker->UpdateOcclusionState(mMap, mShowAllWindows);
|
tracker->UpdateOcclusionState(mMap, mShowAllWindows);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,6 @@ class UpdateOcclusionStateRunnable : public Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ThreadSafeWeakPtr<WinWindowOcclusionTracker> mOcclusionTracker;
|
|
||||||
std::unordered_map<HWND, OcclusionState>* const mMap;
|
std::unordered_map<HWND, OcclusionState>* const mMap;
|
||||||
const bool mShowAllWindows;
|
const bool mShowAllWindows;
|
||||||
};
|
};
|
||||||
|
@ -334,7 +333,7 @@ already_AddRefed<SerializedRunnable> SerializedTaskDispatcher::GetNextTask(
|
||||||
StaticRefPtr<WinWindowOcclusionTracker> WinWindowOcclusionTracker::sTracker;
|
StaticRefPtr<WinWindowOcclusionTracker> WinWindowOcclusionTracker::sTracker;
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
RefPtr<WinWindowOcclusionTracker> WinWindowOcclusionTracker::Get() {
|
WinWindowOcclusionTracker* WinWindowOcclusionTracker::Get() {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
return sTracker;
|
return sTracker;
|
||||||
}
|
}
|
||||||
|
@ -762,9 +761,8 @@ WinWindowOcclusionTracker::WindowOcclusionCalculator::
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
LOG(LogLevel::Info, "WindowOcclusionCalculator()");
|
LOG(LogLevel::Info, "WindowOcclusionCalculator()");
|
||||||
|
|
||||||
auto tracker = WinWindowOcclusionTracker::Get();
|
mSerializedTaskDispatcher =
|
||||||
mSerializedTaskDispatcher = tracker->GetSerializedTaskDispatcher();
|
WinWindowOcclusionTracker::Get()->GetSerializedTaskDispatcher();
|
||||||
mOcclusionTracker = ThreadSafeWeakPtr<WinWindowOcclusionTracker>(tracker);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WinWindowOcclusionTracker::WindowOcclusionCalculator::
|
WinWindowOcclusionTracker::WindowOcclusionCalculator::
|
||||||
|
@ -989,7 +987,7 @@ void WinWindowOcclusionTracker::WindowOcclusionCalculator::
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Runnable> runnable = new UpdateOcclusionStateRunnable(
|
RefPtr<Runnable> runnable = new UpdateOcclusionStateRunnable(
|
||||||
mOcclusionTracker, &mRootWindowHwndsOcclusionState, mShowingThumbnails);
|
&mRootWindowHwndsOcclusionState, mShowingThumbnails);
|
||||||
mSerializedTaskDispatcher->PostTaskToMain(runnable.forget());
|
mSerializedTaskDispatcher->PostTaskToMain(runnable.forget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1205,8 +1203,7 @@ void WinWindowOcclusionTracker::WindowOcclusionCalculator::
|
||||||
mShowingThumbnails = true;
|
mShowingThumbnails = true;
|
||||||
|
|
||||||
RefPtr<Runnable> runnable = new UpdateOcclusionStateRunnable(
|
RefPtr<Runnable> runnable = new UpdateOcclusionStateRunnable(
|
||||||
mOcclusionTracker, &mRootWindowHwndsOcclusionState,
|
&mRootWindowHwndsOcclusionState, mShowingThumbnails);
|
||||||
mShowingThumbnails);
|
|
||||||
mSerializedTaskDispatcher->PostTaskToMain(runnable.forget());
|
mSerializedTaskDispatcher->PostTaskToMain(runnable.forget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,16 +39,13 @@ class UpdateOcclusionStateRunnable;
|
||||||
|
|
||||||
// This class handles window occlusion tracking by using HWND.
|
// This class handles window occlusion tracking by using HWND.
|
||||||
// Implementation is borrowed from chromium's NativeWindowOcclusionTrackerWin.
|
// Implementation is borrowed from chromium's NativeWindowOcclusionTrackerWin.
|
||||||
class WinWindowOcclusionTracker final
|
class WinWindowOcclusionTracker final : public DisplayStatusListener,
|
||||||
: public SupportsThreadSafeWeakPtr<WinWindowOcclusionTracker>,
|
public SessionChangeListener {
|
||||||
public DisplayStatusListener,
|
|
||||||
public SessionChangeListener {
|
|
||||||
public:
|
public:
|
||||||
MOZ_DECLARE_THREADSAFEWEAKREFERENCE_TYPENAME(WinWindowOcclusionTracker)
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WinWindowOcclusionTracker)
|
||||||
MOZ_DECLARE_REFCOUNTED_TYPENAME(WinWindowOcclusionTracker)
|
|
||||||
|
|
||||||
/// Can only be called from the main thread.
|
/// Can only be called from the main thread.
|
||||||
static RefPtr<WinWindowOcclusionTracker> Get();
|
static WinWindowOcclusionTracker* Get();
|
||||||
|
|
||||||
/// Can only be called from the main thread.
|
/// Can only be called from the main thread.
|
||||||
static void Ensure();
|
static void Ensure();
|
||||||
|
@ -62,8 +59,6 @@ class WinWindowOcclusionTracker final
|
||||||
/// Can be called from any thread.
|
/// Can be called from any thread.
|
||||||
static bool IsInWinWindowOcclusionThread();
|
static bool IsInWinWindowOcclusionThread();
|
||||||
|
|
||||||
virtual ~WinWindowOcclusionTracker();
|
|
||||||
|
|
||||||
// Enables notifying to widget via NotifyOcclusionState() when the occlusion
|
// Enables notifying to widget via NotifyOcclusionState() when the occlusion
|
||||||
// state has been computed.
|
// state has been computed.
|
||||||
void Enable(nsBaseWidget* aWindow, HWND aHwnd);
|
void Enable(nsBaseWidget* aWindow, HWND aHwnd);
|
||||||
|
@ -86,6 +81,7 @@ class WinWindowOcclusionTracker final
|
||||||
friend class ::WinWindowOcclusionTrackerInteractiveTest;
|
friend class ::WinWindowOcclusionTrackerInteractiveTest;
|
||||||
|
|
||||||
explicit WinWindowOcclusionTracker(base::Thread* aThread);
|
explicit WinWindowOcclusionTracker(base::Thread* aThread);
|
||||||
|
virtual ~WinWindowOcclusionTracker();
|
||||||
|
|
||||||
// This class computes the occlusion state of the tracked windows.
|
// This class computes the occlusion state of the tracked windows.
|
||||||
// It runs on a separate thread, and notifies the main thread of
|
// It runs on a separate thread, and notifies the main thread of
|
||||||
|
@ -245,8 +241,6 @@ class WinWindowOcclusionTracker final
|
||||||
// Used to serialize tasks related to mRootWindowHwndsOcclusionState.
|
// Used to serialize tasks related to mRootWindowHwndsOcclusionState.
|
||||||
RefPtr<SerializedTaskDispatcher> mSerializedTaskDispatcher;
|
RefPtr<SerializedTaskDispatcher> mSerializedTaskDispatcher;
|
||||||
|
|
||||||
ThreadSafeWeakPtr<WinWindowOcclusionTracker> mOcclusionTracker;
|
|
||||||
|
|
||||||
friend class OcclusionUpdateRunnable;
|
friend class OcclusionUpdateRunnable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче