зеркало из https://github.com/mozilla/gecko-dev.git
Bug 943041 - Don't delay compositing on the compositor thread in ASAP mode (layout.frame_rate == 0). r=BenWa
This commit is contained in:
Родитель
30aeb02de9
Коммит
3ba56fecc6
|
@ -498,6 +498,10 @@ CompositorParent::NotifyShadowTreeTransaction(uint64_t aId, bool aIsFirstPaint)
|
|||
ScheduleComposition();
|
||||
}
|
||||
|
||||
// Used when layout.frame_rate is -1. Needs to be kept in sync with
|
||||
// DEFAULT_FRAME_RATE in nsRefreshDriver.cpp.
|
||||
static const int32_t kDefaultFrameRate = 60;
|
||||
|
||||
void
|
||||
CompositorParent::ScheduleComposition()
|
||||
{
|
||||
|
@ -510,19 +514,29 @@ CompositorParent::ScheduleComposition()
|
|||
if (!initialComposition)
|
||||
delta = TimeStamp::Now() - mLastCompose;
|
||||
|
||||
int32_t rate = gfxPlatform::GetPrefLayoutFrameRate();
|
||||
if (rate < 0) {
|
||||
// TODO: The main thread frame scheduling code consults the actual monitor
|
||||
// refresh rate in this case. We should do the same.
|
||||
rate = kDefaultFrameRate;
|
||||
}
|
||||
|
||||
// If rate == 0 (ASAP mode), minFrameDelta must be 0 so there's no delay.
|
||||
TimeDuration minFrameDelta = TimeDuration::FromMilliseconds(
|
||||
rate == 0 ? 0.0 : std::max(0.0, 1000.0 / rate));
|
||||
|
||||
#ifdef COMPOSITOR_PERFORMANCE_WARNING
|
||||
mExpectedComposeTime = TimeStamp::Now() + TimeDuration::FromMilliseconds(15);
|
||||
mExpectedComposeTime = TimeStamp::Now() + minFrameDelta;
|
||||
#endif
|
||||
|
||||
mCurrentCompositeTask = NewRunnableMethod(this, &CompositorParent::Composite);
|
||||
|
||||
// Since 60 fps is the maximum frame rate we can acheive, scheduling composition
|
||||
// events less than 15 ms apart wastes computation..
|
||||
if (!initialComposition && delta.ToMilliseconds() < 15) {
|
||||
if (!initialComposition && delta < minFrameDelta) {
|
||||
TimeDuration delay = minFrameDelta - delta;
|
||||
#ifdef COMPOSITOR_PERFORMANCE_WARNING
|
||||
mExpectedComposeTime = TimeStamp::Now() + TimeDuration::FromMilliseconds(15 - delta.ToMilliseconds());
|
||||
mExpectedComposeTime = TimeStamp::Now() + delay;
|
||||
#endif
|
||||
ScheduleTask(mCurrentCompositeTask, 15 - delta.ToMilliseconds());
|
||||
ScheduleTask(mCurrentCompositeTask, delay.ToMilliseconds());
|
||||
} else {
|
||||
ScheduleTask(mCurrentCompositeTask, 0);
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "nsTArray.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "MainThreadUtils.h"
|
||||
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
|
@ -2049,6 +2050,12 @@ InitLayersAccelerationPrefs()
|
|||
{
|
||||
if (!sLayersAccelerationPrefsInitialized)
|
||||
{
|
||||
// If this is called for the first time on a non-main thread, we're screwed.
|
||||
// At the moment there's no explicit guarantee that the main thread calls
|
||||
// this before the compositor thread, but let's at least make the assumption
|
||||
// explicit.
|
||||
MOZ_ASSERT(NS_IsMainThread(), "can only initialize prefs on the main thread");
|
||||
|
||||
sPrefLayersOffMainThreadCompositionEnabled = Preferences::GetBool("layers.offmainthreadcomposition.enabled", false);
|
||||
sPrefLayersOffMainThreadCompositionTestingEnabled = Preferences::GetBool("layers.offmainthreadcomposition.testing.enabled", false);
|
||||
sPrefLayersOffMainThreadCompositionForceEnabled = Preferences::GetBool("layers.offmainthreadcomposition.force-enabled", false);
|
||||
|
|
Загрузка…
Ссылка в новой задаче