summaryrefslogtreecommitdiff
path: root/chromium/ui/gl/dual_gpu_state.h
blob: 98b7192edf3e1fe2c89ce8465b6a4011dc1efe05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GL_DUAL_GPU_STATE_H_
#define UI_GL_DUAL_GPU_STATE_H_

#include "base/containers/flat_set.h"
#include "base/macros.h"
#include "ui/gl/gl_export.h"

namespace gl {

class GLContext;

class GL_EXPORT DualGPUState {
 public:
  void RegisterHighPerformanceContext(GLContext* context);
  void RemoveHighPerformanceContext(GLContext* context);

 protected:
  DualGPUState();
  ~DualGPUState();

 private:
  virtual void SwitchToHighPerformanceGPUIfNeeded() = 0;
  virtual void SwitchToLowPowerGPU() = 0;
  virtual void AttemptSwitchToLowPowerGPUWithDelay() = 0;
  virtual void CancelDelayedSwitchToLowPowerGPU() = 0;

  base::flat_set<GLContext*> contexts_;

  DISALLOW_COPY_AND_ASSIGN(DualGPUState);
};

}  // namespace gl

#endif  // UI_GL_DUAL_GPU_STATE_H_