Use dpi ref in ui context and weather

This commit is contained in:
Gymnasiast 2023-04-03 22:18:42 +02:00 committed by duncanspumpkin
parent 16c5c1b752
commit fc0e0d029a
12 changed files with 44 additions and 44 deletions

View File

@ -142,11 +142,11 @@ public:
_inGameConsole.Update();
}
void Draw(DrawPixelInfo* dpi) override
void Draw(DrawPixelInfo& dpi) override
{
auto bgColour = ThemeGetColour(WindowClass::Chat, 0);
ChatDraw(*dpi, bgColour);
_inGameConsole.Draw(*dpi);
ChatDraw(dpi, bgColour);
_inGameConsole.Draw(dpi);
}
// Window
@ -291,12 +291,12 @@ public:
return std::make_shared<DrawingEngineFactory>();
}
void DrawWeatherAnimation(IWeatherDrawer* weatherDrawer, DrawPixelInfo* dpi, DrawWeatherFunc drawFunc) override
void DrawWeatherAnimation(IWeatherDrawer* weatherDrawer, DrawPixelInfo& dpi, DrawWeatherFunc drawFunc) override
{
int32_t left = dpi->x;
int32_t right = left + dpi->width;
int32_t top = dpi->y;
int32_t bottom = top + dpi->height;
int32_t left = dpi.x;
int32_t right = left + dpi.width;
int32_t top = dpi.y;
int32_t bottom = top + dpi.height;
for (auto& w : g_window_list)
{
@ -888,7 +888,7 @@ private:
}
static void DrawWeatherWindow(
DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer, WindowBase* original_w, int16_t left, int16_t right, int16_t top,
DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer, WindowBase* original_w, int16_t left, int16_t right, int16_t top,
int16_t bottom, DrawWeatherFunc drawFunc)
{
WindowBase* w{};

View File

@ -131,7 +131,7 @@ public:
}
virtual void Draw(
DrawPixelInfo* dpi, int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
DrawPixelInfo& dpi, int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
const uint8_t* weatherpattern) override
{
const uint8_t* pattern = weatherpattern;
@ -141,7 +141,7 @@ public:
uint8_t patternStartXOffset = xStart % patternXSpace;
uint8_t patternStartYOffset = yStart % patternYSpace;
uint32_t pixelOffset = (dpi->pitch + dpi->width) * y + x;
uint32_t pixelOffset = (dpi.pitch + dpi.width) * y + x;
uint8_t patternYPos = patternStartYOffset % patternYSpace;
for (; height != 0; height--)
@ -157,14 +157,14 @@ public:
auto patternPixel = pattern[patternYPos * 2 + 1];
for (; xPixelOffset < finalPixelOffset; xPixelOffset += patternXSpace)
{
int32_t pixelX = xPixelOffset % dpi->width;
int32_t pixelY = (xPixelOffset / dpi->width) % dpi->height;
int32_t pixelX = xPixelOffset % dpi.width;
int32_t pixelY = (xPixelOffset / dpi.width) % dpi.height;
_drawingContext->DrawLine(dpi, patternPixel, { { pixelX, pixelY }, { pixelX + 1, pixelY + 1 } });
_drawingContext->DrawLine(&dpi, patternPixel, { { pixelX, pixelY }, { pixelX + 1, pixelY + 1 } });
}
}
pixelOffset += dpi->pitch + dpi->width;
pixelOffset += dpi.pitch + dpi.width;
patternYPos++;
patternYPos %= patternYSpace;
}
@ -332,7 +332,7 @@ public:
{
_drawingContext->CalculcateClipping(&_bitsDPI);
DrawWeather(&_bitsDPI, &_weatherDrawer);
DrawWeather(_bitsDPI, &_weatherDrawer);
}
std::string Screenshot() override

View File

@ -92,7 +92,7 @@ namespace OpenRCT2::Drawing
{
virtual ~IWeatherDrawer() = default;
virtual void Draw(
DrawPixelInfo* dpi, int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
DrawPixelInfo& dpi, int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
const uint8_t* weatherpattern) abstract;
};
} // namespace OpenRCT2::Drawing

View File

@ -23,13 +23,13 @@ using namespace OpenRCT2;
using namespace OpenRCT2::Drawing;
static void DrawLightRain(
DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
static void DrawHeavyRain(
DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
static void DrawLightSnow(
DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
static void DrawHeavySnow(
DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
/**
*
@ -51,7 +51,7 @@ const DrawWeatherFunc DrawSnowFunctions[] = {
*
* rct2: 0x00684218
*/
void DrawWeather(DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer)
void DrawWeather(DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer)
{
if (gConfigGeneral.RenderWeatherEffects)
{
@ -81,7 +81,7 @@ void DrawWeather(DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer)
* rct2: 0x00684114
*/
static void DrawLightRain(
DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
{
int32_t x_start = -static_cast<int32_t>(gCurrentTicks) + 8;
int32_t y_start = (gCurrentTicks * 3) + 7;
@ -103,7 +103,7 @@ static void DrawLightRain(
* rct2: 0x0068416D
*/
static void DrawHeavyRain(
DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
{
int32_t x_start = -static_cast<int32_t>(gCurrentTicks);
int32_t y_start = gCurrentTicks * 5;
@ -135,7 +135,7 @@ static void DrawHeavyRain(
}
static void DrawLightSnow(
DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
{
const uint32_t t = gCurrentTicks / 2;
const int32_t negT = -static_cast<int32_t>(t);
@ -157,7 +157,7 @@ static void DrawLightSnow(
}
static void DrawHeavySnow(
DrawPixelInfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
DrawPixelInfo& dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
{
int32_t x_start = -static_cast<int32_t>(gCurrentTicks * 3) + 1;
int32_t y_start = gCurrentTicks + 23;

View File

@ -37,4 +37,4 @@ static constexpr const uint8_t SnowPattern[] =
// clang-format on
void DrawWeather(DrawPixelInfo* dpi, OpenRCT2::Drawing::IWeatherDrawer* weatherDrawer);
void DrawWeather(DrawPixelInfo& dpi, OpenRCT2::Drawing::IWeatherDrawer* weatherDrawer);

View File

@ -44,7 +44,7 @@ X8WeatherDrawer::~X8WeatherDrawer()
}
void X8WeatherDrawer::Draw(
DrawPixelInfo* dpi, int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
DrawPixelInfo& dpi, int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
const uint8_t* weatherpattern)
{
const uint8_t* pattern = weatherpattern;
@ -54,10 +54,10 @@ void X8WeatherDrawer::Draw(
uint8_t patternStartXOffset = xStart % patternXSpace;
uint8_t patternStartYOffset = yStart % patternYSpace;
uint32_t pixelOffset = (dpi->pitch + dpi->width) * y + x;
uint32_t pixelOffset = (dpi.pitch + dpi.width) * y + x;
uint8_t patternYPos = patternStartYOffset % patternYSpace;
uint8_t* screenBits = dpi->bits;
uint8_t* screenBits = dpi.bits;
// Stores the colours of changed pixels
WeatherPixel* newPixels = &_weatherPixels[_weatherPixelsCount];
@ -86,7 +86,7 @@ void X8WeatherDrawer::Draw(
}
}
pixelOffset += dpi->pitch + dpi->width;
pixelOffset += dpi.pitch + dpi.width;
patternYPos++;
patternYPos %= patternYSpace;
}
@ -214,7 +214,7 @@ void X8DrawingEngine::PaintWindows()
void X8DrawingEngine::PaintWeather()
{
DrawWeather(&_bitsDPI, &_weatherDrawer);
DrawWeather(_bitsDPI, &_weatherDrawer);
}
void X8DrawingEngine::CopyRect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t dx, int32_t dy)

View File

@ -56,7 +56,7 @@ namespace OpenRCT2
X8WeatherDrawer();
~X8WeatherDrawer();
void Draw(
DrawPixelInfo* dpi, int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
DrawPixelInfo& dpi, int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
const uint8_t* weatherpattern) override;
void Restore(DrawPixelInfo* dpi);
};

View File

@ -50,11 +50,11 @@ void Painter::Paint(IDrawingEngine& de)
de.PaintWindows();
UpdatePaletteEffects();
_uiContext->Draw(dpi);
_uiContext->Draw(*dpi);
if ((gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && !TitleShouldHideVersionInfo())
{
DrawOpenRCT2(dpi, { 0, _uiContext->GetHeight() - 20 });
DrawOpenRCT2(*dpi, { 0, _uiContext->GetHeight() - 20 });
}
GfxDrawPickedUpPeep(dpi);

View File

@ -440,7 +440,7 @@ bool TitleIsPreviewingSequence()
return false;
}
void DrawOpenRCT2(DrawPixelInfo* dpi, const ScreenCoordsXY& screenCoords)
void DrawOpenRCT2(DrawPixelInfo& dpi, const ScreenCoordsXY& screenCoords)
{
thread_local std::string buffer;
buffer.clear();
@ -448,7 +448,7 @@ void DrawOpenRCT2(DrawPixelInfo* dpi, const ScreenCoordsXY& screenCoords)
// Write name and version information
buffer += gVersionInfoFull;
GfxDrawString(*dpi, screenCoords + ScreenCoordsXY(5, 5 - 13), buffer.c_str(), { COLOUR_BLACK });
GfxDrawString(dpi, screenCoords + ScreenCoordsXY(5, 5 - 13), buffer.c_str(), { COLOUR_BLACK });
// Invalidate screen area
int16_t width = static_cast<int16_t>(GfxGetStringWidth(buffer, FontStyle::Medium));
@ -461,5 +461,5 @@ void DrawOpenRCT2(DrawPixelInfo* dpi, const ScreenCoordsXY& screenCoords)
buffer.append(" (");
buffer.append(OPENRCT2_ARCHITECTURE);
buffer.append(")");
GfxDrawString(*dpi, screenCoords + ScreenCoordsXY(5, 5), buffer.c_str(), { COLOUR_BLACK });
GfxDrawString(dpi, screenCoords + ScreenCoordsXY(5, 5), buffer.c_str(), { COLOUR_BLACK });
}

View File

@ -65,4 +65,4 @@ size_t TitleGetCurrentSequence();
bool TitlePreviewSequence(size_t value);
void TitleStopPreviewingSequence();
bool TitleIsPreviewingSequence();
void DrawOpenRCT2(DrawPixelInfo* dpi, const ScreenCoordsXY& screenCoords);
void DrawOpenRCT2(DrawPixelInfo& dpi, const ScreenCoordsXY& screenCoords);

View File

@ -31,7 +31,7 @@ namespace OpenRCT2::Ui
void Tick() override
{
}
void Draw(DrawPixelInfo* /*dpi*/) override
void Draw(DrawPixelInfo& /*dpi*/) override
{
}
@ -173,7 +173,7 @@ namespace OpenRCT2::Ui
{
return std::make_shared<X8DrawingEngineFactory>();
}
void DrawWeatherAnimation(IWeatherDrawer* weatherDrawer, DrawPixelInfo* dpi, DrawWeatherFunc drawFunc) override
void DrawWeatherAnimation(IWeatherDrawer* weatherDrawer, DrawPixelInfo& dpi, DrawWeatherFunc drawFunc) override
{
}

View File

@ -29,7 +29,7 @@ namespace OpenRCT2
struct IDrawingEngineFactory;
struct IWeatherDrawer;
using DrawWeatherFunc = void (*)(
DrawPixelInfo* dpi, OpenRCT2::Drawing::IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width,
DrawPixelInfo& dpi, OpenRCT2::Drawing::IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width,
int32_t height);
} // namespace Drawing
@ -101,7 +101,7 @@ namespace OpenRCT2
virtual void Initialise() abstract;
virtual void Tick() abstract;
virtual void Draw(DrawPixelInfo* dpi) abstract;
virtual void Draw(DrawPixelInfo& dpi) abstract;
// Window
virtual void CreateWindow() abstract;
@ -149,7 +149,7 @@ namespace OpenRCT2
// Drawing
[[nodiscard]] virtual std::shared_ptr<Drawing::IDrawingEngineFactory> GetDrawingEngineFactory() abstract;
virtual void DrawWeatherAnimation(
OpenRCT2::Drawing::IWeatherDrawer* weatherDrawer, DrawPixelInfo* dpi,
OpenRCT2::Drawing::IWeatherDrawer* weatherDrawer, DrawPixelInfo& dpi,
OpenRCT2::Drawing::DrawWeatherFunc drawFunc) abstract;
// Text input