Wrap the display globals in a struct (#16998)

* Wrap the display globals in a struct

Makes it easier to search/replace these, for future refactorings.

* Some renaming

* Qt buildfix, also fix the Qt build on Mac (got broken with battery changes)

* Attempt at buildfixing ios

* UWP buildfix
This commit is contained in:
Henrik Rydgård
2023-02-25 13:09:44 +01:00
committed by GitHub
parent 3e98d313a8
commit 8b431b39ba
48 changed files with 319 additions and 313 deletions
+9 -1
View File
@@ -1188,7 +1188,15 @@ elseif(USING_QT_UI)
if(USING_GLES2)
add_definitions(-DQT_OPENGL_ES -DQT_OPENGL_ES_2)
endif()
if(APPLE)
list(APPEND NativeAppSource
UI/DarwinFileSystemServices.mm
UI/DarwinFileSystemServices.h
Common/Battery/AppleBatteryClient.m)
set_source_files_properties(Common/Battery/AppleBatteryClient.m PROPERTIES COMPILE_FLAGS -fobjc-arc)
set_source_files_properties(UI/DarwinFileSystemServices.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
set(nativeExtraLibs ${nativeExtraLibs} ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${IOKIT_LIBRARY})
endif()
include_directories(Qt)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(nativeExtraLibs ${nativeExtraLibs} Qt5::OpenGL Qt5::Gui Qt5::Core Qt5::Multimedia)
+9 -9
View File
@@ -1288,8 +1288,8 @@ bool VulkanContext::InitSwapchain() {
VkSurfaceTransformFlagBitsKHR preTransform;
std::string supportedTransforms = surface_transforms_to_string(surfCapabilities_.supportedTransforms);
std::string currentTransform = surface_transforms_to_string(surfCapabilities_.currentTransform);
g_display_rotation = DisplayRotation::ROTATE_0;
g_display_rot_matrix.setIdentity();
g_display.rotation = DisplayRotation::ROTATE_0;
g_display.rot_matrix.setIdentity();
uint32_t allowedRotations = VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR | VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR | VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR;
// Hack: Don't allow 270 degrees pretransform (inverse landscape), it creates bizarre issues on some devices (see #15773).
@@ -1300,20 +1300,20 @@ bool VulkanContext::InitSwapchain() {
} else if (surfCapabilities_.currentTransform & allowedRotations) {
// Normal, sensible rotations. Let's handle it.
preTransform = surfCapabilities_.currentTransform;
g_display_rot_matrix.setIdentity();
g_display.rot_matrix.setIdentity();
switch (surfCapabilities_.currentTransform) {
case VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR:
g_display_rotation = DisplayRotation::ROTATE_90;
g_display_rot_matrix.setRotationZ90();
g_display.rotation = DisplayRotation::ROTATE_90;
g_display.rot_matrix.setRotationZ90();
std::swap(swapChainExtent_.width, swapChainExtent_.height);
break;
case VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR:
g_display_rotation = DisplayRotation::ROTATE_180;
g_display_rot_matrix.setRotationZ180();
g_display.rotation = DisplayRotation::ROTATE_180;
g_display.rot_matrix.setRotationZ180();
break;
case VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR:
g_display_rotation = DisplayRotation::ROTATE_270;
g_display_rot_matrix.setRotationZ270();
g_display.rotation = DisplayRotation::ROTATE_270;
g_display.rot_matrix.setRotationZ270();
std::swap(swapChainExtent_.width, swapChainExtent_.height);
break;
default:
+2 -1
View File
@@ -884,7 +884,8 @@ void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRR
} else {
curWidthRaw_ = vulkan_->GetBackbufferWidth();
curHeightRaw_ = vulkan_->GetBackbufferHeight();
if (g_display_rotation == DisplayRotation::ROTATE_90 || g_display_rotation == DisplayRotation::ROTATE_270) {
if (g_display.rotation == DisplayRotation::ROTATE_90 ||
g_display.rotation == DisplayRotation::ROTATE_270) {
curWidth_ = curHeightRaw_;
curHeight_ = curWidthRaw_;
} else {
+8 -8
View File
@@ -111,14 +111,14 @@ 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) {
// Round Y to the closest full pixel, since we're making it 1-pixel-thin.
y -= fmodf(y, pixel_in_dps_y);
Rect(x1, y, x2 - x1, pixel_in_dps_y, color);
y -= fmodf(y, g_display.pixel_in_dps_y);
Rect(x1, y, x2 - x1, g_display.pixel_in_dps_y, color);
}
void DrawBuffer::vLine(float x, float y1, float y2, uint32_t color) {
// Round X to the closest full pixel, since we're making it 1-pixel-thin.
x -= fmodf(x, pixel_in_dps_x);
Rect(x, y1, pixel_in_dps_x, y2 - y1, color);
x -= fmodf(x, g_display.pixel_in_dps_x);
Rect(x, y1, g_display.pixel_in_dps_x, y2 - y1, color);
}
void DrawBuffer::RectVGradient(float x, float y, float w, float h, uint32_t colorTop, uint32_t colorBottom) {
@@ -131,11 +131,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_x, color);
hLine(x, y + h, x + w + pixel_in_dps_x, color);
hLine(x, y, x + w + g_display.pixel_in_dps_x, color);
hLine(x, y + h, x + w + g_display.pixel_in_dps_x, color);
vLine(x, y, y + h + pixel_in_dps_y, color);
vLine(x + w, y, y + h + pixel_in_dps_y, color);
vLine(x, y, y + h + g_display.pixel_in_dps_y, color);
vLine(x + w, y, y + h + g_display.pixel_in_dps_y, color);
}
void DrawBuffer::MultiVGradient(float x, float y, float w, float h, const GradientStop *stops, int numStops) {
+1 -1
View File
@@ -38,7 +38,7 @@ void TextDrawer::SetFontScale(float xscale, float yscale) {
float TextDrawer::CalculateDPIScale() {
if (ignoreGlobalDpi_)
return dpiScale_;
float scale = g_dpi_scale_y;
float scale = g_display.dpi_scale_y;
if (scale >= 1.0f) {
scale = 1.0f;
}
+2 -18
View File
@@ -1,27 +1,11 @@
#include "Common/System/Display.h"
#include "Common/Math/math_util.h"
int dp_xres;
int dp_yres;
int pixel_xres;
int pixel_yres;
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;
Lin::Matrix4x4 g_display_rot_matrix = Lin::Matrix4x4::identity();
DisplayProperties g_display;
template<class T>
void RotateRectToDisplayImpl(DisplayRect<T> &rect, T curRTWidth, T curRTHeight) {
switch (g_display_rotation) {
switch (g_display.rotation) {
case DisplayRotation::ROTATE_180:
rect.x = curRTWidth - rect.w - rect.x;
rect.y = curRTHeight - rect.h - rect.y;
+25 -16
View File
@@ -5,20 +5,6 @@
// This is meant to be a framework for handling DPI scaling etc.
// For now, it just consists of these ugly globals.
extern int dp_xres;
extern int dp_yres;
extern int pixel_xres;
extern int pixel_yres;
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
// our rendered output to match the display. Use these to do so.
enum class DisplayRotation {
@@ -28,8 +14,31 @@ enum class DisplayRotation {
ROTATE_270,
};
extern DisplayRotation g_display_rotation;
extern Lin::Matrix4x4 g_display_rot_matrix;
struct DisplayProperties {
int dp_xres;
int dp_yres;
int pixel_xres;
int pixel_yres;
float dpi = 1.0f; // will be overwritten with a value that makes sense.
float dpi_scale_x = 1.0f;
float dpi_scale_y = 1.0f;
// pixel_xres/yres in dps
float pixel_in_dps_x = 1.0f;
float pixel_in_dps_y = 1.0f;
// If DPI is overridden (like in small window mode), these are still the original DPI.
float dpi_scale_real_x = 1.0f;
float dpi_scale_real_y = 1.0f;
float display_hz = 60.0f;
DisplayRotation rotation;
Lin::Matrix4x4 rot_matrix;
};
extern DisplayProperties g_display;
template<class T>
struct DisplayRect {
+12 -12
View File
@@ -15,7 +15,7 @@
UIContext::UIContext() {
fontStyle_ = new UI::FontStyle();
bounds_ = Bounds(0, 0, dp_xres, dp_yres);
bounds_ = Bounds(0, 0, g_display.dp_xres, g_display.dp_yres);
}
UIContext::~UIContext() {
@@ -163,22 +163,22 @@ Bounds UIContext::GetLayoutBounds() const {
void UIContext::ActivateTopScissor() {
Bounds bounds;
if (scissorStack_.size()) {
float scale_x = pixel_in_dps_x;
float scale_y = pixel_in_dps_y;
float scale_x = g_display.pixel_in_dps_x;
float scale_y = g_display.pixel_in_dps_y;
bounds = scissorStack_.back();
int x = floorf(scale_x * bounds.x);
int y = floorf(scale_y * bounds.y);
int w = std::max(0.0f, ceilf(scale_x * bounds.w));
int h = std::max(0.0f, ceilf(scale_y * bounds.h));
if (x < 0 || y < 0 || x + w > pixel_xres || y + h > pixel_yres) {
if (x < 0 || y < 0 || x + w > g_display.pixel_xres || y + h > g_display.pixel_yres) {
// This won't actually report outside a game, but we can try.
DEBUG_LOG(G3D, "UI scissor out of bounds in %sScreen: %d,%d-%d,%d / %d,%d", screenTag_ ? screenTag_ : "N/A", x, y, w, h, pixel_xres, pixel_yres);
DEBUG_LOG(G3D, "UI scissor out of bounds in %sScreen: %d,%d-%d,%d / %d,%d", screenTag_ ? screenTag_ : "N/A", x, y, w, h, g_display.pixel_xres, g_display.pixel_yres);
if (x < 0) { w += x; x = 0; }
if (y < 0) { h += y; y = 0; }
if (x >= pixel_xres) { x = pixel_xres - 1; }
if (y >= pixel_yres) { y = pixel_yres - 1; }
if (x + w > pixel_xres) { w = std::min(w, pixel_xres - x); }
if (y + w > pixel_yres) { h = std::min(h, pixel_yres - y); }
if (x >= g_display.pixel_xres) { x = g_display.pixel_xres - 1; }
if (y >= g_display.pixel_yres) { y = g_display.pixel_yres - 1; }
if (x + w > g_display.pixel_xres) { w = std::min(w, g_display.pixel_xres - x); }
if (y + w > g_display.pixel_yres) { h = std::min(h, g_display.pixel_yres - y); }
if (w == 0) w = 1;
if (h == 0) h = 1;
draw_->SetScissorRect(x, y, w, h);
@@ -190,7 +190,7 @@ void UIContext::ActivateTopScissor() {
}
} else {
// Avoid rounding errors
draw_->SetScissorRect(0, 0, pixel_xres, pixel_yres);
draw_->SetScissorRect(0, 0, g_display.pixel_xres, g_display.pixel_yres);
}
}
@@ -351,8 +351,8 @@ Bounds UIContext::TransformBounds(const Bounds &bounds) {
Bounds translated = bounds.Offset(t.translate.x, t.translate.y);
// Scale around the center as the origin.
float scaledX = (translated.x - dp_xres * 0.5f) * t.scale.x + dp_xres * 0.5f;
float scaledY = (translated.y - dp_yres * 0.5f) * t.scale.y + dp_yres * 0.5f;
float scaledX = (translated.x - g_display.dp_xres * 0.5f) * t.scale.x + g_display.dp_xres * 0.5f;
float scaledY = (translated.y - g_display.dp_yres * 0.5f) * t.scale.y + g_display.dp_yres * 0.5f;
return Bounds(scaledX, scaledY, translated.w * t.scale.x, translated.h * t.scale.y);
}
+1 -1
View File
@@ -138,7 +138,7 @@ void ScreenManager::deviceRestored() {
}
void ScreenManager::resized() {
INFO_LOG(SYSTEM, "ScreenManager::resized(dp: %dx%d)", dp_xres, dp_yres);
INFO_LOG(SYSTEM, "ScreenManager::resized(dp: %dx%d)", g_display.dp_xres, g_display.dp_yres);
std::lock_guard<std::recursive_mutex> guard(inputLock_);
// Have to notify the whole stack, otherwise there will be problems when going back
// to non-top screens.
+10 -10
View File
@@ -24,7 +24,7 @@ UIScreen::~UIScreen() {
}
bool UIScreen::UseVerticalLayout() const {
return dp_yres > dp_xres * 1.1f;
return g_display.dp_yres > g_display.dp_xres * 1.1f;
}
void UIScreen::DoRecreateViews() {
@@ -98,12 +98,12 @@ void UIScreen::preRender() {
Draw::Viewport viewport;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = pixel_xres;
viewport.Height = pixel_yres;
viewport.Width = g_display.pixel_xres;
viewport.Height = g_display.pixel_yres;
viewport.MaxDepth = 1.0;
viewport.MinDepth = 0.0;
draw->SetViewport(viewport);
draw->SetTargetSize(pixel_xres, pixel_yres);
draw->SetTargetSize(g_display.pixel_xres, g_display.pixel_yres);
}
void UIScreen::postRender() {
@@ -141,8 +141,8 @@ TouchInput UIScreen::transformTouch(const TouchInput &touch) {
float x = touch.x - translation_.x;
float y = touch.y - translation_.y;
// Scale around the center as the origin.
updated.x = (x - dp_xres * 0.5f) / scale_.x + dp_xres * 0.5f;
updated.y = (y - dp_yres * 0.5f) / scale_.y + dp_yres * 0.5f;
updated.x = (x - g_display.dp_xres * 0.5f) / scale_.x + g_display.dp_xres * 0.5f;
updated.y = (y - g_display.dp_yres * 0.5f) / scale_.y + g_display.dp_yres * 0.5f;
return updated;
}
@@ -280,14 +280,14 @@ void PopupScreen::update() {
scale_.y = 0.9f + animatePos * 0.1f;
if (hasPopupOrigin_) {
float xoff = popupOrigin_.x - dp_xres / 2;
float yoff = popupOrigin_.y - dp_yres / 2;
float xoff = popupOrigin_.x - g_display.dp_xres / 2;
float yoff = popupOrigin_.y - g_display.dp_yres / 2;
// Pull toward the origin a bit.
translation_.x = xoff * (1.0f - animatePos) * 0.2f;
translation_.y = yoff * (1.0f - animatePos) * 0.2f;
} else {
translation_.y = -dp_yres * (1.0f - animatePos) * 0.2f;
translation_.y = -g_display.dp_yres * (1.0f - animatePos) * 0.2f;
}
} else {
alpha_ = 1.0f;
@@ -333,7 +333,7 @@ void PopupScreen::CreateViews() {
box_->SetBG(dc.theme->popupStyle.background);
box_->SetHasDropShadow(hasDropShadow_);
// Since we scale a bit, make the dropshadow bleed past the edges.
box_->SetDropShadowExpand(std::max(dp_xres, dp_yres));
box_->SetDropShadowExpand(std::max(g_display.dp_xres, g_display.dp_yres));
box_->SetSpacing(0.0f);
View *title = new PopupHeader(title_);
+26 -26
View File
@@ -154,8 +154,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_x);
int h = (int)(pixelHeight * g_dpi_scale_y);
int w = (int)(pixelWidth * g_display.dpi_scale_x);
int h = (int)(pixelHeight * g_display.dpi_scale_y);
return g_Config.IsPortrait() ? (h < 480 + 80) : (w < 480 + 80);
}
@@ -163,42 +163,42 @@ static bool IsWindowSmall(int pixelWidth, int pixelHeight) {
bool UpdateScreenScale(int width, int height) {
bool smallWindow;
#if defined(USING_QT_UI)
g_dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_DPI);
g_display.dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_DPI);
float g_logical_dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_LOGICAL_DPI);
g_dpi_scale_x = g_logical_dpi / g_dpi;
g_dpi_scale_y = g_logical_dpi / g_dpi;
g_display.dpi_scale_x = g_logical_dpi / g_display.dpi;
g_display.dpi_scale_y = g_logical_dpi / g_display.dpi;
#elif PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP)
g_dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_DPI);
g_dpi_scale_x = 96.0f / g_dpi;
g_dpi_scale_y = 96.0f / g_dpi;
g_display.dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_DPI);
g_display.dpi_scale_x = 96.0f / g_display.dpi;
g_display.dpi_scale_y = 96.0f / g_display.dpi;
#else
g_dpi = 96.0f;
g_dpi_scale_x = 1.0f;
g_dpi_scale_y = 1.0f;
g_display.dpi = 96.0f;
g_display.dpi_scale_x = 1.0f;
g_display.dpi_scale_y = 1.0f;
#endif
g_dpi_scale_real_x = g_dpi_scale_x;
g_dpi_scale_real_y = g_dpi_scale_y;
g_display.dpi_scale_real_x = g_display.dpi_scale_x;
g_display.dpi_scale_real_y = g_display.dpi_scale_y;
smallWindow = IsWindowSmall(width, height);
if (smallWindow) {
g_dpi /= 2.0f;
g_dpi_scale_x *= 2.0f;
g_dpi_scale_y *= 2.0f;
g_display.dpi /= 2.0f;
g_display.dpi_scale_x *= 2.0f;
g_display.dpi_scale_y *= 2.0f;
}
pixel_in_dps_x = 1.0f / g_dpi_scale_x;
pixel_in_dps_y = 1.0f / g_dpi_scale_y;
g_display.pixel_in_dps_x = 1.0f / g_display.dpi_scale_x;
g_display.pixel_in_dps_y = 1.0f / g_display.dpi_scale_y;
int new_dp_xres = (int)(width * g_dpi_scale_x);
int new_dp_yres = (int)(height * g_dpi_scale_y);
int new_dp_xres = (int)(width * g_display.dpi_scale_x);
int new_dp_yres = (int)(height * g_display.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;
bool dp_changed = new_dp_xres != g_display.dp_xres || new_dp_yres != g_display.dp_yres;
bool px_changed = g_display.pixel_xres != width || g_display.pixel_yres != height;
if (dp_changed || px_changed) {
dp_xres = new_dp_xres;
dp_yres = new_dp_yres;
pixel_xres = width;
pixel_yres = height;
g_display.dp_xres = new_dp_xres;
g_display.dp_yres = new_dp_yres;
g_display.pixel_xres = width;
g_display.pixel_yres = height;
NativeResized();
return true;
}
+2 -2
View File
@@ -2055,7 +2055,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
// I have a planned further refactoring.
float ar;
if (g_Config.bDisplayStretch) {
ar = (float)dp_xres / (float)dp_yres;
ar = (float)g_display.dp_xres / (float)g_display.dp_yres;
} else {
ar = g_Config.fDisplayAspectRatio * (480.0f / 272.0f);
}
@@ -2066,7 +2066,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
if (Memory::IsValidAddress(outPtr)) {
// TODO: Maybe do something more sophisticated taking the longest side and screen rotation
// into account, etc.
float scale = float(dp_xres) * g_Config.fDisplayScale / 480.0f;
float scale = (float)g_display.dp_xres * g_Config.fDisplayScale / 480.0f;
Memory::Write_Float(scale, outPtr);
}
return 0;
+2 -2
View File
@@ -344,11 +344,11 @@ bool TakeGameScreenshot(const Path &filename, ScreenshotFormat fmt, ScreenshotTy
// Only crop to the top left when using a render screenshot.
w = maxRes > 0 ? 480 * maxRes : PSP_CoreParameter().renderWidth;
h = maxRes > 0 ? 272 * maxRes : PSP_CoreParameter().renderHeight;
} else if (g_display_rotation != DisplayRotation::ROTATE_0) {
} else if (g_display.rotation != DisplayRotation::ROTATE_0) {
GPUDebugBuffer temp;
success = gpuDebug->GetOutputFramebuffer(temp);
if (success) {
buf = ApplyRotation(temp, g_display_rotation);
buf = ApplyRotation(temp, g_display.rotation);
}
} else {
success = gpuDebug->GetOutputFramebuffer(buf);
+4 -4
View File
@@ -1205,8 +1205,8 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int
// TODO: Replace with draw2D_.Blit() directly.
DrawActiveTexture(dstX, dstY, width, height,
vfb ? vfb->bufferWidth : pixel_xres,
vfb ? vfb->bufferHeight : pixel_yres,
vfb ? vfb->bufferWidth : g_display.pixel_xres,
vfb ? vfb->bufferHeight : g_display.pixel_yres,
u0, v0, u1, v1, ROTATION_LOCKED_HORIZONTAL, flags);
gpuStats.numUploads++;
@@ -3081,11 +3081,11 @@ void FramebufferManagerCommon::DrawActiveTexture(float x, float y, float w, floa
coord[i].y = coord[i].y * invDestH - 1.0f;
}
if ((flags & DRAWTEX_TO_BACKBUFFER) && g_display_rotation != DisplayRotation::ROTATE_0) {
if ((flags & DRAWTEX_TO_BACKBUFFER) && g_display.rotation != DisplayRotation::ROTATE_0) {
for (int i = 0; i < 4; i++) {
// backwards notation, should fix that...
Lin::Vec3 pos = Lin::Vec3(coord[i].x, coord[i].y, 0.0);
pos = pos * g_display_rot_matrix;
pos = pos * g_display.rot_matrix;
coord[i].x = pos.x;
coord[i].y = pos.y;
}
+9 -9
View File
@@ -55,10 +55,10 @@ FRect GetScreenFrame(float pixelWidth, float pixelHeight) {
if (applyInset) {
// Remove the DPI scale to get back to pixels.
float left = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT) / g_dpi_scale_x;
float right = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_RIGHT) / g_dpi_scale_x;
float top = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_TOP) / g_dpi_scale_y;
float bottom = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_BOTTOM) / g_dpi_scale_y;
float left = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT) / g_display.dpi_scale_x;
float right = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_RIGHT) / g_display.dpi_scale_x;
float top = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_TOP) / g_display.dpi_scale_y;
float bottom = System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_BOTTOM) / g_display.dpi_scale_y;
// Adjust left edge to compensate for cutouts (notches) if any.
rc.x += left;
@@ -100,8 +100,8 @@ void CenterDisplayOutputRect(FRect *rc, float origW, float origH, const FRect &f
if (stretch) {
// Automatically set aspect ratio to match the display, IF the rotation matches the output display ratio! Otherwise, just
// sets standard aspect ratio because actually stretching will just look silly.
bool globalRotated = g_display_rotation == DisplayRotation::ROTATE_90 || g_display_rotation == DisplayRotation::ROTATE_270;
if (rotated == dp_yres > dp_xres) {
bool globalRotated = g_display.rotation == DisplayRotation::ROTATE_90 || g_display.rotation == DisplayRotation::ROTATE_270;
if (rotated == g_display.dp_yres > g_display.dp_xres) {
origRatio = frameRatio;
} else {
origRatio *= aspectRatioAdjust;
@@ -699,11 +699,11 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
if (isFinalAtOutputResolution || useStereo) {
// In this mode, we ignore the g_display_rot_matrix. Apply manually.
if (g_display_rotation != DisplayRotation::ROTATE_0) {
if (g_display.rotation != DisplayRotation::ROTATE_0) {
for (int i = 0; i < 4; i++) {
Lin::Vec3 v(verts[i].x, verts[i].y, verts[i].z);
// Backwards notation, should fix that...
v = v * g_display_rot_matrix;
v = v * g_display.rot_matrix;
verts[i].x = v.x;
verts[i].y = v.y;
}
@@ -840,7 +840,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u
draw_->UpdateDynamicUniformBuffer(&uniforms, sizeof(uniforms));
} else {
Draw::VsTexColUB ub{};
memcpy(ub.WorldViewProj, g_display_rot_matrix.m, sizeof(float) * 16);
memcpy(ub.WorldViewProj, g_display.rot_matrix.m, sizeof(float) * 16);
draw_->UpdateDynamicUniformBuffer(&ub, sizeof(ub));
}
+5 -5
View File
@@ -135,12 +135,12 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
ConvertProjMatrixToVulkan(flippedMatrix);
}
if (!useBufferedRendering && g_display_rotation != DisplayRotation::ROTATE_0) {
flippedMatrix = flippedMatrix * g_display_rot_matrix;
if (!useBufferedRendering && g_display.rotation != DisplayRotation::ROTATE_0) {
flippedMatrix = flippedMatrix * g_display.rot_matrix;
}
CopyMatrix4x4(ub->proj, flippedMatrix.getReadPtr());
ub->rotation = useBufferedRendering ? 0 : (float)g_display_rotation;
ub->rotation = useBufferedRendering ? 0 : (float)g_display.rotation;
}
if (dirtyUniforms & DIRTY_PROJTHROUGHMATRIX) {
@@ -150,8 +150,8 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
} else {
proj_through.setOrthoVulkan(0.0f, gstate_c.curRTWidth, 0, gstate_c.curRTHeight, 0, 1);
}
if (!useBufferedRendering && g_display_rotation != DisplayRotation::ROTATE_0) {
proj_through = proj_through * g_display_rot_matrix;
if (!useBufferedRendering && g_display.rotation != DisplayRotation::ROTATE_0) {
proj_through = proj_through * g_display.rot_matrix;
}
// Negative RT offsets come from split framebuffers (Killzone)
+1 -1
View File
@@ -443,7 +443,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin
ScaleProjMatrix(flippedMatrix, useBufferedRendering);
render_->SetUniformM4x4(&u_proj, flippedMatrix.m);
render_->SetUniformF1(&u_rotation, useBufferedRendering ? 0 : (float)g_display_rotation);
render_->SetUniformF1(&u_rotation, useBufferedRendering ? 0 : (float)g_display.rotation);
}
if (dirty & DIRTY_PROJTHROUGHMATRIX) {
Matrix4x4 proj_through;
+18 -18
View File
@@ -423,8 +423,8 @@ void MainUI::resizeGL(int w, int h) {
xscale = w / this->width();
yscale = h / this->height();
PSP_CoreParameter().pixelWidth = pixel_xres;
PSP_CoreParameter().pixelHeight = pixel_yres;
PSP_CoreParameter().pixelWidth = g_display.pixel_xres;
PSP_CoreParameter().pixelHeight = g_display.pixel_yres;
}
void MainUI::timerEvent(QTimerEvent *) {
@@ -453,15 +453,15 @@ bool MainUI::event(QEvent *e) {
break;
case Qt::TouchPointPressed:
case Qt::TouchPointReleased:
input.x = touchPoint.pos().x() * g_dpi_scale_x * xscale;
input.y = touchPoint.pos().y() * g_dpi_scale_y * yscale;
input.x = touchPoint.pos().x() * g_display.dpi_scale_x * xscale;
input.y = touchPoint.pos().y() * g_display.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_x * xscale;
input.y = touchPoint.pos().y() * g_dpi_scale_y * yscale;
input.x = touchPoint.pos().x() * g_display.dpi_scale_x * xscale;
input.y = touchPoint.pos().y() * g_display.dpi_scale_y * yscale;
input.flags = TOUCH_MOVE;
input.id = touchPoint.id();
NativeTouch(input);
@@ -479,8 +479,8 @@ bool MainUI::event(QEvent *e) {
case QEvent::MouseButtonRelease:
switch(((QMouseEvent*)e)->button()) {
case Qt::LeftButton:
input.x = ((QMouseEvent*)e)->pos().x() * g_dpi_scale_x * xscale;
input.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale_y * yscale;
input.x = ((QMouseEvent*)e)->pos().x() * g_display.dpi_scale_x * xscale;
input.y = ((QMouseEvent*)e)->pos().y() * g_display.dpi_scale_y * yscale;
input.flags = (e->type() == QEvent::MouseButtonPress) ? TOUCH_DOWN : TOUCH_UP;
input.id = 0;
NativeTouch(input);
@@ -502,8 +502,8 @@ bool MainUI::event(QEvent *e) {
}
break;
case QEvent::MouseMove:
input.x = ((QMouseEvent*)e)->pos().x() * g_dpi_scale_x * xscale;
input.y = ((QMouseEvent*)e)->pos().y() * g_dpi_scale_y * yscale;
input.x = ((QMouseEvent*)e)->pos().x() * g_display.dpi_scale_x * xscale;
input.y = ((QMouseEvent*)e)->pos().y() * g_display.dpi_scale_y * yscale;
input.flags = TOUCH_MOVE;
input.id = 0;
NativeTouch(input);
@@ -738,15 +738,15 @@ int main(int argc, char *argv[])
if (res.width() < res.height())
res.transpose();
pixel_xres = res.width();
pixel_yres = res.height();
g_display.pixel_xres = res.width();
g_display.pixel_yres = res.height();
g_dpi_scale_x = screen->logicalDotsPerInchX() / screen->physicalDotsPerInchX();
g_dpi_scale_y = screen->logicalDotsPerInchY() / screen->physicalDotsPerInchY();
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);
g_display.dpi_scale_x = screen->logicalDotsPerInchX() / screen->physicalDotsPerInchX();
g_display.dpi_scale_y = screen->logicalDotsPerInchY() / screen->physicalDotsPerInchY();
g_display.dpi_scale_real_x = g_display.dpi_scale_x;
g_display.dpi_scale_real_y = g_display.dpi_scale_y;
g_display.dp_xres = (int)(g_display.pixel_xres * g_display.dpi_scale_x);
g_display.dp_yres = (int)(g_display.pixel_yres * g_display.dpi_scale_y);
refreshRate = screen->refreshRate();
+2 -2
View File
@@ -375,7 +375,7 @@ void MainWindow::SetFullScreen(bool fullscreen) {
#endif
showFullScreen();
InitPadLayout(dp_xres, dp_yres);
InitPadLayout(g_display.dp_xres, g_display.dp_yres);
if (GetUIState() == UISTATE_INGAME && !g_Config.bShowTouchControls)
QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
@@ -387,7 +387,7 @@ void MainWindow::SetFullScreen(bool fullscreen) {
showNormal();
SetWindowScale(-1);
InitPadLayout(dp_xres, dp_yres);
InitPadLayout(g_display.dp_xres, g_display.dp_yres);
if (GetUIState() == UISTATE_INGAME && QApplication::overrideCursor())
QApplication::restoreOverrideCursor();
+2 -2
View File
@@ -333,7 +333,7 @@ int SDLGLGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, std:
SetGLCoreContext(true);
#endif
window = SDL_CreateWindow("PPSSPP", x, y, pixel_xres, pixel_yres, mode);
window = SDL_CreateWindow("PPSSPP", x, y, g_display.pixel_xres, g_display.pixel_yres, mode);
if (!window) {
// Definitely don't shutdown here: we'll keep trying more GL versions.
fprintf(stderr, "SDL_CreateWindow failed for GL %d.%d: %s\n", ver.major, ver.minor, SDL_GetError());
@@ -358,7 +358,7 @@ int SDLGLGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, std:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SetGLCoreContext(false);
window = SDL_CreateWindow("PPSSPP", x, y, pixel_xres, pixel_yres, mode);
window = SDL_CreateWindow("PPSSPP", x, y, g_display.pixel_xres, g_display.pixel_yres, mode);
if (window == nullptr) {
NativeShutdown();
fprintf(stderr, "SDL_CreateWindow failed: %s\n", SDL_GetError());
+24 -24
View File
@@ -670,16 +670,16 @@ int main(int argc, char *argv[]) {
#endif
if (mode & SDL_WINDOW_FULLSCREEN_DESKTOP) {
pixel_xres = g_DesktopWidth;
pixel_yres = g_DesktopHeight;
g_display.pixel_xres = g_DesktopWidth;
g_display.pixel_yres = g_DesktopHeight;
if (g_Config.iForceFullScreen == -1)
g_Config.bFullScreen = true;
} else {
// set a sensible default resolution (2x)
pixel_xres = 480 * 2 * set_scale;
pixel_yres = 272 * 2 * set_scale;
g_display.pixel_xres = 480 * 2 * set_scale;
g_display.pixel_yres = 272 * 2 * set_scale;
if (portrait) {
std::swap(pixel_xres, pixel_yres);
std::swap(g_display.pixel_xres, g_display.pixel_yres);
}
if (g_Config.iForceFullScreen == -1)
g_Config.bFullScreen = false;
@@ -688,26 +688,26 @@ int main(int argc, char *argv[]) {
set_dpi = 1.0f / set_dpi;
if (set_ipad) {
pixel_xres = 1024;
pixel_yres = 768;
g_display.pixel_xres = 1024;
g_display.pixel_yres = 768;
}
if (!landscape) {
std::swap(pixel_xres, pixel_yres);
std::swap(g_display.pixel_xres, g_display.pixel_yres);
}
if (set_xres > 0) {
pixel_xres = set_xres;
g_display.pixel_xres = set_xres;
}
if (set_yres > 0) {
pixel_yres = set_yres;
g_display.pixel_yres = set_yres;
}
float dpi_scale = 1.0f;
if (set_dpi > 0) {
dpi_scale = set_dpi;
}
dp_xres = (float)pixel_xres * dpi_scale;
dp_yres = (float)pixel_yres * dpi_scale;
g_display.dp_xres = (float)g_display.pixel_xres * dpi_scale;
g_display.dp_yres = (float)g_display.pixel_yres * dpi_scale;
// Mac / Linux
char path[2048];
@@ -745,15 +745,15 @@ int main(int argc, char *argv[]) {
int x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(getDisplayNumber());
int y = SDL_WINDOWPOS_UNDEFINED;
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;
g_display.pixel_in_dps_x = (float)g_display.pixel_xres / g_display.dp_xres;
g_display.pixel_in_dps_y = (float)g_display.pixel_yres / g_display.dp_yres;
g_display.dpi_scale_x = g_display.dp_xres / (float)g_display.pixel_xres;
g_display.dpi_scale_y = g_display.dp_yres / (float)g_display.pixel_yres;
g_display.dpi_scale_real_x = g_display.dpi_scale_x;
g_display.dpi_scale_real_y = g_display.dpi_scale_y;
printf("Pixels: %i x %i\n", pixel_xres, pixel_yres);
printf("Virtual pixels: %i x %i\n", dp_xres, dp_yres);
printf("Pixels: %i x %i\n", g_display.pixel_xres, g_display.pixel_yres);
printf("Virtual pixels: %i x %i\n", g_display.dp_xres, g_display.dp_yres);
GraphicsContext *graphicsContext = nullptr;
SDL_Window *window = nullptr;
@@ -873,8 +873,8 @@ int main(int argc, char *argv[]) {
}
SDL_Event event, touchEvent;
while (SDL_PollEvent(&event)) {
float mx = event.motion.x * g_dpi_scale_x;
float my = event.motion.y * g_dpi_scale_y;
float mx = event.motion.x * g_display.dpi_scale_x;
float my = event.motion.y * g_display.dpi_scale_y;
switch (event.type) {
case SDL_QUIT:
@@ -1182,8 +1182,8 @@ int main(int argc, char *argv[]) {
// Disabled by default, needs a workaround to map to psp keys.
if (g_Config.bMouseControl) {
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 scaleFactor_x = g_display.dpi_scale_x * 0.1 * g_Config.fMouseSensitivity;
float scaleFactor_y = g_display.dpi_scale_y * 0.1 * g_Config.fMouseSensitivity;
AxisInput axisX, axisY;
axisX.axisId = JOYSTICK_AXIS_MOUSE_REL_X;
+1 -1
View File
@@ -33,7 +33,7 @@ static uint32_t FlagsFromConfig() {
}
bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, std::string *error_message) {
window = SDL_CreateWindow("Initializing Vulkan...", x, y, pixel_xres, pixel_yres, mode);
window = SDL_CreateWindow("Initializing Vulkan...", x, y, g_display.pixel_xres, g_display.pixel_yres, mode);
if (!window) {
fprintf(stderr, "Error creating SDL window: %s\n", SDL_GetError());
exit(1);
+6 -6
View File
@@ -684,7 +684,7 @@ void TouchTestScreen::render() {
if (touches_[i].id != -1) {
ui_context->Draw()->Circle(touches_[i].x, touches_[i].y, 100.0, 3.0, 80, 0.0f, 0xFFFFFFFF, 1.0);
snprintf(buffer, sizeof(buffer), "%0.1fx%0.1f", touches_[i].x, touches_[i].y);
ui_context->DrawText(buffer, touches_[i].x, touches_[i].y + (touches_[i].y > dp_yres - 100.0f ? -135.0f : 95.0f), 0xFFFFFFFF, ALIGN_HCENTER | FLAG_DYNAMIC_ASCII);
ui_context->DrawText(buffer, touches_[i].x, touches_[i].y + (touches_[i].y > g_display.dp_yres - 100.0f ? -135.0f : 95.0f), 0xFFFFFFFF, ALIGN_HCENTER | FLAG_DYNAMIC_ASCII);
}
}
@@ -704,11 +704,11 @@ void TouchTestScreen::render() {
#if PPSSPP_PLATFORM(ANDROID)
display_xres, display_yres,
#endif
dp_xres, dp_yres,
pixel_xres, pixel_yres,
g_dpi,
g_dpi_scale_x, g_dpi_scale_y,
g_dpi_scale_real_x, g_dpi_scale_real_y, extra_debug);
g_display.dp_xres, g_display.dp_yres,
g_display.pixel_xres, g_display.pixel_yres,
g_display.dpi,
g_display.dpi_scale_x, g_display.dpi_scale_y,
g_display.dpi_scale_real_x, g_display.dpi_scale_real_y, extra_debug);
// On Android, also add joystick debug data.
+3 -3
View File
@@ -585,10 +585,10 @@ void SystemInfoScreen::CreateViews() {
System_GetPropertyInt(SYSPROP_DISPLAY_XRES),
System_GetPropertyInt(SYSPROP_DISPLAY_YRES))));
deviceSpecs->Add(new InfoItem(si->T("UI Resolution"), StringFromFormat("%dx%d (%s: %0.2f)",
dp_xres,
dp_yres,
g_display.dp_xres,
g_display.dp_yres,
si->T("DPI"),
g_dpi)));
g_display.dpi)));
#endif
#if !PPSSPP_PLATFORM(WINDOWS)
+5 -5
View File
@@ -50,10 +50,10 @@ enum Mode {
static Bounds FRectToBounds(FRect rc) {
Bounds b;
b.x = rc.x * g_dpi_scale_x;
b.y = rc.y * g_dpi_scale_y;
b.w = rc.w * g_dpi_scale_x;
b.h = rc.h * g_dpi_scale_y;
b.x = rc.x * g_display.dpi_scale_x;
b.y = rc.y * g_display.dpi_scale_y;
b.w = rc.w * g_display.dpi_scale_x;
b.h = rc.h * g_display.dpi_scale_y;
return b;
}
@@ -132,7 +132,7 @@ void DisplayLayoutScreen::DrawBackground(UIContext &dc) {
// we have to draw a substitute ourselves.
// TODO: Clean this up a bit, this GetScreenFrame/CenterDisplay combo is too common.
FRect screenFrame = GetScreenFrame(pixel_xres, pixel_yres);
FRect screenFrame = GetScreenFrame(g_display.pixel_xres, g_display.pixel_yres);
FRect rc;
CenterDisplayOutputRect(&rc, 480.0f, 272.0f, screenFrame, g_Config.iInternalScreenRotation);
+11 -11
View File
@@ -311,16 +311,16 @@ void EmuScreen::bootGame(const Path &filename) {
coreParam.headLess = false;
if (g_Config.iInternalResolution == 0) {
coreParam.renderWidth = pixel_xres;
coreParam.renderHeight = pixel_yres;
coreParam.renderWidth = g_display.pixel_xres;
coreParam.renderHeight = g_display.pixel_yres;
} else {
if (g_Config.iInternalResolution < 0)
g_Config.iInternalResolution = 1;
coreParam.renderWidth = 480 * g_Config.iInternalResolution;
coreParam.renderHeight = 272 * g_Config.iInternalResolution;
}
coreParam.pixelWidth = pixel_xres;
coreParam.pixelHeight = pixel_yres;
coreParam.pixelWidth = g_display.pixel_xres;
coreParam.pixelHeight = g_display.pixel_yres;
std::string error_string;
if (!PSP_InitStart(coreParam, &error_string)) {
@@ -1027,8 +1027,8 @@ void EmuScreen::update() {
#ifndef _WIN32
const Bounds &bounds = screenManager()->getUIContext()->GetBounds();
PSP_CoreParameter().pixelWidth = pixel_xres * bounds.w / dp_xres;
PSP_CoreParameter().pixelHeight = pixel_yres * bounds.h / dp_yres;
PSP_CoreParameter().pixelWidth = g_display.pixel_xres * bounds.w / g_display.dp_xres;
PSP_CoreParameter().pixelHeight = g_display.pixel_yres * bounds.h / g_display.dp_yres;
#endif
if (!invalid_) {
@@ -1371,13 +1371,13 @@ void EmuScreen::preRender() {
Viewport viewport;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = pixel_xres;
viewport.Height = pixel_yres;
viewport.Width = g_display.pixel_xres;
viewport.Height = g_display.pixel_yres;
viewport.MaxDepth = 1.0;
viewport.MinDepth = 0.0;
draw->SetViewport(viewport);
}
draw->SetTargetSize(pixel_xres, pixel_yres);
draw->SetTargetSize(g_display.pixel_xres, g_display.pixel_yres);
}
void EmuScreen::postRender() {
@@ -1519,8 +1519,8 @@ void EmuScreen::renderUI() {
Viewport viewport;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = pixel_xres;
viewport.Height = pixel_yres;
viewport.Width = g_display.pixel_xres;
viewport.Height = g_display.pixel_yres;
viewport.MaxDepth = 1.0;
viewport.MinDepth = 0.0;
thin3d->SetViewport(viewport);
+5 -3
View File
@@ -237,8 +237,10 @@ void GameSettingsScreen::CreateViews() {
if (!vertical) {
leftSide += 200.0f;
}
settingInfo_ = new SettingInfoMessage(ALIGN_CENTER | FLAG_WRAP_TEXT, new AnchorLayoutParams(dp_xres - leftSide - 40.0f, WRAP_CONTENT, leftSide, dp_yres - 80.0f - 40.0f, NONE, NONE));
settingInfo_->SetBottomCutoff(dp_yres - 200.0f);
settingInfo_ = new SettingInfoMessage(ALIGN_CENTER | FLAG_WRAP_TEXT, new AnchorLayoutParams(
g_display.dp_xres - leftSide - 40.0f, WRAP_CONTENT,
leftSide, g_display.dp_yres - 80.0f - 40.0f, NONE, NONE));
settingInfo_->SetBottomCutoff(g_display.dp_yres - 200.0f);
root_->Add(settingInfo_);
// Show it again if we recreated the view
@@ -273,7 +275,7 @@ void GameSettingsScreen::CreateViews() {
#if !defined(MOBILE_DEVICE) || PPSSPP_PLATFORM(ANDROID)
// Hide search if screen is too small.
if (dp_xres < dp_yres || dp_yres >= 500) {
if (g_display.dp_xres < g_display.dp_yres || g_display.dp_yres >= 500) {
auto se = GetI18NCategory("Search");
// Search
LinearLayout *searchSettings = AddTab("GameSettingsSearch", ms->T("Search"), true);
+3 -3
View File
@@ -711,7 +711,7 @@ void InitPadLayout(float xres, float yres, float globalScale) {
//select, start, throttle--------------------------------------------
//space between the bottom keys (space between select, start and un-throttle)
float bottom_key_spacing = 100;
if (dp_xres < 750) {
if (g_display.dp_xres < 750) {
bottom_key_spacing *= 0.8f;
}
@@ -956,8 +956,8 @@ bool GestureGamepad::Touch(const TouchInput &input) {
void GestureGamepad::Update() {
const float th = 1.0f;
float dx = deltaX_ * g_dpi_scale_x * g_Config.fSwipeSensitivity;
float dy = deltaY_ * g_dpi_scale_y * g_Config.fSwipeSensitivity;
float dx = deltaX_ * g_display.dpi_scale_x * g_Config.fSwipeSensitivity;
float dy = deltaY_ * g_display.dpi_scale_y * g_Config.fSwipeSensitivity;
if (g_Config.iSwipeRight != 0) {
if (dx > th) {
controlMapper_->pspKey(DEVICE_ID_TOUCH, GestureKey::keyList[g_Config.iSwipeRight-1], KEY_DOWN);
+6 -6
View File
@@ -134,7 +134,7 @@ public:
dc.BeginNoTex();
// Be sure to not overflow our vertex buffer
const float step = ceil(24*bounds.w/pixel_in_dps_x) > MAX_VERTS ? 24*bounds.w/(MAX_VERTS-48) : pixel_in_dps_x;
const float step = ceilf(24*bounds.w/ g_display.pixel_in_dps_x) > MAX_VERTS ? 24*bounds.w/(MAX_VERTS-48) : g_display.pixel_in_dps_x;
t *= speed;
for (float x = 0; x < bounds.w; x += step) {
@@ -146,8 +146,8 @@ public:
dc.Draw()->RectVGradient(x, wave1*bounds.h, step, (1.0-wave1)*bounds.h, color, 0x00000000);
// Add some "antialiasing"
dc.Draw()->RectVGradient(x, wave0*bounds.h-3*pixel_in_dps_y, step, 3*pixel_in_dps_y, 0x00000000, color);
dc.Draw()->RectVGradient(x, wave1*bounds.h-3*pixel_in_dps_y, step, 3*pixel_in_dps_y, 0x00000000, color);
dc.Draw()->RectVGradient(x, wave0*bounds.h-3.0f * g_display.pixel_in_dps_y, step, 3.0f * g_display.pixel_in_dps_y, 0x00000000, color);
dc.Draw()->RectVGradient(x, wave1*bounds.h-3.0f * g_display.pixel_in_dps_y, step, 3.0f * g_display.pixel_in_dps_y, 0x00000000, color);
}
dc.Flush();
@@ -371,8 +371,8 @@ void DrawGameBackground(UIContext &dc, const Path &gamePath, float x, float y, f
Viewport viewport;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = pixel_xres;
viewport.Height = pixel_yres;
viewport.Width = g_display.pixel_xres;
viewport.Height = g_display.pixel_yres;
viewport.MaxDepth = 1.0;
viewport.MinDepth = 0.0;
draw->SetViewport(viewport);
@@ -1080,7 +1080,7 @@ void SettingInfoMessage::Show(const std::string &text, const UI::View *refView)
if (b.y >= cutOffY_) {
ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, 80.0f, lp->right, lp->bottom, lp->center));
} else {
ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, dp_yres - 80.0f - 40.0f, lp->right, lp->bottom, lp->center));
ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, g_display.dp_yres - 80.0f - 40.0f, lp->right, lp->bottom, lp->center));
}
}
text_->SetText(text);
+14 -12
View File
@@ -1095,8 +1095,8 @@ void NativeRender(GraphicsContext *graphicsContext) {
g_BackgroundAudio.Update();
}
float xres = dp_xres;
float yres = dp_yres;
float xres = g_display.dp_xres;
float yres = g_display.dp_yres;
// Apply the UIContext bounds as a 2D transformation matrix.
// TODO: This should be moved into the draw context...
@@ -1109,7 +1109,9 @@ void NativeRender(GraphicsContext *graphicsContext) {
ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
Matrix4x4 translation;
// Account for the small window adjustment.
translation.setTranslation(Vec3(-0.5f * g_dpi_scale_x / g_dpi_scale_real_x, -0.5f * g_dpi_scale_y / g_dpi_scale_real_y, 0.0f));
translation.setTranslation(Vec3(
-0.5f * g_display.dpi_scale_x / g_display.dpi_scale_real_x,
-0.5f * g_display.dpi_scale_y / g_display.dpi_scale_real_y, 0.0f));
ortho = translation * ortho;
break;
case GPUBackend::DIRECT3D11:
@@ -1122,8 +1124,8 @@ void NativeRender(GraphicsContext *graphicsContext) {
}
// Compensate for rotated display if needed.
if (g_display_rotation != DisplayRotation::ROTATE_0) {
ortho = ortho * g_display_rot_matrix;
if (g_display.rotation != DisplayRotation::ROTATE_0) {
ortho = ortho * g_display.rot_matrix;
}
ui_draw2d.PushDrawMatrix(ortho);
@@ -1151,13 +1153,13 @@ void NativeRender(GraphicsContext *graphicsContext) {
if (uiContext) {
// Modifying the bounds here can be used to "inset" the whole image to gain borders for TV overscan etc.
// The UI now supports any offset but not the EmuScreen yet.
uiContext->SetBounds(Bounds(0, 0, dp_xres, dp_yres));
uiContext->SetBounds(Bounds(0, 0, g_display.dp_xres, g_display.dp_yres));
// OSX 10.6 and SDL 1.2 bug.
#if defined(__APPLE__) && !defined(USING_QT_UI)
static int dp_xres_old = dp_xres;
if (dp_xres != dp_xres_old) {
dp_xres_old = dp_xres;
static int dp_xres_old = g_display.dp_xres;
if (g_display.dp_xres != dp_xres_old) {
dp_xres_old = g_display.dp_xres;
}
#endif
}
@@ -1167,8 +1169,8 @@ void NativeRender(GraphicsContext *graphicsContext) {
// TODO: Move this to the GraphicsContext objects for each backend.
#if !PPSSPP_PLATFORM(WINDOWS) && !defined(ANDROID)
PSP_CoreParameter().pixelWidth = pixel_xres;
PSP_CoreParameter().pixelHeight = pixel_yres;
PSP_CoreParameter().pixelWidth = g_display.pixel_xres;
PSP_CoreParameter().pixelHeight = g_display.pixel_yres;
NativeMessageReceived("gpu_displayResized", "");
#endif
} else {
@@ -1402,7 +1404,7 @@ void NativeAxis(const AxisInput &axis) {
// sent with respect to the portrait coordinate system, while we
// take all events in landscape.
// see [http://developer.android.com/guide/topics/sensors/sensors_overview.html] for details
bool landscape = dp_yres < dp_xres;
bool landscape = g_display.dp_yres < g_display.dp_xres;
// now transform out current tilt to the calibrated coordinate system
ProcessTilt(landscape, tiltBaseAngleY, tiltX, tiltY, tiltZ,
g_Config.bInvertTiltX, g_Config.bInvertTiltY,
+1 -1
View File
@@ -253,7 +253,7 @@ void ReportScreen::CreateViews() {
Margins actionMenuMargins(0, 20, 15, 0);
Margins contentMargins(0, 20, 5, 5);
float leftColumnWidth = dp_xres - actionMenuMargins.horiz() - contentMargins.horiz() - 300.0f;
float leftColumnWidth = g_display.dp_xres - actionMenuMargins.horiz() - contentMargins.horiz() - 300.0f;
ViewGroup *leftColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, FILL_PARENT, 0.4f, contentMargins));
LinearLayout *leftColumnItems = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(WRAP_CONTENT, FILL_PARENT));
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins));
+2 -2
View File
@@ -318,8 +318,8 @@ public:
float xOffset = bounds_.x;
float yOffset = bounds_.y;
dc.Draw()->Rect((x1+x2)/2 + xOffset - pixel_in_dps_x, y1 + yOffset, 3.0*pixel_in_dps_x, y2-y1, col);
dc.Draw()->Rect(x1 + xOffset, (y1+y2)/2 + yOffset - pixel_in_dps_y, x2-x1, 3.0*pixel_in_dps_y, col);
dc.Draw()->Rect((x1+x2)/2 + xOffset - g_display.pixel_in_dps_x, y1 + yOffset, 3.0f * g_display.pixel_in_dps_x, y2-y1, col);
dc.Draw()->Rect(x1 + xOffset, (y1+y2)/2 + yOffset - g_display.pixel_in_dps_y, x2-x1, 3.0f * g_display.pixel_in_dps_y, col);
for (int x = x1 + (x1+x2)/2 % g_Config.iTouchSnapGridSize; x < x2; x += g_Config.iTouchSnapGridSize)
dc.Draw()->vLine(x + xOffset, y1 + yOffset, y2 + yOffset, col);
+19 -19
View File
@@ -167,39 +167,39 @@ bool PPSSPP_UWPMain::Render() {
auto context = m_deviceResources->GetD3DDeviceContext();
switch (m_deviceResources->ComputeDisplayRotation()) {
case DXGI_MODE_ROTATION_IDENTITY: g_display_rotation = DisplayRotation::ROTATE_0; break;
case DXGI_MODE_ROTATION_ROTATE90: g_display_rotation = DisplayRotation::ROTATE_90; break;
case DXGI_MODE_ROTATION_ROTATE180: g_display_rotation = DisplayRotation::ROTATE_180; break;
case DXGI_MODE_ROTATION_ROTATE270: g_display_rotation = DisplayRotation::ROTATE_270; break;
case DXGI_MODE_ROTATION_IDENTITY: g_display.rotation = DisplayRotation::ROTATE_0; break;
case DXGI_MODE_ROTATION_ROTATE90: g_display.rotation = DisplayRotation::ROTATE_90; break;
case DXGI_MODE_ROTATION_ROTATE180: g_display.rotation = DisplayRotation::ROTATE_180; break;
case DXGI_MODE_ROTATION_ROTATE270: g_display.rotation = DisplayRotation::ROTATE_270; break;
}
// Not super elegant but hey.
memcpy(&g_display_rot_matrix, &m_deviceResources->GetOrientationTransform3D(), sizeof(float) * 16);
memcpy(&g_display.rot_matrix, &m_deviceResources->GetOrientationTransform3D(), sizeof(float) * 16);
// Reset the viewport to target the whole screen.
auto viewport = m_deviceResources->GetScreenViewport();
pixel_xres = viewport.Width;
pixel_yres = viewport.Height;
g_display.pixel_xres = viewport.Width;
g_display.pixel_yres = viewport.Height;
if (g_display_rotation == DisplayRotation::ROTATE_90 || g_display_rotation == DisplayRotation::ROTATE_270) {
if (g_display.rotation == DisplayRotation::ROTATE_90 || g_display.rotation == DisplayRotation::ROTATE_270) {
// We need to swap our width/height.
std::swap(pixel_xres, pixel_yres);
std::swap(g_display.pixel_xres, g_display.pixel_yres);
}
g_dpi = m_deviceResources->GetActualDpi();
g_display.dpi = m_deviceResources->GetActualDpi();
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_MOBILE) {
// Boost DPI a bit to look better.
g_dpi *= 96.0f / 136.0f;
g_display.dpi *= 96.0f / 136.0f;
}
g_dpi_scale_x = 96.0f / g_dpi;
g_dpi_scale_y = 96.0f / g_dpi;
g_display.dpi_scale_x = 96.0f / g_display.dpi;
g_display.dpi_scale_y = 96.0f / g_display.dpi;
pixel_in_dps_x = 1.0f / g_dpi_scale_x;
pixel_in_dps_y = 1.0f / g_dpi_scale_y;
g_display.pixel_in_dps_x = 1.0f / g_display.dpi_scale_x;
g_display.pixel_in_dps_y = 1.0f / g_display.dpi_scale_y;
dp_xres = pixel_xres * g_dpi_scale_x;
dp_yres = pixel_yres * g_dpi_scale_y;
g_display.dp_xres = g_display.pixel_xres * g_display.dpi_scale_x;
g_display.dp_yres = g_display.pixel_yres * g_display.dpi_scale_y;
context->RSSetViewports(1, &viewport);
@@ -274,8 +274,8 @@ void PPSSPP_UWPMain::OnTouchEvent(int touchEvent, int touchId, float x, float y,
// and then apply our own "dpi".
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;
dpiFactor_x /= g_display.pixel_in_dps_x;
dpiFactor_y /= g_display.pixel_in_dps_y;
TouchInput input{};
input.id = touchId;
+1 -1
View File
@@ -172,7 +172,7 @@ CtrlDisAsmView::CtrlDisAsmView(HWND _wnd)
SetWindowLong(wnd, GWL_STYLE, GetWindowLong(wnd,GWL_STYLE) | WS_VSCROLL);
SetScrollRange(wnd, SB_VERT, -1, 1, TRUE);
const float fontScale = 1.0f / g_dpi_scale_real_y;
const float fontScale = 1.0f / g_display.dpi_scale_real_y;
charWidth = g_Config.iFontWidth * fontScale;
rowHeight = (g_Config.iFontHeight + 2) * fontScale;
int scaledFontHeight = g_Config.iFontHeight * fontScale;
+1 -1
View File
@@ -34,7 +34,7 @@ CtrlMemView::CtrlMemView(HWND _wnd) {
SetWindowLong(wnd, GWL_STYLE, GetWindowLong(wnd,GWL_STYLE) | WS_VSCROLL);
SetScrollRange(wnd, SB_VERT, -1,1,TRUE);
const float fontScale = 1.0f / g_dpi_scale_real_y;
const float fontScale = 1.0f / g_display.dpi_scale_real_y;
charWidth_ = g_Config.iFontWidth * fontScale;
rowHeight_ = g_Config.iFontHeight * fontScale;
offsetPositionY_ = offsetLine * rowHeight_;
+1 -1
View File
@@ -133,7 +133,7 @@ CtrlRegisterList::CtrlRegisterList(HWND _wnd)
: wnd(_wnd) {
SetWindowLongPtr(wnd, GWLP_USERDATA, (LONG_PTR)this);
const float fontScale = 1.0f / g_dpi_scale_real_y;
const float fontScale = 1.0f / g_display.dpi_scale_real_y;
rowHeight = g_Config.iFontHeight * fontScale;
int charWidth = g_Config.iFontWidth * fontScale;
font = CreateFont(rowHeight, charWidth, 0, 0,
+1 -1
View File
@@ -257,7 +257,7 @@ void CMemoryDlg::Goto(u32 addr)
void CMemoryDlg::Size()
{
const float fontScale = 1.0f / g_dpi_scale_real_y;
const float fontScale = 1.0f / g_display.dpi_scale_real_y;
GetClientRect(m_hDlg,&winRect);
int dlg_w = winRect.right - winRect.left;
+1 -1
View File
@@ -45,7 +45,7 @@ CtrlDisplayListView::CtrlDisplayListView(HWND _wnd)
instructionSize = 4;
// In small window mode, g_dpi_scale may have been adjusted.
const float fontScale = 1.0f / g_dpi_scale_real_y;
const float fontScale = 1.0f / g_display.dpi_scale_real_y;
int fontHeight = g_Config.iFontHeight * fontScale;
int charWidth = g_Config.iFontWidth * fontScale;
+2 -2
View File
@@ -51,8 +51,8 @@ void D3D11Context::SwapInterval(int interval) {
HRESULT D3D11Context::CreateTheDevice(IDXGIAdapter *adapter) {
bool windowed = true;
// D3D11 has no need for display rotation.
g_display_rotation = DisplayRotation::ROTATE_0;
g_display_rot_matrix.setIdentity();
g_display.rotation = DisplayRotation::ROTATE_0;
g_display.rot_matrix.setIdentity();
#if defined(_DEBUG) && !PPSSPP_ARCH(ARM) && !PPSSPP_ARCH(ARM64)
UINT createDeviceFlags = D3D11_CREATE_DEVICE_DEBUG;
#else
+2 -2
View File
@@ -51,8 +51,8 @@ bool D3D9Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
hWnd_ = wnd;
// D3D9 has no need for display rotation.
g_display_rotation = DisplayRotation::ROTATE_0;
g_display_rot_matrix.setIdentity();
g_display.rotation = DisplayRotation::ROTATE_0;
g_display.rot_matrix.setIdentity();
DIRECT3DCREATE9EX g_pfnCreate9ex;
+6 -6
View File
@@ -643,8 +643,8 @@ namespace MainWindow
// Hack: Take the opportunity to show the cursor.
mouseButtonDown = true;
float x = GET_X_LPARAM(lParam) * g_dpi_scale_x;
float y = GET_Y_LPARAM(lParam) * g_dpi_scale_y;
float x = GET_X_LPARAM(lParam) * g_display.dpi_scale_x;
float y = GET_Y_LPARAM(lParam) * g_display.dpi_scale_y;
WindowsRawInput::SetMousePos(x, y);
TouchInput touch;
@@ -684,8 +684,8 @@ namespace MainWindow
prevCursorX = cursorX;
prevCursorY = cursorY;
float x = (float)cursorX * g_dpi_scale_x;
float y = (float)cursorY * g_dpi_scale_y;
float x = (float)cursorX * g_display.dpi_scale_x;
float y = (float)cursorY * g_display.dpi_scale_y;
WindowsRawInput::SetMousePos(x, y);
if (wParam & MK_LBUTTON) {
@@ -706,8 +706,8 @@ namespace MainWindow
// Hack: Take the opportunity to hide the cursor.
mouseButtonDown = false;
float x = (float)GET_X_LPARAM(lParam) * g_dpi_scale_x;
float y = (float)GET_Y_LPARAM(lParam) * g_dpi_scale_y;
float x = (float)GET_X_LPARAM(lParam) * g_display.dpi_scale_x;
float y = (float)GET_Y_LPARAM(lParam) * g_display.dpi_scale_y;
WindowsRawInput::SetMousePos(x, y);
TouchInput touch;
+2 -2
View File
@@ -54,8 +54,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_x;
y = point.y * g_dpi_scale_y;
x = point.x * g_display.dpi_scale_x;
y = point.y * g_display.dpi_scale_y;
return true;
}
+2 -2
View File
@@ -238,8 +238,8 @@ void WindowsHost::PollControllers() {
// Disabled by default, needs a workaround to map to psp keys.
if (g_Config.bMouseControl) {
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 scaleFactor_x = g_display.dpi_scale_x * 0.1 * g_Config.fMouseSensitivity;
float scaleFactor_y = g_display.dpi_scale_y * 0.1 * g_Config.fMouseSensitivity;
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));
+2 -2
View File
@@ -19,8 +19,8 @@ bool AndroidJavaEGLGraphicsContext::InitFromRenderThread(ANativeWindow *wnd, int
}
// OpenGL handles rotated rendering in the driver.
g_display_rotation = DisplayRotation::ROTATE_0;
g_display_rot_matrix.setIdentity();
g_display.rotation = DisplayRotation::ROTATE_0;
g_display.rot_matrix.setIdentity();
draw_ = Draw::T3DCreateGLContext(); // Can't fail
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
+4 -4
View File
@@ -119,8 +119,8 @@ bool RunTests() {
output.clear();
if (!PSP_Init(coreParam, &error_string)) {
ERROR_LOG(SYSTEM, "Failed to init unittest %s : %s", testsToRun[i], error_string.c_str());
PSP_CoreParameter().pixelWidth = pixel_xres;
PSP_CoreParameter().pixelHeight = pixel_yres;
PSP_CoreParameter().pixelWidth = g_display.pixel_xres;
PSP_CoreParameter().pixelHeight = g_display.pixel_yres;
return false;
}
@@ -176,8 +176,8 @@ bool RunTests() {
}
PSP_Shutdown();
}
PSP_CoreParameter().pixelWidth = pixel_xres;
PSP_CoreParameter().pixelHeight = pixel_yres;
PSP_CoreParameter().pixelWidth = g_display.pixel_xres;
PSP_CoreParameter().pixelHeight = g_display.pixel_yres;
PSP_CoreParameter().headLess = false;
PSP_CoreParameter().graphicsContext = tempCtx;
+27 -27
View File
@@ -461,7 +461,7 @@ int System_GetPropertyInt(SystemProperty prop) {
float System_GetPropertyFloat(SystemProperty prop) {
switch (prop) {
case SYSPROP_DISPLAY_REFRESH_RATE:
return display_hz;
return g_display.display_hz;
case SYSPROP_DISPLAY_SAFE_INSET_LEFT:
return g_safeInsetLeft;
case SYSPROP_DISPLAY_SAFE_INSET_RIGHT:
@@ -977,35 +977,35 @@ extern "C" bool Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * env,
}
static void recalculateDpi() {
g_dpi = display_dpi_x;
g_dpi_scale_x = 240.0f / display_dpi_x;
g_dpi_scale_y = 240.0f / display_dpi_y;
g_dpi_scale_real_x = g_dpi_scale_x;
g_dpi_scale_real_y = g_dpi_scale_y;
g_display.dpi = display_dpi_x;
g_display.dpi_scale_x = 240.0f / display_dpi_x;
g_display.dpi_scale_y = 240.0f / display_dpi_y;
g_display.dpi_scale_real_x = g_display.dpi_scale_x;
g_display.dpi_scale_real_y = g_display.dpi_scale_y;
dp_xres = display_xres * g_dpi_scale_x;
dp_yres = display_yres * g_dpi_scale_y;
g_display.dp_xres = display_xres * g_display.dpi_scale_x;
g_display.dp_yres = display_yres * g_display.dpi_scale_y;
pixel_in_dps_x = (float)pixel_xres / dp_xres;
pixel_in_dps_y = (float)pixel_yres / dp_yres;
g_display.pixel_in_dps_x = (float)g_display.pixel_xres / g_display.dp_xres;
g_display.pixel_in_dps_y = (float)g_display.pixel_yres / g_display.dp_yres;
INFO_LOG(G3D, "RecalcDPI: display_xres=%d display_yres=%d pixel_xres=%d pixel_yres=%d", display_xres, display_yres, pixel_xres, pixel_yres);
INFO_LOG(G3D, "RecalcDPI: g_dpi=%f g_dpi_scale_x=%f g_dpi_scale_y=%f dp_xres=%d dp_yres=%d", g_dpi, g_dpi_scale_x, g_dpi_scale_y, dp_xres, dp_yres);
INFO_LOG(G3D, "RecalcDPI: display_xres=%d display_yres=%d pixel_xres=%d pixel_yres=%d", display_xres, display_yres, g_display.pixel_xres, g_display.pixel_yres);
INFO_LOG(G3D, "RecalcDPI: g_dpi=%f g_dpi_scale_x=%f g_dpi_scale_y=%f dp_xres=%d dp_yres=%d", g_display.dpi, g_display.dpi_scale_x, g_display.dpi_scale_y, g_display.dp_xres, g_display.dp_yres);
}
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv *, jclass, jint bufw, jint bufh, jint format) {
INFO_LOG(SYSTEM, "NativeApp.backbufferResize(%d x %d)", bufw, bufh);
bool new_size = pixel_xres != bufw || pixel_yres != bufh;
int old_w = pixel_xres;
int old_h = pixel_yres;
bool new_size = g_display.pixel_xres != bufw || g_display.pixel_yres != bufh;
int old_w = g_display.pixel_xres;
int old_h = g_display.pixel_yres;
// pixel_*res is the backbuffer resolution.
pixel_xres = bufw;
pixel_yres = bufh;
g_display.pixel_xres = bufw;
g_display.pixel_yres = bufh;
backbuffer_format = format;
if (IsVREnabled()) {
GetVRResolutionPerEye(&pixel_xres, &pixel_yres);
GetVRResolutionPerEye(&g_display.pixel_xres, &g_display.pixel_yres);
}
recalculateDpi();
@@ -1093,7 +1093,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env,
}
if (IsVREnabled()) {
UpdateVRInput(g_Config.bHapticFeedback, g_dpi_scale_x, g_dpi_scale_y);
UpdateVRInput(g_Config.bHapticFeedback, g_display.dpi_scale_x, g_display.dpi_scale_y);
FinishVRRender();
}
}
@@ -1117,8 +1117,8 @@ PermissionStatus System_GetPermissionStatus(SystemPermission permission) {
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_touch
(JNIEnv *, jclass, float x, float y, int code, int pointerId) {
float scaledX = x * g_dpi_scale_x;
float scaledY = y * g_dpi_scale_y;
float scaledX = x * g_display.dpi_scale_x;
float scaledY = y * g_display.dpi_scale_y;
TouchInput touch;
touch.id = pointerId;
@@ -1215,10 +1215,10 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendMessage(JNIEnv *env
// We don't bother with supporting exact rectangular regions. Safe insets are good enough.
int left, right, top, bottom;
if (4 == sscanf(prm.c_str(), "%d:%d:%d:%d", &left, &right, &top, &bottom)) {
g_safeInsetLeft = (float)left * g_dpi_scale_x;
g_safeInsetRight = (float)right * g_dpi_scale_x;
g_safeInsetTop = (float)top * g_dpi_scale_y;
g_safeInsetBottom = (float)bottom * g_dpi_scale_y;
g_safeInsetLeft = (float)left * g_display.dpi_scale_x;
g_safeInsetRight = (float)right * g_display.dpi_scale_x;
g_safeInsetTop = (float)top * g_display.dpi_scale_y;
g_safeInsetBottom = (float)bottom * g_display.dpi_scale_y;
}
}
@@ -1251,14 +1251,14 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setDisplayParameters(JN
bool changed = false;
changed = changed || display_xres != xres || display_yres != yres;
changed = changed || display_dpi_x != dpi || display_dpi_y != dpi;
changed = changed || display_hz != refreshRate;
changed = changed || g_display.display_hz != refreshRate;
if (changed) {
display_xres = xres;
display_yres = yres;
display_dpi_x = dpi;
display_dpi_y = dpi;
display_hz = refreshRate;
g_display.display_hz = refreshRate;
recalculateDpi();
NativeResized();
+15 -15
View File
@@ -148,33 +148,33 @@
}
if (screen == [UIScreen mainScreen]) {
g_dpi = (IS_IPAD() ? 200.0f : 150.0f) * scale;
g_display.dpi = (IS_IPAD() ? 200.0f : 150.0f) * scale;
} else {
float diagonal = sqrt(size.height * size.height + size.width * size.width);
g_dpi = diagonal * scale * 0.1f;
g_display.dpi = diagonal * scale * 0.1f;
}
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;
g_display.dpi_scale_x = 240.0f / g_display.dpi;
g_display.dpi_scale_y = 240.0f / g_display.dpi;
g_display.dpi_scale_real_x = g_display.dpi_scale_x;
g_display.dpi_scale_real_y = g_display.dpi_scale_y;
g_display.pixel_xres = size.width * scale;
g_display.pixel_yres = size.height * scale;
dp_xres = pixel_xres * g_dpi_scale_x;
dp_yres = pixel_yres * g_dpi_scale_y;
g_display.dp_xres = g_display.pixel_xres * g_display.dpi_scale_x;
g_display.dp_yres = g_display.pixel_yres * g_display.dpi_scale_y;
pixel_in_dps_x = (float)pixel_xres / (float)dp_xres;
pixel_in_dps_y = (float)pixel_yres / (float)dp_yres;
g_display.pixel_in_dps_x = (float)g_display.pixel_xres / (float)g_display.dp_xres;
g_display.pixel_in_dps_y = (float)g_display.pixel_yres / (float)g_display.dp_yres;
[[sharedViewController view] setContentScaleFactor:scale];
// PSP native resize
PSP_CoreParameter().pixelWidth = pixel_xres;
PSP_CoreParameter().pixelHeight = pixel_yres;
PSP_CoreParameter().pixelWidth = g_display.pixel_xres;
PSP_CoreParameter().pixelHeight = g_display.pixel_yres;
NativeResized();
NSLog(@"Updated display resolution: (%d, %d) @%.1fx", pixel_xres, pixel_yres, scale);
NSLog(@"Updated display resolution: (%d, %d) @%.1fx", g_display.pixel_xres, g_display.pixel_yres, scale);
}
@end
+2 -2
View File
@@ -200,8 +200,8 @@ static LocationHelper *locationHelper;
graphicsContext->ThreadStart();
dp_xscale = (float)dp_xres / (float)pixel_xres;
dp_yscale = (float)dp_yres / (float)pixel_yres;
dp_xscale = (float)g_display.dp_xres / (float)g_display.pixel_xres;
dp_yscale = (float)g_display.dp_yres / (float)g_display.pixel_yres;
/*self.iCadeView = [[iCadeReaderView alloc] init];
[self.view addSubview:self.iCadeView];