Bug 888899 - Part 2 - Uses layout.frame_rate=0 for ASAP mode instead of 10k. r=jrmuizel

This commit is contained in:
Avi Halachmi 2013-08-02 23:29:57 +03:00
parent f1700221b6
commit 91d31fafd1
2 changed files with 17 additions and 6 deletions

View File

@ -138,12 +138,13 @@ public:
if (mContext) {
[mContext makeCurrentContext];
// Use blocking swap only with the default frame rate.
// Use non-blocking swap in "ASAP mode".
// ASAP mode means that rendering is iterated as fast as possible.
// ASAP mode is entered when layout.frame_rate=0 (requires restart).
// If swapInt is 1, then glSwapBuffers will block and wait for a vblank signal.
// While this is fine for the default refresh rate, if the user chooses some
// other rate, and specifically if this rate is higher than the screen refresh rate,
// then we want a non-blocking glSwapBuffers, which will happen when swapInt==0.
GLint swapInt = gfxPlatform::GetPrefLayoutFrameRate() == -1 ? 1 : 0;
// When we're iterating as fast as possible, however, we want a non-blocking
// glSwapBuffers, which will happen when swapInt==0.
GLint swapInt = gfxPlatform::GetPrefLayoutFrameRate() == 0 ? 0 : 1;
[mContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
}
return true;

View File

@ -654,11 +654,16 @@ nsRefreshDriver::DefaultInterval()
// Compute the interval to use for the refresh driver timer, in milliseconds.
// outIsDefault indicates that rate was not explicitly set by the user
// so we might choose other, more appropriate rates (e.g. vsync, etc)
// layout.frame_rate=0 indicates "ASAP mode".
// In ASAP mode rendering is iterated as fast as possible (typically for stress testing).
// A target rate of 10k is used internally instead of special-handling 0.
// Backends which block on swap/present/etc should try to not block
// when layout.frame_rate=0 - to comply with "ASAP" as much as possible.
double
nsRefreshDriver::GetRegularTimerInterval(bool *outIsDefault) const
{
int32_t rate = Preferences::GetInt("layout.frame_rate", -1);
if (rate <= 0) {
if (rate < 0) {
rate = DEFAULT_FRAME_RATE;
if (outIsDefault) {
*outIsDefault = true;
@ -668,6 +673,11 @@ nsRefreshDriver::GetRegularTimerInterval(bool *outIsDefault) const
*outIsDefault = false;
}
}
if (rate == 0) {
rate = 10000;
}
return 1000.0 / rate;
}