diff --git a/Core/Core.cpp b/Core/Core.cpp
index 44caf06911..55783375a8 100644
--- a/Core/Core.cpp
+++ b/Core/Core.cpp
@@ -132,8 +132,8 @@ bool Core_GetPowerSaving() {
static bool IsWindowSmall(int pixelWidth, int pixelHeight) {
// Can't take this from config as it will not be set if windows is maximized.
- int w = (int)(pixelWidth * g_dpi_scale);
- int h = (int)(pixelHeight * g_dpi_scale);
+ int w = (int)(pixelWidth * g_dpi_scale_x);
+ int h = (int)(pixelHeight * g_dpi_scale_y);
return g_Config.IsPortrait() ? (h < 480 + 80) : (w < 480 + 80);
}
@@ -141,23 +141,28 @@ static bool IsWindowSmall(int pixelWidth, int pixelHeight) {
bool UpdateScreenScale(int width, int height) {
bool smallWindow;
#ifdef _WIN32
- g_dpi = System_GetPropertyInt(SYSPROP_DISPLAY_DPI);
- g_dpi_scale = 96.0f / g_dpi;
+ g_dpi = (float)System_GetPropertyInt(SYSPROP_DISPLAY_DPI);
+ g_dpi_scale_x = 96.0f / g_dpi;
+ g_dpi_scale_y = 96.0f / g_dpi;
#else
- g_dpi = 96;
- g_dpi_scale = 1.0f;
+ g_dpi = 96.0f;
+ g_dpi_scale_x = 1.0f;
+ g_dpi_scale_y = 1.0f;
#endif
- g_dpi_scale_real = g_dpi_scale;
+ g_dpi_scale_real_x = g_dpi_scale_x;
+ g_dpi_scale_real_y = g_dpi_scale_y;
smallWindow = IsWindowSmall(width, height);
if (smallWindow) {
g_dpi /= 2.0f;
- g_dpi_scale *= 2.0f;
+ g_dpi_scale_x *= 2.0f;
+ g_dpi_scale_y *= 2.0f;
}
- pixel_in_dps = 1.0f / g_dpi_scale;
+ pixel_in_dps_x = 1.0f / g_dpi_scale_x;
+ pixel_in_dps_y = 1.0f / g_dpi_scale_y;
- int new_dp_xres = width * g_dpi_scale;
- int new_dp_yres = height * g_dpi_scale;
+ int new_dp_xres = width * g_dpi_scale_x;
+ int new_dp_yres = height * g_dpi_scale_y;
bool dp_changed = new_dp_xres != dp_xres || new_dp_yres != dp_yres;
bool px_changed = pixel_xres != width || pixel_yres != height;
diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp
index ae663fc2e9..697a86751d 100644
--- a/UI/ReportScreen.cpp
+++ b/UI/ReportScreen.cpp
@@ -248,7 +248,7 @@ void ReportScreen::CreateViews() {
screenshotFilename_ = path + ".reporting.jpg";
int shotWidth = 0, shotHeight = 0;
if (TakeGameScreenshot(screenshotFilename_.c_str(), SCREENSHOT_JPG, SCREENSHOT_DISPLAY, &shotWidth, &shotHeight, 4)) {
- float scale = 340.0f * (1.0f / g_dpi_scale) * (1.0f / shotHeight);
+ float scale = 340.0f * (1.0f / g_dpi_scale_y) * (1.0f / shotHeight);
leftColumnItems->Add(new CheckBox(&includeScreenshot_, rp->T("FeedbackIncludeScreen", "Include a screenshot")))->SetEnabledPtr(&enableReporting_);
screenshot_ = leftColumnItems->Add(new AsyncImageFileView(screenshotFilename_, IS_DEFAULT, nullptr, new LinearLayoutParams(shotWidth * scale, shotHeight * scale, Margins(12, 0))));
} else {
diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp
index cc839f29cb..7f764c03be 100644
--- a/UWP/PPSSPP_UWPMain.cpp
+++ b/UWP/PPSSPP_UWPMain.cpp
@@ -203,12 +203,14 @@ bool PPSSPP_UWPMain::Render() {
// Boost DPI a bit to look better.
g_dpi *= 96.0f / 136.0f;
}
- g_dpi_scale = 96.0f / g_dpi;
+ g_dpi_scale_x = 96.0f / g_dpi;
+ g_dpi_scale_y = 96.0f / g_dpi;
- pixel_in_dps = 1.0f / g_dpi_scale;
+ pixel_in_dps_x = 1.0f / g_dpi_scale_x;
+ pixel_in_dps_y = 1.0f / g_dpi_scale_y;
- dp_xres = pixel_xres * g_dpi_scale;
- dp_yres = pixel_yres * g_dpi_scale;
+ dp_xres = pixel_xres * g_dpi_scale_x;
+ dp_yres = pixel_yres * g_dpi_scale_y;
context->RSSetViewports(1, &viewport);
@@ -281,13 +283,15 @@ bool PPSSPP_UWPMain::OnHardwareButton(HardwareButton button) {
void PPSSPP_UWPMain::OnTouchEvent(int touchEvent, int touchId, float x, float y, double timestamp) {
// We get the coordinate in Windows' device independent pixels already. So let's undo that,
// and then apply our own "dpi".
- float dpiFactor = m_deviceResources->GetActualDpi() / 96.0f;
- dpiFactor /= pixel_in_dps;
+ float dpiFactor_x = m_deviceResources->GetActualDpi() / 96.0f;
+ float dpiFactor_y = dpiFactor_x;
+ dpiFactor_x /= pixel_in_dps_x;
+ dpiFactor_y /= pixel_in_dps_y;
TouchInput input{};
input.id = touchId;
- input.x = x * dpiFactor;
- input.y = y * dpiFactor;
+ input.x = x * dpiFactor_x;
+ input.y = y * dpiFactor_y;
input.flags = touchEvent;
input.timestamp = timestamp;
NativeTouch(input);
diff --git a/Windows/GEDebugger/CtrlDisplayListView.cpp b/Windows/GEDebugger/CtrlDisplayListView.cpp
index 85cd6f1e47..07cc0490db 100644
--- a/Windows/GEDebugger/CtrlDisplayListView.cpp
+++ b/Windows/GEDebugger/CtrlDisplayListView.cpp
@@ -45,12 +45,12 @@ CtrlDisplayListView::CtrlDisplayListView(HWND _wnd)
instructionSize = 4;
- // In small window mode, g_dpi_scal may have been adjusted.
- const float fontScale = 1.0f / g_dpi_scale_real;
+ // In small window mode, g_dpi_scale may have been adjusted.
+ const float fontScale = 1.0f / g_dpi_scale_real_y;
int fontHeight = g_Config.iFontHeight * fontScale;
int charWidth = g_Config.iFontWidth * fontScale;
- rowHeight = fontHeight +2;
+ rowHeight = fontHeight + 2;
font = CreateFont(fontHeight,charWidth,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,
L"Lucida Console");
diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp
index ad3d46d8e8..054c63bc1e 100644
--- a/Windows/MainWindow.cpp
+++ b/Windows/MainWindow.cpp
@@ -574,8 +574,8 @@ namespace MainWindow
// Hack: Take the opportunity to show the cursor.
mouseButtonDown = true;
- float x = GET_X_LPARAM(lParam) * g_dpi_scale;
- float y = GET_Y_LPARAM(lParam) * g_dpi_scale;
+ float x = GET_X_LPARAM(lParam) * g_dpi_scale_x;
+ float y = GET_Y_LPARAM(lParam) * g_dpi_scale_y;
WindowsRawInput::SetMousePos(x, y);
TouchInput touch;
@@ -615,8 +615,8 @@ namespace MainWindow
prevCursorX = cursorX;
prevCursorY = cursorY;
- float x = GET_X_LPARAM(lParam) * g_dpi_scale;
- float y = GET_Y_LPARAM(lParam) * g_dpi_scale;
+ float x = (float)cursorX * g_dpi_scale_x;
+ float y = (float)cursorY * g_dpi_scale_y;
WindowsRawInput::SetMousePos(x, y);
if (wParam & MK_LBUTTON) {
@@ -637,8 +637,8 @@ namespace MainWindow
// Hack: Take the opportunity to hide the cursor.
mouseButtonDown = false;
- float x = GET_X_LPARAM(lParam) * g_dpi_scale;
- float y = GET_Y_LPARAM(lParam) * g_dpi_scale;
+ float x = (float)GET_X_LPARAM(lParam) * g_dpi_scale_x;
+ float y = (float)GET_Y_LPARAM(lParam) * g_dpi_scale_y;
WindowsRawInput::SetMousePos(x, y);
TouchInput touch;
diff --git a/Windows/TouchInputHandler.cpp b/Windows/TouchInputHandler.cpp
index fc6b3b85ef..cab9cf085f 100644
--- a/Windows/TouchInputHandler.cpp
+++ b/Windows/TouchInputHandler.cpp
@@ -10,20 +10,13 @@
#include "base/NativeApp.h"
#include "Windows/MainWindow.h"
-TouchInputHandler::TouchInputHandler() :
- touchInfo(nullptr),
- closeTouch(nullptr),
- registerTouch(nullptr)
-{
-
+TouchInputHandler::TouchInputHandler() {
touchInfo = (getTouchInputProc) GetProcAddress(
GetModuleHandle(TEXT("User32.dll")),
"GetTouchInputInfo");
-
closeTouch = (closeTouchInputProc) GetProcAddress(
GetModuleHandle(TEXT("User32.dll")),
"CloseTouchInputHandle");
-
registerTouch = (registerTouchProc) GetProcAddress(
GetModuleHandle(TEXT("User32.dll")),
"RegisterTouchWindow");
@@ -65,8 +58,8 @@ bool TouchInputHandler::GetTouchPoint(HWND hWnd, const TOUCHINPUT &input, float
point.x = (LONG)(TOUCH_COORD_TO_PIXEL(input.x));
point.y = (LONG)(TOUCH_COORD_TO_PIXEL(input.y));
if (ScreenToClient(hWnd, &point)) {
- x = point.x * g_dpi_scale;
- y = point.y * g_dpi_scale;
+ x = point.x * g_dpi_scale_x;
+ y = point.y * g_dpi_scale_y;
return true;
}
diff --git a/Windows/TouchInputHandler.h b/Windows/TouchInputHandler.h
index 7477ae7fc6..7d2761ecb7 100644
--- a/Windows/TouchInputHandler.h
+++ b/Windows/TouchInputHandler.h
@@ -34,7 +34,7 @@ private:
void touchDown(int id, float x, float y);
void touchMove(int id, float x, float y);
- int touchIds[10];
+ int touchIds[10]{};
getTouchInputProc touchInfo;
closeTouchInputProc closeTouch;
registerTouchProc registerTouch;
diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp
index e0eb554525..de2e7ff9bf 100644
--- a/Windows/WindowsHost.cpp
+++ b/Windows/WindowsHost.cpp
@@ -211,10 +211,11 @@ void WindowsHost::PollControllers() {
doPad = false;
}
- float scaleFactor = g_dpi_scale * 0.1 * g_Config.fMouseSensitivity;
+ float scaleFactor_x = g_dpi_scale_x * 0.1 * g_Config.fMouseSensitivity;
+ float scaleFactor_y = g_dpi_scale_y * 0.1 * g_Config.fMouseSensitivity;
- float mx = std::max(-1.0f, std::min(1.0f, g_mouseDeltaX * scaleFactor));
- float my = std::max(-1.0f, std::min(1.0f, g_mouseDeltaY * scaleFactor));
+ float mx = std::max(-1.0f, std::min(1.0f, g_mouseDeltaX * scaleFactor_x));
+ float my = std::max(-1.0f, std::min(1.0f, g_mouseDeltaY * scaleFactor_y));
AxisInput axisX, axisY;
axisX.axisId = JOYSTICK_AXIS_MOUSE_REL_X;
axisX.deviceId = DEVICE_ID_MOUSE;
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
index 807bf410db..7b8664b419 100644
--- a/android/AndroidManifest.xml
+++ b/android/AndroidManifest.xml
@@ -38,10 +38,9 @@
+ android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp
index 2e5ebe068d..4e7ad514bd 100644
--- a/android/jni/app-android.cpp
+++ b/android/jni/app-android.cpp
@@ -362,7 +362,8 @@ static int deviceType;
// Should only be used for display detection during startup (for config defaults etc)
// This is the ACTUAL display size, not the hardware scaled display size.
-static int display_dpi;
+static int display_dpi_x;
+static int display_dpi_y;
static int display_xres;
static int display_yres;
static int backbuffer_format; // Android PixelFormat enum
@@ -697,44 +698,39 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * env,
NativeMessageReceived("recreateviews", "");
}
-// JavaEGL
-extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayResize(JNIEnv *, jobject clazz, jint w, jint h, jint dpi, jfloat refreshRate) {
- ILOG("NativeApp.displayResize(%i x %i, dpi=%i, refresh=%0.2f)", w, h, dpi, refreshRate);
+extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv *, jclass, jint bufw, jint bufh, jint format) {
+ ILOG("NativeApp.backbufferResize(%d x %d)", bufw, bufh);
- /*
- g_dpi = dpi;
- g_dpi_scale = 240.0f / (float)g_dpi;
- g_dpi_scale_real = g_dpi_scale;
+ // pixel_*res is the backbuffer resolution.
+ pixel_xres = bufw;
+ pixel_yres = bufh;
+ backbuffer_format = format;
- pixel_xres = w;
- pixel_yres = h;
- dp_xres = pixel_xres * g_dpi_scale;
- dp_yres = pixel_yres * g_dpi_scale;
- dp_xscale = (float)dp_xres / pixel_xres;
- dp_yscale = (float)dp_yres / pixel_yres;
- */
- // display_hz = refreshRate;
+ g_dpi = display_dpi_x;
+ g_dpi_scale_x = 240.0f / g_dpi;
+ g_dpi_scale_y = 240.0f / g_dpi;
+ g_dpi_scale_real_x = g_dpi_scale_x;
+ g_dpi_scale_real_y = g_dpi_scale_y;
- pixel_xres = w;
- pixel_yres = h;
- // backbuffer_format = format;
-
- g_dpi = (int)display_dpi;
- g_dpi_scale = 240.0f / (float)g_dpi;
- g_dpi_scale_real = g_dpi_scale;
-
- dp_xres = display_xres * g_dpi_scale;
- dp_yres = display_yres * g_dpi_scale;
+ dp_xres = display_xres * g_dpi_scale_x;
+ dp_yres = display_yres * g_dpi_scale_y;
// Touch scaling is from display pixels to dp pixels.
dp_xscale = (float)dp_xres / (float)display_xres;
dp_yscale = (float)dp_yres / (float)display_yres;
- pixel_in_dps = (float)pixel_xres / dp_xres;
+ pixel_in_dps_x = (float)pixel_xres / dp_xres;
+ pixel_in_dps_y = (float)pixel_yres / dp_yres;
+
+ ILOG("dp_xscale=%f dp_yscale=%f", dp_xscale, dp_yscale);
+ ILOG("dp_xres=%d dp_yres=%d", dp_xres, dp_yres);
+ ILOG("pixel_xres=%d pixel_yres=%d", pixel_xres, pixel_yres);
+ ILOG("g_dpi=%d g_dpi_scale_x=%f g_dpi_scale_y", g_dpi, g_dpi_scale_x, g_dpi_scale_y);
NativeResized();
}
+
// JavaEGL
extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, jobject obj) {
static bool hasSetThreadName = false;
@@ -976,39 +972,11 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setDisplayParameters(JN
ILOG("NativeApp.setDisplayParameters(%d x %d, dpi=%d, refresh=%0.2f)", xres, yres, dpi, refreshRate);
display_xres = xres;
display_yres = yres;
- display_dpi = dpi;
+ display_dpi_x = dpi;
+ display_dpi_y = dpi;
display_hz = refreshRate;
}
-extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv *, jclass, jint bufw, jint bufh, jint format) {
- ILOG("NativeApp.backbufferResize(%d x %d)", bufw, bufh);
-
- // pixel_*res is the backbuffer resolution.
- pixel_xres = bufw;
- pixel_yres = bufh;
- backbuffer_format = format;
-
- g_dpi = (int)display_dpi;
- g_dpi_scale = 240.0f / (float)g_dpi;
- g_dpi_scale_real = g_dpi_scale;
-
- dp_xres = display_xres * g_dpi_scale;
- dp_yres = display_yres * g_dpi_scale;
-
- // Touch scaling is from display pixels to dp pixels.
- dp_xscale = (float)dp_xres / (float)display_xres;
- dp_yscale = (float)dp_yres / (float)display_yres;
-
- pixel_in_dps = (float)pixel_xres / dp_xres;
-
- ILOG("dp_xscale=%f dp_yscale=%f", dp_xscale, dp_yscale);
- ILOG("dp_xres=%d dp_yres=%d", dp_xres, dp_yres);
- ILOG("pixel_xres=%d pixel_yres=%d", pixel_xres, pixel_yres);
- ILOG("g_dpi=%d g_dpi_scale=%f", g_dpi, g_dpi_scale);
-
- NativeResized();
-}
-
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_computeDesiredBackbufferDimensions() {
getDesiredBackbufferSize(desiredBackbufferSizeX, desiredBackbufferSizeY);
}
diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java
index f96d70713c..98d3c46553 100644
--- a/android/src/org/ppsspp/ppsspp/NativeActivity.java
+++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java
@@ -24,6 +24,7 @@ import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.PixelFormat;
import android.graphics.Point;
+import android.graphics.Rect;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Build;
@@ -93,14 +94,19 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
private boolean shuttingDown;
private static int RESULT_LOAD_IMAGE = 1;
- // Allow for multiple connected gamepads but just consider them the same for now.
- // Actually this is not entirely true, see the code.
- InputDeviceState inputPlayerA;
- InputDeviceState inputPlayerB;
- InputDeviceState inputPlayerC;
- String inputPlayerADesc;
+ // Allow for multiple connected gamepads but just consider them the same for now.
+ // Actually this is not entirely true, see the code.
+ InputDeviceState inputPlayerA;
+ InputDeviceState inputPlayerB;
+ InputDeviceState inputPlayerC;
+ String inputPlayerADesc;
- // Functions for the app activity to override to change behaviour.
+ float densityDpi;
+ float refreshRate;
+ int pixelWidth;
+ int pixelHeight;
+
+ // Functions for the app activity to override to change behaviour.
public native void registerCallbacks();
public native void unregisterCallbacks();
@@ -145,37 +151,6 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
return libdir;
}
- @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
- void GetScreenSizeJB(Point size, boolean real) {
- WindowManager w = getWindowManager();
- if (real) {
- w.getDefaultDisplay().getRealSize(size);
- }
- }
-
- @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
- void GetScreenSizeHC(Point size, boolean real) {
- WindowManager w = getWindowManager();
- if (real && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- GetScreenSizeJB(size, real);
- } else {
- w.getDefaultDisplay().getSize(size);
- }
- }
-
- @SuppressWarnings("deprecation")
- public void GetScreenSize(Point size) {
- boolean real = useImmersive();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
- GetScreenSizeHC(size, real);
- } else {
- WindowManager w = getWindowManager();
- Display d = w.getDefaultDisplay();
- size.x = d.getWidth();
- size.y = d.getHeight();
- }
- }
-
public static final int REQUEST_CODE_STORAGE_PERMISSION = 1337;
@TargetApi(23)
@@ -384,19 +359,6 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
// Tells the render loop thread to exit, so we can restart it.
public native void exitEGLRenderLoop();
- void updateDisplayMetrics(Point outSize) {
- DisplayMetrics metrics = new DisplayMetrics();
- Display display = getWindowManager().getDefaultDisplay();
- display.getMetrics(metrics);
-
- float refreshRate = display.getRefreshRate();
- if (outSize == null) {
- outSize = new Point();
- }
- GetScreenSize(outSize);
- NativeApp.setDisplayParameters(outSize.x, outSize.y, metrics.densityDpi, refreshRate);
- }
-
public void getDesiredBackbufferSize(Point sz) {
NativeApp.computeDesiredBackbufferDimensions();
sz.x = NativeApp.getDesiredBackbufferWidth();
@@ -410,13 +372,17 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
shuttingDown = false;
registerCallbacks();
- updateDisplayMetrics(null);
-
if (!initialized) {
Initialize();
initialized = true;
}
+ Display display = getWindowManager().getDefaultDisplay();
+ DisplayMetrics metrics = new DisplayMetrics();
+ display.getMetrics(metrics);
+ densityDpi = metrics.densityDpi;
+ refreshRate = display.getRefreshRate();
+
// OK, config should be initialized, we can query for screen rotation.
updateScreenRotation();
@@ -428,19 +394,11 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
gainAudioFocus(this.audioManager, this.audioFocusChangeListener);
NativeApp.audioInit();
- updateDisplayMetrics(null);
if (javaGL) {
mGLSurfaceView = new NativeGLView(this);
nativeRenderer = new NativeRenderer(this);
-
- Point sz = new Point();
- getDesiredBackbufferSize(sz);
- if (sz.x > 0) {
- Log.i(TAG, "Requesting fixed size buffer: " + sz.x + "x" + sz.y);
- // Auto-calculates new DPI and forwards to the correct call on mGLSurfaceView.getHolder()
- nativeRenderer.setFixedSize(sz.x, sz.y, mGLSurfaceView);
- }
- mGLSurfaceView.setEGLContextClientVersion(2);
+ mGLSurfaceView.setEGLContextClientVersion(2);
+ mGLSurfaceView.getHolder().addCallback(NativeActivity.this);
// Setup the GLSurface and ask android for the correct
// Number of bits for r, g, b, a, depth and stencil components
@@ -462,8 +420,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
mGLSurfaceView.setEGLConfigChooser(new NativeEGLConfigChooser());
}
// Tried to mess around with config choosers here but fail completely on Xperia Play.
-
- mGLSurfaceView.setRenderer(nativeRenderer);
+ mGLSurfaceView.setRenderer(nativeRenderer);
setContentView(mGLSurfaceView);
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
@@ -473,46 +430,45 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
}
}
- NativeApp.computeDesiredBackbufferDimensions();
- int bbW = NativeApp.getDesiredBackbufferWidth();
- int bbH = NativeApp.getDesiredBackbufferHeight();
-
- mSurfaceView = new NativeSurfaceView(NativeActivity.this, bbW, bbH);
+ mSurfaceView = new NativeSurfaceView(NativeActivity.this);
mSurfaceView.getHolder().addCallback(NativeActivity.this);
Log.i(TAG, "setcontentview before");
setContentView(mSurfaceView);
Log.i(TAG, "setcontentview after");
-
ensureRenderLoop();
}
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
- Log.d(TAG, "Surface created.");
+ pixelWidth = holder.getSurfaceFrame().width();
+ pixelHeight = holder.getSurfaceFrame().height();
+ Log.d(TAG, "Surface created. pixelWidth=" + pixelWidth + ", pixelHeight=" + pixelHeight);
+ NativeApp.setDisplayParameters(pixelWidth, pixelHeight, (int)densityDpi, refreshRate);
+ Point sz = new Point();
+ getDesiredBackbufferSize(sz);
+ Log.d(TAG, "Setting fixed size " + sz.x + " x " + sz.y);
+ if (mGLSurfaceView != null) {
+ mGLSurfaceView.getHolder().setFixedSize(sz.x, sz.y);
+ } else {
+ mSurfaceView.getHolder().setFixedSize(sz.x, sz.y);
+ }
}
//
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- if (javaGL) {
- Log.e(TAG, "JavaGL - should not get into surfaceChanged.");
- return;
- }
-
Log.w(TAG, "Surface changed. Resolution: " + width + "x" + height + " Format: " + format);
- // Make sure we have fresh display metrics so the computations go right.
- // This is needed on some very old devices, I guess event order is different or something...
- Point sz = new Point();
- updateDisplayMetrics(sz);
NativeApp.backbufferResize(width, height, format);
-
mSurface = holder.getSurface();
- // If we got a surface, this starts the thread. If not, it doesn't.
- if (mSurface == null) {
- joinRenderLoopThread();
- } else {
- ensureRenderLoop();
+
+ if (!javaGL) {
+ // If we got a surface, this starts the thread. If not, it doesn't.
+ if (mSurface == null) {
+ joinRenderLoopThread();
+ } else {
+ ensureRenderLoop();
+ }
}
}
@@ -676,14 +632,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
updateSystemUiVisibility();
}
- updateDisplayMetrics(null);
- if (javaGL) {
- Point sz = new Point();
- getDesiredBackbufferSize(sz);
- if (sz.x > 0) {
- mGLSurfaceView.getHolder().setFixedSize(sz.x/2, sz.y/2);
- }
- }
+ densityDpi = (float)newConfig.densityDpi;
}
//keep this static so we can call this even if we don't
diff --git a/android/src/org/ppsspp/ppsspp/NativeApp.java b/android/src/org/ppsspp/ppsspp/NativeApp.java
index 0e6f68d893..81506a9d1a 100644
--- a/android/src/org/ppsspp/ppsspp/NativeApp.java
+++ b/android/src/org/ppsspp/ppsspp/NativeApp.java
@@ -44,9 +44,6 @@ public class NativeApp {
public static native boolean mouseWheelEvent(float x, float y);
- // will only be called between init() and shutdown()
- public static native int audioRender(short[] buffer);
-
// Sensor/input data. These are asynchronous, beware!
public static native boolean touch(float x, float y, int data, int pointerId);
diff --git a/android/src/org/ppsspp/ppsspp/NativeGLView.java b/android/src/org/ppsspp/ppsspp/NativeGLView.java
index 0581ef57fe..9e430bc34a 100644
--- a/android/src/org/ppsspp/ppsspp/NativeGLView.java
+++ b/android/src/org/ppsspp/ppsspp/NativeGLView.java
@@ -18,6 +18,8 @@ import android.os.Build;
import android.os.Handler;
import android.util.Log;
import android.view.MotionEvent;
+import android.view.View;
+
import com.bda.controller.*;
public class NativeGLView extends GLSurfaceView implements SensorEventListener, ControllerListener {
diff --git a/android/src/org/ppsspp/ppsspp/NativeRenderer.java b/android/src/org/ppsspp/ppsspp/NativeRenderer.java
index 578116ff0c..87191e8089 100644
--- a/android/src/org/ppsspp/ppsspp/NativeRenderer.java
+++ b/android/src/org/ppsspp/ppsspp/NativeRenderer.java
@@ -13,77 +13,27 @@ import android.view.Display;
public class NativeRenderer implements GLSurfaceView.Renderer {
private static String TAG = "NativeRenderer";
private NativeActivity mActivity;
- private boolean isDark = false;
- private int dpi;
- private float refreshRate;
-
- private double dpi_scale_x;
- private double dpi_scale_y;
-
- int last_width, last_height;
NativeRenderer(NativeActivity act) {
mActivity = act;
- DisplayMetrics metrics = new DisplayMetrics();
- Display display = act.getWindowManager().getDefaultDisplay();
- display.getMetrics(metrics);
- dpi = metrics.densityDpi;
-
- refreshRate = display.getRefreshRate();
- }
-
- double getDpiScaleX() {
- return dpi_scale_x;
- }
- double getDpiScaleY() {
- return dpi_scale_y;
- }
-
- public void setDark(boolean d) {
- isDark = d;
- }
-
- public void setFixedSize(int xres, int yres, GLSurfaceView surfaceView) {
- Log.i(TAG, "Setting surface to fixed size " + xres + "x" + yres);
- surfaceView.getHolder().setFixedSize(xres, yres);
}
public void onDrawFrame(GL10 unused /*use GLES20*/) {
- if (isDark) {
- GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
- GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_STENCIL_BUFFER_BIT);
- } else {
- displayRender();
- }
+ displayRender();
}
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
- Log.i(TAG, "onSurfaceCreated");
+ Log.i(TAG, "NativeRenderer: onSurfaceCreated");
// Log.i(TAG, "onSurfaceCreated - EGL context is new or was lost");
// Actually, it seems that it is here we should recreate lost GL objects.
displayInit();
}
public void onSurfaceChanged(GL10 unused, int width, int height) {
- Point sz = new Point();
- mActivity.GetScreenSize(sz);
- double actualW = sz.x;
- double actualH = sz.y;
- dpi_scale_x = ((double)width / (double)actualW);
- dpi_scale_y = ((double)height / (double)actualH);
- Log.i(TAG, "onSurfaceChanged: Scale: " + dpi_scale_x + "x" + dpi_scale_y + " (width=" + width + ", actualW=" + actualW);
- int scaled_dpi = (int)((double)dpi * dpi_scale_x);
- displayResize(width, height, scaled_dpi, refreshRate);
- last_width = width;
- last_height = height;
}
- // NATIVE METHODS
-
// Note: This also means "device lost" and you should reload
// all buffered objects.
public native void displayInit();
- public native void displayResize(int w, int h, int dpi, float refreshRate);
public native void displayRender();
}
diff --git a/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java b/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java
index 9e74c5a3a7..c645907902 100644
--- a/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java
+++ b/android/src/org/ppsspp/ppsspp/NativeSurfaceView.java
@@ -30,7 +30,7 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene
private Controller mController = null;
private boolean isMogaPro = false;
- public NativeSurfaceView(NativeActivity activity, int fixedW, int fixedH) {
+ public NativeSurfaceView(NativeActivity activity) {
super(activity);
Log.i(TAG, "NativeSurfaceView");
@@ -40,14 +40,6 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene
mController = Controller.getInstance(activity);
- // Maybe we need to use this?
- if (fixedW != 0 && fixedH != 0) {
- Log.i(TAG, "Setting surface holder to use a fixed size of " + fixedW + "x" + fixedH + " pixels");
- this.getHolder().setFixedSize(fixedW, fixedH);
- } else {
- Log.i(TAG, "Using default backbuffer size.");
- }
-
// this.getHolder().setFormat(PixelFormat.RGBA_8888);
try {
diff --git a/ext/native/base/PCMain.cpp b/ext/native/base/PCMain.cpp
index 256121384e..362b5ff7e1 100644
--- a/ext/native/base/PCMain.cpp
+++ b/ext/native/base/PCMain.cpp
@@ -631,9 +631,12 @@ int main(int argc, char *argv[]) {
NativeInit(remain_argc, (const char **)remain_argv, path, "/tmp", nullptr);
#endif
- pixel_in_dps = (float)pixel_xres / dp_xres;
- g_dpi_scale = dp_xres / (float)pixel_xres;
- g_dpi_scale_real = g_dpi_scale;
+ pixel_in_dps_x = (float)pixel_xres / dp_xres;
+ pixel_in_dps_y = (float)pixel_yres / dp_yres;
+ g_dpi_scale_x = dp_xres / (float)pixel_xres;
+ g_dpi_scale_y = dp_yres / (float)pixel_yres;
+ g_dpi_scale_real_x = g_dpi_scale_x;
+ g_dpi_scale_real_y = g_dpi_scale_y;
printf("Pixels: %i x %i\n", pixel_xres, pixel_yres);
printf("Virtual pixels: %i x %i\n", dp_xres, dp_yres);
@@ -686,8 +689,8 @@ int main(int argc, char *argv[]) {
while (true) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
- float mx = event.motion.x * g_dpi_scale;
- float my = event.motion.y * g_dpi_scale;
+ float mx = event.motion.x * g_dpi_scale_x;
+ float my = event.motion.y * g_dpi_scale_y;
switch (event.type) {
case SDL_QUIT:
diff --git a/ext/native/base/QtMain.cpp b/ext/native/base/QtMain.cpp
index 586c973965..06a050291a 100644
--- a/ext/native/base/QtMain.cpp
+++ b/ext/native/base/QtMain.cpp
@@ -263,15 +263,15 @@ bool MainUI::event(QEvent *e)
break;
case Qt::TouchPointPressed:
case Qt::TouchPointReleased:
- input.x = touchPoint.pos().x() * g_dpi_scale * xscale;
- input.y = touchPoint.pos().y() * g_dpi_scale * yscale;
+ input.x = touchPoint.pos().x() * g_dpi_scale_x * xscale;
+ input.y = touchPoint.pos().y() * g_dpi_scale_y * yscale;
input.flags = (touchPoint.state() == Qt::TouchPointPressed) ? TOUCH_DOWN : TOUCH_UP;
input.id = touchPoint.id();
NativeTouch(input);
break;
case Qt::TouchPointMoved:
- input.x = touchPoint.pos().x() * g_dpi_scale * xscale;
- input.y = touchPoint.pos().y() * g_dpi_scale * yscale;
+ input.x = touchPoint.pos().x() * g_dpi_scale_x * xscale;
+ input.y = touchPoint.pos().y() * g_dpi_scale_y * yscale;
input.flags = TOUCH_MOVE;
input.id = touchPoint.id();
NativeTouch(input);
@@ -287,15 +287,15 @@ bool MainUI::event(QEvent *e)
break;
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
- input.x = ((QMouseEvent*)e)->pos().x() * g_dpi_scale * xscale;
- input.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale * yscale;
+ input.x = ((QMouseEvent*)e)->pos().x() * g_dpi_scale_x * xscale;
+ input.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale_y * yscale;
input.flags = (e->type() == QEvent::MouseButtonPress) ? TOUCH_DOWN : TOUCH_UP;
input.id = 0;
NativeTouch(input);
break;
case QEvent::MouseMove:
- input.x = ((QMouseEvent*)e)->pos().x() * g_dpi_scale * xscale;
- input.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale * yscale;
+ input.x = ((QMouseEvent*)e)->pos().x() * g_dpi_scale_x * xscale;
+ input.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale_y * yscale;
input.flags = TOUCH_MOVE;
input.id = 0;
NativeTouch(input);
@@ -437,9 +437,12 @@ int main(int argc, char *argv[])
res.transpose();
pixel_xres = res.width();
pixel_yres = res.height();
- g_dpi_scale = CalculateDPIScale();
- g_dpi_scale_real = g_dpi_scale;
- dp_xres = (int)(pixel_xres * g_dpi_scale); dp_yres = (int)(pixel_yres * g_dpi_scale);
+ g_dpi_scale_x = CalculateDPIScale();
+ g_dpi_scale_y = CalculateDPIScale();
+ g_dpi_scale_real_x = g_dpi_scale_x;
+ g_dpi_scale_real_y = g_dpi_scale_y;
+ dp_xres = (int)(pixel_xres * g_dpi_scale_x);
+ dp_yres = (int)(pixel_yres * g_dpi_scale_y);
std::string savegame_dir = ".";
std::string external_dir = ".";
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
diff --git a/ext/native/base/display.cpp b/ext/native/base/display.cpp
index a72b6bcb3c..2223753a7d 100644
--- a/ext/native/base/display.cpp
+++ b/ext/native/base/display.cpp
@@ -6,10 +6,13 @@ int dp_yres;
int pixel_xres;
int pixel_yres;
-int g_dpi = 1; // will be overwritten
-float g_dpi_scale = 1.0f;
-float g_dpi_scale_real = 1.0f;
-float pixel_in_dps = 1.0f;
+float g_dpi = 1.0f; // will be overwritten with a value that makes sense.
+float g_dpi_scale_x = 1.0f;
+float g_dpi_scale_y = 1.0f;
+float g_dpi_scale_real_x = 1.0f;
+float g_dpi_scale_real_y = 1.0f;
+float pixel_in_dps_x = 1.0f;
+float pixel_in_dps_y = 1.0f;
float display_hz = 60.0f;
DisplayRotation g_display_rotation;
diff --git a/ext/native/base/display.h b/ext/native/base/display.h
index ccb88083aa..ca01fe1997 100644
--- a/ext/native/base/display.h
+++ b/ext/native/base/display.h
@@ -10,10 +10,13 @@ extern int dp_yres;
extern int pixel_xres;
extern int pixel_yres;
-extern int g_dpi;
-extern float g_dpi_scale;
-extern float g_dpi_scale_real;
-extern float pixel_in_dps;
+extern float g_dpi;
+extern float g_dpi_scale_x;
+extern float g_dpi_scale_y;
+extern float g_dpi_scale_real_x;
+extern float g_dpi_scale_real_y;
+extern float pixel_in_dps_x;
+extern float pixel_in_dps_y;
extern float display_hz;
// On some platforms (currently only Windows UWP) we need to manually rotate
diff --git a/ext/native/gfx_es2/draw_buffer.cpp b/ext/native/gfx_es2/draw_buffer.cpp
index b45f352949..7f343ee928 100644
--- a/ext/native/gfx_es2/draw_buffer.cpp
+++ b/ext/native/gfx_es2/draw_buffer.cpp
@@ -86,14 +86,13 @@ void DrawBuffer::End() {
void DrawBuffer::Flush(bool set_blend_state) {
using namespace Draw;
- if (!pipeline_) {
- ELOG("No program set!");
- return;
- }
-
if (count_ == 0)
return;
-
+ if (!pipeline_) {
+ ELOG("DrawBuffer: No program set, skipping flush!");
+ count_ = 0;
+ return;
+ }
draw_->BindPipeline(pipeline_);
VsTexColUB ub{};
@@ -131,15 +130,15 @@ void DrawBuffer::Rect(float x, float y, float w, float h, uint32_t color, int al
}
void DrawBuffer::hLine(float x1, float y, float x2, uint32_t color) {
- Rect(x1, y, x2 - x1, pixel_in_dps, color);
+ Rect(x1, y, x2 - x1, pixel_in_dps_y, color);
}
void DrawBuffer::vLine(float x, float y1, float y2, uint32_t color) {
- Rect(x, y1, pixel_in_dps, y2 - y1, color);
+ Rect(x, y1, pixel_in_dps_x, y2 - y1, color);
}
void DrawBuffer::vLineAlpha50(float x, float y1, float y2, uint32_t color) {
- Rect(x, y1, pixel_in_dps, y2 - y1, (color | 0xFF000000) & 0x7F000000);
+ Rect(x, y1, pixel_in_dps_x, y2 - y1, (color | 0xFF000000) & 0x7F000000);
}
void DrawBuffer::RectVGradient(float x, float y, float w, float h, uint32_t colorTop, uint32_t colorBottom) {
@@ -152,11 +151,11 @@ void DrawBuffer::RectVGradient(float x, float y, float w, float h, uint32_t colo
}
void DrawBuffer::RectOutline(float x, float y, float w, float h, uint32_t color, int align) {
- hLine(x, y, x + w + pixel_in_dps, color);
- hLine(x, y + h, x + w + pixel_in_dps, color);
+ hLine(x, y, x + w + pixel_in_dps_x, color);
+ hLine(x, y + h, x + w + pixel_in_dps_x, color);
- vLine(x, y, y + h + pixel_in_dps, color);
- vLine(x + w, y, y + h + pixel_in_dps, color);
+ vLine(x, y, y + h + pixel_in_dps_y, color);
+ vLine(x + w, y, y + h + pixel_in_dps_y, color);
}
void DrawBuffer::MultiVGradient(float x, float y, float w, float h, GradientStop *stops, int numStops) {
diff --git a/ext/native/gfx_es2/draw_text.cpp b/ext/native/gfx_es2/draw_text.cpp
index 3666a765b7..b71c1ddc4c 100644
--- a/ext/native/gfx_es2/draw_text.cpp
+++ b/ext/native/gfx_es2/draw_text.cpp
@@ -34,7 +34,7 @@ void TextDrawer::SetFontScale(float xscale, float yscale) {
}
float TextDrawer::CalculateDPIScale() {
- float scale = g_dpi_scale;
+ float scale = g_dpi_scale_y;
if (scale >= 1.0f) {
scale = 1.0f;
}
diff --git a/ext/native/thin3d/thin3d_gl.cpp b/ext/native/thin3d/thin3d_gl.cpp
index 7aeba44140..96579f8ff7 100644
--- a/ext/native/thin3d/thin3d_gl.cpp
+++ b/ext/native/thin3d/thin3d_gl.cpp
@@ -273,12 +273,13 @@ GLuint ShaderStageToOpenGL(ShaderStage stage) {
class OpenGLShaderModule : public ShaderModule, public GfxResourceHolder {
public:
OpenGLShaderModule(ShaderStage stage) : stage_(stage) {
+ ILOG("Shader module created (%p)", this);
register_gl_resource_holder(this, "drawcontext_shader_module", 0);
glstage_ = ShaderStageToOpenGL(stage);
}
~OpenGLShaderModule() {
- ILOG("Shader module destroyed");
+ ILOG("Shader module destroyed (%p)", this);
if (shader_)
glDeleteShader(shader_);
unregister_gl_resource_holder(this);
diff --git a/ext/native/ui/ui_context.cpp b/ext/native/ui/ui_context.cpp
index 4c9f5fd19b..fc36b16e9e 100644
--- a/ext/native/ui/ui_context.cpp
+++ b/ext/native/ui/ui_context.cpp
@@ -90,12 +90,13 @@ Bounds UIContext::GetScissorBounds() {
void UIContext::ActivateTopScissor() {
Bounds bounds;
if (scissorStack_.size()) {
- float scale = pixel_in_dps;
+ float scale_x = pixel_in_dps_x;
+ float scale_y = pixel_in_dps_y;
bounds = scissorStack_.back();
- int x = floorf(scale * bounds.x);
- int y = floorf(scale * bounds.y);
- int w = ceilf(scale * bounds.w);
- int h = ceilf(scale * bounds.h);
+ int x = floorf(scale_x * bounds.x);
+ int y = floorf(scale_y * bounds.y);
+ int w = ceilf(scale_x * bounds.w);
+ int h = ceilf(scale_y * bounds.h);
draw_->SetScissorRect(x, y, w, h);
} else {
// Avoid rounding errors
diff --git a/ios/ViewController.mm b/ios/ViewController.mm
index 21087936ff..2832d10cc1 100644
--- a/ios/ViewController.mm
+++ b/ios/ViewController.mm
@@ -174,16 +174,19 @@ static GraphicsContext *graphicsContext;
size.width = h;
}
- g_dpi = (IS_IPAD() ? 200 : 150) * scale;
- g_dpi_scale = 240.0f / (float)g_dpi;
- g_dpi_scale_real = g_dpi_scale;
+ g_dpi = (IS_IPAD() ? 200.0f : 150.0f) * scale;
+ g_dpi_scale_x = 240.0f / g_dpi;
+ g_dpi_scale_y = 240.0f / g_dpi;
+ g_dpi_scale_real_x = g_dpi_scale_x;
+ g_dpi_scale_real_y = g_dpi_scale_y;
pixel_xres = size.width * scale;
pixel_yres = size.height * scale;
- dp_xres = pixel_xres * g_dpi_scale;
- dp_yres = pixel_yres * g_dpi_scale;
+ dp_xres = pixel_xres * g_dpi_scale_x;
+ dp_yres = pixel_yres * g_dpi_scale_y;
- pixel_in_dps = (float)pixel_xres / (float)dp_xres;
+ pixel_in_dps_x = (float)pixel_xres / (float)dp_xres;
+ pixel_in_dps_y = (float)pixel_yres / (float)dp_yres;
graphicsContext = new IOSDummyGraphicsContext();