2017-06-15 17:37:39 -06:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-06-15 17:37:39 -06:00
|
|
|
|
|
|
|
#include "UICommon/VideoUtils.h"
|
|
|
|
|
|
|
|
#include "Common/Assert.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
|
|
|
|
2019-05-08 13:00:23 -06:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <Windows.h>
|
|
|
|
#endif
|
|
|
|
|
2021-02-22 06:32:53 -07:00
|
|
|
#ifdef HAVE_XRANDR
|
2017-06-15 17:37:39 -06:00
|
|
|
#include "UICommon/X11Utils.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace VideoUtils
|
|
|
|
{
|
|
|
|
#if !defined(__APPLE__)
|
|
|
|
std::vector<std::string> GetAvailableResolutions(X11Utils::XRRConfiguration* xrr_config)
|
|
|
|
{
|
|
|
|
std::vector<std::string> resos;
|
|
|
|
#ifdef _WIN32
|
|
|
|
DWORD iModeNum = 0;
|
|
|
|
DEVMODE dmi;
|
|
|
|
ZeroMemory(&dmi, sizeof(dmi));
|
|
|
|
dmi.dmSize = sizeof(dmi);
|
|
|
|
|
|
|
|
while (EnumDisplaySettings(nullptr, iModeNum++, &dmi) != 0)
|
|
|
|
{
|
|
|
|
char res[100];
|
|
|
|
sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight);
|
|
|
|
std::string strRes(res);
|
|
|
|
// Only add unique resolutions
|
|
|
|
if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
|
|
|
|
{
|
|
|
|
resos.push_back(strRes);
|
|
|
|
}
|
|
|
|
ZeroMemory(&dmi, sizeof(dmi));
|
|
|
|
}
|
|
|
|
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
|
|
|
|
xrr_config->AddResolutions(resos);
|
|
|
|
#endif
|
|
|
|
return resos;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
std::vector<std::string> GetAvailableAntialiasingModes(int& msaa_modes)
|
|
|
|
{
|
|
|
|
std::vector<std::string> modes;
|
|
|
|
const auto& aa_modes = g_Config.backend_info.AAModes;
|
|
|
|
const bool supports_ssaa = g_Config.backend_info.bSupportsSSAA;
|
|
|
|
msaa_modes = 0;
|
|
|
|
|
|
|
|
for (const auto mode : aa_modes)
|
|
|
|
{
|
|
|
|
if (mode == 1)
|
|
|
|
{
|
|
|
|
modes.push_back("None");
|
2018-03-14 18:34:35 -06:00
|
|
|
ASSERT_MSG(VIDEO, !supports_ssaa || msaa_modes == 0, "SSAA setting won't work correctly");
|
2017-06-15 17:37:39 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
modes.push_back(std::to_string(mode) + "x MSAA");
|
|
|
|
msaa_modes++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (supports_ssaa)
|
|
|
|
{
|
|
|
|
for (const auto mode : aa_modes)
|
|
|
|
{
|
|
|
|
if (mode != 1)
|
|
|
|
modes.push_back(std::to_string(mode) + "x SSAA");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return modes;
|
|
|
|
}
|
2019-05-05 17:48:12 -06:00
|
|
|
} // namespace VideoUtils
|