Bug 1746813 - Remove UpdateOcclusionStateRunnable r=gfx-reviewers,nical

Removing UpdateOcclusionStateRunnable could make code cleaner.

Differential Revision: https://phabricator.services.mozilla.com/D134255
This commit is contained in:
sotaro 2022-01-06 04:31:03 +00:00
Родитель 024fdf5a8d
Коммит 4779775168
2 изменённых файлов: 31 добавлений и 27 удалений

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

@ -84,29 +84,6 @@ class OcclusionUpdateRunnable : public CancelableRunnable {
TimeStamp mTimeStamp;
};
class UpdateOcclusionStateRunnable : public Runnable {
public:
UpdateOcclusionStateRunnable(std::unordered_map<HWND, OcclusionState>* aMap,
bool aShowAllWindows)
: Runnable("UpdateOcclusionStateRunnable"),
mMap(aMap),
mShowAllWindows(aShowAllWindows) {}
NS_IMETHOD Run() override {
MOZ_ASSERT(NS_IsMainThread());
auto* tracker = WinWindowOcclusionTracker::Get();
if (tracker) {
tracker->UpdateOcclusionState(mMap, mShowAllWindows);
}
return NS_OK;
}
private:
std::unordered_map<HWND, OcclusionState>* const mMap;
const bool mShowAllWindows;
};
// Used to serialize tasks related to mRootWindowHwndsOcclusionState.
class SerializedTaskDispatcher {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SerializedTaskDispatcher)
@ -610,6 +587,18 @@ bool WinWindowOcclusionTracker::IsWindowVisibleAndFullyOpaque(
return true;
}
// static
void WinWindowOcclusionTracker::CallUpdateOcclusionState(
std::unordered_map<HWND, OcclusionState>* aMap, bool aShowAllWindows) {
MOZ_ASSERT(NS_IsMainThread());
auto* tracker = WinWindowOcclusionTracker::Get();
if (!tracker) {
return;
}
tracker->UpdateOcclusionState(aMap, aShowAllWindows);
}
void WinWindowOcclusionTracker::UpdateOcclusionState(
std::unordered_map<HWND, OcclusionState>* aMap, bool aShowAllWindows) {
MOZ_ASSERT(NS_IsMainThread());
@ -972,8 +961,14 @@ void WinWindowOcclusionTracker::WindowOcclusionCalculator::
}
}
RefPtr<Runnable> runnable = new UpdateOcclusionStateRunnable(
&mRootWindowHwndsOcclusionState, mShowingThumbnails);
std::unordered_map<HWND, OcclusionState>* map =
&mRootWindowHwndsOcclusionState;
bool showAllWindows = mShowingThumbnails;
RefPtr<Runnable> runnable = NS_NewRunnableFunction(
"CallUpdateOcclusionState", [map, showAllWindows]() {
WinWindowOcclusionTracker::CallUpdateOcclusionState(map,
showAllWindows);
});
mSerializedTaskDispatcher->PostTaskToMain(runnable.forget());
}
@ -1189,8 +1184,14 @@ void WinWindowOcclusionTracker::WindowOcclusionCalculator::
"ProcessEventHookCallback() mShowingThumbnails = true");
mShowingThumbnails = true;
RefPtr<Runnable> runnable = new UpdateOcclusionStateRunnable(
&mRootWindowHwndsOcclusionState, mShowingThumbnails);
std::unordered_map<HWND, OcclusionState>* map =
&mRootWindowHwndsOcclusionState;
bool showAllWindows = mShowingThumbnails;
RefPtr<Runnable> runnable = NS_NewRunnableFunction(
"CallUpdateOcclusionState", [map, showAllWindows]() {
WinWindowOcclusionTracker::CallUpdateOcclusionState(
map, showAllWindows);
});
mSerializedTaskDispatcher->PostTaskToMain(runnable.forget());
}
}

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

@ -255,6 +255,9 @@ class WinWindowOcclusionTracker final : public DisplayStatusListener,
void Destroy();
static void CallUpdateOcclusionState(
std::unordered_map<HWND, OcclusionState>* aMap, bool aShowAllWindows);
// Updates root windows occclusion state. If aShowAllWindows is true,
// all non-hidden windows will be marked visible. This is used to force
// rendering of thumbnails.