dual_gpu_state.cc 854 B

123456789101112131415161718192021222324252627282930313233343536
  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. #include "ui/gl/dual_gpu_state.h"
  5. #include "base/containers/flat_set.h"
  6. #include "base/trace_event/trace_event.h"
  7. namespace gl {
  8. class GLContext;
  9. DualGPUState::DualGPUState() {}
  10. DualGPUState::~DualGPUState() {}
  11. void DualGPUState::RegisterHighPerformanceContext(GLContext* context) {
  12. if (contexts_.contains(context))
  13. return;
  14. CancelDelayedSwitchToLowPowerGPU();
  15. contexts_.insert(context);
  16. SwitchToHighPerformanceGPUIfNeeded();
  17. }
  18. void DualGPUState::RemoveHighPerformanceContext(GLContext* context) {
  19. if (!contexts_.contains(context))
  20. return;
  21. contexts_.erase(context);
  22. if (contexts_.empty())
  23. AttemptSwitchToLowPowerGPUWithDelay();
  24. }
  25. } // namespace gl