aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author浅倉麗子2020-04-23 17:22:04 -0400
committer浅倉麗子2020-04-23 17:22:04 -0400
commit21e21bf1fcc1a965f55a0b8e88bc172fb5ec11b8 (patch)
treebcb8aae89155a61ab98bb4924609210cc9da1079
parentUse floating point arithmetics (diff)
downloadsharpscale-21e21bf1fcc1a965f55a0b8e88bc172fb5ec11b8.tar.gz
Add fitted scaling mode
-rw-r--r--README.md4
-rw-r--r--main.c6
-rw-r--r--sharpscale.h1
3 files changed, 9 insertions, 2 deletions
diff --git a/README.md b/README.md
index 10eb5e6..04868c9 100644
--- a/README.md
+++ b/README.md
@@ -13,12 +13,13 @@ Sharpscale can be configured to different scaling methods.
- Original: system default
- Integer: scale by multiplying the width and height of the framebuffer by the largest integer less than or equal to four such that the product width and height is less than or equal to the display width and height, respectively
- Real: no scaling
+- Fitted: scale the framebuffer up to four times larger or eight times smaller to fit exactly within the display while preserving aspect ratio
In integer and real modes, a few lines may be cropped from the top and bottom to preserve aspect ratio of the framebuffer.
#### PS1 aspect ratio modes
-PS1 aspect ratio modes only take effect in integer or real scaling modes but is applied before scaling.
+PS1 aspect ratio modes only take effect in integer, real, and fitted scaling modes and is applied before scaling.
- Pixel: aspect ratio of the framebuffer
- 4∶3: aspect ratio is forced to 4∶3
@@ -27,6 +28,7 @@ PS1 aspect ratio modes only take effect in integer or real scaling modes but is
Scaling and PS1 aspect ratio will not apply when
- in integer and real modes, if the framebuffer is already larger than the display
+- in fitted mode, if the framebuffer is too big to be scaled
- in 4∶3 and 16∶9 modes, aspect ratio is too different to be forced
#### Bilinear filtering
diff --git a/main.c b/main.c
index cec53f0..6d34078 100644
--- a/main.c
+++ b/main.c
@@ -166,9 +166,13 @@ static int sceIftuSetInputFrameBuffer_hook(int plane, SceIftuPlaneState *state,
} else if (ss_config.mode == SHARPSCALE_MODE_REAL) {
scale = (fb_w <= head_w && (fb_h - 16) <= head_h) ? 1.0 : 0.0;
scale = floorf(fminf(scale, 4.0 / ar_scale));
+ } else if (ss_config.mode == SHARPSCALE_MODE_FITTED) {
+ scale = fminf((float)head_w / (float)fb_w, (float)head_h / (float)fb_h);
+ scale = fminf(scale, 4.0 / ar_scale);
+ scale = fminf(scale, 4.0);
}
- if (isgreater(scale, 0.0)) {
+ if (isgreater(scale, 0.125)) {
state->src_w = lroundf(65536.0 / scale / ar_scale);
state->src_h = lroundf(65536.0 / scale);
diff --git a/sharpscale.h b/sharpscale.h
index 6dd1dae..e538f28 100644
--- a/sharpscale.h
+++ b/sharpscale.h
@@ -7,6 +7,7 @@ typedef enum SharpscaleMode {
SHARPSCALE_MODE_ORIGINAL,
SHARPSCALE_MODE_INTEGER,
SHARPSCALE_MODE_REAL,
+ SHARPSCALE_MODE_FITTED,
SHARPSCALE_MODE_INVALID,
} SharpscaleMode;