gl_display_egl_util.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2020 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. #ifndef UI_GL_GL_DISPLAY_EGL_UTIL_H_
  5. #define UI_GL_GL_DISPLAY_EGL_UTIL_H_
  6. #include <vector>
  7. #include "base/scoped_environment_variable_override.h"
  8. #include "third_party/abseil-cpp/absl/types/optional.h"
  9. #include "third_party/khronos/EGL/egl.h"
  10. #include "ui/gl/gl_export.h"
  11. #include "ui/gl/gl_surface_egl.h"
  12. namespace gl {
  13. // Utility singleton class that helps to set additional egl properties. This
  14. // class should be implemented by each platform except Ozone. In case of Ozone,
  15. // there is a common implementation that forwards calls to a public interface of
  16. // a platform.
  17. // The reason why it is defined here in ui/gl is that ui/gl cannot depend on
  18. // ozone and we have to provide an interface here. ui/gl/init will provide an
  19. // implementation for this utility class upon initialization of gl.
  20. class GL_EXPORT GLDisplayEglUtil {
  21. public:
  22. // Returns either set instance or stub instance.
  23. static GLDisplayEglUtil* GetInstance();
  24. static void SetInstance(GLDisplayEglUtil* gl_display_util);
  25. // Returns display attributes for the given |platform_type|. Each platform can
  26. // have different attributes.
  27. virtual void GetPlatformExtraDisplayAttribs(
  28. EGLenum platform_type,
  29. std::vector<EGLAttrib>* attributes) = 0;
  30. // Sets custom alpha and buffer size for a given platform. By default, the
  31. // values are not modified.
  32. virtual void ChoosePlatformCustomAlphaAndBufferSize(EGLint* alpha_size,
  33. EGLint* buffer_size) = 0;
  34. // X11 specific; returns scoped unset display env variable if vulkan surface
  35. // is not supported.
  36. virtual absl::optional<base::ScopedEnvironmentVariableOverride>
  37. MaybeGetScopedDisplayUnsetForVulkan() = 0;
  38. protected:
  39. virtual ~GLDisplayEglUtil() = default;
  40. };
  41. } // namespace gl
  42. #endif // UI_GL_GL_DISPLAY_EGL_UTIL_H_