OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 class ScopedPtrXFree { | 29 class ScopedPtrXFree { |
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_oml_sync_control_supported = false; |
39 | 40 |
40 } // namespace | 41 } // namespace |
41 | 42 |
42 GLSurfaceGLX::GLSurfaceGLX() {} | 43 GLSurfaceGLX::GLSurfaceGLX() {} |
43 | 44 |
44 bool GLSurfaceGLX::InitializeOneOff() { | 45 bool GLSurfaceGLX::InitializeOneOff() { |
45 static bool initialized = false; | 46 static bool initialized = false; |
46 if (initialized) | 47 if (initialized) |
47 return true; | 48 return true; |
48 | 49 |
(...skipping 11 matching lines...) Expand all Loading... |
60 | 61 |
61 if (major == 1 && minor < 3) { | 62 if (major == 1 && minor < 3) { |
62 LOG(ERROR) << "GLX 1.3 or later is required."; | 63 LOG(ERROR) << "GLX 1.3 or later is required."; |
63 return false; | 64 return false; |
64 } | 65 } |
65 | 66 |
66 g_glx_extensions = glXQueryExtensionsString(g_display, 0); | 67 g_glx_extensions = glXQueryExtensionsString(g_display, 0); |
67 g_glx_create_context_robustness_supported = | 68 g_glx_create_context_robustness_supported = |
68 HasGLXExtension("GLX_ARB_create_context_robustness"); | 69 HasGLXExtension("GLX_ARB_create_context_robustness"); |
69 | 70 |
| 71 g_glx_oml_sync_control_supported = |
| 72 HasGLXExtension("GLX_OML_sync_control"); |
| 73 |
70 initialized = true; | 74 initialized = true; |
71 return true; | 75 return true; |
72 } | 76 } |
73 | 77 |
74 // static | 78 // static |
75 const char* GLSurfaceGLX::GetGLXExtensions() { | 79 const char* GLSurfaceGLX::GetGLXExtensions() { |
76 return g_glx_extensions; | 80 return g_glx_extensions; |
77 } | 81 } |
78 | 82 |
79 // static | 83 // static |
80 bool GLSurfaceGLX::HasGLXExtension(const char* name) { | 84 bool GLSurfaceGLX::HasGLXExtension(const char* name) { |
81 return ExtensionsContain(GetGLXExtensions(), name); | 85 return ExtensionsContain(GetGLXExtensions(), name); |
82 } | 86 } |
83 | 87 |
84 // static | 88 // static |
85 bool GLSurfaceGLX::IsCreateContextRobustnessSupported() { | 89 bool GLSurfaceGLX::IsCreateContextRobustnessSupported() { |
86 return g_glx_create_context_robustness_supported; | 90 return g_glx_create_context_robustness_supported; |
87 } | 91 } |
88 | 92 |
| 93 // static |
| 94 bool GLSurfaceGLX::IsOMLSyncControlSupported() { |
| 95 return g_glx_oml_sync_control_supported; |
| 96 } |
| 97 |
89 void* GLSurfaceGLX::GetDisplay() { | 98 void* GLSurfaceGLX::GetDisplay() { |
90 return g_display; | 99 return g_display; |
91 } | 100 } |
92 | 101 |
93 GLSurfaceGLX::~GLSurfaceGLX() {} | 102 GLSurfaceGLX::~GLSurfaceGLX() {} |
94 | 103 |
95 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window) | 104 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX(gfx::AcceleratedWidget window) |
96 : window_(window), | 105 : window_(window), |
97 config_(NULL) { | 106 config_(NULL) { |
98 } | 107 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return config_; | 218 return config_; |
210 } | 219 } |
211 | 220 |
212 bool NativeViewGLSurfaceGLX::PostSubBuffer( | 221 bool NativeViewGLSurfaceGLX::PostSubBuffer( |
213 int x, int y, int width, int height) { | 222 int x, int y, int width, int height) { |
214 DCHECK(g_GLX_MESA_copy_sub_buffer); | 223 DCHECK(g_GLX_MESA_copy_sub_buffer); |
215 glXCopySubBufferMESA(g_display, window_, x, y, width, height); | 224 glXCopySubBufferMESA(g_display, window_, x, y, width, height); |
216 return true; | 225 return true; |
217 } | 226 } |
218 | 227 |
| 228 bool NativeViewGLSurfaceGLX::GetSyncValues(int64_t* systemTime, |
| 229 int64_t* mediaStreamCounter, |
| 230 int64_t* swapBufferCounter) { |
| 231 if (g_glx_oml_sync_control_supported) { |
| 232 return glXGetSyncValuesOML(g_display, window_, systemTime, |
| 233 mediaStreamCounter, swapBufferCounter); |
| 234 } |
| 235 |
| 236 return false; |
| 237 } |
| 238 |
219 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX() | 239 NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX() |
220 : window_(0), | 240 : window_(0), |
221 config_(NULL) { | 241 config_(NULL) { |
222 } | 242 } |
223 | 243 |
224 NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() { | 244 NativeViewGLSurfaceGLX::~NativeViewGLSurfaceGLX() { |
225 Destroy(); | 245 Destroy(); |
226 } | 246 } |
227 | 247 |
228 PbufferGLSurfaceGLX::PbufferGLSurfaceGLX(const gfx::Size& size) | 248 PbufferGLSurfaceGLX::PbufferGLSurfaceGLX(const gfx::Size& size) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 328 |
309 void* PbufferGLSurfaceGLX::GetConfig() { | 329 void* PbufferGLSurfaceGLX::GetConfig() { |
310 return config_; | 330 return config_; |
311 } | 331 } |
312 | 332 |
313 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { | 333 PbufferGLSurfaceGLX::~PbufferGLSurfaceGLX() { |
314 Destroy(); | 334 Destroy(); |
315 } | 335 } |
316 | 336 |
317 } // namespace gfx | 337 } // namespace gfx |
OLD | NEW |