diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 24a372b894e0..f278d40edacf 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -403,6 +403,24 @@ MessageLoop* CompositorParent::CompositorLoop() return CompositorThread() ? CompositorThread()->message_loop() : nullptr; } +static bool +IsInCompositorAsapMode() +{ + // Returns true if the compositor is allowed to be in ASAP mode + // and layout is not in ASAP mode + return gfxPrefs::LayersCompositionFrameRate() == 0 && + !gfxPlatform::IsInLayoutAsapMode(); +} + +static bool +UseVsyncComposition() +{ + return gfxPrefs::VsyncAlignedCompositor() + && gfxPrefs::HardwareVsyncEnabled() + && !IsInCompositorAsapMode() + && !gfxPlatform::IsInLayoutAsapMode(); +} + CompositorParent::CompositorParent(nsIWidget* aWidget, bool aUseExternalSurfaceSize, int aSurfaceWidth, int aSurfaceHeight) @@ -445,7 +463,8 @@ CompositorParent::CompositorParent(nsIWidget* aWidget, mApzcTreeManager = new APZCTreeManager(); } - if (gfxPrefs::VsyncAlignedCompositor() && gfxPrefs::HardwareVsyncEnabled()) { + if (UseVsyncComposition()) { + NS_WARNING("Enabling vsync compositor\n"); mCompositorVsyncObserver = new CompositorVsyncObserver(this, aWidget); } diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 7892bcb4092e..966871c5e619 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -2303,3 +2303,15 @@ gfxPlatform::CreateHardwareVsyncSource() nsRefPtr softwareVsync = new SoftwareVsyncSource(); return softwareVsync.forget(); } + +/* static */ bool +gfxPlatform::IsInLayoutAsapMode() +{ + // There are 2 modes of ASAP mode. + // 1 is that the refresh driver and compositor are in lock step + // the second is that the compositor goes ASAP and the refresh driver + // goes at whatever the configurated rate is. This only checks the version + // talos uses, which is the refresh driver and compositor are in lockstep. + return Preferences::GetInt("layout.frame_rate", -1) == 0; +} + diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 5c5b3416cebe..62de0dc4b3a2 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -608,6 +608,13 @@ public: return mVsyncSource; } + /** + * True if layout rendering should use ASAP mode, which means + * the refresh driver and compositor should render ASAP. + * Used for talos testing purposes + */ + static bool IsInLayoutAsapMode(); + protected: gfxPlatform(); virtual ~gfxPlatform(); diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 395f65d54844..6562d7ea3750 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -849,10 +849,14 @@ CreateVsyncRefreshTimer() // ready. gfxPrefs::GetSingleton(); - if (!gfxPrefs::VsyncAlignedRefreshDriver() || !gfxPrefs::HardwareVsyncEnabled()) { + if (!gfxPrefs::VsyncAlignedRefreshDriver() + || !gfxPrefs::HardwareVsyncEnabled() + || gfxPlatform::IsInLayoutAsapMode()) { return; } + NS_WARNING("Enabling vsync refresh driver\n"); + if (XRE_IsParentProcess()) { // Make sure all vsync systems are ready. gfxPlatform::GetPlatform();