gl_bindings.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "build/build_config.h"
  5. #if defined(USE_EGL)
  6. #include <EGL/egl.h>
  7. #endif
  8. #include "ui/gl/gl_bindings.h"
  9. #if defined(USE_GLX)
  10. #include "ui/gfx/x/connection.h"
  11. #include "ui/gfx/x/glx.h"
  12. #endif
  13. #if defined(USE_EGL)
  14. #include "ui/gl/gl_display.h"
  15. #include "ui/gl/gl_surface_egl.h"
  16. #endif
  17. namespace gl {
  18. #if defined(USE_EGL)
  19. void DisplayExtensionsEGL::UpdateConditionalExtensionSettings(
  20. EGLDisplay display) {
  21. // For the moment, only two extensions can be conditionally disabled
  22. // through GPU driver bug workarounds mechanism:
  23. // EGL_KHR_fence_sync
  24. // EGL_KHR_wait_sync
  25. // In theory it's OK to allow disabling other EGL extensions, as far as they
  26. // are not the ones used in GLSurfaceEGL::InitializeOneOff().
  27. std::string extensions(GetPlatformExtensions(display));
  28. extensions += " ";
  29. b_EGL_KHR_fence_sync =
  30. extensions.find("EGL_KHR_fence_sync ") != std::string::npos;
  31. b_EGL_KHR_wait_sync =
  32. extensions.find("EGL_KHR_wait_sync ") != std::string::npos;
  33. }
  34. // static
  35. std::string DisplayExtensionsEGL::GetPlatformExtensions(EGLDisplay display) {
  36. if (display == EGL_NO_DISPLAY)
  37. return "";
  38. const char* str = eglQueryString(display, EGL_EXTENSIONS);
  39. return str ? std::string(str) : "";
  40. }
  41. // static
  42. std::string ClientExtensionsEGL::GetClientExtensions() {
  43. const char* str = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
  44. return str ? std::string(str) : "";
  45. }
  46. #endif
  47. #if defined(USE_GLX)
  48. std::string DriverGLX::GetPlatformExtensions() {
  49. auto* connection = x11::Connection::Get();
  50. const int screen = connection ? connection->DefaultScreenId() : 0;
  51. const char* str =
  52. glXQueryExtensionsString(connection->GetXlibDisplay(), screen);
  53. return str ? std::string(str) : "";
  54. }
  55. #endif
  56. } // namespace gl