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 a08583556d
commit ed3a4890f3
2 changed files with 17 additions and 6 deletions

View File

@ -138,12 +138,13 @@ public:
if (mContext) { if (mContext) {
[mContext makeCurrentContext]; [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. // 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 // When we're iterating as fast as possible, however, we want a non-blocking
// other rate, and specifically if this rate is higher than the screen refresh rate, // glSwapBuffers, which will happen when swapInt==0.
// then we want a non-blocking glSwapBuffers, which will happen when swapInt==0. GLint swapInt = gfxPlatform::GetPrefLayoutFrameRate() == 0 ? 0 : 1;
GLint swapInt = gfxPlatform::GetPrefLayoutFrameRate() == -1 ? 1 : 0;
[mContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; [mContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
} }
return true; return true;

View File

@ -654,11 +654,16 @@ nsRefreshDriver::DefaultInterval()
// Compute the interval to use for the refresh driver timer, in milliseconds. // Compute the interval to use for the refresh driver timer, in milliseconds.
// outIsDefault indicates that rate was not explicitly set by the user // outIsDefault indicates that rate was not explicitly set by the user
// so we might choose other, more appropriate rates (e.g. vsync, etc) // 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 double
nsRefreshDriver::GetRegularTimerInterval(bool *outIsDefault) const nsRefreshDriver::GetRegularTimerInterval(bool *outIsDefault) const
{ {
int32_t rate = Preferences::GetInt("layout.frame_rate", -1); int32_t rate = Preferences::GetInt("layout.frame_rate", -1);
if (rate <= 0) { if (rate < 0) {
rate = DEFAULT_FRAME_RATE; rate = DEFAULT_FRAME_RATE;
if (outIsDefault) { if (outIsDefault) {
*outIsDefault = true; *outIsDefault = true;
@ -668,6 +673,11 @@ nsRefreshDriver::GetRegularTimerInterval(bool *outIsDefault) const
*outIsDefault = false; *outIsDefault = false;
} }
} }
if (rate == 0) {
rate = 10000;
}
return 1000.0 / rate; return 1000.0 / rate;
} }