MythTV  master
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Related Functions | List of all members
DisplayRes Class Referenceabstract

The DisplayRes module allows for the display resolution and refresh rateto be changed "on the fly". More...

#include <DisplayRes.h>

Inheritance diagram for DisplayRes:
Inheritance graph
[legend]
Collaboration diagram for DisplayRes:
Collaboration graph
[legend]

Public Member Functions

bool Initialize (void)
 Initialize DisplayRes, normally called automatically. More...
 
Resolution/Refresh Rate Changing methods.

These return true if mode is changed

bool SwitchToVideo (int iwidth, int iheight, double frate=0.0)
 Switches to the resolution and refresh rate defined in the database for the specified video resolution and frame rate. More...
 
bool SwitchToGUI (tmode next_mode=GUI)
 Switches to the GUI resolution specified. More...
 
bool SwitchToCustomGUI (int width, int height, short rate=0)
 Switches to the custom GUI resolution specified. More...
 
Queries of current video mode
int GetWidth (void) const
 Returns current screen width in pixels. More...
 
int GetHeight (void) const
 Returns current screen width in pixels. More...
 
int GetPhysicalWidth (void) const
 Returns current screen width in millimeters. More...
 
int GetPhysicalHeight (void) const
 Returns current screen height in millimeters. More...
 
double GetRefreshRate (void) const
 Returns current screen refresh rate. More...
 
double GetAspectRatio (void) const
 Returns current screen aspect ratio. More...
 
These methods are global for all video modes
int GetMaxWidth (void) const
 Returns maximum width in pixels supported by display. More...
 
int GetMaxHeight (void) const
 Returns maximum height in pixels supported by display. More...
 
double GetPixelAspectRatio (void) const
 Returns the pixel aspect ratio of the display. More...
 
virtual const DisplayResVectorGetVideoModes () const =0
 Returns all video modes supported by the display. More...
 
std::vector< double > GetRefreshRates (int width, int height) const
 Returns refresh rates available at a specific screen resolution. More...
 

Static Public Member Functions

static DisplayResGetDisplayRes (bool lock=false)
 Factory method that returns a DisplayRes singleton. More...
 
static void Unlock (void)
 Release any access restrictions. More...
 
static void SwitchToDesktop (void)
 Return the screen to the original desktop settings. More...
 

Protected Member Functions

 DisplayRes (void)
 DisplayRes is an abstract class, instanciate with GetDisplayRes(void) More...
 
virtual ~DisplayRes (void)
 
virtual bool GetDisplayInfo (int &w_pix, int &h_pix, int &w_mm, int &h_mm, double &rate, double &par) const =0
 
virtual bool SwitchToVideoMode (int width, int height, double framerate)=0
 

Private Member Functions

 DisplayRes (const DisplayRes &rhs)
 

Private Attributes

tmode m_curMode
 
DisplayResScreen m_mode [MAX_MODES]
 
DisplayResScreen m_last
 
DisplayResMap m_inSizeToOutputMode
 maps input video parameters to output video modes More...
 
int m_maxWidth
 
int m_maxHeight
 
double m_pixelAspectRatio
 

Static Private Attributes

static DisplayRess_instance = nullptr
 
static bool s_locked = false
 

Related Functions

(Note that these are not member functions.)

 GetVideoModes (void)
 Returns all video modes available. More...
 

Detailed Description

The DisplayRes module allows for the display resolution and refresh rateto be changed "on the fly".

Resolution and refresh rate can be changed using an explicit call or based on the video resolution.

The SwitchToVideoMode routine takes care of the actual work involved in changing the display mode. There are currently XRandR and OS X Carbon implementation so this works for X (Linux/BSD/UNIX) and Mac OS X.

Definition at line 32 of file DisplayRes.h.

Constructor & Destructor Documentation

◆ DisplayRes() [1/2]

DisplayRes::DisplayRes ( void  )
inlineprotected

DisplayRes is an abstract class, instanciate with GetDisplayRes(void)

Definition at line 141 of file DisplayRes.h.

◆ ~DisplayRes()

virtual DisplayRes::~DisplayRes ( void  )
inlineprotectedvirtual

Definition at line 142 of file DisplayRes.h.

◆ DisplayRes() [2/2]

DisplayRes::DisplayRes ( const DisplayRes rhs)
private

Member Function Documentation

◆ GetDisplayRes()

DisplayRes * DisplayRes::GetDisplayRes ( bool  lock = false)
static

Factory method that returns a DisplayRes singleton.

Parameters
lockprevent other objects that also request a lock from altering the display resolution
See also
Unlock(void)

Definition at line 18 of file DisplayRes.cpp.

Referenced by MythUIHelperPrivate::GetPixelAspectRatio(), HostRefreshRateComboBoxSetting::GetRefreshRates(), GetVideoModes(), TV::Init(), MythUIHelper::LoadQtConfig(), VideoOutputOMX::VideoOutputOMX(), VideoOutputOpenGL::VideoOutputOpenGL(), VideoOutputVDPAU::VideoOutputVDPAU(), and VideoOutputXv::VideoOutputXv().

◆ Unlock()

void DisplayRes::Unlock ( void  )
static

Release any access restrictions.

See also
GetDisplayRes(bool)

Definition at line 38 of file DisplayRes.cpp.

Referenced by VideoOutput::~VideoOutput().

◆ SwitchToDesktop()

void DisplayRes::SwitchToDesktop ( void  )
static

Return the screen to the original desktop settings.

Definition at line 43 of file DisplayRes.cpp.

Referenced by MythUIHelperPrivate::~MythUIHelperPrivate().

◆ Initialize()

bool DisplayRes::Initialize ( void  )

Initialize DisplayRes, normally called automatically.

While Initialize is called automatically by GetDisplayRes(void) it should be called again if the database settings for DisplayRes have changed.

Definition at line 49 of file DisplayRes.cpp.

Referenced by DisplayResOSX::DisplayResOSX(), DisplayResX::DisplayResX(), and MythUIHelper::LoadQtConfig().

◆ SwitchToVideo()

DisplayRes::SwitchToVideo ( int  iwidth,
int  iheight,
double  frate = 0.0 
)

Switches to the resolution and refresh rate defined in the database for the specified video resolution and frame rate.

Definition at line 126 of file DisplayRes.cpp.

Referenced by VideoOutput::ResizeForVideo().

◆ SwitchToGUI()

bool DisplayRes::SwitchToGUI ( tmode  next_mode = GUI)

Switches to the GUI resolution specified.

If which_gui is GUI then this switches to the resolution and refresh rate set in the database for the GUI. If which_gui is set to CUSTOM_GUI then we switch to the resolution and refresh rate specified in the last call to SwitchToCustomGUI(int, int, short).

Parameters
which_guieither regular GUI or CUSTOM_GUI
See also
SwitchToCustomGUI(int, int, short)

Definition at line 188 of file DisplayRes.cpp.

Referenced by MythUIHelper::LoadQtConfig(), VideoOutput::ResizeForGui(), SwitchToCustomGUI(), and SwitchToDesktop().

◆ SwitchToCustomGUI()

bool DisplayRes::SwitchToCustomGUI ( int  width,
int  height,
short  rate = 0 
)

Switches to the custom GUI resolution specified.

This switches to the specified resolution, and refresh rate if specified. It also makes saves this resolution as the CUSTOM_GUI resolution, so that it can be recalled with SwitchToGUI(CUSTOM_GUI) in later DisplayRes calls.

See also
SwitchToGUI(tmode)

Definition at line 230 of file DisplayRes.cpp.

◆ GetWidth()

int DisplayRes::GetWidth ( void  ) const
inline

Returns current screen width in pixels.

Definition at line 101 of file DisplayRes.h.

Referenced by VideoOutput::ResizeForVideo(), SwitchToGUI(), and SwitchToVideo().

◆ GetHeight()

int DisplayRes::GetHeight ( void  ) const
inline

Returns current screen width in pixels.

Definition at line 104 of file DisplayRes.h.

Referenced by VideoOutput::ResizeForVideo(), SwitchToGUI(), and SwitchToVideo().

◆ GetPhysicalWidth()

int DisplayRes::GetPhysicalWidth ( void  ) const
inline

Returns current screen width in millimeters.

Definition at line 107 of file DisplayRes.h.

Referenced by VideoOutput::ResizeForVideo(), and SwitchToVideo().

◆ GetPhysicalHeight()

int DisplayRes::GetPhysicalHeight ( void  ) const
inline

Returns current screen height in millimeters.

Definition at line 110 of file DisplayRes.h.

Referenced by VideoOutput::ResizeForVideo(), and SwitchToVideo().

◆ GetRefreshRate()

double DisplayRes::GetRefreshRate ( void  ) const
inline

Returns current screen refresh rate.

Definition at line 113 of file DisplayRes.h.

Referenced by SwitchToGUI().

◆ GetAspectRatio()

double DisplayRes::GetAspectRatio ( void  ) const
inline

Returns current screen aspect ratio.

If there is an aspect overide in the database that aspect ratio is returned instead of the actual screen aspect ratio.

Definition at line 119 of file DisplayRes.h.

Referenced by VideoOutput::InitDisplayMeasurements(), and VideoOutput::ResizeForVideo().

◆ GetMaxWidth()

int DisplayRes::GetMaxWidth ( void  ) const
inline

Returns maximum width in pixels supported by display.

Definition at line 128 of file DisplayRes.h.

Referenced by TV::Init(), and VideoOutput::InitDisplayMeasurements().

◆ GetMaxHeight()

int DisplayRes::GetMaxHeight ( void  ) const
inline

Returns maximum height in pixels supported by display.

Definition at line 130 of file DisplayRes.h.

Referenced by TV::Init(), and VideoOutput::InitDisplayMeasurements().

◆ GetPixelAspectRatio()

double DisplayRes::GetPixelAspectRatio ( void  ) const
inline

Returns the pixel aspect ratio of the display.

Definition at line 132 of file DisplayRes.h.

Referenced by MythUIHelperPrivate::GetPixelAspectRatio().

◆ GetVideoModes()

GetVideoModes ( void  ) const
pure virtual

Returns all video modes supported by the display.

Returns all video modes available.

This is a conveniance class that instanciates a DisplayRes class if needed, and returns a copy of vector returned by DisplayRes::GetVideoModes(void).

Implemented in DisplayResOSX, and DisplayResX.

Referenced by GetRefreshRates(), GetVideoModes(), Initialize(), SwitchToGUI(), and SwitchToVideo().

◆ GetRefreshRates()

std::vector< double > DisplayRes::GetRefreshRates ( int  width,
int  height 
) const

Returns refresh rates available at a specific screen resolution.

Definition at line 238 of file DisplayRes.cpp.

Referenced by HostRefreshRateComboBoxSetting::GetRefreshRates().

◆ GetDisplayInfo()

virtual bool DisplayRes::GetDisplayInfo ( int &  w_pix,
int &  h_pix,
int &  w_mm,
int &  h_mm,
double &  rate,
double &  par 
) const
protectedpure virtual

Implemented in DisplayResOSX, and DisplayResX.

Referenced by Initialize().

◆ SwitchToVideoMode()

virtual bool DisplayRes::SwitchToVideoMode ( int  width,
int  height,
double  framerate 
)
protectedpure virtual

Implemented in DisplayResOSX, and DisplayResX.

Referenced by SwitchToGUI(), and SwitchToVideo().

Friends And Related Function Documentation

◆ GetVideoModes()

GetVideoModes ( void  )
related

Returns all video modes available.

This is a conveniance class that instanciates a DisplayRes class if needed, and returns a copy of vector returned by GetVideoModes(void).

Definition at line 262 of file DisplayRes.cpp.

Referenced by GuiVidModeResolution(), and TVVidModeResolution().

Member Data Documentation

◆ m_curMode

tmode DisplayRes::m_curMode
private

Definition at line 152 of file DisplayRes.h.

Referenced by Initialize(), SwitchToGUI(), and SwitchToVideo().

◆ m_mode

DisplayResScreen DisplayRes::m_mode[MAX_MODES]
private

Definition at line 153 of file DisplayRes.h.

Referenced by Initialize(), SwitchToCustomGUI(), SwitchToGUI(), and SwitchToVideo().

◆ m_last

DisplayResScreen DisplayRes::m_last
private

Definition at line 154 of file DisplayRes.h.

Referenced by Initialize(), SwitchToGUI(), and SwitchToVideo().

◆ m_inSizeToOutputMode

DisplayResMap DisplayRes::m_inSizeToOutputMode
private

maps input video parameters to output video modes

Definition at line 157 of file DisplayRes.h.

Referenced by Initialize(), and SwitchToVideo().

◆ m_maxWidth

int DisplayRes::m_maxWidth
private

Definition at line 159 of file DisplayRes.h.

Referenced by Initialize().

◆ m_maxHeight

int DisplayRes::m_maxHeight
private

Definition at line 159 of file DisplayRes.h.

Referenced by Initialize().

◆ m_pixelAspectRatio

double DisplayRes::m_pixelAspectRatio
private

Definition at line 161 of file DisplayRes.h.

Referenced by Initialize().

◆ s_instance

DisplayRes * DisplayRes::s_instance = nullptr
staticprivate

Definition at line 163 of file DisplayRes.h.

Referenced by GetDisplayRes(), and SwitchToDesktop().

◆ s_locked

bool DisplayRes::s_locked = false
staticprivate

Definition at line 164 of file DisplayRes.h.

Referenced by GetDisplayRes(), and Unlock().


The documentation for this class was generated from the following files: