Commit 0d45ee3a authored by nduca@chromium.org's avatar nduca@chromium.org

Apply setInterval to new surface-context pairs

BUG=83832

Review URL: http://codereview.chromium.org/6987025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86720 0039d316-1c4b-4281-b951-d872f2087c98
parent 7ab471ac
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
#include "gpu/command_buffer/service/gpu_scheduler.h" #include "gpu/command_buffer/service/gpu_scheduler.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/command_line.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "ui/gfx/gl/gl_context.h" #include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_bindings.h" #include "ui/gfx/gl/gl_bindings.h"
#include "ui/gfx/gl/gl_surface.h" #include "ui/gfx/gl/gl_surface.h"
#include "ui/gfx/gl/gl_switches.h"
using ::base::SharedMemory; using ::base::SharedMemory;
...@@ -66,6 +68,16 @@ bool GpuScheduler::InitializeCommon( ...@@ -66,6 +68,16 @@ bool GpuScheduler::InitializeCommon(
if (!context->MakeCurrent(surface)) if (!context->MakeCurrent(surface))
return false; return false;
#if !defined(OS_MACOSX)
// Set up swap interval for onscreen contexts.
if (!surface->IsOffscreen()) {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync))
context->SetSwapInterval(0);
else
context->SetSwapInterval(1);
}
#endif
// Do not limit to a certain number of commands before scheduling another // Do not limit to a certain number of commands before scheduling another
// update when rendering onscreen. // update when rendering onscreen.
if (!surface->IsOffscreen()) if (!surface->IsOffscreen())
......
...@@ -119,12 +119,21 @@ void GLContextGLX::SetSwapInterval(int interval) { ...@@ -119,12 +119,21 @@ void GLContextGLX::SetSwapInterval(int interval) {
// manager. At the moment, compositing window managers don't // manager. At the moment, compositing window managers don't
// respect this setting anyway (tearing still occurs) and it // respect this setting anyway (tearing still occurs) and it
// dramatically increases latency. // dramatically increases latency.
if (!IsCompositingWindowManagerActive(GLSurfaceGLX::GetDisplay())) { if (interval == 1 &&
glXSwapIntervalEXT( IsCompositingWindowManagerActive(GLSurfaceGLX::GetDisplay())) {
GLSurfaceGLX::GetDisplay(), LOG(INFO) <<
glXGetCurrentDrawable(), "Forcing vsync off because compositing window manager was detected.";
interval); interval = 0;
} }
glXSwapIntervalEXT(
GLSurfaceGLX::GetDisplay(),
glXGetCurrentDrawable(),
interval);
} else {
if(interval == 0)
LOG(WARNING) <<
"Could not disable vsync: driver does not "
"support GLX_EXT_swap_control";
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment