| 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 16 matching lines...) Expand all Loading... |
| 27 #include "ui/gfx/x/x11_types.h" | 27 #include "ui/gfx/x/x11_types.h" |
| 28 #include "ui/gl/gl_bindings.h" | 28 #include "ui/gl/gl_bindings.h" |
| 29 #include "ui/gl/gl_implementation.h" | 29 #include "ui/gl/gl_implementation.h" |
| 30 #include "ui/gl/sync_control_vsync_provider.h" | 30 #include "ui/gl/sync_control_vsync_provider.h" |
| 31 | 31 |
| 32 namespace gfx { | 32 namespace gfx { |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 Display* g_display = nullptr; | 36 Display* g_display = nullptr; |
| 37 const char* g_glx_extensions = nullptr; | |
| 38 bool g_glx_context_create = false; | 37 bool g_glx_context_create = false; |
| 39 bool g_glx_create_context_robustness_supported = false; | 38 bool g_glx_create_context_robustness_supported = false; |
| 40 bool g_glx_texture_from_pixmap_supported = false; | 39 bool g_glx_texture_from_pixmap_supported = false; |
| 41 bool g_glx_oml_sync_control_supported = false; | 40 bool g_glx_oml_sync_control_supported = false; |
| 42 | 41 |
| 43 // Track support of glXGetMscRateOML separately from GLX_OML_sync_control as a | 42 // Track support of glXGetMscRateOML separately from GLX_OML_sync_control as a |
| 44 // whole since on some platforms (e.g. crosbug.com/34585), glXGetMscRateOML | 43 // whole since on some platforms (e.g. crosbug.com/34585), glXGetMscRateOML |
| 45 // always fails even though GLX_OML_sync_control is reported as being supported. | 44 // always fails even though GLX_OML_sync_control is reported as being supported. |
| 46 bool g_glx_get_msc_rate_oml_supported = false; | 45 bool g_glx_get_msc_rate_oml_supported = false; |
| 47 | 46 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 if (!glXQueryVersion(g_display, &major, &minor)) { | 341 if (!glXQueryVersion(g_display, &major, &minor)) { |
| 343 LOG(ERROR) << "glxQueryVersion failed"; | 342 LOG(ERROR) << "glxQueryVersion failed"; |
| 344 return false; | 343 return false; |
| 345 } | 344 } |
| 346 | 345 |
| 347 if (major == 1 && minor < 3) { | 346 if (major == 1 && minor < 3) { |
| 348 LOG(ERROR) << "GLX 1.3 or later is required."; | 347 LOG(ERROR) << "GLX 1.3 or later is required."; |
| 349 return false; | 348 return false; |
| 350 } | 349 } |
| 351 | 350 |
| 352 g_glx_extensions = glXQueryExtensionsString(g_display, 0); | |
| 353 g_glx_context_create = | 351 g_glx_context_create = |
| 354 HasGLXExtension("GLX_ARB_create_context"); | 352 HasGLXExtension("GLX_ARB_create_context"); |
| 355 g_glx_create_context_robustness_supported = | 353 g_glx_create_context_robustness_supported = |
| 356 HasGLXExtension("GLX_ARB_create_context_robustness"); | 354 HasGLXExtension("GLX_ARB_create_context_robustness"); |
| 357 g_glx_texture_from_pixmap_supported = | 355 g_glx_texture_from_pixmap_supported = |
| 358 HasGLXExtension("GLX_EXT_texture_from_pixmap"); | 356 HasGLXExtension("GLX_EXT_texture_from_pixmap"); |
| 359 g_glx_oml_sync_control_supported = | 357 g_glx_oml_sync_control_supported = |
| 360 HasGLXExtension("GLX_OML_sync_control"); | 358 HasGLXExtension("GLX_OML_sync_control"); |
| 361 g_glx_get_msc_rate_oml_supported = g_glx_oml_sync_control_supported; | 359 g_glx_get_msc_rate_oml_supported = g_glx_oml_sync_control_supported; |
| 362 g_glx_sgi_video_sync_supported = | 360 g_glx_sgi_video_sync_supported = |
| 363 HasGLXExtension("GLX_SGI_video_sync"); | 361 HasGLXExtension("GLX_SGI_video_sync"); |
| 364 | 362 |
| 365 if (!g_glx_get_msc_rate_oml_supported && g_glx_sgi_video_sync_supported) | 363 if (!g_glx_get_msc_rate_oml_supported && g_glx_sgi_video_sync_supported) |
| 366 SGIVideoSyncProviderThreadShim::display_ = gfx::OpenNewXDisplay(); | 364 SGIVideoSyncProviderThreadShim::display_ = gfx::OpenNewXDisplay(); |
| 367 | 365 |
| 368 initialized = true; | 366 initialized = true; |
| 369 return true; | 367 return true; |
| 370 } | 368 } |
| 371 | 369 |
| 372 // static | 370 // static |
| 373 const char* GLSurfaceGLX::GetGLXExtensions() { | 371 const char* GLSurfaceGLX::GetGLXExtensions() { |
| 374 return g_glx_extensions; | 372 return glXQueryExtensionsString(g_display, 0); |
| 375 } | 373 } |
| 376 | 374 |
| 377 // static | 375 // static |
| 378 bool GLSurfaceGLX::HasGLXExtension(const char* name) { | 376 bool GLSurfaceGLX::HasGLXExtension(const char* name) { |
| 379 return ExtensionsContain(GetGLXExtensions(), name); | 377 return ExtensionsContain(GetGLXExtensions(), name); |
| 380 } | 378 } |
| 381 | 379 |
| 382 // static | 380 // static |
| 383 bool GLSurfaceGLX::IsCreateContextSupported() { | 381 bool GLSurfaceGLX::IsCreateContextSupported() { |
| 384 return g_glx_context_create; | 382 return g_glx_context_create; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 if (!config_) | 634 if (!config_) |
| 637 config_ = GLSurfaceGLX::GetConfig(window_); | 635 config_ = GLSurfaceGLX::GetConfig(window_); |
| 638 return config_; | 636 return config_; |
| 639 } | 637 } |
| 640 | 638 |
| 641 UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() { | 639 UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() { |
| 642 Destroy(); | 640 Destroy(); |
| 643 } | 641 } |
| 644 | 642 |
| 645 } // namespace gfx | 643 } // namespace gfx |
| OLD | NEW |