From 9db7dbaaf4a362e444b36f7dd7c78f642433ea10 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 23 Apr 2023 19:18:14 +0300 Subject: [PATCH] Integer scale updates --- od-win32/win32_scaler.cpp | 25 +++++-------------------- od-win32/win32gfx.cpp | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/od-win32/win32_scaler.cpp b/od-win32/win32_scaler.cpp index 574383fd..ceb8ffe4 100644 --- a/od-win32/win32_scaler.cpp +++ b/od-win32/win32_scaler.cpp @@ -218,24 +218,6 @@ static bool get_aspect(int monid, float *dstratiop, float *srcratiop, float *xmu return aspect; } -static int res_match(int w) -{ - if (currprefs.gfx_vresolution == VRES_NONDOUBLE) { - if (currprefs.gfx_resolution == RES_HIRES) { - w *= 2; - } else if (currprefs.gfx_resolution == RES_SUPERHIRES) { - w *= 4; - } - } else { - if (currprefs.gfx_resolution == RES_LORES) { - w /= 2; - } else if (currprefs.gfx_resolution == RES_SUPERHIRES) { - w *= 2; - } - } - return w; -} - void getfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height, int aw, int ah, int scale, int *mode, int temp_width, int temp_height) { struct AmigaMonitor *mon = &AMonitors[monid]; @@ -447,8 +429,6 @@ void getfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int dst_width, int filter_horiz_zoom_mult = 1.0; filter_vert_zoom_mult = 1.0; - maxw = res_match(maxw); - float multadd = 1.0f / (1 << currprefs.gf[idx].gfx_filter_integerscalelimit); if (cw2 > maxw || ch2 > maxh) { while (cw2 / mult - adjw > maxw || ch2 / mult - adjh > maxh) { @@ -461,11 +441,16 @@ void getfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int dst_width, int while (cw2 * (mult + multadd) - adjw <= maxw && ch2 * (mult + multadd) - adjh <= maxh) { mult += multadd; } + float multx = mult, multy = mult; // if width is smaller than height, double width (programmed modes) if (cw2 * (mult + multadd) - adjw <= maxw && cw2 < ch2) { multx += multadd; } + // if width is >2.5x height, double height (non-doublescanned superhires) + if (ch2 * (mult + multadd) - adjh <= maxh && cw2 > ch2 * 2.5) { + multy += multadd; + } maxw = (int)((maxw + multx - multadd) / multx); maxh = (int)((maxh + multy - multadd) / multy); } diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 317f95b5..b2c6ff5b 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -1599,14 +1599,22 @@ void getrtgfilterrect2(int monid, RECT *sr, RECT *dr, RECT *zr, int *mode, int d if (mon->scalepicasso == RTG_MODE_INTEGER_SCALE) { int divx = mon->currentmode.native_width / srcwidth; int divy = mon->currentmode.native_height / srcheight; - int mul = !divx || !divy ? 1 : (divx > divy ? divy : divx); - SetRect(dr, 0, 0, mon->currentmode.native_width / mul, mon->currentmode.native_height / mul); - int xx = (mon->currentmode.native_width / mul - srcwidth) / 2; - int yy = (mon->currentmode.native_height / mul - srcheight) / 2; + float mul = (float)(!divx || !divy ? 1 : (divx > divy ? divy : divx)); + if (!divx || !divy) { + if ((float)mon->currentmode.native_width / srcwidth <= 0.95f || ((float)mon->currentmode.native_height / srcheight <= 0.95f)) { + mul = 0.5f; + } + if ((float)mon->currentmode.native_width / srcwidth <= 0.45f || ((float)mon->currentmode.native_height / srcheight <= 0.45f)) { + mul = 0.25f; + } + } + SetRect(dr, 0, 0, (int)(mon->currentmode.native_width / mul), (int)(mon->currentmode.native_height / mul)); + int xx = (int)((mon->currentmode.native_width / mul - srcwidth) / 2); + int yy = (int)((mon->currentmode.native_height / mul - srcheight) / 2); picasso_offset_x = -xx; picasso_offset_y = -yy; - mx = (float)mul; - my = (float)mul; + mx = mul; + my = mul; outwidth = srcwidth; outheight = srcheight; *mode = 1; -- 2.47.3