mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use dpi ref in misc drawing functions
This commit is contained in:
parent
bb83a80eab
commit
91f4c1e752
|
@ -554,7 +554,7 @@ namespace OpenRCT2::Ui::Windows
|
|||
{
|
||||
DrawPixelInfo widgetDpi;
|
||||
if (ClipDrawPixelInfo(
|
||||
&widgetDpi, &dpi, { windowPos.x + widget.left, windowPos.y + widget.top }, widget.width(),
|
||||
widgetDpi, dpi, { windowPos.x + widget.left, windowPos.y + widget.top }, widget.width(),
|
||||
widget.height()))
|
||||
{
|
||||
auto ctx = onDraw.context();
|
||||
|
|
|
@ -181,7 +181,7 @@ namespace OpenRCT2::Scripting
|
|||
void clip(int32_t x, int32_t y, int32_t width, int32_t height)
|
||||
{
|
||||
DrawPixelInfo newDpi;
|
||||
ClipDrawPixelInfo(&newDpi, &_dpi, { x, y }, width, height);
|
||||
ClipDrawPixelInfo(newDpi, _dpi, { x, y }, width, height);
|
||||
_dpi = newDpi;
|
||||
}
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ public:
|
|||
screenPos = windowPos + ScreenCoordsXY{ bkWidget.left + 1, bkWidget.top + 1 };
|
||||
const auto clipWidth = bkWidget.width() - 1;
|
||||
const auto clipHeight = bkWidget.height() - 1;
|
||||
if (ClipDrawPixelInfo(&clipDPI, &dpi, screenPos, clipWidth, clipHeight))
|
||||
if (ClipDrawPixelInfo(clipDPI, dpi, screenPos, clipWidth, clipHeight))
|
||||
{
|
||||
object->DrawPreview(clipDPI, clipWidth, clipHeight);
|
||||
}
|
||||
|
|
|
@ -1057,7 +1057,7 @@ public:
|
|||
auto screenPos = windowPos + ScreenCoordsXY{ previewWidget.left + 1, previewWidget.top + 1 };
|
||||
_width = previewWidget.width() - 1;
|
||||
int32_t _height = previewWidget.height() - 1;
|
||||
if (ClipDrawPixelInfo(&clipDPI, &dpi, screenPos, _width, _height))
|
||||
if (ClipDrawPixelInfo(clipDPI, dpi, screenPos, _width, _height))
|
||||
{
|
||||
_loadedObject->DrawPreview(clipDPI, _width, _height);
|
||||
}
|
||||
|
|
|
@ -580,7 +580,7 @@ static void WindowGameBottomToolbarDrawNewsItem(DrawPixelInfo& dpi, WindowBase*
|
|||
break;
|
||||
|
||||
DrawPixelInfo cliped_dpi;
|
||||
if (!ClipDrawPixelInfo(&cliped_dpi, &dpi, screenCoords + ScreenCoordsXY{ 1, 1 }, 22, 22))
|
||||
if (!ClipDrawPixelInfo(cliped_dpi, dpi, screenCoords + ScreenCoordsXY{ 1, 1 }, 22, 22))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -527,7 +527,7 @@ private:
|
|||
widgHeight++;
|
||||
|
||||
DrawPixelInfo clipDpi;
|
||||
if (!ClipDrawPixelInfo(&clipDpi, &dpi, screenCoords, widgWidth, widgHeight))
|
||||
if (!ClipDrawPixelInfo(clipDpi, dpi, screenCoords, widgWidth, widgHeight))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -783,7 +783,7 @@ private:
|
|||
int32_t top = marqueeWidget.top + windowPos.y;
|
||||
int32_t marqHeight = marqueeWidget.height();
|
||||
DrawPixelInfo dpiMarquee;
|
||||
if (!ClipDrawPixelInfo(&dpiMarquee, &dpi, { left, top }, marqWidth, marqHeight))
|
||||
if (!ClipDrawPixelInfo(dpiMarquee, dpi, { left, top }, marqWidth, marqHeight))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -401,7 +401,7 @@ static void WindowMultiplayerInformationPaint(WindowBase* w, DrawPixelInfo& dpi)
|
|||
WindowMultiplayerDrawTabImages(w, dpi);
|
||||
|
||||
DrawPixelInfo clippedDPI;
|
||||
if (ClipDrawPixelInfo(&clippedDPI, &dpi, w->windowPos, w->width, w->height))
|
||||
if (ClipDrawPixelInfo(clippedDPI, dpi, w->windowPos, w->width, w->height))
|
||||
{
|
||||
auto screenCoords = ScreenCoordsXY{ 3, 50 };
|
||||
int32_t width = w->width - 6;
|
||||
|
|
|
@ -232,7 +232,7 @@ public:
|
|||
case News::ItemType::PeepOnRide:
|
||||
{
|
||||
DrawPixelInfo cliped_dpi;
|
||||
if (!ClipDrawPixelInfo(&cliped_dpi, &dpi, screenCoords + ScreenCoordsXY{ 1, 1 }, 22, 22))
|
||||
if (!ClipDrawPixelInfo(cliped_dpi, dpi, screenCoords + ScreenCoordsXY{ 1, 1 }, 22, 22))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -937,7 +937,7 @@ static void WindowRideDrawTabVehicle(DrawPixelInfo& dpi, WindowBase* w)
|
|||
screenCoords += w->windowPos;
|
||||
|
||||
DrawPixelInfo clipDPI;
|
||||
if (!ClipDrawPixelInfo(&clipDPI, &dpi, screenCoords, width, height))
|
||||
if (!ClipDrawPixelInfo(clipDPI, dpi, screenCoords, width, height))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -4962,7 +4962,7 @@ static void WindowRideColourPaint(WindowBase* w, DrawPixelInfo& dpi)
|
|||
if (entrancePreviewWidget.type != WindowWidgetType::Empty)
|
||||
{
|
||||
if (ClipDrawPixelInfo(
|
||||
&clippedDpi, &dpi,
|
||||
clippedDpi, dpi,
|
||||
w->windowPos + ScreenCoordsXY{ entrancePreviewWidget.left + 1, entrancePreviewWidget.top + 1 },
|
||||
entrancePreviewWidget.width(), entrancePreviewWidget.height()))
|
||||
{
|
||||
|
|
|
@ -1517,7 +1517,7 @@ public:
|
|||
auto screenCoords = ScreenCoordsXY{ windowPos.x + widget->left + 1, windowPos.y + widget->top + 1 };
|
||||
widgetWidth = widget->width() - 1;
|
||||
widgetHeight = widget->height() - 1;
|
||||
if (ClipDrawPixelInfo(&clipdpi, &dpi, screenCoords, widgetWidth, widgetHeight))
|
||||
if (ClipDrawPixelInfo(clipdpi, dpi, screenCoords, widgetWidth, widgetHeight))
|
||||
{
|
||||
DrawTrackPiece(clipdpi, rideIndex, trackType, trackDirection, liftHillAndInvertedState, widgetWidth, widgetHeight);
|
||||
}
|
||||
|
|
|
@ -1618,7 +1618,7 @@ private:
|
|||
|
||||
DrawPixelInfo clipdpi;
|
||||
if (ClipDrawPixelInfo(
|
||||
&clipdpi, &dpi, topLeft + ScreenCoordsXY{ 1, 1 }, SCENERY_BUTTON_WIDTH - 2, SCENERY_BUTTON_HEIGHT - 2))
|
||||
clipdpi, dpi, topLeft + ScreenCoordsXY{ 1, 1 }, SCENERY_BUTTON_WIDTH - 2, SCENERY_BUTTON_HEIGHT - 2))
|
||||
{
|
||||
DrawSceneryItem(clipdpi, currentSceneryGlobal);
|
||||
}
|
||||
|
|
|
@ -553,7 +553,7 @@ private:
|
|||
widgetHeight++;
|
||||
|
||||
DrawPixelInfo clip_dpi;
|
||||
if (!ClipDrawPixelInfo(&clip_dpi, &dpi, screenCoords, widgetWidth, widgetHeight))
|
||||
if (!ClipDrawPixelInfo(clip_dpi, dpi, screenCoords, widgetWidth, widgetHeight))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -608,7 +608,7 @@ private:
|
|||
const auto& widget = widgets[widgetIndex];
|
||||
DrawPixelInfo clippedDpi;
|
||||
if (ClipDrawPixelInfo(
|
||||
&clippedDpi, &dpi, windowPos + ScreenCoordsXY{ widget.left + 1, widget.top + 1 },
|
||||
clippedDpi, dpi, windowPos + ScreenCoordsXY{ widget.left + 1, widget.top + 1 },
|
||||
widget.right - widget.left - 1, widget.bottom - widget.top - 1))
|
||||
{
|
||||
auto imageId = (_selectedTab == 3 ? (_tabAnimationIndex & ~3) : 0);
|
||||
|
|
|
@ -92,10 +92,10 @@ public:
|
|||
GfxFilterRect(dpi, { { left + 2, top + 0 }, { right - 2, top + 0 } }, FilterPaletteID::PaletteDarken3);
|
||||
|
||||
// Corners
|
||||
GfxFilterPixel(&dpi, { left + 1, top + 1 }, FilterPaletteID::PaletteDarken3);
|
||||
GfxFilterPixel(&dpi, { right - 1, top + 1 }, FilterPaletteID::PaletteDarken3);
|
||||
GfxFilterPixel(&dpi, { left + 1, bottom - 1 }, FilterPaletteID::PaletteDarken3);
|
||||
GfxFilterPixel(&dpi, { right - 1, bottom - 1 }, FilterPaletteID::PaletteDarken3);
|
||||
GfxFilterPixel(dpi, { left + 1, top + 1 }, FilterPaletteID::PaletteDarken3);
|
||||
GfxFilterPixel(dpi, { right - 1, top + 1 }, FilterPaletteID::PaletteDarken3);
|
||||
GfxFilterPixel(dpi, { left + 1, bottom - 1 }, FilterPaletteID::PaletteDarken3);
|
||||
GfxFilterPixel(dpi, { right - 1, bottom - 1 }, FilterPaletteID::PaletteDarken3);
|
||||
|
||||
// Text
|
||||
left = windowPos.x + ((width + 1) / 2) - 1;
|
||||
|
|
|
@ -292,7 +292,7 @@ public:
|
|||
|
||||
// Draw mini tile preview
|
||||
DrawPixelInfo clippedDpi;
|
||||
if (ClipDrawPixelInfo(&clippedDpi, &dpi, this->windowPos + ScreenCoordsXY{ 4, 18 }, 168, 78))
|
||||
if (ClipDrawPixelInfo(clippedDpi, dpi, this->windowPos + ScreenCoordsXY{ 4, 18 }, 168, 78))
|
||||
{
|
||||
G1Element g1temp = {};
|
||||
g1temp.offset = _miniPreview.data();
|
||||
|
|
|
@ -733,9 +733,9 @@ void MaskInit()
|
|||
}
|
||||
}
|
||||
|
||||
void GfxFilterPixel(DrawPixelInfo* dpi, const ScreenCoordsXY& coords, FilterPaletteID palette)
|
||||
void GfxFilterPixel(DrawPixelInfo& dpi, const ScreenCoordsXY& coords, FilterPaletteID palette)
|
||||
{
|
||||
GfxFilterRect(*dpi, { coords, coords }, palette);
|
||||
GfxFilterRect(dpi, { coords, coords }, palette);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -825,49 +825,49 @@ void GfxInvalidateScreen()
|
|||
* height (dx)
|
||||
* drawpixelinfo (edi)
|
||||
*/
|
||||
bool ClipDrawPixelInfo(DrawPixelInfo* dst, DrawPixelInfo* src, const ScreenCoordsXY& coords, int32_t width, int32_t height)
|
||||
bool ClipDrawPixelInfo(DrawPixelInfo& dst, DrawPixelInfo& src, const ScreenCoordsXY& coords, int32_t width, int32_t height)
|
||||
{
|
||||
int32_t right = coords.x + width;
|
||||
int32_t bottom = coords.y + height;
|
||||
|
||||
*dst = *src;
|
||||
dst->zoom_level = ZoomLevel{ 0 };
|
||||
dst = src;
|
||||
dst.zoom_level = ZoomLevel{ 0 };
|
||||
|
||||
if (coords.x > dst->x)
|
||||
if (coords.x > dst.x)
|
||||
{
|
||||
uint16_t clippedFromLeft = coords.x - dst->x;
|
||||
dst->width -= clippedFromLeft;
|
||||
dst->x = coords.x;
|
||||
dst->pitch += clippedFromLeft;
|
||||
dst->bits += clippedFromLeft;
|
||||
uint16_t clippedFromLeft = coords.x - dst.x;
|
||||
dst.width -= clippedFromLeft;
|
||||
dst.x = coords.x;
|
||||
dst.pitch += clippedFromLeft;
|
||||
dst.bits += clippedFromLeft;
|
||||
}
|
||||
|
||||
int32_t stickOutWidth = dst->x + dst->width - right;
|
||||
int32_t stickOutWidth = dst.x + dst.width - right;
|
||||
if (stickOutWidth > 0)
|
||||
{
|
||||
dst->width -= stickOutWidth;
|
||||
dst->pitch += stickOutWidth;
|
||||
dst.width -= stickOutWidth;
|
||||
dst.pitch += stickOutWidth;
|
||||
}
|
||||
|
||||
if (coords.y > dst->y)
|
||||
if (coords.y > dst.y)
|
||||
{
|
||||
uint16_t clippedFromTop = coords.y - dst->y;
|
||||
dst->height -= clippedFromTop;
|
||||
dst->y = coords.y;
|
||||
uint32_t bitsPlus = (dst->pitch + dst->width) * clippedFromTop;
|
||||
dst->bits += bitsPlus;
|
||||
uint16_t clippedFromTop = coords.y - dst.y;
|
||||
dst.height -= clippedFromTop;
|
||||
dst.y = coords.y;
|
||||
uint32_t bitsPlus = (dst.pitch + dst.width) * clippedFromTop;
|
||||
dst.bits += bitsPlus;
|
||||
}
|
||||
|
||||
int32_t bp = dst->y + dst->height - bottom;
|
||||
int32_t bp = dst.y + dst.height - bottom;
|
||||
if (bp > 0)
|
||||
{
|
||||
dst->height -= bp;
|
||||
dst.height -= bp;
|
||||
}
|
||||
|
||||
if (dst->width > 0 && dst->height > 0)
|
||||
if (dst.width > 0 && dst.height > 0)
|
||||
{
|
||||
dst->x -= coords.x;
|
||||
dst->y -= coords.y;
|
||||
dst.x -= coords.x;
|
||||
dst.y -= coords.y;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -891,11 +891,11 @@ void GfxInvalidatePickedUpPeep()
|
|||
}
|
||||
}
|
||||
|
||||
void GfxDrawPickedUpPeep(DrawPixelInfo* dpi)
|
||||
void GfxDrawPickedUpPeep(DrawPixelInfo& dpi)
|
||||
{
|
||||
if (gPickupPeepImage.HasValue())
|
||||
{
|
||||
GfxDrawSprite(*dpi, gPickupPeepImage, { gPickupPeepX, gPickupPeepY });
|
||||
GfxDrawSprite(dpi, gPickupPeepImage, { gPickupPeepX, gPickupPeepY });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -502,7 +502,7 @@ extern int32_t gPickupPeepY;
|
|||
|
||||
extern bool gTinyFontAntiAliased;
|
||||
|
||||
bool ClipDrawPixelInfo(DrawPixelInfo* dst, DrawPixelInfo* src, const ScreenCoordsXY& coords, int32_t width, int32_t height);
|
||||
bool ClipDrawPixelInfo(DrawPixelInfo& dst, DrawPixelInfo& src, const ScreenCoordsXY& coords, int32_t width, int32_t height);
|
||||
void GfxSetDirtyBlocks(const ScreenRect& rect);
|
||||
void GfxInvalidateScreen();
|
||||
|
||||
|
@ -512,9 +512,9 @@ void LoadPalette();
|
|||
|
||||
// other
|
||||
void GfxClear(DrawPixelInfo* dpi, uint8_t paletteIndex);
|
||||
void GfxFilterPixel(DrawPixelInfo* dpi, const ScreenCoordsXY& coords, FilterPaletteID palette);
|
||||
void GfxFilterPixel(DrawPixelInfo& dpi, const ScreenCoordsXY& coords, FilterPaletteID palette);
|
||||
void GfxInvalidatePickedUpPeep();
|
||||
void GfxDrawPickedUpPeep(DrawPixelInfo* dpi);
|
||||
void GfxDrawPickedUpPeep(DrawPixelInfo& dpi);
|
||||
|
||||
// line
|
||||
void GfxDrawLine(DrawPixelInfo& dpi, const ScreenLine& line, int32_t colour);
|
||||
|
|
|
@ -1440,9 +1440,7 @@ ImageId ScrollingTextSetup(
|
|||
|
||||
assert(scrollingMode < MAX_SCROLLING_TEXT_MODES);
|
||||
|
||||
DrawPixelInfo* dpi = &session.DPI;
|
||||
|
||||
if (dpi->zoom_level > ZoomLevel{ 0 })
|
||||
if (session.DPI.zoom_level > ZoomLevel{ 0 })
|
||||
return ImageId(SPR_SCROLLING_TEXT_DEFAULT);
|
||||
|
||||
_drawSCrollNextIndex++;
|
||||
|
|
|
@ -57,7 +57,7 @@ void Painter::Paint(IDrawingEngine& de)
|
|||
DrawOpenRCT2(*dpi, { 0, _uiContext->GetHeight() - 20 });
|
||||
}
|
||||
|
||||
GfxDrawPickedUpPeep(dpi);
|
||||
GfxDrawPickedUpPeep(*dpi);
|
||||
GfxInvalidatePickedUpPeep();
|
||||
|
||||
de.PaintWeather();
|
||||
|
|
Loading…
Reference in New Issue