1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-02-01 03:05:24 +01:00

Refactor DPI to distinguish screen and world coords

This commit is contained in:
Michael Bernardi
2024-09-16 03:42:54 +10:00
parent 68daa0d735
commit 4cd5548352
51 changed files with 471 additions and 386 deletions

View File

@@ -715,22 +715,22 @@ namespace OpenRCT2::Ui
DrawPixelInfo scroll_dpi = dpi;
// Clip the scroll dpi against the outer dpi
int32_t cl = std::max<int32_t>(dpi.x, topLeft.x);
int32_t ct = std::max<int32_t>(dpi.y, topLeft.y);
int32_t cr = std::min<int32_t>(dpi.x + dpi.width, bottomRight.x);
int32_t cb = std::min<int32_t>(dpi.y + dpi.height, bottomRight.y);
int32_t cl = std::max<int32_t>(dpi.ScreenX(), topLeft.x);
int32_t ct = std::max<int32_t>(dpi.ScreenY(), topLeft.y);
int32_t cr = std::min<int32_t>(dpi.ScreenX() + dpi.ScreenWidth(), bottomRight.x);
int32_t cb = std::min<int32_t>(dpi.ScreenY() + dpi.ScreenHeight(), bottomRight.y);
// Set the respective dpi attributes
scroll_dpi.x = cl - topLeft.x + scroll.contentOffsetX;
scroll_dpi.y = ct - topLeft.y + scroll.contentOffsetY;
scroll_dpi.width = cr - cl;
scroll_dpi.height = cb - ct;
scroll_dpi.bits += cl - dpi.x;
scroll_dpi.bits += (ct - dpi.y) * (dpi.width + dpi.pitch);
scroll_dpi.pitch = (dpi.width + dpi.pitch) - scroll_dpi.width;
scroll_dpi.SetX(cl - topLeft.x + scroll.contentOffsetX);
scroll_dpi.SetY(ct - topLeft.y + scroll.contentOffsetY);
scroll_dpi.SetWidth(cr - cl);
scroll_dpi.SetHeight(cb - ct);
scroll_dpi.bits += cl - dpi.ScreenX();
scroll_dpi.bits += (ct - dpi.ScreenY()) * dpi.LineStride();
scroll_dpi.pitch = dpi.LineStride() - scroll_dpi.ScreenWidth();
// Draw the scroll contents
if (scroll_dpi.width > 0 && scroll_dpi.height > 0)
if (scroll_dpi.ScreenWidth() > 0 && scroll_dpi.ScreenHeight() > 0)
w.OnScrollDraw(scrollIndex, scroll_dpi);
}