Changed GetDisplayResolutions on Windows to ignore modes with less than 32bpp and not test modes that have already been tested. Changed ScreenOptionsMasterPrefs to cache the resolutions list once when the screen starts instead of fetching it multiple times.

This commit is contained in:
Kyzentun Keeslala
2016-01-14 16:33:19 -07:00
parent 31688cc804
commit 79f4037088
2 changed files with 30 additions and 14 deletions
+17 -11
View File
@@ -248,12 +248,16 @@ static void ThemeChoices( vector<RString> &out )
*s = THEME->GetThemeDisplayName( *s );
}
static DisplayResolutions display_resolution_list;
static void cache_display_resolution_list()
{
display_resolution_list.clear();
DISPLAY->GetDisplayResolutions(display_resolution_list);
}
static void DisplayResolutionChoices( vector<RString> &out )
{
DisplayResolutions d;
DISPLAY->GetDisplayResolutions( d );
FOREACHS_CONST( DisplayResolution, d, iter )
FOREACHS_CONST( DisplayResolution, display_resolution_list, iter )
{
RString s = ssprintf("%dx%d", iter->iWidth, iter->iHeight);
out.push_back( s );
@@ -574,18 +578,18 @@ inline res_t operator-(res_t lhs, res_t const &rhs)
static void DisplayResolutionM( int &sel, bool ToSel, const ConfOption *pConfOption )
{
vector<res_t> v;
static vector<res_t> res_choices;
DisplayResolutions d;
DISPLAY->GetDisplayResolutions( d );
FOREACHS_CONST( DisplayResolution, d, iter )
if(res_choices.empty())
{
v.push_back( res_t(iter->iWidth, iter->iHeight) );
FOREACHS_CONST(DisplayResolution, display_resolution_list, iter)
{
res_choices.push_back(res_t(iter->iWidth, iter->iHeight));
}
}
res_t sel_res( PREFSMAN->m_iDisplayWidth, PREFSMAN->m_iDisplayHeight );
MoveMap( sel, sel_res, ToSel, &v[0], v.size() );
MoveMap( sel, sel_res, ToSel, &res_choices[0], res_choices.size());
if( !ToSel )
{
PREFSMAN->m_iDisplayWidth.Set( sel_res.w );
@@ -702,6 +706,8 @@ static void InitializeConfOptions()
if( !g_ConfOptions.empty() )
return;
cache_display_resolution_list();
// There are a couple ways of getting the current preference column or turning
// a new choice in the interface into a new preference. The easiest is when
// the interface choices are an exact mapping to the values the preference
+13 -3
View File
@@ -519,10 +519,20 @@ void GraphicsWindow::GetDisplayResolutions( DisplayResolutions &out )
int i=0;
while(EnumDisplaySettings(NULL, i++, &dm))
{
if(ChangeDisplaySettings(&dm, CDS_TEST)==DISP_CHANGE_SUCCESSFUL)
// Windows 8 and later don't support less than 32bpp, so don't even test
// for them. GetDisplayResolutions is only for resolutions anyway. -Kyz
if(dm.dmBitsPerPel < 32)
{
DisplayResolution res = { dm.dmPelsWidth, dm.dmPelsHeight };
out.insert( res );
continue;
}
DisplayResolution res = { dm.dmPelsWidth, dm.dmPelsHeight };
std::set<DisplayResolution>::iterator entry= out.find(res);
if(entry == out.end())
{
if(ChangeDisplaySettings(&dm, CDS_TEST)==DISP_CHANGE_SUCCESSFUL)
{
out.insert(res);
}
}
}
}