From 7e58c18000dbae473f2f8e736285ecf6ae538a76 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 24 Mar 2025 19:02:11 +0200 Subject: [PATCH] Filter update. --- od-win32/direct3d.cpp | 4 ++-- od-win32/direct3d11.cpp | 8 ++++---- od-win32/gdirender.cpp | 12 ++++++------ od-win32/win32_scaler.cpp | 24 ++++++++++++++++-------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index f79608f8..6866f031 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -2101,8 +2101,8 @@ static void setupscenecoords(struct d3dstruct *d3d, bool normalrender, int monid float dw = (float)ds.dstwidth; float dh = (float)ds.dstheight; - float w = ds.outwidth; - float h = ds.outheight; + float w = (float)ds.outwidth; + float h = (float)ds.outheight; d3d->fakesize.x = w; d3d->fakesize.y = h; diff --git a/od-win32/direct3d11.cpp b/od-win32/direct3d11.cpp index d181b162..edd06db5 100644 --- a/od-win32/direct3d11.cpp +++ b/od-win32/direct3d11.cpp @@ -1581,8 +1581,8 @@ static void setupscenecoords(struct d3d11struct *d3d, bool normalrender, int mon float sw = dw / d3d->m_screenWidth; float sh = dh / d3d->m_screenHeight; - int xshift = -ds.xoffset; - int yshift = -ds.yoffset; + float xshift = (float)-ds.xoffset; + float yshift = (float)-ds.yoffset; xshift -= (w - d3d->m_screenWidth) / 2; yshift -= (h - d3d->m_screenHeight) / 2; @@ -5055,8 +5055,6 @@ static bool xD3D11_alloctexture(int monid, int w, int h) D3D_unlocktexture(monid, -1, -1); } - recheck(d3d, monid); - if (d3d->invalidmode || !d3d->m_device) { return false; } @@ -5069,6 +5067,8 @@ static bool xD3D11_alloctexture(int monid, int w, int h) d3d->m_bitmapWidthX = d3d->m_bitmapWidth * d3d->dmultxh; d3d->m_bitmapHeightX = d3d->m_bitmapHeight * d3d->dmultxv; + recheck(d3d, monid); + v = CreateTexture(d3d); if (!v) return false; diff --git a/od-win32/gdirender.cpp b/od-win32/gdirender.cpp index 51d937ed..e8340ab5 100644 --- a/od-win32/gdirender.cpp +++ b/od-win32/gdirender.cpp @@ -95,20 +95,20 @@ static void setupscenecoords(struct gdistruct *gdi, int monid) float w = (float)ds.outwidth; float h = (float)ds.outheight; - int tx = (dw * gdi->bm.width) / (gdi->wwidth * 2); - int ty = (dh * gdi->bm.height) / (gdi->wheight * 2); + float tx = (dw * gdi->bm.width) / (gdi->wwidth * 2); + float ty = (dh * gdi->bm.height) / (gdi->wheight * 2); float sw = dw / gdi->wwidth; float sh = dh / gdi->wheight; - int xshift = -ds.xoffset; - int yshift = -ds.yoffset; + float xshift = (float)-ds.xoffset; + float yshift = (float)-ds.yoffset; xshift -= (w - gdi->wwidth) / 2; yshift -= (h - gdi->wheight) / 2; - gdi->xoffset = tx + xshift - gdi->wwidth / 2; - gdi->yoffset = ty + yshift - gdi->wheight / 2; + gdi->xoffset = (int)(tx + xshift - gdi->wwidth / 2); + gdi->yoffset = (int)(ty + yshift - gdi->wheight / 2); gdi->xmult = filterrectmult(gdi->wwidth, w, gdi->dmode); gdi->ymult = filterrectmult(gdi->wheight, h, gdi->dmode); diff --git a/od-win32/win32_scaler.cpp b/od-win32/win32_scaler.cpp index d27f2651..4e6d1354 100644 --- a/od-win32/win32_scaler.cpp +++ b/od-win32/win32_scaler.cpp @@ -201,8 +201,6 @@ void getfilterdata(int monid, struct displayscale *ds) store_custom_limits (-1, -1, -1, -1); ds->mode = 0; - ds->outwidth = ds->srcwidth; - ds->outheight = ds->srcheight; if (mon->screen_is_picasso) { getrtgfilterdata(monid, ds); @@ -288,6 +286,9 @@ void getfilterdata(int monid, struct displayscale *ds) filterxmult = (float)ds->scale; filterymult = (float)ds->scale; + ds->xoffset = 0; + ds->yoffset = 0; + if (scalemode == AUTOSCALE_STATIC_MAX || scalemode == AUTOSCALE_STATIC_NOMINAL || scalemode == AUTOSCALE_INTEGER || scalemode == AUTOSCALE_INTEGER_AUTOSCALE) { @@ -395,8 +396,8 @@ void getfilterdata(int monid, struct displayscale *ds) mult += multadd; } float multx = mult, multy = mult; - maxw = maxw * mult; - maxh = maxh * mult; + maxw = (int)(maxw * mult); + maxh = (int)(maxh * mult); } else { while (((cw2 * (mult + multadd)) / m) - adjw <= maxw && ch2 * (mult + multadd) - adjh <= maxh) { mult += multadd; @@ -411,8 +412,8 @@ void getfilterdata(int monid, struct displayscale *ds) if (ch2 * (mult * 2) - adjh <= maxh && cw2 > ch2 * 2.4) { multy *= 2; } - maxw = (maxw + mult - multadd) / mult; - maxh = (maxh + mult - multadd) / mult; + maxw = (int)((maxw + mult - multadd) / mult); + maxh = (int)((maxh + mult - multadd) / mult); } } @@ -611,14 +612,21 @@ void getfilterdata(int monid, struct displayscale *ds) ds->xoffset += (int)(-filter_horiz_offset * aws); ds->yoffset += (int)(-filter_vert_offset * ahs); - diff = ds->dstwidth; + diff = ds->outwidth; filterxmult = ((float)ds->dstwidth * ds->scale) / diff; - diff = ds->dstheight; + diff = ds->outheight; filterymult = ((float)ds->dstheight * ds->scale) / diff; goto end; } + } else { + + ds->outwidth = ds->dstwidth; + ds->outheight = ds->dstheight; + ds->xoffset = (ds->srcwidth - ds->dstwidth) / 2; + ds->yoffset = (ds->srcheight - ds->dstheight) / 2; + } cont: -- 2.47.3