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);
96 static void SettingOptionsStereoscopicModesFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t);
97 static void SettingOptionsPreferredStereoscopicViewModesFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t);
101 CDisplaySettings(const CDisplaySettings&);
102 CDisplaySettings& operator=(CDisplaySettings const&);
103 virtual ~CDisplaySettings();
105 DisplayMode GetCurrentDisplayMode() const;
107 static RESOLUTION GetResolutionFromString(const std::string &strResolution);
108 static std::string GetStringFromResolution(RESOLUTION resolution, float refreshrate = 0.0f);
109 static RESOLUTION GetResolutionForScreen();
111 static RESOLUTION FindBestMatchingResolution(const std::map<RESOLUTION, RESOLUTION_INFO> &resolutionInfos, int screen, int width, int height, float refreshrate, unsigned int flags);
114 // holds the real gui resolution
115 RESOLUTION m_currentResolution;
117 typedef std::vector<RESOLUTION_INFO> ResolutionInfos;
118 ResolutionInfos m_resolutions;
119 ResolutionInfos m_calibrations;
121 float m_zoomAmount; // current zoom amount
122 float m_pixelRatio; // current pixel ratio
123 float m_verticalShift; // current vertical shift
124 bool m_nonLinearStretched; // current non-linear stretch
126 bool m_resolutionChangeAborted;
127 CCriticalSection m_critical;