Bug 956263 - Add a preference to control the compositor frame-rate. r=mstange

This commit is contained in:
Benoit Girard 2014-01-29 18:26:38 -05:00
Родитель d641551daa
Коммит 07811375fe
4 изменённых файлов: 41 добавлений и 7 удалений

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

@ -526,10 +526,27 @@ CompositorParent::NotifyShadowTreeTransaction(uint64_t aId, bool aIsFirstPaint,
// DEFAULT_FRAME_RATE in nsRefreshDriver.cpp.
static const int32_t kDefaultFrameRate = 60;
static int32_t
CalculateCompositionFrameRate()
{
int32_t compositionFrameRatePref = gfxPlatform::GetPrefLayersCompositionFrameRate();
if (compositionFrameRatePref < 0) {
// Use the same frame rate for composition as for layout.
int32_t layoutFrameRatePref = gfxPlatform::GetPrefLayoutFrameRate();
if (layoutFrameRatePref < 0) {
// TODO: The main thread frame scheduling code consults the actual
// monitor refresh rate in this case. We should do the same.
return kDefaultFrameRate;
}
return layoutFrameRatePref;
}
return compositionFrameRatePref;
}
void
CompositorParent::ScheduleComposition()
{
if (mCurrentCompositeTask) {
if (mCurrentCompositeTask || mPaused) {
return;
}
@ -538,12 +555,7 @@ 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;
}
int32_t rate = CalculateCompositionFrameRate();
// If rate == 0 (ASAP mode), minFrameDelta must be 0 so there's no delay.
TimeDuration minFrameDelta = TimeDuration::FromMilliseconds(
@ -630,6 +642,13 @@ CompositorParent::CompositeInTransaction()
15 + (int)(TimeStamp::Now() - mExpectedComposeTime).ToMilliseconds());
}
#endif
// 0 -> Full-tilt composite
if (gfxPlatform::GetPrefLayersCompositionFrameRate() == 0) {
// Special full-tilt composite mode for performance testing
ScheduleComposition();
}
profiler_tracing("Paint", "Composite", TRACING_INTERVAL_END);
}

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

@ -2070,6 +2070,7 @@ static bool sPrefLayersScrollGraph = false;
static bool sPrefLayersEnableTiles = false;
static bool sLayersSupportsD3D9 = false;
static int sPrefLayoutFrameRate = -1;
static int sPrefLayersCompositionFrameRate = -1;
static bool sBufferRotationEnabled = false;
static bool sComponentAlphaEnabled = true;
static bool sPrefBrowserTabsRemote = false;
@ -2098,6 +2099,7 @@ InitLayersAccelerationPrefs()
sPrefLayersScrollGraph = Preferences::GetBool("layers.scroll-graph", false);
sPrefLayersEnableTiles = Preferences::GetBool("layers.enable-tiles", false);
sPrefLayoutFrameRate = Preferences::GetInt("layout.frame_rate", -1);
sPrefLayersCompositionFrameRate = Preferences::GetInt("layers.offmainthreadcomposition.frame-rate", -1);
sBufferRotationEnabled = Preferences::GetBool("layers.bufferrotation.enabled", true);
sComponentAlphaEnabled = Preferences::GetBool("layers.componentalpha.enabled", true);
sPrefBrowserTabsRemote = BrowserTabsRemote();
@ -2217,6 +2219,13 @@ gfxPlatform::GetPrefLayersEnableTiles()
return sPrefLayersEnableTiles;
}
int
gfxPlatform::GetPrefLayersCompositionFrameRate()
{
InitLayersAccelerationPrefs();
return sPrefLayersCompositionFrameRate;
}
bool
gfxPlatform::BufferRotationEnabled()
{

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

@ -510,6 +510,7 @@ public:
static bool GetPrefLayersPreferD3D9();
static bool CanUseDirect3D9();
static int GetPrefLayoutFrameRate();
static int GetPrefLayersCompositionFrameRate();
static bool GetPrefLayersDump();
static bool GetPrefLayersScrollGraph();
static bool GetPrefLayersEnableTiles();

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

@ -4093,6 +4093,11 @@ pref("layers.scroll-graph", false);
// Set the default values, and then override per-platform as needed
pref("layers.offmainthreadcomposition.enabled", false);
// Compositor target frame rate. NOTE: If vsync is enabled the compositor
// frame rate will still be capped.
// -1 -> default (match layout.frame_rate or 60 FPS)
// 0 -> full-tilt mode: Recomposite even if not transaction occured.
pref("layers.offmainthreadcomposition.frame-rate", -1);
// Whether to use the deprecated texture architecture rather than the new one.
pref("layers.use-deprecated-textures", true);
#ifndef XP_WIN