MythTV  master
DisplayRes.h
Go to the documentation of this file.
1 #ifndef _Display_Res_H_
2 #define _Display_Res_H_
3 
4 #include <vector>
5 
6 #include "DisplayResScreen.h"
7 #include "mythuiexp.h"
8 
22 typedef enum
23 {
24  GUI = 0,
25  VIDEO = 1,
28  DESKTOP = 4,
29  MAX_MODES = 5,
30 } tmode;
31 
33 {
34  public:
42  static DisplayRes *GetDisplayRes(bool lock = false);
43 
47  static void Unlock(void);
48 
51  static void SwitchToDesktop(void);
52 
59  bool Initialize(void);
60 
70  bool SwitchToVideo(int iwidth, int iheight, double frate = 0.0);
82  bool SwitchToGUI(tmode next_mode=GUI);
92  bool SwitchToCustomGUI(int width, int height, short rate = 0);
101  int GetWidth(void) const { return m_last.Width(); }
102 
104  int GetHeight(void) const { return m_last.Height(); }
105 
107  int GetPhysicalWidth(void) const { return m_last.Width_mm(); }
108 
110  int GetPhysicalHeight(void) const { return m_last.Height_mm(); }
111 
113  double GetRefreshRate(void) const { return m_last.RefreshRate(); }
119  double GetAspectRatio(void) const { return m_last.AspectRatio(); }
127  int GetMaxWidth(void) const { return m_maxWidth; }
130  int GetMaxHeight(void) const { return m_maxHeight; }
132  double GetPixelAspectRatio(void) const { return m_pixelAspectRatio; }
134  virtual const DisplayResVector& GetVideoModes() const = 0;
136  std::vector<double> GetRefreshRates(int width, int height) const;
139  protected:
141  DisplayRes(void) : m_curMode(GUI), m_maxWidth(0), m_maxHeight(0), m_pixelAspectRatio(1.0) {;}
142  virtual ~DisplayRes(void) {;}
143 
144  // These methods are implemented by the subclasses
145  virtual bool GetDisplayInfo(int &w_pix, int &h_pix, int &w_mm,
146  int &h_mm, double &rate, double &par) const = 0;
147  virtual bool SwitchToVideoMode(int width, int height, double framerate) = 0;
148 
149  private:
150  DisplayRes(const DisplayRes & rhs); // disable copy constructor;
151 
152  tmode m_curMode; // current mode
154  DisplayResScreen m_last; // mirror of mode[current_mode]
155 
158 
159  int m_maxWidth, m_maxHeight;
160 
162 
164  static bool s_locked;
165 };
166 
176 
177 #endif
double GetPixelAspectRatio(void) const
Returns the pixel aspect ratio of the display.
Definition: DisplayRes.h:132
int GetMaxHeight(void) const
Returns maximum height in pixels supported by display.
Definition: DisplayRes.h:130
virtual ~DisplayRes(void)
Definition: DisplayRes.h:142
double GetAspectRatio(void) const
Returns current screen aspect ratio.
Definition: DisplayRes.h:119
tmode m_curMode
Definition: DisplayRes.h:152
DisplayResMap m_inSizeToOutputMode
maps input video parameters to output video modes
Definition: DisplayRes.h:157
DisplayRes(void)
DisplayRes is an abstract class, instanciate with GetDisplayRes(void)
Definition: DisplayRes.h:141
static bool s_locked
Definition: DisplayRes.h:164
Definition: DisplayRes.h:24
double m_pixelAspectRatio
Definition: DisplayRes.h:161
int GetWidth(void) const
Returns current screen width in pixels.
Definition: DisplayRes.h:101
int GetHeight(void) const
Returns current screen width in pixels.
Definition: DisplayRes.h:104
std::vector< DisplayResScreen > DisplayResVector
int GetPhysicalHeight(void) const
Returns current screen height in millimeters.
Definition: DisplayRes.h:110
MUI_PUBLIC DisplayResVector GetVideoModes(void)
Definition: DisplayRes.cpp:262
int GetPhysicalWidth(void) const
Returns current screen width in millimeters.
Definition: DisplayRes.h:107
int m_maxWidth
Definition: DisplayRes.h:159
double GetRefreshRate(void) const
Returns current screen refresh rate.
Definition: DisplayRes.h:113
tmode
Definition: DisplayRes.h:22
std::map< uint64_t, DisplayResScreen > DisplayResMap
#define MUI_PUBLIC
Definition: mythuiexp.h:9
static DisplayRes * s_instance
Definition: DisplayRes.h:163
DisplayResScreen m_last
Definition: DisplayRes.h:154
The DisplayRes module allows for the display resolution and refresh rateto be changed "on the fly".
Definition: DisplayRes.h:32
GetVideoModes(void)
Returns all video modes available.
Definition: DisplayRes.cpp:262