diff --git a/src/openrct2-ui/scripting/CustomListView.cpp b/src/openrct2-ui/scripting/CustomListView.cpp index 903a5bb8c0..2a9d95131d 100644 --- a/src/openrct2-ui/scripting/CustomListView.cpp +++ b/src/openrct2-ui/scripting/CustomListView.cpp @@ -549,21 +549,21 @@ void CustomListView::MouseUp(const ScreenCoordsXY& pos) } } -void CustomListView::Paint(WindowBase* w, DrawPixelInfo* dpi, const ScrollBar* scroll) const +void CustomListView::Paint(WindowBase* w, DrawPixelInfo& dpi, const ScrollBar* scroll) const { auto paletteIndex = ColourMapA[w->colours[1]].mid_light; - GfxFillRect(dpi, { { dpi->x, dpi->y }, { dpi->x + dpi->width, dpi->y + dpi->height } }, paletteIndex); + GfxFillRect(&dpi, { { dpi.x, dpi.y }, { dpi.x + dpi.width, dpi.y + dpi.height } }, paletteIndex); int32_t y = ShowColumnHeaders ? COLUMN_HEADER_HEIGHT : 0; for (size_t i = 0; i < Items.size(); i++) { - if (y > dpi->y + dpi->height) + if (y > dpi.y + dpi.height) { // Past the scroll view area break; } - if (y + LIST_ROW_HEIGHT >= dpi->y) + if (y + LIST_ROW_HEIGHT >= dpi.y) { const auto& itemIndex = static_cast(SortedItems[i]); const auto& item = Items[itemIndex]; @@ -583,19 +583,19 @@ void CustomListView::Paint(WindowBase* w, DrawPixelInfo* dpi, const ScrollBar* s if (isSelected) { GfxFilterRect( - dpi, { { dpi->x, y }, { dpi->x + dpi->width, y + (LIST_ROW_HEIGHT - 1) } }, + &dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + (LIST_ROW_HEIGHT - 1) } }, FilterPaletteID::PaletteDarken2); } else if (isHighlighted) { GfxFilterRect( - dpi, { { dpi->x, y }, { dpi->x + dpi->width, y + (LIST_ROW_HEIGHT - 1) } }, + &dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + (LIST_ROW_HEIGHT - 1) } }, FilterPaletteID::PaletteDarken2); } else if (isStriped) { GfxFillRect( - dpi, { { dpi->x, y }, { dpi->x + dpi->width, y + (LIST_ROW_HEIGHT - 1) } }, + &dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + (LIST_ROW_HEIGHT - 1) } }, ColourMapA[w->colours[1]].lighter | 0x1000000); } @@ -641,7 +641,7 @@ void CustomListView::Paint(WindowBase* w, DrawPixelInfo* dpi, const ScrollBar* s y = scroll->v_top; auto bgColour = ColourMapA[w->colours[1]].mid_light; - GfxFillRect(dpi, { { dpi->x, y }, { dpi->x + dpi->width, y + 12 } }, bgColour); + GfxFillRect(&dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + 12 } }, bgColour); int32_t x = 0; for (int32_t j = 0; j < static_cast(Columns.size()); j++) @@ -665,7 +665,7 @@ void CustomListView::Paint(WindowBase* w, DrawPixelInfo* dpi, const ScrollBar* s } void CustomListView::PaintHeading( - WindowBase* w, DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const std::string& text, + WindowBase* w, DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const std::string& text, ColumnSortOrder sortOrder, bool isPressed) const { auto boxFlags = 0; @@ -673,7 +673,7 @@ void CustomListView::PaintHeading( { boxFlags = INSET_RECT_FLAG_BORDER_INSET; } - GfxFillRectInset(dpi, { pos, pos + ScreenCoordsXY{ size.width - 1, size.height - 1 } }, w->colours[1], boxFlags); + GfxFillRectInset(&dpi, { pos, pos + ScreenCoordsXY{ size.width - 1, size.height - 1 } }, w->colours[1], boxFlags); if (!text.empty()) { PaintCell(dpi, pos, size, text.c_str(), false); @@ -683,18 +683,18 @@ void CustomListView::PaintHeading( { auto ft = Formatter(); ft.Add(STR_UP); - DrawTextBasic(*dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, { TextAlignment::RIGHT }); + DrawTextBasic(dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, { TextAlignment::RIGHT }); } else if (sortOrder == ColumnSortOrder::Descending) { auto ft = Formatter(); ft.Add(STR_DOWN); - DrawTextBasic(*dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, { TextAlignment::RIGHT }); + DrawTextBasic(dpi, pos + ScreenCoordsXY{ size.width - 1, 0 }, STR_BLACK_STRING, ft, { TextAlignment::RIGHT }); } } void CustomListView::PaintSeperator( - DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text) const + DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text) const { auto hasText = text != nullptr && text[0] != '\0'; auto left = pos.x + 4; @@ -712,7 +712,7 @@ void CustomListView::PaintSeperator( // Draw string Formatter ft; ft.Add(text); - DrawTextBasic(*dpi, { centreX, pos.y }, STR_STRING, ft, { baseColour, TextAlignment::CENTRE }); + DrawTextBasic(dpi, { centreX, pos.y }, STR_STRING, ft, { baseColour, TextAlignment::CENTRE }); // Get string dimensions FormatStringLegacy(gCommonStringFormatBuffer, sizeof(gCommonStringFormatBuffer), STR_STRING, ft.Data()); @@ -723,44 +723,44 @@ void CustomListView::PaintSeperator( // Draw light horizontal rule auto lightLineLeftTop1 = ScreenCoordsXY{ left, lineY0 }; auto lightLineRightBottom1 = ScreenCoordsXY{ strLeft, lineY0 }; - GfxDrawLine(dpi, { lightLineLeftTop1, lightLineRightBottom1 }, lightColour); + GfxDrawLine(&dpi, { lightLineLeftTop1, lightLineRightBottom1 }, lightColour); auto lightLineLeftTop2 = ScreenCoordsXY{ strRight, lineY0 }; auto lightLineRightBottom2 = ScreenCoordsXY{ right, lineY0 }; - GfxDrawLine(dpi, { lightLineLeftTop2, lightLineRightBottom2 }, lightColour); + GfxDrawLine(&dpi, { lightLineLeftTop2, lightLineRightBottom2 }, lightColour); // Draw dark horizontal rule auto darkLineLeftTop1 = ScreenCoordsXY{ left, lineY1 }; auto darkLineRightBottom1 = ScreenCoordsXY{ strLeft, lineY1 }; - GfxDrawLine(dpi, { darkLineLeftTop1, darkLineRightBottom1 }, darkColour); + GfxDrawLine(&dpi, { darkLineLeftTop1, darkLineRightBottom1 }, darkColour); auto darkLineLeftTop2 = ScreenCoordsXY{ strRight, lineY1 }; auto darkLineRightBottom2 = ScreenCoordsXY{ right, lineY1 }; - GfxDrawLine(dpi, { darkLineLeftTop2, darkLineRightBottom2 }, darkColour); + GfxDrawLine(&dpi, { darkLineLeftTop2, darkLineRightBottom2 }, darkColour); } else { // Draw light horizontal rule auto lightLineLeftTop1 = ScreenCoordsXY{ left, lineY0 }; auto lightLineRightBottom1 = ScreenCoordsXY{ right, lineY0 }; - GfxDrawLine(dpi, { lightLineLeftTop1, lightLineRightBottom1 }, lightColour); + GfxDrawLine(&dpi, { lightLineLeftTop1, lightLineRightBottom1 }, lightColour); // Draw dark horizontal rule auto darkLineLeftTop1 = ScreenCoordsXY{ left, lineY1 }; auto darkLineRightBottom1 = ScreenCoordsXY{ right, lineY1 }; - GfxDrawLine(dpi, { darkLineLeftTop1, darkLineRightBottom1 }, darkColour); + GfxDrawLine(&dpi, { darkLineLeftTop1, darkLineRightBottom1 }, darkColour); } } void CustomListView::PaintCell( - DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text, bool isHighlighted) const + DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text, bool isHighlighted) const { StringId stringId = isHighlighted ? STR_WINDOW_COLOUR_2_STRINGID : STR_BLACK_STRING; auto ft = Formatter(); ft.Add(STR_STRING); ft.Add(text); - DrawTextEllipsised(*dpi, pos, size.width, stringId, ft, {}); + DrawTextEllipsised(dpi, pos, size.width, stringId, ft, {}); } std::optional CustomListView::GetItemIndexAt(const ScreenCoordsXY& pos) diff --git a/src/openrct2-ui/scripting/CustomListView.h b/src/openrct2-ui/scripting/CustomListView.h index 3178d9121c..2cd5a1655f 100644 --- a/src/openrct2-ui/scripting/CustomListView.h +++ b/src/openrct2-ui/scripting/CustomListView.h @@ -136,15 +136,15 @@ namespace OpenRCT2::Ui::Windows void MouseOver(const ScreenCoordsXY& pos, bool isMouseDown); void MouseDown(const ScreenCoordsXY& pos); void MouseUp(const ScreenCoordsXY& pos); - void Paint(WindowBase* w, DrawPixelInfo* dpi, const ScrollBar* scroll) const; + void Paint(WindowBase* w, DrawPixelInfo& dpi, const ScrollBar* scroll) const; private: void PaintHeading( - WindowBase* w, DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const std::string& text, + WindowBase* w, DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const std::string& text, ColumnSortOrder sortOrder, bool isPressed) const; - void PaintSeperator(DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text) const; + void PaintSeperator(DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text) const; void PaintCell( - DrawPixelInfo* dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text, bool isHighlighted) const; + DrawPixelInfo& dpi, const ScreenCoordsXY& pos, const ScreenSize& size, const char* text, bool isHighlighted) const; std::optional GetItemIndexAt(const ScreenCoordsXY& pos); Widget* GetWidget() const; void Invalidate(); diff --git a/src/openrct2-ui/scripting/CustomWindow.cpp b/src/openrct2-ui/scripting/CustomWindow.cpp index e34c875947..b0d9d74b58 100644 --- a/src/openrct2-ui/scripting/CustomWindow.cpp +++ b/src/openrct2-ui/scripting/CustomWindow.cpp @@ -751,7 +751,7 @@ namespace OpenRCT2::Ui::Windows const auto& info = GetInfo(this); if (scrollIndex < static_cast(info.ListViews.size())) { - info.ListViews[scrollIndex].Paint(this, &dpi, &scrolls[scrollIndex]); + info.ListViews[scrollIndex].Paint(this, dpi, &scrolls[scrollIndex]); } } diff --git a/src/openrct2/drawing/NewDrawing.cpp b/src/openrct2/drawing/NewDrawing.cpp index 14c3cccc63..e1a4b164d9 100644 --- a/src/openrct2/drawing/NewDrawing.cpp +++ b/src/openrct2/drawing/NewDrawing.cpp @@ -115,11 +115,11 @@ void DrawingEngineDispose() } } -DrawPixelInfo* DrawingEngineGetDpi() +DrawPixelInfo& DrawingEngineGetDpi() { auto context = GetContext(); auto drawingEngine = context->GetDrawingEngine(); - return drawingEngine->GetDrawingPixelInfo(); + return *(drawingEngine->GetDrawingPixelInfo()); } bool DrawingEngineHasDirtyOptimisations() diff --git a/src/openrct2/drawing/NewDrawing.h b/src/openrct2/drawing/NewDrawing.h index 19dd91bad6..5fbe548568 100644 --- a/src/openrct2/drawing/NewDrawing.h +++ b/src/openrct2/drawing/NewDrawing.h @@ -25,7 +25,7 @@ void DrawingEngineSetPalette(const GamePalette& colours); void DrawingEngineCopyRect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t dx, int32_t dy); void DrawingEngineDispose(); -DrawPixelInfo* DrawingEngineGetDpi(); +DrawPixelInfo& DrawingEngineGetDpi(); bool DrawingEngineHasDirtyOptimisations(); void DrawingEngineInvalidateImage(uint32_t image); void DrawingEngineSetVSync(bool vsync); diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index b15b724e02..7b3cda8106 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -2801,8 +2801,7 @@ void Peep::Paint(PaintSession& session, int32_t imageDirection) const } } - DrawPixelInfo* dpi = &session.DPI; - if (dpi->zoom_level > ZoomLevel{ 2 }) + if (session.DPI.zoom_level > ZoomLevel{ 2 }) { return; } diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 207148f981..c53c0e05ad 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -479,8 +479,8 @@ static void ViewportMove(const ScreenCoordsXY& coords, WindowBase* w, Viewport* if (DrawingEngineHasDirtyOptimisations()) { - DrawPixelInfo* dpi = DrawingEngineGetDpi(); - WindowDrawAll(*dpi, left, top, right, bottom); + DrawPixelInfo& dpi = DrawingEngineGetDpi(); + WindowDrawAll(dpi, left, top, right, bottom); return; } } @@ -531,8 +531,8 @@ static void ViewportMove(const ScreenCoordsXY& coords, WindowBase* w, Viewport* if (DrawingEngineHasDirtyOptimisations()) { - DrawPixelInfo* dpi = DrawingEngineGetDpi(); - ViewportShiftPixels(*dpi, w, viewport, x_diff, y_diff); + DrawPixelInfo& dpi = DrawingEngineGetDpi(); + ViewportShiftPixels(dpi, w, viewport, x_diff, y_diff); } *viewport = view_copy; diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index fee8a92901..6664ffb5ca 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -85,7 +85,7 @@ namespace WindowCloseFlags } // namespace WindowCloseFlags static void WindowDrawCore(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom); -static void WindowDrawSingle(DrawPixelInfo* dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom); +static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom); std::list>::iterator WindowGetIterator(const WindowBase* w) { @@ -1203,56 +1203,55 @@ static void WindowDrawCore(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int3 auto* v = (*it).get(); if ((&w == v || (v->flags & WF_TRANSPARENT)) && WindowIsVisible(*v)) { - WindowDrawSingle(&dpi, *v, left, top, right, bottom); + WindowDrawSingle(dpi, *v, left, top, right, bottom); } } } -static void WindowDrawSingle(DrawPixelInfo* dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom) +static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom) { // Copy dpi so we can crop it - DrawPixelInfo copy = *dpi; - dpi = © + DrawPixelInfo copy = dpi; // Clamp left to 0 - int32_t overflow = left - dpi->x; + int32_t overflow = left - copy.x; if (overflow > 0) { - dpi->x += overflow; - dpi->width -= overflow; - if (dpi->width <= 0) + copy.x += overflow; + copy.width -= overflow; + if (copy.width <= 0) return; - dpi->pitch += overflow; - dpi->bits += overflow; + copy.pitch += overflow; + copy.bits += overflow; } // Clamp width to right - overflow = dpi->x + dpi->width - right; + overflow = copy.x + copy.width - right; if (overflow > 0) { - dpi->width -= overflow; - if (dpi->width <= 0) + copy.width -= overflow; + if (copy.width <= 0) return; - dpi->pitch += overflow; + copy.pitch += overflow; } // Clamp top to 0 - overflow = top - dpi->y; + overflow = top - copy.y; if (overflow > 0) { - dpi->y += overflow; - dpi->height -= overflow; - if (dpi->height <= 0) + copy.y += overflow; + copy.height -= overflow; + if (copy.height <= 0) return; - dpi->bits += (dpi->width + dpi->pitch) * overflow; + copy.bits += (copy.width + copy.pitch) * overflow; } // Clamp height to bottom - overflow = dpi->y + dpi->height - bottom; + overflow = copy.y + copy.height - bottom; if (overflow > 0) { - dpi->height -= overflow; - if (dpi->height <= 0) + copy.height -= overflow; + if (copy.height <= 0) return; } @@ -1266,7 +1265,7 @@ static void WindowDrawSingle(DrawPixelInfo* dpi, WindowBase& w, int32_t left, in gCurrentWindowColours[2] = NOT_TRANSLUCENT(w.colours[2]); gCurrentWindowColours[3] = NOT_TRANSLUCENT(w.colours[3]); - WindowEventPaintCall(&w, *dpi); + WindowEventPaintCall(&w, copy); } /** diff --git a/src/openrct2/ride/gentle/MiniGolf.cpp b/src/openrct2/ride/gentle/MiniGolf.cpp index 87fbdef5c2..5a59701e36 100644 --- a/src/openrct2/ride/gentle/MiniGolf.cpp +++ b/src/openrct2/ride/gentle/MiniGolf.cpp @@ -1190,8 +1190,7 @@ void VehicleVisualMiniGolfPlayer( return; } - DrawPixelInfo* edi = &session.DPI; - if (edi->zoom_level >= ZoomLevel{ 2 }) + if (session.DPI.zoom_level >= ZoomLevel{ 2 }) { return; } @@ -1227,8 +1226,7 @@ void VehicleVisualMiniGolfBall( return; } - DrawPixelInfo* edi = &session.DPI; - if (edi->zoom_level >= ZoomLevel{ 1 }) + if (session.DPI.zoom_level >= ZoomLevel{ 1 }) { return; } diff --git a/src/openrct2/ride/gentle/SpiralSlide.cpp b/src/openrct2/ride/gentle/SpiralSlide.cpp index 1bd16f22ec..1032121658 100644 --- a/src/openrct2/ride/gentle/SpiralSlide.cpp +++ b/src/openrct2/ride/gentle/SpiralSlide.cpp @@ -134,8 +134,7 @@ static void SpiralSlidePaintTileFront( PaintAddImageAsParent(session, imageId, { 16, 16, height }, { { 8, 0, height + 3 }, { 8, 16, 108 } }); } - DrawPixelInfo* dpi = &session.DPI; - if (dpi->zoom_level <= ZoomLevel{ 0 } && ride.slide_in_use != 0) + if (session.DPI.zoom_level <= ZoomLevel{ 0 } && ride.slide_in_use != 0) { uint8_t slide_progress = ride.spiral_slide_progress; if (slide_progress != 0)