Bug 1822175 - Clean up dynamic refresh rate support on GeckoView. r=geckoview-reviewers,owlish

Differential Revision: https://phabricator.services.mozilla.com/D172782
This commit is contained in:
Makoto Kato 2023-03-22 15:35:16 +00:00
parent dc003c64c8
commit 56258a05fc

View File

@ -6,6 +6,7 @@
#include "AndroidVsync.h"
#include "AndroidBridge.h"
#include "nsTArray.h"
/**
@ -113,6 +114,8 @@ void AndroidVsync::Impl::UpdateObservingVsync() {
// Always called on the Java UI thread.
void AndroidVsync::NotifyVsync(int64_t aFrameTimeNanos) {
MOZ_ASSERT(AndroidBridge::IsJavaUiThread());
// Convert aFrameTimeNanos to a TimeStamp. The value converts trivially to
// the internal ticks representation of TimeStamp_posix; both use the
// monotonic clock and are in nanoseconds.
@ -131,13 +134,13 @@ void AndroidVsync::NotifyVsync(int64_t aFrameTimeNanos) {
}
void AndroidVsync::OnMaybeUpdateRefreshRate() {
// Do not keep the lock held while calling OnVsync.
MOZ_ASSERT(NS_IsMainThread());
auto impl = mImpl.Lock();
nsTArray<Observer*> observers;
{
auto impl = mImpl.Lock();
observers.AppendElements(impl->mInputObservers);
observers.AppendElements(impl->mRenderObservers);
}
observers.AppendElements(impl->mRenderObservers);
for (Observer* observer : observers) {
observer->OnMaybeUpdateRefreshRate();
}