mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 11:54:30 +01:00
Add overlay (bezel) support
Draws a user image around or behind the PSP screen, to fill the black bars on displays whose aspect ratio doesn't match the PSP's (#20325). - Overlays are PNGs in PSP/OVERLAYS. A plain PNG there just works: it's drawn in front of the game, and its transparent hole is found by walking from the image center to each edge until a nearly opaque pixel. Existing RetroArch overlay images can be dropped in as-is. - A subfolder with an overlay.ini can define overlays with a Name, Layer (Foreground/Background) and an explicit Hole=x,y,w,h. - "Load overlay image..." in the display layout screen imports any PNG (including Android content URIs) into the overlays folder and selects it. - The overlay is fit to the screen (aspect preserved, centered). The hole is mapped with the same scale, and the game is fit into it with the normal stretch / integer scale / aspect ratio options. Offset and scale don't apply while an overlay with a hole is active. This goes through CalculateDisplayOutputRect, so touch mapping and post shaders agree. - The selection is a per-orientation, per-game DisplayLayout setting. - Disabled in VR, Cardboard, and with skip buffer effects (except software rendering), since the presentation path doesn't run there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QGBg32EFPsTXjAFu7dnTcz
This commit is contained in:
1 parent
ff3d184b43
commit
3ce3973781
18 files changed
+697
-6
No files matched your search
@@ -123,6 +123,7 @@
|
||||
#include "GPU/Common/DepthSwizzle.h"
|
||||
#include "GPU/Common/TextureDecoder.h"
|
||||
#include "GPU/Common/GPUStateUtils.h"
|
||||
#include "GPU/Common/Overlay.h"
|
||||
#include "GPU/Math3D.h"
|
||||
|
||||
#include "Common/File/AndroidContentURI.h"
|
||||
@@ -3415,6 +3416,52 @@ bool TestLang() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool TestOverlayHole() {
|
||||
const int W = 64, H = 48;
|
||||
std::vector<uint8_t> img(W * H * 4);
|
||||
auto fill = [&](int x0, int y0, int x1, int y1, uint8_t a) {
|
||||
for (int y = y0; y < y1; y++)
|
||||
for (int x = x0; x < x1; x++)
|
||||
img[(y * W + x) * 4 + 3] = a;
|
||||
};
|
||||
int x, y, w, h;
|
||||
|
||||
// Opaque frame with a transparent hole at 8,4 size 40x30 (contains the center 32,24).
|
||||
fill(0, 0, W, H, 255);
|
||||
fill(8, 4, 48, 34, 0);
|
||||
EXPECT_TRUE(DetectOverlayHole(img.data(), W, H, &x, &y, &w, &h));
|
||||
EXPECT_EQ_INT(x, 8);
|
||||
EXPECT_EQ_INT(y, 4);
|
||||
EXPECT_EQ_INT(w, 40);
|
||||
EXPECT_EQ_INT(h, 30);
|
||||
|
||||
// A semi-transparent glare over the screen area and soft edges still count as the hole.
|
||||
fill(20, 10, 40, 30, 200);
|
||||
fill(7, 4, 8, 34, 128);
|
||||
EXPECT_TRUE(DetectOverlayHole(img.data(), W, H, &x, &y, &w, &h));
|
||||
EXPECT_EQ_INT(x, 7);
|
||||
EXPECT_EQ_INT(w, 41);
|
||||
|
||||
// Fully transparent image: the hole is the whole image.
|
||||
fill(0, 0, W, H, 0);
|
||||
EXPECT_TRUE(DetectOverlayHole(img.data(), W, H, &x, &y, &w, &h));
|
||||
EXPECT_EQ_INT(x, 0);
|
||||
EXPECT_EQ_INT(y, 0);
|
||||
EXPECT_EQ_INT(w, W);
|
||||
EXPECT_EQ_INT(h, H);
|
||||
|
||||
// Hole not covering the center: no valid start point.
|
||||
fill(0, 0, W, H, 255);
|
||||
fill(0, 0, 30, 20, 0);
|
||||
EXPECT_FALSE(DetectOverlayHole(img.data(), W, H, &x, &y, &w, &h));
|
||||
|
||||
// Tiny hole is rejected.
|
||||
fill(0, 0, W, H, 255);
|
||||
fill(30, 22, 36, 28, 0);
|
||||
EXPECT_FALSE(DetectOverlayHole(img.data(), W, H, &x, &y, &w, &h));
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef bool (*TestFunc)();
|
||||
struct TestItem {
|
||||
const char *name;
|
||||
@@ -3877,6 +3924,7 @@ TestItem availableTests[] = {
|
||||
TEST_ITEM(BlockShadow),
|
||||
TEST_ITEM(ShaderGenerators),
|
||||
TEST_ITEM(Path),
|
||||
TEST_ITEM(OverlayHole),
|
||||
TEST_ITEM(AndroidContentURI),
|
||||
TEST_ITEM(ThreadManager),
|
||||
TEST_ITEM(WrapText),
|
||||
|
||||
Reference in new issue
Block a user