gl_context_cgl.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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
  3. // found in the LICENSE file.
  4. #ifndef UI_GL_GL_CONTEXT_CGL_H_
  5. #define UI_GL_GL_CONTEXT_CGL_H_
  6. #include <OpenGL/CGLTypes.h>
  7. #include <memory>
  8. #include "ui/gfx/color_space.h"
  9. #include "ui/gl/gl_context.h"
  10. #include "ui/gl/gl_export.h"
  11. namespace gl {
  12. class GLSurface;
  13. // Encapsulates a CGL OpenGL context.
  14. class GL_EXPORT GLContextCGL final : public GLContextReal {
  15. public:
  16. explicit GLContextCGL(GLShareGroup* share_group);
  17. GLContextCGL(const GLContextCGL&) = delete;
  18. GLContextCGL& operator=(const GLContextCGL&) = delete;
  19. // Implement GLContext.
  20. bool Initialize(GLSurface* compatible_surface,
  21. const GLContextAttribs& attribs) override;
  22. bool MakeCurrentImpl(GLSurface* surface) override;
  23. void ReleaseCurrent(GLSurface* surface) override;
  24. bool IsCurrent(GLSurface* surface) override;
  25. void* GetHandle() override;
  26. void SetSafeToForceGpuSwitch() override;
  27. bool ForceGpuSwitchIfNeeded() override;
  28. YUVToRGBConverter* GetYUVToRGBConverter(
  29. const gfx::ColorSpace& color_space) override;
  30. void SetVisibility(bool visibility) override;
  31. protected:
  32. ~GLContextCGL() override;
  33. private:
  34. void Destroy();
  35. GpuPreference GetGpuPreference();
  36. void* context_ = nullptr;
  37. GpuPreference gpu_preference_ = GpuPreference::kLowPower;
  38. std::map<gfx::ColorSpace, std::unique_ptr<YUVToRGBConverter>>
  39. yuv_to_rgb_converters_;
  40. int screen_ = -1;
  41. int renderer_id_ = -1;
  42. bool safe_to_force_gpu_switch_ = true;
  43. bool is_high_performance_context_ = false;
  44. // Debugging for https://crbug.com/863817
  45. bool has_switched_gpus_ = false;
  46. };
  47. } // namespace gl
  48. #endif // UI_GL_GL_CONTEXT_CGL_H_