3 * Copyright (C) 2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
26 #include "guilib/Resolution.h"
27 #include "settings/ISettingCallback.h"
28 #include "settings/ISubSettings.h"
29 #include "threads/CriticalSection.h"
30 #include "utils/Observer.h"
34 class CDisplaySettings : public ISettingCallback, public ISubSettings,
38 static CDisplaySettings& Get();
40 virtual bool Load(const TiXmlNode *settings);
41 virtual bool Save(TiXmlNode *settings) const;
44 virtual bool OnSettingChanging(const CSetting *setting);
45 virtual bool OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode);
48 \brief Returns the currently active resolution
50 This resolution might differ from the display resolution which is based on
53 \sa SetCurrentResolution
55 \sa GetDisplayResolution
57 RESOLUTION GetCurrentResolution() const { return m_currentResolution; }
58 void SetCurrentResolution(RESOLUTION resolution, bool save = false);
60 \brief Returns the best-matching resolution of the videoscreen.screenmode setting value
62 This resolution might differ from the current resolution which is based on
63 the properties of the operating system and the attached displays.
65 \sa GetCurrentResolution
67 RESOLUTION GetDisplayResolution() const;
69 const RESOLUTION_INFO& GetResolutionInfo(size_t index) const;
70 const RESOLUTION_INFO& GetResolutionInfo(RESOLUTION resolution) const;
71 RESOLUTION_INFO& GetResolutionInfo(size_t index);
72 RESOLUTION_INFO& GetResolutionInfo(RESOLUTION resolution);
73 size_t ResolutionInfoSize() const { return m_resolutions.size(); }
74 void AddResolutionInfo(const RESOLUTION_INFO &resolution);
76 const RESOLUTION_INFO& GetCurrentResolutionInfo() const { return GetResolutionInfo(m_currentResolution); }
77 RESOLUTION_INFO& GetCurrentResolutionInfo() { return GetResolutionInfo(m_currentResolution); }
79 void ApplyCalibrations();
80 void UpdateCalibrations();
82 float GetZoomAmount() const { return m_zoomAmount; }
83 void SetZoomAmount(float zoomAmount) { m_zoomAmount = zoomAmount; }
84 float GetPixelRatio() const { return m_pixelRatio; }
85 void SetPixelRatio(float pixelRatio) { m_pixelRatio = pixelRatio; }
86 float GetVerticalShift() const { return m_verticalShift; }
87 void SetVerticalShift(float verticalShift) { m_verticalShift = verticalShift; }
88 bool IsNonLinearStretched() const { return m_nonLinearStretched; }
89 void SetNonLinearStretched(bool nonLinearStretch) { m_nonLinearStretched = nonLinearStretch; }
91 static void SettingOptionsRefreshChangeDelaysFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t);
92 static void SettingOptionsRefreshRatesFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t);
93 static void SettingOptionsResolutionsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t);
94 static void SettingOptionsScreensFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t);
95 static void SettingOptionsVerticalSyncsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t);
99 CDisplaySettings(const CDisplaySettings&);
100 CDisplaySettings& operator=(CDisplaySettings const&);
101 virtual ~CDisplaySettings();
103 DisplayMode GetCurrentDisplayMode() const;
105 static RESOLUTION GetResolutionFromString(const std::string &strResolution);
106 static std::string GetStringFromResolution(RESOLUTION resolution, float refreshrate = 0.0f);
107 static RESOLUTION GetResolutionForScreen();
109 static RESOLUTION FindBestMatchingResolution(const std::map<RESOLUTION, RESOLUTION_INFO> &resolutionInfos, int screen, int width, int height, float refreshrate, bool interlaced);
112 // holds the real gui resolution
113 RESOLUTION m_currentResolution;
115 typedef std::vector<RESOLUTION_INFO> ResolutionInfos;
116 ResolutionInfos m_resolutions;
117 ResolutionInfos m_calibrations;
119 float m_zoomAmount; // current zoom amount
120 float m_pixelRatio; // current pixel ratio
121 float m_verticalShift; // current vertical shift
122 bool m_nonLinearStretched; // current non-linear stretch
124 bool m_resolutionChangeAborted;
125 CCriticalSection m_critical;