Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: ui/gl/gl_surface_glx.cc

Issue 11195011: Send vsync timebase updates to the browser compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use the existing output surface mechanism to feed vsync info into the compositor Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« ui/gl/gl_surface.h ('K') | « ui/gl/gl_surface_glx.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gl/gl_surface_glx.h" 9 #include "ui/gl/gl_surface_glx.h"
10 10
(...skipping 19 matching lines...) Expand all
30 public: 30 public:
31 void operator()(void* x) const { 31 void operator()(void* x) const {
32 ::XFree(x); 32 ::XFree(x);
33 } 33 }
34 }; 34 };
35 35
36 Display* g_display; 36 Display* g_display;
37 const char* g_glx_extensions = NULL; 37 const char* g_glx_extensions = NULL;
38 bool g_glx_create_context_robustness_supported = false; 38 bool g_glx_create_context_robustness_supported = false;
39 bool g_glx_texture_from_pixmap_supported = false; 39 bool g_glx_texture_from_pixmap_supported = false;
40 bool g_glx_oml_sync_control_supported = false;
40 41
41 } // namespace 42 } // namespace
42 43
43 GLSurfaceGLX::GLSurfaceGLX() {} 44 GLSurfaceGLX::GLSurfaceGLX() {}
44 45
45 bool GLSurfaceGLX::InitializeOneOff() { 46 bool GLSurfaceGLX::InitializeOneOff() {
46 static bool initialized = false; 47 static bool initialized = false;
47 if (initialized) 48 if (initialized)
48 return true; 49 return true;
49 50
(...skipping 12 matching lines...) Expand all
62 if (major == 1 && minor < 3) { 63 if (major == 1 && minor < 3) {
63 LOG(ERROR) << "GLX 1.3 or later is required."; 64 LOG(ERROR) << "GLX 1.3 or later is required.";
64 return false; 65 return false;
65 } 66 }
66 67
67 g_glx_extensions = glXQueryExtensionsString(g_display, 0); 68 g_glx_extensions = glXQueryExtensionsString(g_display, 0);
68 g_glx_create_context_robustness_supported = 69 g_glx_create_context_robustness_supported =
69 HasGLXExtension("GLX_ARB_create_context_robustness"); 70 HasGLXExtension("GLX_ARB_create_context_robustness");
70 g_glx_texture_from_pixmap_supported = 71 g_glx_texture_from_pixmap_supported =
71 HasGLXExtension("GLX_EXT_texture_from_pixmap"); 72 HasGLXExtension("GLX_EXT_texture_from_pixmap");
73 g_glx_oml_sync_control_supported =
74 HasGLXExtension("GLX_OML_sync_control");
72 75
73 initialized = true; 76 initialized = true;
74 return true; 77 return true;
75 } 78 }
76 79
77 // static 80 // static
78 const char* GLSurfaceGLX::GetGLXExtensions() { 81 const char* GLSurfaceGLX::GetGLXExtensions() {
79 return g_glx_extensions; 82 return g_glx_extensions;
80 } 83 }
81 84
82 // static 85 // static
83 bool GLSurfaceGLX::HasGLXExtension(const char* name) { 86 bool GLSurfaceGLX::HasGLXExtension(const char* name) {
84 return ExtensionsContain(GetGLXExtensions(), name); 87 return ExtensionsContain(GetGLXExtensions(), name);
85 } 88 }
86 89
87 // static 90 // static
88 bool GLSurfaceGLX::IsCreateContextRobustnessSupported() { 91 bool GLSurfaceGLX::IsCreateContextRobustnessSupported() {
89 return g_glx_create_context_robustness_supported; 92 return g_glx_create_context_robustness_supported;
90 } 93 }
91 94
92 // static 95 // static
93 bool GLSurfaceGLX::IsTextureFromPixmapSupported() { 96 bool GLSurfaceGLX::IsTextureFromPixmapSupported() {
94 return g_glx_texture_from_pixmap_supported; 97 return g_glx_texture_from_pixmap_supported;
95 } 98 }
96 99
100 // static
101 bool GLSurfaceGLX::IsOMLSyncControlSupported() {
102 return g_glx_oml_sync_control_supported;
103 }
104
97 void* GLSurfaceGLX::GetDisplay() { 105 void* GLSurfaceGLX::GetDisplay() {
98 return g_display; 106 return g_display;
99 } 107 }
100 108
101 GLSurfaceGLX::~GLSurfaceGLX() {} 109 GLSurfaceGLX::~GLSurfaceGLX() {}
102 110
103 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window) 111 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window)
104 : window_(window), 112 : window_(window),
105 config_(NULL) { 113 config_(NULL) {
106 } 114 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 return config_; 225 return config_;
218 } 226 }
219 227
220 bool NativeViewGLSurfaceGLX::PostSubBuffer( 228 bool NativeViewGLSurfaceGLX::PostSubBuffer(
221 int x, int y, int width, int height) { 229 int x, int y, int width, int height) {
222 DCHECK(g_GLX_MESA_copy_sub_buffer); 230 DCHECK(g_GLX_MESA_copy_sub_buffer);
223 glXCopySubBufferMESA(g_display, window_, x, y, width, height); 231 glXCopySubBufferMESA(g_display, window_, x, y, width, height);
224 return true; 232 return true;
225 } 233 }
226 234
235 bool NativeViewGLSurfaceGLX::GetSyncValues(int64* monotonicTime,
236 int64* mediaStreamCounter,
237 int64* swapBufferCounter) {
238 if (g_glx_oml_sync_control_supported) {
239 // Though the actual clock used for the system time returned by
240 // glXGetSyncValuesOML is unspecified, in practice it turns out to
241 // be CLOCK_REALTIME. We need the time according to CLOCK_MONOTONIC,
piman 2012/10/24 16:56:54 Where did we test that assumption? Only Intel driv
ajuma 2012/10/26 20:12:39 Only on Intel (I haven't managed to get my hands o
242 // so we have to convert.
243 int64 systemTime;
piman 2012/10/24 16:56:54 nit: chrome style, here and everywhere.
ajuma 2012/10/26 20:12:39 Done.
244 if (glXGetSyncValuesOML(g_display, window_, &systemTime,
245 mediaStreamCounter, swapBufferCounter)) {
246 struct timespec currentRealTime;
247 struct timespec currentMonotonicTime;
248 clock_gettime(CLOCK_REALTIME, &currentRealTime);
249 clock_gettime(CLOCK_MONOTONIC, &currentMonotonicTime);
250
251 int64 currentRealTimeInMicroseconds =
252 currentRealTime.tv_sec * base::Time::kMicrosecondsPerSecond +
253 currentRealTime.tv_nsec / base::Time::kNanosecondsPerMicrosecond;
254 int64 currentMonotonicTimeInMicroseconds =
255 currentMonotonicTime.tv_sec * base::Time::kMicrosecondsPerSecond +
256 currentMonotonicTime.tv_nsec / base::Time::kNanosecondsPerMicrosecond;
257
258 int64 timeDifference =
259 currentRealTimeInMicroseconds - currentMonotonicTimeInMicroseconds;
260 *monotonicTime = systemTime - timeDifference;
261
262 return true;
263 }
264 }
265
266 return false;
267 }
268
227 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX() 269 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX()
228 : window_(0), 270 : window_(0),
229 config_(NULL) { 271 config_(NULL) {
230 } 272 }
231 273
232 NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() { 274 NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() {
233 Destroy(); 275 Destroy();
234 } 276 }
235 277
236 PbufferGLSurfaceGLX::PbufferGLSurfaceGLX(const gfx::Size& size) 278 PbufferGLSurfaceGLX::PbufferGLSurfaceGLX(const gfx::Size& size)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 358
317 void* PbufferGLSurfaceGLX::GetConfig() { 359 void* PbufferGLSurfaceGLX::GetConfig() {
318 return config_; 360 return config_;
319 } 361 }
320 362
321 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { 363 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() {
322 Destroy(); 364 Destroy();
323 } 365 }
324 366
325 } // namespace gfx 367 } // namespace gfx
OLDNEW
« ui/gl/gl_surface.h ('K') | « ui/gl/gl_surface_glx.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698