summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgraphics.c4
-rwxr-xr-xreduced_system_layer.c42
2 files changed, 28 insertions, 18 deletions
diff --git a/graphics.c b/graphics.c
index 17afe97..c8df0c8 100755
--- a/graphics.c
+++ b/graphics.c
@@ -313,13 +313,13 @@ void draw_pixels_to_buffer(Pixel_Buffer dst, Box area, Pixel_Buffer src) {
f64 di = src.width / area.width;
f64 dj = src.height / area.height;
- f64 jj = (j0 - area.y) * dj;
+ f64 jj = (j0 - area.y) * dj + dj * .5;
for (i64 j = j0; j < j1; ++j, jj += dj) {
if (jj < 0 || jj >= src.height) continue;
vec4_f32 *d = dst.pixels + j * dst.stride + i0;
vec4_f32 *d_end = d + i1 - i0;
vec4_f32 *s = src.pixels + (i64) jj * src.stride;
- f64 ii = (i0 - area.x) * di;
+ f64 ii = (i0 - area.x) * di + di * .5;
if (ii < 0 || ii >= src.width) continue;
for (; d < d_end; ++d, ii += di)
put_pixel_(d, s[(i64) ii]);
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];
+ }
}
}
}