Skip to content

Commit

Permalink
NativeApp: add System_GetPropertyFloat all the places
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Feb 4, 2020
1 parent 0a2aa2c commit 55bb58e
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 66 deletions.
2 changes: 1 addition & 1 deletion Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bool UpdateScreenScale(int width, int height) {
g_dpi_scale_x = g_logical_dpi / g_dpi;
g_dpi_scale_y = g_logical_dpi / g_dpi;
#elif PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP)
g_dpi = (float)System_GetPropertyInt(SYSPROP_DISPLAY_DPI);
g_dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_DPI);
g_dpi_scale_x = 96.0f / g_dpi;
g_dpi_scale_y = 96.0f / g_dpi;
#else
Expand Down
11 changes: 5 additions & 6 deletions Core/HLE/sceDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,7 @@ static bool IsRunningSlow() {
best = std::max(fpsHistory[index], best);
}

// Note that SYSPROP_DISPLAY_REFRESH_RATE is multiplied by 1000.
return best < System_GetPropertyInt(SYSPROP_DISPLAY_REFRESH_RATE) * (1.0 / 1001.0);
return best < System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE) * 0.999;
}

return false;
Expand Down Expand Up @@ -510,12 +509,12 @@ static void DoFrameDropLogging(float scaledTimestep) {

static int CalculateFrameSkip() {
int frameSkipNum;
if (g_Config.iFrameSkipType == 1) {
if (g_Config.iFrameSkipType == 1) {
// Calculate the frames to skip dynamically using the set percentage of the current fps
frameSkipNum = ceil( flips * (static_cast<double>(g_Config.iFrameSkip) / 100.00) );
} else {
frameSkipNum = ceil( flips * (static_cast<double>(g_Config.iFrameSkip) / 100.00) );
} else {
// Use the set number of frames to skip
frameSkipNum = g_Config.iFrameSkip;
frameSkipNum = g_Config.iFrameSkip;
}
return frameSkipNum;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/HW/StereoResampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ StereoResampler::StereoResampler()

// Some Android devices are v-synced to non-60Hz framerates. We simply timestretch audio to fit.
// TODO: should only do this if auto frameskip is off?
float refresh = System_GetPropertyInt(SYSPROP_DISPLAY_REFRESH_RATE) / 1000.0f;
float refresh = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE);

// If framerate is "close"...
if (refresh != 60.0f && refresh > 50.0f && refresh < 70.0f) {
Expand Down
12 changes: 6 additions & 6 deletions Qt/QtMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <string.h>

MainUI *emugl = nullptr;
static int refreshRate = 60000;
static float refreshRate = 60.f;
static int browseFileEvent = -1;
static int browseFolderEvent = -1;

Expand Down Expand Up @@ -145,8 +145,6 @@ int System_GetPropertyInt(SystemProperty prop) {
switch (prop) {
case SYSPROP_AUDIO_SAMPLE_RATE:
return 44100;
case SYSPROP_DISPLAY_REFRESH_RATE:
return refreshRate;
case SYSPROP_DEVICE_TYPE:
#if defined(__ANDROID__)
return DEVICE_TYPE_MOBILE;
Expand All @@ -166,14 +164,16 @@ int System_GetPropertyInt(SystemProperty prop) {
}
}

int System_GetPropertyFloat(SystemProperty prop) {
float System_GetPropertyFloat(SystemProperty prop) {
switch (prop) {
case SYSPROP_DISPLAY_REFRESH_RATE:
return refreshRate;
case SYSPROP_DISPLAY_LOGICAL_DPI:
return QApplication::primaryScreen()->logicalDotsPerInch();
case SYSPROP_DISPLAY_DPI:
return QApplication::primaryScreen()->physicalDotsPerInch();
default:
return System_GetPropertyInt(prop);
return -1;
}
}

Expand Down Expand Up @@ -645,7 +645,7 @@ int main(int argc, char *argv[])
dp_xres = (int)(pixel_xres * g_dpi_scale_x);
dp_yres = (int)(pixel_yres * g_dpi_scale_y);

refreshRate = (int)(screen->refreshRate() * 1000);
refreshRate = screen->refreshRate();

std::string savegame_dir = ".";
std::string external_dir = ".";
Expand Down
15 changes: 11 additions & 4 deletions SDL/SDLMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int g_QuitRequested = 0;

static int g_DesktopWidth = 0;
static int g_DesktopHeight = 0;
static int g_RefreshRate = 60000;
static float g_RefreshRate = 60.f;

int getDisplayNumber(void) {
int displayNumber = 0;
Expand Down Expand Up @@ -307,8 +307,6 @@ int System_GetPropertyInt(SystemProperty prop) {
switch (prop) {
case SYSPROP_AUDIO_SAMPLE_RATE:
return 44100;
case SYSPROP_DISPLAY_REFRESH_RATE:
return g_RefreshRate;
case SYSPROP_DEVICE_TYPE:
#if defined(MOBILE_DEVICE)
return DEVICE_TYPE_MOBILE;
Expand All @@ -322,6 +320,15 @@ int System_GetPropertyInt(SystemProperty prop) {
}
}

float System_GetPropertyFloat(SystemProperty prop) {
switch (prop) {
case SYSPROP_DISPLAY_REFRESH_RATE:
return g_RefreshRate;
default:
return -1;
}
}

bool System_GetPropertyBool(SystemProperty prop) {
switch (prop) {
case SYSPROP_HAS_BACK_BUTTON:
Expand Down Expand Up @@ -511,7 +518,7 @@ int main(int argc, char *argv[]) {
}
g_DesktopWidth = displayMode.w;
g_DesktopHeight = displayMode.h;
g_RefreshRate = (int)(displayMode.refresh_rate * 1000);
g_RefreshRate = displayMode.refresh_rate;

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
Expand Down
17 changes: 12 additions & 5 deletions UWP/PPSSPP_UWPMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr<DX::DeviceResourc
if (g_Config.memStickDirectory.back() != '/')
g_Config.memStickDirectory += "/";

// On Win32 it makes more sense to initialize the system directories here
// On Win32 it makes more sense to initialize the system directories here
// because the next place it was called was in the EmuThread, and it's too late by then.
InitSysDirectories();

Expand Down Expand Up @@ -328,7 +328,7 @@ void UWPGraphicsContext::Shutdown() {
}

void UWPGraphicsContext::SwapInterval(int interval) {

}

std::string System_GetProperty(SystemProperty prop) {
Expand Down Expand Up @@ -357,8 +357,6 @@ int System_GetPropertyInt(SystemProperty prop) {
switch (prop) {
case SYSPROP_AUDIO_SAMPLE_RATE:
return winAudioBackend ? winAudioBackend->GetSampleRate() : -1;
case SYSPROP_DISPLAY_REFRESH_RATE:
return 60000;
case SYSPROP_DEVICE_TYPE:
{
auto ver = Windows::System::Profile::AnalyticsInfo::VersionInfo;
Expand All @@ -375,6 +373,15 @@ int System_GetPropertyInt(SystemProperty prop) {
}
}

float System_GetPropertyFloat(SystemProperty prop) {
switch (prop) {
case SYSPROP_DISPLAY_REFRESH_RATE:
return 60.f;
default:
return -1;
}
}

bool VulkanMayBeAvailable() {
return false;
}
Expand Down Expand Up @@ -477,7 +484,7 @@ bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &default
std::string GetCPUBrandString() {
Platform::String^ cpu_id = nullptr;
Platform::String^ cpu_name = nullptr;

// GUID_DEVICE_PROCESSOR: {97FADB10-4E33-40AE-359C-8BEF029DBDD0}
Platform::String^ if_filter = L"System.Devices.InterfaceClassGuid:=\"{97FADB10-4E33-40AE-359C-8BEF029DBDD0}\"";

Expand Down
20 changes: 10 additions & 10 deletions Windows/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace MainWindow
// Register classes - Main Window
WNDCLASSEX wcex;
memset(&wcex, 0, sizeof(wcex));
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = 0; // Show in taskbar
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.hInstance = hInstance;
Expand Down Expand Up @@ -228,7 +228,7 @@ namespace MainWindow
if (++g_Config.iInternalResolution > RESOLUTION_MAX)
g_Config.iInternalResolution = 0;
}

// Taking auto-texture scaling into account
if (g_Config.iTexScalingLevel == TEXSCALING_AUTO)
setTexScalingMultiplier(0);
Expand Down Expand Up @@ -329,7 +329,7 @@ namespace MainWindow
dwStyle &= ~WS_POPUP;
// Re-add caption and border styles.
dwStyle |= WS_OVERLAPPEDWINDOW;

// Put back the menu bar.
::SetMenu(hWnd, menu);
} else {
Expand Down Expand Up @@ -437,7 +437,7 @@ namespace MainWindow
bool portrait = g_Config.IsPortrait();

// We want to adjust for DPI but still get an integer pixel scaling ratio.
double dpi_scale = 96.0 / System_GetPropertyInt(SYSPROP_DISPLAY_DPI);
double dpi_scale = 96.0 / System_GetPropertyFloat(SYSPROP_DISPLAY_DPI);
int scale = (int)ceil(2.0 / dpi_scale);

GetWindowSizeAtResolution(scale * (portrait ? 272 : 480), scale * (portrait ? 480 : 272), &windowWidth, &windowHeight);
Expand Down Expand Up @@ -547,7 +547,7 @@ namespace MainWindow
if (disasmWindow[0])
delete disasmWindow[0];
disasmWindow[0] = 0;

#if PPSSPP_API(ANY_GL)
DialogManager::RemoveDlg(geDebuggerWindow);
if (geDebuggerWindow)
Expand Down Expand Up @@ -682,7 +682,7 @@ namespace MainWindow
}
return 0;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_CREATE:
Expand All @@ -691,7 +691,7 @@ namespace MainWindow
RemoveMenu(GetMenu(hWnd), ID_OPTIONS_DIRECT3D11, MF_BYCOMMAND);
}
break;

case WM_GETMINMAXINFO:
{
MINMAXINFO *minmax = reinterpret_cast<MINMAXINFO *>(lParam);
Expand Down Expand Up @@ -975,10 +975,10 @@ namespace MainWindow
case WM_SYSCOMMAND:
{
switch (wParam) {
case SC_SCREENSAVE:
case SC_SCREENSAVE:
return 0;
case SC_MONITORPOWER:
return 0;
return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
Expand All @@ -988,7 +988,7 @@ namespace MainWindow
}
return 0;
}

void Redraw() {
InvalidateRect(hwndDisplay,0,0);
}
Expand Down
29 changes: 18 additions & 11 deletions Windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ std::string GetVideoCardDriverVersion() {
}

IWbemLocator *pIWbemLocator = NULL;
hr = CoCreateInstance(__uuidof(WbemLocator), NULL, CLSCTX_INPROC_SERVER,
hr = CoCreateInstance(__uuidof(WbemLocator), NULL, CLSCTX_INPROC_SERVER,
__uuidof(IWbemLocator), (LPVOID *)&pIWbemLocator);
if (FAILED(hr)) {
CoUninitialize();
Expand All @@ -143,9 +143,9 @@ std::string GetVideoCardDriverVersion() {
return retvalue;
}

hr = CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE,
hr = CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE,
NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL,EOAC_DEFAULT);

BSTR bstrWQL = SysAllocString(L"WQL");
BSTR bstrPath = SysAllocString(L"select * from Win32_VideoController");
IEnumWbemClassObject* pEnum;
Expand Down Expand Up @@ -232,19 +232,26 @@ int System_GetPropertyInt(SystemProperty prop) {
switch (prop) {
case SYSPROP_AUDIO_SAMPLE_RATE:
return winAudioBackend ? winAudioBackend->GetSampleRate() : -1;
case SYSPROP_DISPLAY_REFRESH_RATE:
return 60000;
case SYSPROP_DEVICE_TYPE:
return DEVICE_TYPE_DESKTOP;
case SYSPROP_DISPLAY_DPI:
return ScreenDPI();
case SYSPROP_DISPLAY_COUNT:
return GetSystemMetrics(SM_CMONITORS);
default:
return -1;
}
}

float System_GetPropertyFloat(SystemProperty prop) {
switch (prop) {
case SYSPROP_DISPLAY_REFRESH_RATE:
return 60.f;
case SYSPROP_DISPLAY_DPI:
return (float)ScreenDPI();
default:
return -1;
}
}

bool System_GetPropertyBool(SystemProperty prop) {
switch (prop) {
case SYSPROP_HAS_FILE_BROWSER:
Expand Down Expand Up @@ -491,7 +498,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin

LogManager::Init();

// On Win32 it makes more sense to initialize the system directories here
// On Win32 it makes more sense to initialize the system directories here
// because the next place it was called was in the EmuThread, and it's too late by then.
g_Config.internalDataDirectory = W32Util::UserDocumentsPath();
InitSysDirectories();
Expand Down Expand Up @@ -589,7 +596,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
// - The -l switch is expected to show the log console, REGARDLESS of config settings.
// - It should be possible to log to a file without showing the console.
LogManager::GetInstance()->GetConsoleListener()->Init(showLog, 150, 120, "PPSSPP Debug Console");

if (debugLogLevel)
LogManager::GetInstance()->SetAllLogLevels(LogTypes::LDEBUG);

Expand All @@ -603,7 +610,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin

HWND hwndMain = MainWindow::GetHWND();
HWND hwndDisplay = MainWindow::GetDisplayHWND();

//initialize custom controls
CtrlDisAsmView::init();
CtrlMemView::init();
Expand Down Expand Up @@ -636,7 +643,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
{
//hack to enable/disable menu command accelerate keys
MainWindow::UpdateCommands();

//hack to make it possible to get to main window from floating windows with Esc
if (msg.hwnd != hwndMain && msg.wParam == VK_ESCAPE)
BringWindowToTop(hwndMain);
Expand Down
11 changes: 9 additions & 2 deletions android/jni/app-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,15 @@ int System_GetPropertyInt(SystemProperty prop) {
return optimalSampleRate;
case SYSPROP_AUDIO_OPTIMAL_FRAMES_PER_BUFFER:
return optimalFramesPerBuffer;
default:
return -1;
}
}

float System_GetPropertyFloat(SystemProperty prop) {
switch (prop) {
case SYSPROP_DISPLAY_REFRESH_RATE:
return (int)(display_hz * 1000.0);
return display_hz;
default:
return -1;
}
Expand Down Expand Up @@ -682,7 +689,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env,
hasSetThreadName = true;
setCurrentThreadName("AndroidRender");
}

if (useCPUThread) {
// This is the "GPU thread".
if (graphicsContext)
Expand Down
Loading

0 comments on commit 55bb58e

Please sign in to comment.