OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 extern "C" { | 5 extern "C" { |
6 #include <X11/Xlib.h> | 6 #include <X11/Xlib.h> |
7 } | 7 } |
8 | 8 |
9 #include "ui/gfx/gl/gl_context_glx.h" | 9 #include "ui/gfx/gl/gl_context_glx.h" |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 return context_; | 112 return context_; |
113 } | 113 } |
114 | 114 |
115 void GLContextGLX::SetSwapInterval(int interval) { | 115 void GLContextGLX::SetSwapInterval(int interval) { |
116 DCHECK(IsCurrent(NULL)); | 116 DCHECK(IsCurrent(NULL)); |
117 if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) { | 117 if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) { |
118 // Only enable vsync if we aren't using a compositing window | 118 // Only enable vsync if we aren't using a compositing window |
119 // manager. At the moment, compositing window managers don't | 119 // manager. At the moment, compositing window managers don't |
120 // respect this setting anyway (tearing still occurs) and it | 120 // respect this setting anyway (tearing still occurs) and it |
121 // dramatically increases latency. | 121 // dramatically increases latency. |
122 if (!IsCompositingWindowManagerActive(GLSurfaceGLX::GetDisplay())) { | 122 if (interval == 1 && |
123 glXSwapIntervalEXT( | 123 IsCompositingWindowManagerActive(GLSurfaceGLX::GetDisplay())) { |
124 GLSurfaceGLX::GetDisplay(), | 124 LOG(INFO) << |
125 glXGetCurrentDrawable(), | 125 "Forcing vsync off because compositing window manager was detected."; |
126 interval); | 126 interval = 0; |
127 } | 127 } |
| 128 glXSwapIntervalEXT( |
| 129 GLSurfaceGLX::GetDisplay(), |
| 130 glXGetCurrentDrawable(), |
| 131 interval); |
| 132 } else { |
| 133 if(interval == 0) |
| 134 LOG(WARNING) << |
| 135 "Could not disable vsync: driver does not " |
| 136 "support GLX_EXT_swap_control"; |
128 } | 137 } |
129 } | 138 } |
130 | 139 |
131 std::string GLContextGLX::GetExtensions() { | 140 std::string GLContextGLX::GetExtensions() { |
132 DCHECK(IsCurrent(NULL)); | 141 DCHECK(IsCurrent(NULL)); |
133 const char* extensions = glXQueryExtensionsString( | 142 const char* extensions = glXQueryExtensionsString( |
134 GLSurfaceGLX::GetDisplay(), | 143 GLSurfaceGLX::GetDisplay(), |
135 0); | 144 0); |
136 if (extensions) { | 145 if (extensions) { |
137 return GLContext::GetExtensions() + " " + extensions; | 146 return GLContext::GetExtensions() + " " + extensions; |
138 } | 147 } |
139 | 148 |
140 return GLContext::GetExtensions(); | 149 return GLContext::GetExtensions(); |
141 } | 150 } |
142 | 151 |
143 } // namespace gfx | 152 } // namespace gfx |
OLD | NEW |