From 5d2c6726681f39ea1e3e98074826ccc04d26c77d Mon Sep 17 00:00:00 2001 From: Avi Halachmi Date: Tue, 9 Jul 2013 03:06:14 +0300 Subject: [PATCH] Bug 888899: Allow fast iterations of the refresh driver on OS X. r=jrmuizel --- gfx/gl/GLContextProviderCGL.mm | 7 ++++++- gfx/thebes/gfxPlatform.cpp | 8 ++++++++ gfx/thebes/gfxPlatform.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm index e5f938111c0f..b04555a43c1a 100644 --- a/gfx/gl/GLContextProviderCGL.mm +++ b/gfx/gl/GLContextProviderCGL.mm @@ -136,7 +136,12 @@ public: if (mContext) { [mContext makeCurrentContext]; - GLint swapInt = 1; + // Use blocking swap only with the default frame rate. + // 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; [mContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; } return true; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 0589666cda74..0163f1cc9cbb 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -1836,6 +1836,7 @@ static bool sPrefLayersAccelerationForceEnabled = false; static bool sPrefLayersAccelerationDisabled = false; static bool sPrefLayersPreferOpenGL = false; static bool sPrefLayersPreferD3D9 = false; +static int sPrefLayoutFrameRate = -1; void InitLayersAccelerationPrefs() { @@ -1849,6 +1850,7 @@ void InitLayersAccelerationPrefs() sPrefLayersAccelerationDisabled = Preferences::GetBool("layers.acceleration.disabled", false); sPrefLayersPreferOpenGL = Preferences::GetBool("layers.prefer-opengl", false); sPrefLayersPreferD3D9 = Preferences::GetBool("layers.prefer-d3d9", false); + sPrefLayoutFrameRate = Preferences::GetInt("layout.frame_rate", -1); sLayersAccelerationPrefsInitialized = true; } @@ -1892,3 +1894,9 @@ bool gfxPlatform::GetPrefLayersPreferD3D9() InitLayersAccelerationPrefs(); return sPrefLayersPreferD3D9; } + +int gfxPlatform::GetPrefLayoutFrameRate() +{ + InitLayersAccelerationPrefs(); + return sPrefLayoutFrameRate; +} diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index b71f33916784..d7ea0886d37f 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -467,6 +467,7 @@ public: static bool GetPrefLayersAccelerationDisabled(); static bool GetPrefLayersPreferOpenGL(); static bool GetPrefLayersPreferD3D9(); + static int GetPrefLayoutFrameRate(); /** * Are we going to try color management?