summaryrefslogtreecommitdiff
path: root/reduced_system_layer.c
diff options
context:
space:
mode:
Diffstat (limited to 'reduced_system_layer.c')
-rwxr-xr-xreduced_system_layer.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/reduced_system_layer.c b/reduced_system_layer.c
index 5e0ef67..2b9ae9e 100755
--- a/reduced_system_layer.c
+++ b/reduced_system_layer.c
@@ -287,7 +287,7 @@ i32 main(i32 argc, c8 **argv);
// The pixel size will increase when the frame duration is higher.
#ifndef MAX_FRAME_DURATION
-#define MAX_FRAME_DURATION 32
+#define MAX_FRAME_DURATION 83
#endif
// The pixel size value will reset if the frame duration is higher.
@@ -1623,23 +1623,33 @@ static void convert_pixels_for_window_(void) {
return;
}
- if (src_len > dst_len) {
- LOG_ERROR("Sanity");
- return;
- }
-
f64 di = ((f64) src_width) / dst_width;
f64 dj = ((f64) src_height) / dst_height;
- f64 jj = src_height - dj;
- for (i64 j = dst_height - 1; j >= 0; --j, jj -= dj) {
- if (jj < 0 || jj >= src_height) continue;
- u32 *d_first = _internal_pixels + j * dst_width;
- u32 *d = d_first + dst_width - 1;
- u32 *s = _internal_pixels + (i64) jj * src_width;
- f64 ii = src_width - di;
- if (ii < 0 || ii >= src_width) continue;
- for (; d >= d_first; --d, ii -= di)
- *d = s[(i64) ii];
+
+ if (src_len < dst_len) {
+ f64 jj = src_height - dj * .5;
+ for (i64 j = dst_height - 1; j >= 0; --j, jj -= dj) {
+ if (jj < 0 || jj >= src_height) continue;
+ u32 *d_first = _internal_pixels + j * dst_width;
+ u32 *d = d_first + dst_width - 1;
+ u32 *s = _internal_pixels + (i64) jj * src_width;
+ f64 ii = src_width - di * .5;
+ if (ii < 0 || ii >= src_width) continue;
+ for (; d >= d_first; --d, ii -= di)
+ *d = s[(i64) ii];
+ }
+ } else {
+ f64 jj = dj * .5;
+ for (i64 j = 0; j < dst_height; ++j, jj += dj) {
+ if (jj < 0 || jj >= src_height) continue;
+ u32 *d = _internal_pixels + j * dst_width;
+ u32 *d_end = d + dst_width;
+ u32 *s = _internal_pixels + (i64) jj * src_width;
+ f64 ii = di * .5;
+ if (ii < 0 || ii >= src_width) continue;
+ for (; d < d_end; ++d, ii += di)
+ *d = s[(i64) ii];
+ }
}
}
}