dual_gpu_state_mac.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2019 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_DUAL_GPU_STATE_MAC_H_
  5. #define UI_GL_DUAL_GPU_STATE_MAC_H_
  6. #include <OpenGL/CGLRenderers.h>
  7. #include <OpenGL/CGLTypes.h>
  8. #include "base/cancelable_callback.h"
  9. #include "base/memory/scoped_refptr.h"
  10. #include "base/no_destructor.h"
  11. #include "base/synchronization/lock.h"
  12. #include "build/build_config.h"
  13. #include "ui/gl/dual_gpu_state.h"
  14. #include "ui/gl/gl_bindings.h"
  15. #include "ui/gl/gl_export.h"
  16. namespace gl {
  17. class GL_EXPORT DualGPUStateMac : public DualGPUState {
  18. public:
  19. static DualGPUStateMac* GetInstance();
  20. DualGPUStateMac(const DualGPUStateMac&) = delete;
  21. DualGPUStateMac& operator=(const DualGPUStateMac&) = delete;
  22. private:
  23. friend base::NoDestructor<DualGPUStateMac>;
  24. DualGPUStateMac();
  25. ~DualGPUStateMac();
  26. void SwitchToHighPerformanceGPUIfNeeded() override;
  27. void SwitchToLowPowerGPU() override;
  28. void AttemptSwitchToLowPowerGPUWithDelay() override;
  29. void CancelDelayedSwitchToLowPowerGPU() override;
  30. void AllocateDiscretePixelFormatObjectIfNeeded();
  31. void ReleaseDiscretePixelFormatObjectIfNeeded();
  32. CGLPixelFormatObj discrete_pixelformat_ = nullptr;
  33. base::CancelableOnceClosure cancelable_delay_callback_;
  34. };
  35. } // namespace gl
  36. #endif // UI_GL_DUAL_GPU_STATE_MAC_H_