summaryrefslogtreecommitdiffstats
path: root/xbmc/powermanagement/DPMSSupport.h
blob: cf10b4c70ed2d5846481852f3c0dce1a1a5ee2a3 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 *  Copyright (C) 2009-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include <vector>

// This class encapsulates support for monitor power-saving features (DPMS).
// An instance is connected to a Surface, provides information on which
// power-saving features are available for that screen, and it is able to
// turn power-saving on an off.
// Note that SDL turns off DPMS timeouts at the beginning of the application.
class CDPMSSupport
{
public:
  // All known DPMS power-saving modes, on any platform.
  enum PowerSavingMode
  {
    STANDBY,
    SUSPEND,
    OFF,
    NUM_MODES,
  };

  CDPMSSupport();
  virtual ~CDPMSSupport() = default;

  // Whether power-saving is supported on this screen.
  bool IsSupported() const { return !m_supportedModes.empty(); }

  // Which power-saving modes are supported, in the order of preference (i.e.
  // the first mode should be the best choice).
  const std::vector<PowerSavingMode>& GetSupportedModes() const
  {
    return m_supportedModes;
  }

  // Whether a given mode is supported.
  bool IsModeSupported(PowerSavingMode mode) const;

  // Turns on the specified power-saving mode, which must be valid
  // and supported. Returns false if this failed.
  virtual bool EnablePowerSaving(PowerSavingMode mode) = 0;

  // Turns off power-saving mode. You should only call this if the display
  // is currently in a power-saving mode, to avoid visual artifacts.
  virtual bool DisablePowerSaving() = 0;

protected:
  std::vector<PowerSavingMode> m_supportedModes;
};