Bug 1765399 - Rename RefreshTimerVsyncDispatcher to VsyncDispatcher. r=smaug

RefreshTimerVsyncDispatcher manages a lot more than just the
RefreshDriverVsyncTimer these days.

Differential Revision: https://phabricator.services.mozilla.com/D144363
This commit is contained in:
Markus Stange 2022-05-05 02:15:13 +00:00
parent eaa6f31297
commit 5ef3c929f4
11 changed files with 64 additions and 71 deletions

View File

@ -4404,7 +4404,7 @@ _moz_cairo_dwrite_set_cleartype_params
?DwmCompositionEnabled@gfxWindowsPlatform@@QAE_NXZ
??_GgfxWindowsPlatform@@UAEPAXI@Z
??0Display@VsyncSource@gfx@mozilla@@QAE@XZ
??0RefreshTimerVsyncDispatcher@mozilla@@QAE@PAVDisplay@VsyncSource@gfx@1@@Z
??0VsyncDispatcher@mozilla@@QAE@PAVDisplay@VsyncSource@gfx@1@@Z
?destroy_sandbox@?$rlbox_sandbox@Vrlbox_noop_sandbox@rlbox@@@rlbox@@QAE?A?<auto>@@XZ
?Start@Thread@base@@QAE_NXZ
?Run@MessagePumpDefault@base@@UAEXPAVDelegate@MessagePump@2@@Z
@ -5824,11 +5824,11 @@ _ZN5style7sharing17SHARING_CACHE_KEY7__getit17he592e433f2be153cE
??8?$StyleGenericCrossFadeImage@U?$StyleGenericImage@U?$StyleGenericGradient@UStyleLineDirection@mozilla@@TStyleLengthPercentageUnion@2@UStyleCSSPixelLength@2@T32@U?$StyleGenericPosition@TStyleLengthPercentageUnion@mozilla@@T12@@2@UStyleAngle@2@UStyleAngleOrPercentage@2@U?$StyleGenericColor@UStyleRGBA@mozilla@@@2@@mozilla@@U?$StyleGenericMozImageRect@UStyleNumberOrPercentage@mozilla@@UStyleComputedUrl@2@@2@UStyleComputedUrl@2@U?$StyleGenericColor@UStyleRGBA@mozilla@@@2@UStylePercentage@2@@mozilla@@U?$StyleGenericColor@UStyleRGBA@mozilla@@@2@@mozilla@@QBE_NABU01@@Z
?Csp@nsDocShellLoadState@@QBEPAVnsIContentSecurityPolicy@@XZ
?GetNextTickHint@nsRefreshDriver@@SA?AV?$Maybe@VTimeStamp@mozilla@@@mozilla@@XZ
?GetRefreshTimerVsyncDispatcher@VsyncSource@gfx@mozilla@@QAE?AV?$RefPtr@VRefreshTimerVsyncDispatcher@mozilla@@@@XZ
?GetVsyncDispatcher@VsyncSource@gfx@mozilla@@QAE?AV?$RefPtr@VVsyncDispatcher@mozilla@@@@XZ
?IsInLayoutAsapMode@gfxPlatform@@SA_NXZ
?GetRootPresContext@nsPresContext@@QBEPAVnsRootPresContext@@XZ
?AddChildRefreshTimer@RefreshTimerVsyncDispatcher@mozilla@@QAEXPAVVsyncObserver@2@@Z
??1RefreshTimerVsyncDispatcher@mozilla@@EAE@XZ
?AddChildRefreshTimer@VsyncDispatcher@mozilla@@QAEXPAVVsyncObserver@2@@Z
??1VsyncDispatcher@mozilla@@EAE@XZ
?NotifyRefreshTimerVsyncStatus@Display@VsyncSource@gfx@mozilla@@QAEX_N@Z
?GetVsyncRate@D3DVsyncDisplay@D3DVsyncSource@@UAE?AV?$BaseTimeDuration@VTimeDurationValueCalculator@mozilla@@@mozilla@@XZ
?PostTask@MessageLoop@@QAEXU?$already_AddRefed@VnsIRunnable@@@@@Z
@ -5899,7 +5899,7 @@ _ZN5style7sharing17SHARING_CACHE_KEY7__getit17he592e433f2be153cE
?SendSetIsInitialDocument@PWindowGlobalChild@dom@mozilla@@QAE_NAB_N@Z
?Run@?$RunnableMethodImpl@$$CBV?$RefPtr@VVideoFrameContainer@mozilla@@@@P8VideoFrameContainer@mozilla@@AEXXZ$00$0A@$$V@detail@mozilla@@UAG?AW4nsresult@@XZ
?NotifyVsync@Display@VsyncSource@gfx@mozilla@@UAEXABVTimeStamp@4@0@Z
?NotifyVsync@RefreshTimerVsyncDispatcher@mozilla@@QAEXABUVsyncEvent@2@@Z
?NotifyVsync@VsyncDispatcher@mozilla@@QAEXABUVsyncEvent@2@@Z
?Release@nsGlobalWindowOuter@@UAGKXZ
?QueryInterface@PrioritizableRunnable@mozilla@@UAG?AW4nsresult@@ABUnsID@@PAPAX@Z
?AddRef@nsGlobalWindowOuter@@UAGKXZ
@ -6834,7 +6834,7 @@ Servo_StyleSet_BuildFontFeatureValueSet
?DeallocManagee@PBackgroundIDBFactoryChild@indexedDB@dom@mozilla@@UAEXHPAVIProtocol@ipc@4@@Z
?DeallocPBackgroundIDBFactoryRequestChild@BackgroundFactoryChild@indexedDB@dom@mozilla@@QAE_NPAVPBackgroundIDBFactoryRequestChild@234@@Z
?Disconnect@nsRefreshDriver@@QAEXXZ
?RemoveChildRefreshTimer@RefreshTimerVsyncDispatcher@mozilla@@QAEXPAVVsyncObserver@2@@Z
?RemoveChildRefreshTimer@VsyncDispatcher@mozilla@@QAEXPAVVsyncObserver@2@@Z
?DisableVsync@D3DVsyncDisplay@D3DVsyncSource@@UAEXXZ
?finishSingleParseTask@GlobalHelperThreadState@js@@AAEPAVJSScript@@PAUJSContext@@W4ParseTaskKind@2@PAVOffThreadToken@JS@@W4StartEncoding@2@@Z
?GetCanceled@DocumentChannel@net@mozilla@@UAG?AW4nsresult@@PA_N@Z

View File

@ -2908,7 +2908,7 @@ moz_cairo_dwrite_set_cleartype_params
?DwmCompositionEnabled@gfxWindowsPlatform@@QEAA_NXZ
??_GgfxWindowsPlatform@@UEAAPEAXI@Z
??0Display@VsyncSource@gfx@mozilla@@QEAA@XZ
??0RefreshTimerVsyncDispatcher@mozilla@@QEAA@PEAVDisplay@VsyncSource@gfx@1@@Z
??0VsyncDispatcher@mozilla@@QEAA@PEAVDisplay@VsyncSource@gfx@1@@Z
?destroy_sandbox@?$rlbox_sandbox@Vrlbox_noop_sandbox@rlbox@@@rlbox@@QEAA?A?<auto>@@XZ
?Start@Thread@base@@QEAA_NXZ
?Run@MessagePumpDefault@base@@UEAAXPEAVDelegate@MessagePump@2@@Z
@ -3996,11 +3996,11 @@ ZN5style7stylist7Stylist17append_stylesheet17he70cadcba5340a98E
?AccessKey@ApplicationAccessible@a11y@mozilla@@UEBA?AVKeyBinding@23@XZ
??8?$StyleGenericCrossFadeImage@U?$StyleGenericImage@U?$StyleGenericGradient@UStyleLineDirection@mozilla@@TStyleLengthPercentageUnion@2@UStyleCSSPixelLength@2@T32@U?$StyleGenericPosition@TStyleLengthPercentageUnion@mozilla@@T12@@2@UStyleAngle@2@UStyleAngleOrPercentage@2@U?$StyleGenericColor@UStyleRGBA@mozilla@@@2@@mozilla@@U?$StyleGenericMozImageRect@UStyleNumberOrPercentage@mozilla@@UStyleComputedUrl@2@@2@UStyleComputedUrl@2@U?$StyleGenericColor@UStyleRGBA@mozilla@@@2@UStylePercentage@2@@mozilla@@U?$StyleGenericColor@UStyleRGBA@mozilla@@@2@@mozilla@@QEBA_NAEBU01@@Z
?GetNextTickHint@nsRefreshDriver@@SA?AV?$Maybe@VTimeStamp@mozilla@@@mozilla@@XZ
?GetRefreshTimerVsyncDispatcher@VsyncSource@gfx@mozilla@@QEAA?AV?$RefPtr@VRefreshTimerVsyncDispatcher@mozilla@@@@XZ
?GetVsyncDispatcher@VsyncSource@gfx@mozilla@@QEAA?AV?$RefPtr@VVsyncDispatcher@mozilla@@@@XZ
?IsInLayoutAsapMode@gfxPlatform@@SA_NXZ
?GetRootPresContext@nsPresContext@@QEBAPEAVnsRootPresContext@@XZ
?AddChildRefreshTimer@RefreshTimerVsyncDispatcher@mozilla@@QEAAXPEAVVsyncObserver@2@@Z
?NotifyVsync@RefreshTimerVsyncDispatcher@mozilla@@QEAAXAEBUVsyncEvent@2@@Z
?AddChildRefreshTimer@VsyncDispatcher@mozilla@@QEAAXPEAVVsyncObserver@2@@Z
?NotifyVsync@VsyncDispatcher@mozilla@@QEAAXAEBUVsyncEvent@2@@Z
?NotifyRefreshTimerVsyncStatus@Display@VsyncSource@gfx@mozilla@@QEAAX_N@Z
?GetVsyncRate@D3DVsyncDisplay@D3DVsyncSource@@UEAA?AV?$BaseTimeDuration@VTimeDurationValueCalculator@mozilla@@@mozilla@@XZ
?PostTask@MessageLoop@@QEAAXU?$already_AddRefed@VnsIRunnable@@@@@Z
@ -6973,7 +6973,7 @@ nsEscape
?GetPromiseState@JS@@YA?AW4PromiseState@1@V?$Handle@PEAVJSObject@@@1@@Z
?DoomAlreadyRemoved@CacheEntry@net@mozilla@@QEAAXXZ
?Disconnect@nsRefreshDriver@@QEAAXXZ
?RemoveChildRefreshTimer@RefreshTimerVsyncDispatcher@mozilla@@QEAAXPEAVVsyncObserver@2@@Z
?RemoveChildRefreshTimer@VsyncDispatcher@mozilla@@QEAAXPEAVVsyncObserver@2@@Z
?DisableVsync@D3DVsyncDisplay@D3DVsyncSource@@UEAAXXZ
?CallTypeSniffers@HttpBaseChannel@net@mozilla@@KAXPEAXPEBEI@Z
?NS_SniffContent@@YAXPEBDPEAVnsIRequest@@PEBEIAEAV?$nsTSubstring@D@@@Z

View File

@ -30,7 +30,7 @@ void VsyncParent::UpdateVsyncSource(
if (mObservingVsync && mVsyncDispatcher) {
mVsyncDispatcher->RemoveVsyncObserver(this);
}
mVsyncDispatcher = mVsyncSource->GetRefreshTimerVsyncDispatcher();
mVsyncDispatcher = mVsyncSource->GetVsyncDispatcher();
if (mObservingVsync) {
mVsyncDispatcher->AddVsyncObserver(this);
}

View File

@ -48,7 +48,7 @@ class VsyncParent final : public PVsyncParent, public VsyncObserver {
bool mDestroyed;
nsCOMPtr<nsIThread> mInitialThread;
RefPtr<gfx::VsyncSource> mVsyncSource;
RefPtr<RefreshTimerVsyncDispatcher> mVsyncDispatcher;
RefPtr<VsyncDispatcher> mVsyncDispatcher;
};
} // namespace mozilla::dom

View File

@ -18,7 +18,7 @@ The flow of our rendering engine is as follows:
1. Hardware Vsync event occurs on an OS specific *Hardware Vsync Thread*
on a per monitor basis.
2. The *Hardware Vsync Thread* attached to the monitor notifies the
``CompositorVsyncDispatchers`` and ``RefreshTimerVsyncDispatcher``.
``CompositorVsyncDispatchers`` and ``VsyncDispatcher``.
3. For every Firefox window on the specific monitor, notify a
``CompositorVsyncDispatcher``. The ``CompositorVsyncDispatcher`` is
specific to one window.
@ -30,9 +30,9 @@ The flow of our rendering engine is as follows:
UI process, which sends an IPDL message to the ``VsyncBridgeParent``
on the compositor thread of the GPU process, which then dispatches to
``CompositorVsyncScheduler::Observer``.
6. The ``RefreshTimerVsyncDispatcher`` notifies the Chrome
6. The ``VsyncDispatcher`` notifies the Chrome
``RefreshTimer`` that a vsync has occurred.
7. The ``RefreshTimerVsyncDispatcher`` sends IPC messages to all content
7. The ``VsyncDispatcher`` sends IPC messages to all content
processes to tick their respective active ``RefreshTimer``.
8. The ``Compositor`` dispatches input events on the *Compositor
Thread*, then composites. Input events are only dispatched on the
@ -69,7 +69,7 @@ callback fetches all ``CompositorVsyncDispatchers`` associated with the
has occurred with the vsyncs timestamp. It is the responsibility of the
``CompositorVsyncDispatcher`` to notify the ``Compositor`` that is
awaiting vsync notifications. The ``Display`` will then notify the
associated ``RefreshTimerVsyncDispatcher``, which should notify all
associated ``VsyncDispatcher``, which should notify all
active ``RefreshDrivers`` to tick.
All ``Display`` objects are encapsulated in a ``VsyncSource`` object.
@ -326,15 +326,15 @@ Instead, we create a new ``RefreshTimer``, the ``VsyncRefreshTimer``
which ticks based on vsync messages. We replace the current active timer
with a ``VsyncRefreshTimer``. All tabs will then tick based on this new
active timer. Since the ``RefreshTimer`` has a lifetime of the process,
we only need to create a single ``RefreshTimerVsyncDispatcher`` per
we only need to create a single ``VsyncDispatcher`` per
``Display`` when Firefox starts. Even if we do not have any content
processes, the Chrome process will still need a ``VsyncRefreshTimer``,
thus we can associate the ``RefreshTimerVsyncDispatcher`` with each
thus we can associate the ``VsyncDispatcher`` with each
``Display``.
When Firefox starts, we initially create a new ``VsyncRefreshTimer`` in
the Chrome process. The ``VsyncRefreshTimer`` will listen to vsync
notifications from ``RefreshTimerVsyncDispatcher`` on the global
notifications from ``VsyncDispatcher`` on the global
``Display``. When nsRefreshDriver::Shutdown executes, it will delete the
``VsyncRefreshTimer``. This creates a problem as all the
``RefreshTimers`` are currently manually memory managed whereas
@ -377,17 +377,17 @@ messages should be sent across the channel. After ActorDestroy is
called, the IPDL machinery will delete the **VsyncParent/Child** pair.
The ``VsyncParent``, due to being a ``VsyncObserver``, is ref counted.
After ``VsyncParent::ActorDestroy`` is called, it unregisters itself
from the ``RefreshTimerVsyncDispatcher``, which holds the last reference
from the ``VsyncDispatcher``, which holds the last reference
to the ``VsyncParent``, and the object will be deleted.
Thus the overall flow during normal execution is:
1. VsyncSource::Display::RefreshTimerVsyncDispatcher receives a Vsync
1. VsyncSource::Display::VsyncDispatcher receives a Vsync
notification from the OS in the parent process.
2. RefreshTimerVsyncDispatcher notifies
2. VsyncDispatcher notifies
VsyncRefreshTimer::RefreshDriverVsyncObserver that a vsync occurred on
the parent process on the hardware vsync thread.
3. RefreshTimerVsyncDispatcher notifies the VsyncParent on the hardware
3. VsyncDispatcher notifies the VsyncParent on the hardware
vsync thread that a vsync occurred.
4. The VsyncRefreshTimer::RefreshDriverVsyncObserver in the parent
process posts a task to the main thread that ticks the refresh
@ -426,7 +426,7 @@ multiple ``RefreshDrivers``.
When a tab or window changes monitors, the ``nsIWidget`` receives a
display changed notification. Based on which display the window is on,
the window switches to the correct ``RefreshTimerVsyncDispatcher`` and
the window switches to the correct ``VsyncDispatcher`` and
``CompositorVsyncDispatcher`` on the parent process based on the display
id. Each ``TabParent`` should also send a notification to their child.
Each ``TabChild``, given the display ID, switches to the correct
@ -444,7 +444,7 @@ Object Lifetime
associated with the VsyncDispatcher
2. CompositorVsyncScheduler::Observer - Lives and dies the same time as
the CompositorBridgeParent.
3. RefreshTimerVsyncDispatcher - As long as the associated display
3. VsyncDispatcher - As long as the associated display
object, which is the lifetime of Firefox.
4. VsyncSource - Lives as long as the gfxPlatform on the chrome process,
which is the lifetime of Firefox.

View File

@ -138,8 +138,7 @@ TEST_F(VsyncTester, ChildRefreshDriverGetVsyncNotifications) {
mVsyncSource->DisableVsync();
ASSERT_FALSE(mVsyncSource->IsVsyncEnabled());
RefPtr<RefreshTimerVsyncDispatcher> vsyncDispatcher =
mVsyncSource->GetRefreshTimerVsyncDispatcher();
RefPtr<VsyncDispatcher> vsyncDispatcher = mVsyncSource->GetVsyncDispatcher();
ASSERT_TRUE(vsyncDispatcher != nullptr);
RefPtr<TestVsyncObserver> testVsyncObserver = new TestVsyncObserver();

View File

@ -22,13 +22,13 @@ VsyncSource::VsyncSource()
mRefreshTimerNeedsVsync(false),
mHasGenericObservers(false) {
MOZ_ASSERT(NS_IsMainThread());
mRefreshTimerVsyncDispatcher = new RefreshTimerVsyncDispatcher(this);
mVsyncDispatcher = new VsyncDispatcher(this);
}
VsyncSource::~VsyncSource() {
MOZ_ASSERT(NS_IsMainThread());
MutexAutoLock lock(mDispatcherLock);
mRefreshTimerVsyncDispatcher = nullptr;
mVsyncDispatcher = nullptr;
MOZ_ASSERT(mRegisteredCompositorVsyncDispatchers.Length() == 0);
MOZ_ASSERT(mEnabledCompositorVsyncDispatchers.Length() == 0);
}
@ -38,11 +38,11 @@ void VsyncSource::NotifyVsync(const TimeStamp& aVsyncTimestamp,
// Called on the vsync thread
MutexAutoLock lock(mDispatcherLock);
// mRefreshTimerVsyncDispatcher might be null here if MoveListenersToNewSource
// mVsyncDispatcher might be null here if MoveListenersToNewSource
// was called concurrently with this function and won the race to acquire
// mDispatcherLock. In this case the new VsyncSource that is replacing this
// one will handle notifications from now on, so we can abort.
if (!mRefreshTimerVsyncDispatcher) {
if (!mVsyncDispatcher) {
return;
}
@ -60,7 +60,7 @@ void VsyncSource::NotifyVsync(const TimeStamp& aVsyncTimestamp,
mEnabledCompositorVsyncDispatchers[i]->NotifyVsync(event);
}
mRefreshTimerVsyncDispatcher->NotifyVsync(event);
mVsyncDispatcher->NotifyVsync(event);
if (dispatchToMainThread) {
mLastVsyncIdSentToMainThread = mVsyncId;
@ -172,9 +172,9 @@ void VsyncSource::MoveListenersToNewSource(
aNewSource);
}
aNewSource->mRefreshTimerVsyncDispatcher = mRefreshTimerVsyncDispatcher;
mRefreshTimerVsyncDispatcher->MoveToSource(aNewSource);
mRefreshTimerVsyncDispatcher = nullptr;
aNewSource->mVsyncDispatcher = mVsyncDispatcher;
mVsyncDispatcher->MoveToSource(aNewSource);
mVsyncDispatcher = nullptr;
}
void VsyncSource::NotifyRefreshTimerVsyncStatus(bool aEnable) {
@ -209,9 +209,8 @@ void VsyncSource::UpdateVsyncStatus() {
}
}
RefPtr<RefreshTimerVsyncDispatcher>
VsyncSource::GetRefreshTimerVsyncDispatcher() {
return mRefreshTimerVsyncDispatcher;
RefPtr<VsyncDispatcher> VsyncSource::GetVsyncDispatcher() {
return mVsyncDispatcher;
}
// static

View File

@ -15,7 +15,7 @@
#include "mozilla/layers/LayersTypes.h"
namespace mozilla {
class RefreshTimerVsyncDispatcher;
class VsyncDispatcher;
class CompositorVsyncDispatcher;
class VsyncObserver;
struct VsyncEvent;
@ -30,7 +30,7 @@ namespace gfx {
class VsyncSource {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncSource)
typedef mozilla::RefreshTimerVsyncDispatcher RefreshTimerVsyncDispatcher;
typedef mozilla::VsyncDispatcher VsyncDispatcher;
typedef mozilla::CompositorVsyncDispatcher CompositorVsyncDispatcher;
public:
@ -83,7 +83,7 @@ class VsyncSource {
void MoveListenersToNewSource(const RefPtr<VsyncSource>& aNewSource);
RefPtr<RefreshTimerVsyncDispatcher> GetRefreshTimerVsyncDispatcher();
RefPtr<VsyncDispatcher> GetVsyncDispatcher();
// Returns the rate of the fastest enabled VsyncSource or Nothing().
static Maybe<TimeDuration> GetFastestVsyncRate();
@ -100,7 +100,7 @@ class VsyncSource {
mEnabledCompositorVsyncDispatchers;
nsTArray<RefPtr<CompositorVsyncDispatcher>>
mRegisteredCompositorVsyncDispatchers;
RefPtr<RefreshTimerVsyncDispatcher> mRefreshTimerVsyncDispatcher;
RefPtr<VsyncDispatcher> mVsyncDispatcher;
nsTArray<RefPtr<VsyncObserver>>
mGenericObservers; // can only be touched from the main thread
VsyncId mVsyncId;

View File

@ -448,8 +448,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
MOZ_RELEASE_ASSERT(NS_IsMainThread());
RefPtr<gfx::VsyncSource> vsyncSource =
gfxPlatform::GetPlatform()->GetHardwareVsync();
RefPtr<RefreshTimerVsyncDispatcher> vsyncDispatcher =
vsyncSource->GetRefreshTimerVsyncDispatcher();
RefPtr<VsyncDispatcher> vsyncDispatcher = vsyncSource->GetVsyncDispatcher();
RefPtr<VsyncRefreshDriverTimer> timer = new VsyncRefreshDriverTimer(
std::move(vsyncSource), std::move(vsyncDispatcher), nullptr);
return timer.forget();
@ -463,8 +462,8 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
RefPtr<gfx::VsyncSource>&& aVsyncSource) {
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
RefPtr<RefreshTimerVsyncDispatcher> vsyncDispatcher =
aVsyncSource->GetRefreshTimerVsyncDispatcher();
RefPtr<VsyncDispatcher> vsyncDispatcher =
aVsyncSource->GetVsyncDispatcher();
RefPtr<VsyncRefreshDriverTimer> timer = new VsyncRefreshDriverTimer(
std::move(aVsyncSource), std::move(vsyncDispatcher), nullptr);
return timer.forget();
@ -618,10 +617,9 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
}; // RefreshDriverVsyncObserver
VsyncRefreshDriverTimer(
RefPtr<gfx::VsyncSource>&& aVsyncSource,
RefPtr<RefreshTimerVsyncDispatcher>&& aVsyncDispatcher,
RefPtr<VsyncMainChild>&& aVsyncChild)
VsyncRefreshDriverTimer(RefPtr<gfx::VsyncSource>&& aVsyncSource,
RefPtr<VsyncDispatcher>&& aVsyncDispatcher,
RefPtr<VsyncMainChild>&& aVsyncChild)
: mVsyncSource(aVsyncSource),
mVsyncDispatcher(aVsyncDispatcher),
mVsyncChild(aVsyncChild),
@ -906,7 +904,7 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer {
// Used in the parent process. We register mVsyncObserver with it for the
// duration during which we want to receive vsync notifications.
RefPtr<RefreshTimerVsyncDispatcher> mVsyncDispatcher;
RefPtr<VsyncDispatcher> mVsyncDispatcher;
// Used it the content process. We register mVsyncObserver with it for the
// duration during which we want to receive vsync notifications. The
// mVsyncChild will be always available before VsyncChild::ActorDestroy().

View File

@ -110,25 +110,24 @@ void CompositorVsyncDispatcher::Shutdown() {
mVsyncSource = nullptr;
}
RefreshTimerVsyncDispatcher::RefreshTimerVsyncDispatcher(
gfx::VsyncSource* aVsyncSource)
VsyncDispatcher::VsyncDispatcher(gfx::VsyncSource* aVsyncSource)
: mVsyncSource(aVsyncSource),
mVsyncObservers("RefreshTimerVsyncDispatcher::mVsyncObservers") {
mVsyncObservers("VsyncDispatcher::mVsyncObservers") {
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
}
RefreshTimerVsyncDispatcher::~RefreshTimerVsyncDispatcher() {
VsyncDispatcher::~VsyncDispatcher() {
MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
}
void RefreshTimerVsyncDispatcher::MoveToSource(gfx::VsyncSource* aVsyncSource) {
void VsyncDispatcher::MoveToSource(gfx::VsyncSource* aVsyncSource) {
MOZ_ASSERT(NS_IsMainThread());
mVsyncSource = aVsyncSource;
}
void RefreshTimerVsyncDispatcher::NotifyVsync(const VsyncEvent& aVsync) {
void VsyncDispatcher::NotifyVsync(const VsyncEvent& aVsync) {
auto observers = mVsyncObservers.Lock();
for (const auto& observer : *observers) {
@ -136,8 +135,7 @@ void RefreshTimerVsyncDispatcher::NotifyVsync(const VsyncEvent& aVsync) {
}
}
void RefreshTimerVsyncDispatcher::AddVsyncObserver(
VsyncObserver* aVsyncObserver) {
void VsyncDispatcher::AddVsyncObserver(VsyncObserver* aVsyncObserver) {
MOZ_ASSERT(aVsyncObserver);
{ // scope lock - called on PBackground thread or main thread
auto observers = mVsyncObservers.Lock();
@ -149,8 +147,7 @@ void RefreshTimerVsyncDispatcher::AddVsyncObserver(
UpdateVsyncStatus();
}
void RefreshTimerVsyncDispatcher::RemoveVsyncObserver(
VsyncObserver* aVsyncObserver) {
void VsyncDispatcher::RemoveVsyncObserver(VsyncObserver* aVsyncObserver) {
MOZ_ASSERT(aVsyncObserver);
{ // scope lock - called on PBackground thread or main thread
auto observers = mVsyncObservers.Lock();
@ -160,18 +157,18 @@ void RefreshTimerVsyncDispatcher::RemoveVsyncObserver(
UpdateVsyncStatus();
}
void RefreshTimerVsyncDispatcher::UpdateVsyncStatus() {
void VsyncDispatcher::UpdateVsyncStatus() {
if (!NS_IsMainThread()) {
NS_DispatchToMainThread(NewRunnableMethod(
"RefreshTimerVsyncDispatcher::UpdateVsyncStatus", this,
&RefreshTimerVsyncDispatcher::UpdateVsyncStatus));
NS_DispatchToMainThread(
NewRunnableMethod("VsyncDispatcher::UpdateVsyncStatus", this,
&VsyncDispatcher::UpdateVsyncStatus));
return;
}
mVsyncSource->NotifyRefreshTimerVsyncStatus(NeedsVsync());
}
bool RefreshTimerVsyncDispatcher::NeedsVsync() {
bool VsyncDispatcher::NeedsVsync() {
MOZ_ASSERT(NS_IsMainThread());
auto observers = mVsyncObservers.Lock();
return !observers->IsEmpty();

View File

@ -75,11 +75,11 @@ class CompositorVsyncDispatcher final {
// VsyncMainChild)
// - IPC for content process worker requestAnimationFrame (VsyncParent <->
// VsyncWorkerChild)
class RefreshTimerVsyncDispatcher final {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RefreshTimerVsyncDispatcher)
class VsyncDispatcher final {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncDispatcher)
public:
explicit RefreshTimerVsyncDispatcher(gfx::VsyncSource* aVsyncSource);
explicit VsyncDispatcher(gfx::VsyncSource* aVsyncSource);
// Please check CompositorVsyncDispatcher::NotifyVsync().
void NotifyVsync(const VsyncEvent& aVsync);
@ -95,7 +95,7 @@ class RefreshTimerVsyncDispatcher final {
void RemoveVsyncObserver(VsyncObserver* aVsyncObserver);
private:
virtual ~RefreshTimerVsyncDispatcher();
virtual ~VsyncDispatcher();
void UpdateVsyncStatus();
bool NeedsVsync();