mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-11 18:12:23 +01:00
Merge pull request #15538 from ZehMatt/feature/parallel-draw
Implement multithreaded drawing
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
- Fix: [#15503] Freeze when doing specific coaster merges with block brakes.
|
- Fix: [#15503] Freeze when doing specific coaster merges with block brakes.
|
||||||
- Fix: [#15514] Two different “quit to menu” menu items are available in track designer and track design manager.
|
- Fix: [#15514] Two different “quit to menu” menu items are available in track designer and track design manager.
|
||||||
- Improved: [#3417] Crash dumps are now placed in their own folder.
|
- Improved: [#3417] Crash dumps are now placed in their own folder.
|
||||||
|
- Improved: [#15538] Software rendering can now draw in parallel when Multithreading is enabled.
|
||||||
- Change: [#8601] Revert ToonTower base block fix to re-enable support blocking.
|
- Change: [#8601] Revert ToonTower base block fix to re-enable support blocking.
|
||||||
- Change: [#15174] [Plugin] Deprecate the type "peep" and add support to target a specific scripting api version.
|
- Change: [#15174] [Plugin] Deprecate the type "peep" and add support to target a specific scripting api version.
|
||||||
|
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ public:
|
|||||||
|
|
||||||
for (auto& w : g_window_list)
|
for (auto& w : g_window_list)
|
||||||
{
|
{
|
||||||
DrawWeatherWindow(weatherDrawer, w.get(), left, right, top, bottom, drawFunc);
|
DrawWeatherWindow(dpi, weatherDrawer, w.get(), left, right, top, bottom, drawFunc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -869,8 +869,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void DrawWeatherWindow(
|
static void DrawWeatherWindow(
|
||||||
IWeatherDrawer* weatherDrawer, rct_window* original_w, int16_t left, int16_t right, int16_t top, int16_t bottom,
|
rct_drawpixelinfo* dpi, IWeatherDrawer* weatherDrawer, rct_window* original_w, int16_t left, int16_t right, int16_t top,
|
||||||
DrawWeatherFunc drawFunc)
|
int16_t bottom, DrawWeatherFunc drawFunc)
|
||||||
{
|
{
|
||||||
rct_window* w{};
|
rct_window* w{};
|
||||||
auto itStart = window_get_iterator(original_w);
|
auto itStart = window_get_iterator(original_w);
|
||||||
@@ -890,7 +890,7 @@ private:
|
|||||||
{
|
{
|
||||||
auto width = right - left;
|
auto width = right - left;
|
||||||
auto height = bottom - top;
|
auto height = bottom - top;
|
||||||
drawFunc(weatherDrawer, left, top, width, height);
|
drawFunc(dpi, weatherDrawer, left, top, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -912,39 +912,39 @@ private:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawWeatherWindow(weatherDrawer, original_w, left, w->windowPos.x, top, bottom, drawFunc);
|
DrawWeatherWindow(dpi, weatherDrawer, original_w, left, w->windowPos.x, top, bottom, drawFunc);
|
||||||
|
|
||||||
left = w->windowPos.x;
|
left = w->windowPos.x;
|
||||||
DrawWeatherWindow(weatherDrawer, original_w, left, right, top, bottom, drawFunc);
|
DrawWeatherWindow(dpi, weatherDrawer, original_w, left, right, top, bottom, drawFunc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t w_right = RCT_WINDOW_RIGHT(w);
|
int16_t w_right = RCT_WINDOW_RIGHT(w);
|
||||||
if (right > w_right)
|
if (right > w_right)
|
||||||
{
|
{
|
||||||
DrawWeatherWindow(weatherDrawer, original_w, left, w_right, top, bottom, drawFunc);
|
DrawWeatherWindow(dpi, weatherDrawer, original_w, left, w_right, top, bottom, drawFunc);
|
||||||
|
|
||||||
left = w_right;
|
left = w_right;
|
||||||
DrawWeatherWindow(weatherDrawer, original_w, left, right, top, bottom, drawFunc);
|
DrawWeatherWindow(dpi, weatherDrawer, original_w, left, right, top, bottom, drawFunc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (top < w->windowPos.y)
|
if (top < w->windowPos.y)
|
||||||
{
|
{
|
||||||
DrawWeatherWindow(weatherDrawer, original_w, left, right, top, w->windowPos.y, drawFunc);
|
DrawWeatherWindow(dpi, weatherDrawer, original_w, left, right, top, w->windowPos.y, drawFunc);
|
||||||
|
|
||||||
top = w->windowPos.y;
|
top = w->windowPos.y;
|
||||||
DrawWeatherWindow(weatherDrawer, original_w, left, right, top, bottom, drawFunc);
|
DrawWeatherWindow(dpi, weatherDrawer, original_w, left, right, top, bottom, drawFunc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t w_bottom = RCT_WINDOW_BOTTOM(w);
|
int16_t w_bottom = RCT_WINDOW_BOTTOM(w);
|
||||||
if (bottom > w_bottom)
|
if (bottom > w_bottom)
|
||||||
{
|
{
|
||||||
DrawWeatherWindow(weatherDrawer, original_w, left, right, top, w_bottom, drawFunc);
|
DrawWeatherWindow(dpi, weatherDrawer, original_w, left, right, top, w_bottom, drawFunc);
|
||||||
|
|
||||||
top = w_bottom;
|
top = w_bottom;
|
||||||
DrawWeatherWindow(weatherDrawer, original_w, left, right, top, bottom, drawFunc);
|
DrawWeatherWindow(dpi, weatherDrawer, original_w, left, right, top, bottom, drawFunc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ class OpenGLDrawingContext final : public IDrawingContext
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
OpenGLDrawingEngine* _engine = nullptr;
|
OpenGLDrawingEngine* _engine = nullptr;
|
||||||
rct_drawpixelinfo* _dpi = nullptr;
|
|
||||||
ApplyTransparencyShader* _applyTransparencyShader = nullptr;
|
ApplyTransparencyShader* _applyTransparencyShader = nullptr;
|
||||||
DrawLineShader* _drawLineShader = nullptr;
|
DrawLineShader* _drawLineShader = nullptr;
|
||||||
DrawRectShader* _drawRectShader = nullptr;
|
DrawRectShader* _drawRectShader = nullptr;
|
||||||
@@ -101,27 +100,25 @@ public:
|
|||||||
void ResetPalette();
|
void ResetPalette();
|
||||||
void StartNewDraw();
|
void StartNewDraw();
|
||||||
|
|
||||||
void Clear(uint8_t paletteIndex) override;
|
void Clear(rct_drawpixelinfo* dpi, uint8_t paletteIndex) override;
|
||||||
void FillRect(uint32_t colour, int32_t x, int32_t y, int32_t w, int32_t h) override;
|
void FillRect(rct_drawpixelinfo* dpi, uint32_t colour, int32_t x, int32_t y, int32_t w, int32_t h) override;
|
||||||
void FilterRect(FilterPaletteID palette, int32_t left, int32_t top, int32_t right, int32_t bottom) override;
|
void FilterRect(
|
||||||
void DrawLine(uint32_t colour, const ScreenLine& line) override;
|
rct_drawpixelinfo* dpi, FilterPaletteID palette, int32_t left, int32_t top, int32_t right, int32_t bottom) override;
|
||||||
void DrawSprite(uint32_t image, int32_t x, int32_t y, uint32_t tertiaryColour) override;
|
void DrawLine(rct_drawpixelinfo* dpi, uint32_t colour, const ScreenLine& line) override;
|
||||||
void DrawSpriteRawMasked(int32_t x, int32_t y, uint32_t maskImage, uint32_t colourImage) override;
|
void DrawSprite(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, uint32_t tertiaryColour) override;
|
||||||
void DrawSpriteSolid(uint32_t image, int32_t x, int32_t y, uint8_t colour) override;
|
void DrawSpriteRawMasked(rct_drawpixelinfo* dpi, int32_t x, int32_t y, uint32_t maskImage, uint32_t colourImage) override;
|
||||||
void DrawGlyph(uint32_t image, int32_t x, int32_t y, const PaletteMap& palette) override;
|
void DrawSpriteSolid(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, uint8_t colour) override;
|
||||||
void DrawBitmap(uint32_t image, const void* pixels, int32_t width, int32_t height, int32_t x, int32_t y) override;
|
void DrawGlyph(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, const PaletteMap& palette) override;
|
||||||
|
void DrawBitmap(
|
||||||
|
rct_drawpixelinfo* dpi, uint32_t image, const void* pixels, int32_t width, int32_t height, int32_t x,
|
||||||
|
int32_t y) override;
|
||||||
|
|
||||||
void FlushCommandBuffers();
|
void FlushCommandBuffers();
|
||||||
|
|
||||||
void FlushLines();
|
void FlushLines();
|
||||||
void FlushRectangles();
|
void FlushRectangles();
|
||||||
void HandleTransparency();
|
void HandleTransparency();
|
||||||
|
void CalculcateClipping(rct_drawpixelinfo* dpi);
|
||||||
void SetDPI(rct_drawpixelinfo* dpi);
|
|
||||||
rct_drawpixelinfo* GetDPI() const
|
|
||||||
{
|
|
||||||
return _dpi;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpenGLWeatherDrawer final : public IWeatherDrawer
|
class OpenGLWeatherDrawer final : public IWeatherDrawer
|
||||||
@@ -135,7 +132,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void Draw(
|
virtual void Draw(
|
||||||
int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
|
rct_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* weatherpattern) override
|
||||||
{
|
{
|
||||||
const uint8_t* pattern = weatherpattern;
|
const uint8_t* pattern = weatherpattern;
|
||||||
@@ -145,8 +142,6 @@ public:
|
|||||||
uint8_t patternStartXOffset = xStart % patternXSpace;
|
uint8_t patternStartXOffset = xStart % patternXSpace;
|
||||||
uint8_t patternStartYOffset = yStart % patternYSpace;
|
uint8_t patternStartYOffset = yStart % patternYSpace;
|
||||||
|
|
||||||
const auto* dpi = _drawingContext->GetDPI();
|
|
||||||
|
|
||||||
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 patternYPos = patternStartYOffset % patternYSpace;
|
||||||
|
|
||||||
@@ -166,7 +161,7 @@ public:
|
|||||||
int32_t pixelX = xPixelOffset % dpi->width;
|
int32_t pixelX = xPixelOffset % dpi->width;
|
||||||
int32_t pixelY = (xPixelOffset / dpi->width) % dpi->height;
|
int32_t pixelY = (xPixelOffset / dpi->width) % dpi->height;
|
||||||
|
|
||||||
_drawingContext->DrawLine(patternPixel, { { pixelX, pixelY }, { pixelX + 1, pixelY + 1 } });
|
_drawingContext->DrawLine(dpi, patternPixel, { { pixelX, pixelY }, { pixelX + 1, pixelY + 1 } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,6 +293,7 @@ public:
|
|||||||
assert(_screenFramebuffer != nullptr);
|
assert(_screenFramebuffer != nullptr);
|
||||||
|
|
||||||
_drawingContext->StartNewDraw();
|
_drawingContext->StartNewDraw();
|
||||||
|
_drawingContext->CalculcateClipping(&_bitsDPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndDraw() override
|
void EndDraw() override
|
||||||
@@ -335,13 +331,16 @@ public:
|
|||||||
|
|
||||||
void PaintWindows() override
|
void PaintWindows() override
|
||||||
{
|
{
|
||||||
|
_drawingContext->CalculcateClipping(&_bitsDPI);
|
||||||
|
|
||||||
window_update_all_viewports();
|
window_update_all_viewports();
|
||||||
window_draw_all(&_bitsDPI, 0, 0, _width, _height);
|
window_draw_all(&_bitsDPI, 0, 0, _width, _height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintWeather() override
|
void PaintWeather() override
|
||||||
{
|
{
|
||||||
_drawingContext->SetDPI(&_bitsDPI);
|
_drawingContext->CalculcateClipping(&_bitsDPI);
|
||||||
|
|
||||||
DrawWeather(&_bitsDPI, &_weatherDrawer);
|
DrawWeather(&_bitsDPI, &_weatherDrawer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,9 +358,8 @@ public:
|
|||||||
// Not applicable for this engine
|
// Not applicable for this engine
|
||||||
}
|
}
|
||||||
|
|
||||||
IDrawingContext* GetDrawingContext(rct_drawpixelinfo* dpi) override
|
IDrawingContext* GetDrawingContext() override
|
||||||
{
|
{
|
||||||
_drawingContext->SetDPI(dpi);
|
|
||||||
return _drawingContext;
|
return _drawingContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,13 +539,18 @@ void OpenGLDrawingContext::StartNewDraw()
|
|||||||
_swapFramebuffer->Clear();
|
_swapFramebuffer->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDrawingContext::Clear(uint8_t paletteIndex)
|
void OpenGLDrawingContext::Clear(rct_drawpixelinfo* dpi, uint8_t paletteIndex)
|
||||||
{
|
{
|
||||||
FillRect(paletteIndex, _clipLeft - _offsetX, _clipTop - _offsetY, _clipRight - _offsetX, _clipBottom - _offsetY);
|
CalculcateClipping(dpi);
|
||||||
|
|
||||||
|
FillRect(dpi, paletteIndex, _clipLeft - _offsetX, _clipTop - _offsetY, _clipRight - _offsetX, _clipBottom - _offsetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDrawingContext::FillRect(uint32_t colour, int32_t left, int32_t top, int32_t right, int32_t bottom)
|
void OpenGLDrawingContext::FillRect(
|
||||||
|
rct_drawpixelinfo* dpi, uint32_t colour, int32_t left, int32_t top, int32_t right, int32_t bottom)
|
||||||
{
|
{
|
||||||
|
CalculcateClipping(dpi);
|
||||||
|
|
||||||
left += _offsetX;
|
left += _offsetX;
|
||||||
top += _offsetY;
|
top += _offsetY;
|
||||||
right += _offsetX;
|
right += _offsetX;
|
||||||
@@ -578,8 +581,11 @@ void OpenGLDrawingContext::FillRect(uint32_t colour, int32_t left, int32_t top,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDrawingContext::FilterRect(FilterPaletteID palette, int32_t left, int32_t top, int32_t right, int32_t bottom)
|
void OpenGLDrawingContext::FilterRect(
|
||||||
|
rct_drawpixelinfo* dpi, FilterPaletteID palette, int32_t left, int32_t top, int32_t right, int32_t bottom)
|
||||||
{
|
{
|
||||||
|
CalculcateClipping(dpi);
|
||||||
|
|
||||||
left += _offsetX;
|
left += _offsetX;
|
||||||
top += _offsetY;
|
top += _offsetY;
|
||||||
right += _offsetX;
|
right += _offsetX;
|
||||||
@@ -599,8 +605,10 @@ void OpenGLDrawingContext::FilterRect(FilterPaletteID palette, int32_t left, int
|
|||||||
command.depth = _drawCount++;
|
command.depth = _drawCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDrawingContext::DrawLine(uint32_t colour, const ScreenLine& line)
|
void OpenGLDrawingContext::DrawLine(rct_drawpixelinfo* dpi, uint32_t colour, const ScreenLine& line)
|
||||||
{
|
{
|
||||||
|
CalculcateClipping(dpi);
|
||||||
|
|
||||||
DrawLineCommand& command = _commandBuffers.lines.allocate();
|
DrawLineCommand& command = _commandBuffers.lines.allocate();
|
||||||
|
|
||||||
command.clip = { _clipLeft, _clipTop, _clipRight, _clipBottom };
|
command.clip = { _clipLeft, _clipTop, _clipRight, _clipBottom };
|
||||||
@@ -609,8 +617,10 @@ void OpenGLDrawingContext::DrawLine(uint32_t colour, const ScreenLine& line)
|
|||||||
command.depth = _drawCount++;
|
command.depth = _drawCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDrawingContext::DrawSprite(uint32_t image, int32_t x, int32_t y, uint32_t tertiaryColour)
|
void OpenGLDrawingContext::DrawSprite(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, uint32_t tertiaryColour)
|
||||||
{
|
{
|
||||||
|
CalculcateClipping(dpi);
|
||||||
|
|
||||||
int32_t g1Id = image & 0x7FFFF;
|
int32_t g1Id = image & 0x7FFFF;
|
||||||
auto g1Element = gfx_get_g1_element(g1Id);
|
auto g1Element = gfx_get_g1_element(g1Id);
|
||||||
if (g1Element == nullptr)
|
if (g1Element == nullptr)
|
||||||
@@ -618,20 +628,19 @@ void OpenGLDrawingContext::DrawSprite(uint32_t image, int32_t x, int32_t y, uint
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_dpi->zoom_level > 0)
|
if (dpi->zoom_level > 0)
|
||||||
{
|
{
|
||||||
if (g1Element->flags & G1_FLAG_HAS_ZOOM_SPRITE)
|
if (g1Element->flags & G1_FLAG_HAS_ZOOM_SPRITE)
|
||||||
{
|
{
|
||||||
rct_drawpixelinfo zoomedDPI;
|
rct_drawpixelinfo zoomedDPI;
|
||||||
zoomedDPI.bits = _dpi->bits;
|
zoomedDPI.bits = dpi->bits;
|
||||||
zoomedDPI.x = _dpi->x >> 1;
|
zoomedDPI.x = dpi->x >> 1;
|
||||||
zoomedDPI.y = _dpi->y >> 1;
|
zoomedDPI.y = dpi->y >> 1;
|
||||||
zoomedDPI.height = _dpi->height >> 1;
|
zoomedDPI.height = dpi->height >> 1;
|
||||||
zoomedDPI.width = _dpi->width >> 1;
|
zoomedDPI.width = dpi->width >> 1;
|
||||||
zoomedDPI.pitch = _dpi->pitch;
|
zoomedDPI.pitch = dpi->pitch;
|
||||||
zoomedDPI.zoom_level = _dpi->zoom_level - 1;
|
zoomedDPI.zoom_level = dpi->zoom_level - 1;
|
||||||
SetDPI(&zoomedDPI);
|
DrawSprite(&zoomedDPI, (image & 0xFFF80000) | (g1Id - g1Element->zoomed_offset), x >> 1, y >> 1, tertiaryColour);
|
||||||
DrawSprite((image & 0xFFF80000) | (g1Id - g1Element->zoomed_offset), x >> 1, y >> 1, tertiaryColour);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (g1Element->flags & G1_FLAG_NO_ZOOM_DRAW)
|
if (g1Element->flags & G1_FLAG_NO_ZOOM_DRAW)
|
||||||
@@ -644,11 +653,11 @@ void OpenGLDrawingContext::DrawSprite(uint32_t image, int32_t x, int32_t y, uint
|
|||||||
int32_t top = y + g1Element->y_offset;
|
int32_t top = y + g1Element->y_offset;
|
||||||
|
|
||||||
int32_t zoom_mask;
|
int32_t zoom_mask;
|
||||||
if (_dpi->zoom_level >= 0)
|
if (dpi->zoom_level >= 0)
|
||||||
zoom_mask = 0xFFFFFFFF * _dpi->zoom_level;
|
zoom_mask = 0xFFFFFFFF * dpi->zoom_level;
|
||||||
else
|
else
|
||||||
zoom_mask = 0xFFFFFFFF;
|
zoom_mask = 0xFFFFFFFF;
|
||||||
if (_dpi->zoom_level != 0 && (g1Element->flags & G1_FLAG_RLE_COMPRESSION))
|
if (dpi->zoom_level != 0 && (g1Element->flags & G1_FLAG_RLE_COMPRESSION))
|
||||||
{
|
{
|
||||||
top -= ~zoom_mask;
|
top -= ~zoom_mask;
|
||||||
}
|
}
|
||||||
@@ -664,7 +673,7 @@ void OpenGLDrawingContext::DrawSprite(uint32_t image, int32_t x, int32_t y, uint
|
|||||||
int32_t right = left + g1Element->width;
|
int32_t right = left + g1Element->width;
|
||||||
int32_t bottom = top + g1Element->height;
|
int32_t bottom = top + g1Element->height;
|
||||||
|
|
||||||
if (_dpi->zoom_level != 0 && (g1Element->flags & G1_FLAG_RLE_COMPRESSION))
|
if (dpi->zoom_level != 0 && (g1Element->flags & G1_FLAG_RLE_COMPRESSION))
|
||||||
{
|
{
|
||||||
bottom += top & ~zoom_mask;
|
bottom += top & ~zoom_mask;
|
||||||
}
|
}
|
||||||
@@ -678,15 +687,15 @@ void OpenGLDrawingContext::DrawSprite(uint32_t image, int32_t x, int32_t y, uint
|
|||||||
std::swap(top, bottom);
|
std::swap(top, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
left -= _dpi->x;
|
left -= dpi->x;
|
||||||
top -= _dpi->y;
|
top -= dpi->y;
|
||||||
right -= _dpi->x;
|
right -= dpi->x;
|
||||||
bottom -= _dpi->y;
|
bottom -= dpi->y;
|
||||||
|
|
||||||
left = left / _dpi->zoom_level;
|
left = left / dpi->zoom_level;
|
||||||
top = top / _dpi->zoom_level;
|
top = top / dpi->zoom_level;
|
||||||
right = right / _dpi->zoom_level;
|
right = right / dpi->zoom_level;
|
||||||
bottom = bottom / _dpi->zoom_level;
|
bottom = bottom / dpi->zoom_level;
|
||||||
|
|
||||||
left += _spriteOffset.x;
|
left += _spriteOffset.x;
|
||||||
top += _spriteOffset.y;
|
top += _spriteOffset.y;
|
||||||
@@ -759,8 +768,11 @@ void OpenGLDrawingContext::DrawSprite(uint32_t image, int32_t x, int32_t y, uint
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDrawingContext::DrawSpriteRawMasked(int32_t x, int32_t y, uint32_t maskImage, uint32_t colourImage)
|
void OpenGLDrawingContext::DrawSpriteRawMasked(
|
||||||
|
rct_drawpixelinfo* dpi, int32_t x, int32_t y, uint32_t maskImage, uint32_t colourImage)
|
||||||
{
|
{
|
||||||
|
CalculcateClipping(dpi);
|
||||||
|
|
||||||
auto g1ElementMask = gfx_get_g1_element(maskImage & 0x7FFFF);
|
auto g1ElementMask = gfx_get_g1_element(maskImage & 0x7FFFF);
|
||||||
auto g1ElementColour = gfx_get_g1_element(colourImage & 0x7FFFF);
|
auto g1ElementColour = gfx_get_g1_element(colourImage & 0x7FFFF);
|
||||||
if (g1ElementMask == nullptr || g1ElementColour == nullptr)
|
if (g1ElementMask == nullptr || g1ElementColour == nullptr)
|
||||||
@@ -790,15 +802,15 @@ void OpenGLDrawingContext::DrawSpriteRawMasked(int32_t x, int32_t y, uint32_t ma
|
|||||||
std::swap(top, bottom);
|
std::swap(top, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
left -= _dpi->x;
|
left -= dpi->x;
|
||||||
top -= _dpi->y;
|
top -= dpi->y;
|
||||||
right -= _dpi->x;
|
right -= dpi->x;
|
||||||
bottom -= _dpi->y;
|
bottom -= dpi->y;
|
||||||
|
|
||||||
left = left / _dpi->zoom_level;
|
left = left / dpi->zoom_level;
|
||||||
top = top / _dpi->zoom_level;
|
top = top / dpi->zoom_level;
|
||||||
right = right / _dpi->zoom_level;
|
right = right / dpi->zoom_level;
|
||||||
bottom = bottom / _dpi->zoom_level;
|
bottom = bottom / dpi->zoom_level;
|
||||||
|
|
||||||
left += _spriteOffset.x;
|
left += _spriteOffset.x;
|
||||||
top += _spriteOffset.y;
|
top += _spriteOffset.y;
|
||||||
@@ -819,8 +831,10 @@ void OpenGLDrawingContext::DrawSpriteRawMasked(int32_t x, int32_t y, uint32_t ma
|
|||||||
command.depth = _drawCount++;
|
command.depth = _drawCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDrawingContext::DrawSpriteSolid(uint32_t image, int32_t x, int32_t y, uint8_t colour)
|
void OpenGLDrawingContext::DrawSpriteSolid(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, uint8_t colour)
|
||||||
{
|
{
|
||||||
|
CalculcateClipping(dpi);
|
||||||
|
|
||||||
assert((colour & 0xFF) > 0u);
|
assert((colour & 0xFF) > 0u);
|
||||||
|
|
||||||
int32_t g1Id = image & 0x7FFFF;
|
int32_t g1Id = image & 0x7FFFF;
|
||||||
@@ -870,8 +884,10 @@ void OpenGLDrawingContext::DrawSpriteSolid(uint32_t image, int32_t x, int32_t y,
|
|||||||
command.depth = _drawCount++;
|
command.depth = _drawCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDrawingContext::DrawGlyph(uint32_t image, int32_t x, int32_t y, const PaletteMap& palette)
|
void OpenGLDrawingContext::DrawGlyph(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, const PaletteMap& palette)
|
||||||
{
|
{
|
||||||
|
CalculcateClipping(dpi);
|
||||||
|
|
||||||
auto g1Element = gfx_get_g1_element(image & 0x7FFFF);
|
auto g1Element = gfx_get_g1_element(image & 0x7FFFF);
|
||||||
if (g1Element == nullptr)
|
if (g1Element == nullptr)
|
||||||
{
|
{
|
||||||
@@ -894,15 +910,15 @@ void OpenGLDrawingContext::DrawGlyph(uint32_t image, int32_t x, int32_t y, const
|
|||||||
std::swap(top, bottom);
|
std::swap(top, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
left -= _dpi->x;
|
left -= dpi->x;
|
||||||
top -= _dpi->y;
|
top -= dpi->y;
|
||||||
right -= _dpi->x;
|
right -= dpi->x;
|
||||||
bottom -= _dpi->y;
|
bottom -= dpi->y;
|
||||||
|
|
||||||
left = left / _dpi->zoom_level;
|
left = left / dpi->zoom_level;
|
||||||
top = top / _dpi->zoom_level;
|
top = top / dpi->zoom_level;
|
||||||
right = right / _dpi->zoom_level;
|
right = right / dpi->zoom_level;
|
||||||
bottom = bottom / _dpi->zoom_level;
|
bottom = bottom / dpi->zoom_level;
|
||||||
|
|
||||||
left += _spriteOffset.x;
|
left += _spriteOffset.x;
|
||||||
top += _spriteOffset.y;
|
top += _spriteOffset.y;
|
||||||
@@ -923,8 +939,11 @@ void OpenGLDrawingContext::DrawGlyph(uint32_t image, int32_t x, int32_t y, const
|
|||||||
command.depth = _drawCount++;
|
command.depth = _drawCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDrawingContext::DrawBitmap(uint32_t image, const void* pixels, int32_t width, int32_t height, int32_t x, int32_t y)
|
void OpenGLDrawingContext::DrawBitmap(
|
||||||
|
rct_drawpixelinfo* dpi, uint32_t image, const void* pixels, int32_t width, int32_t height, int32_t x, int32_t y)
|
||||||
{
|
{
|
||||||
|
CalculcateClipping(dpi);
|
||||||
|
|
||||||
const auto texture = _textureCache->GetOrLoadBitmapTexture(image, pixels, width, height);
|
const auto texture = _textureCache->GetOrLoadBitmapTexture(image, pixels, width, height);
|
||||||
|
|
||||||
int32_t drawOffsetX = 0;
|
int32_t drawOffsetX = 0;
|
||||||
@@ -1041,7 +1060,7 @@ void OpenGLDrawingContext::HandleTransparency()
|
|||||||
_commandBuffers.transparent.clear();
|
_commandBuffers.transparent.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDrawingContext::SetDPI(rct_drawpixelinfo* dpi)
|
void OpenGLDrawingContext::CalculcateClipping(rct_drawpixelinfo* dpi)
|
||||||
{
|
{
|
||||||
auto screenDPI = _engine->GetDPI();
|
auto screenDPI = _engine->GetDPI();
|
||||||
auto bytesPerRow = screenDPI->GetBytesPerRow();
|
auto bytesPerRow = screenDPI->GetBytesPerRow();
|
||||||
@@ -1059,8 +1078,6 @@ void OpenGLDrawingContext::SetDPI(rct_drawpixelinfo* dpi)
|
|||||||
_offsetY = _clipTop - dpi->y;
|
_offsetY = _clipTop - dpi->y;
|
||||||
_spriteOffset.x = _clipLeft - dpi->remX;
|
_spriteOffset.x = _clipLeft - dpi->remX;
|
||||||
_spriteOffset.y = _clipTop - dpi->remY;
|
_spriteOffset.y = _clipTop - dpi->remY;
|
||||||
|
|
||||||
_dpi = dpi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* DISABLE_OPENGL */
|
#endif /* DISABLE_OPENGL */
|
||||||
|
|||||||
@@ -578,9 +578,9 @@ static void ttf_draw_string_raw_ttf(rct_drawpixelinfo* dpi, std::string_view tex
|
|||||||
auto baseId = uint32_t(0x7FFFF) - 1024;
|
auto baseId = uint32_t(0x7FFFF) - 1024;
|
||||||
auto imageId = baseId + _ttfGlId;
|
auto imageId = baseId + _ttfGlId;
|
||||||
auto drawingEngine = dpi->DrawingEngine;
|
auto drawingEngine = dpi->DrawingEngine;
|
||||||
auto drawingContext = drawingEngine->GetDrawingContext(dpi);
|
auto drawingContext = drawingEngine->GetDrawingContext();
|
||||||
drawingEngine->InvalidateImage(imageId);
|
drawingEngine->InvalidateImage(imageId);
|
||||||
drawingContext->DrawBitmap(imageId, surface->pixels, surface->pitch, surface->h, drawX, drawY);
|
drawingContext->DrawBitmap(dpi, imageId, surface->pixels, surface->pitch, surface->h, drawX, drawY);
|
||||||
|
|
||||||
_ttfGlId++;
|
_ttfGlId++;
|
||||||
if (_ttfGlId >= 1023)
|
if (_ttfGlId >= 1023)
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ int32_t gPickupPeepY;
|
|||||||
* rct2: 0x0009ABE0C
|
* rct2: 0x0009ABE0C
|
||||||
*/
|
*/
|
||||||
// clang-format off
|
// clang-format off
|
||||||
uint8_t gPeepPalette[256] = {
|
thread_local uint8_t gPeepPalette[256] = {
|
||||||
0x00, 0xF3, 0xF4, 0xF5, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
0x00, 0xF3, 0xF4, 0xF5, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
|
||||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||||
@@ -114,7 +114,7 @@ uint8_t gPeepPalette[256] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** rct2: 0x009ABF0C */
|
/** rct2: 0x009ABF0C */
|
||||||
uint8_t gOtherPalette[256] = {
|
thread_local uint8_t gOtherPalette[256] = {
|
||||||
0x00, 0xF3, 0xF4, 0xF5, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
0x00, 0xF3, 0xF4, 0xF5, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
|
||||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||||
|
|||||||
@@ -657,8 +657,8 @@ extern GamePalette gPalette;
|
|||||||
extern uint8_t gGamePalette[256 * 4];
|
extern uint8_t gGamePalette[256 * 4];
|
||||||
extern uint32_t gPaletteEffectFrame;
|
extern uint32_t gPaletteEffectFrame;
|
||||||
extern const FilterPaletteID GlassPaletteIds[COLOUR_COUNT];
|
extern const FilterPaletteID GlassPaletteIds[COLOUR_COUNT];
|
||||||
extern uint8_t gPeepPalette[256];
|
extern thread_local uint8_t gPeepPalette[256];
|
||||||
extern uint8_t gOtherPalette[256];
|
extern thread_local uint8_t gOtherPalette[256];
|
||||||
extern uint8_t text_palette[];
|
extern uint8_t text_palette[];
|
||||||
extern const translucent_window_palette TranslucentWindowPalettes[COLOUR_COUNT];
|
extern const translucent_window_palette TranslucentWindowPalettes[COLOUR_COUNT];
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,21 @@ namespace OpenRCT2::Drawing
|
|||||||
virtual ~IDrawingContext() = default;
|
virtual ~IDrawingContext() = default;
|
||||||
virtual OpenRCT2::Drawing::IDrawingEngine* GetEngine() abstract;
|
virtual OpenRCT2::Drawing::IDrawingEngine* GetEngine() abstract;
|
||||||
|
|
||||||
virtual void Clear(uint8_t paletteIndex) abstract;
|
virtual void Clear(rct_drawpixelinfo* dpi, uint8_t paletteIndex) abstract;
|
||||||
virtual void FillRect(uint32_t colour, int32_t left, int32_t top, int32_t right, int32_t bottom) abstract;
|
virtual void FillRect(
|
||||||
virtual void FilterRect(FilterPaletteID palette, int32_t left, int32_t top, int32_t right, int32_t bottom) abstract;
|
rct_drawpixelinfo* dpi, uint32_t colour, int32_t left, int32_t top, int32_t right, int32_t bottom) abstract;
|
||||||
virtual void DrawLine(uint32_t colour, const ScreenLine& line) abstract;
|
virtual void FilterRect(
|
||||||
virtual void DrawSprite(uint32_t image, int32_t x, int32_t y, uint32_t tertiaryColour) abstract;
|
rct_drawpixelinfo* dpi, FilterPaletteID palette, int32_t left, int32_t top, int32_t right, int32_t bottom) abstract;
|
||||||
virtual void DrawSpriteRawMasked(int32_t x, int32_t y, uint32_t maskImage, uint32_t colourImage) abstract;
|
virtual void DrawLine(rct_drawpixelinfo* dpi, uint32_t colour, const ScreenLine& line) abstract;
|
||||||
virtual void DrawSpriteSolid(uint32_t image, int32_t x, int32_t y, uint8_t colour) abstract;
|
virtual void DrawSprite(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, uint32_t tertiaryColour) abstract;
|
||||||
virtual void DrawGlyph(uint32_t image, int32_t x, int32_t y, const PaletteMap& palette) abstract;
|
virtual void DrawSpriteRawMasked(
|
||||||
|
rct_drawpixelinfo* dpi, int32_t x, int32_t y, uint32_t maskImage, uint32_t colourImage) abstract;
|
||||||
|
virtual void DrawSpriteSolid(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, uint8_t colour) abstract;
|
||||||
|
virtual void DrawGlyph(
|
||||||
|
rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, const PaletteMap& palette) abstract;
|
||||||
virtual void DrawBitmap(
|
virtual void DrawBitmap(
|
||||||
uint32_t image, const void* pixels, int32_t width, int32_t height, int32_t x, int32_t y) abstract;
|
rct_drawpixelinfo* dpi, uint32_t image, const void* pixels, int32_t width, int32_t height, int32_t x,
|
||||||
|
int32_t y) abstract;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OpenRCT2::Drawing
|
} // namespace OpenRCT2::Drawing
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ enum DRAWING_ENGINE_FLAGS
|
|||||||
* Whether or not the engine will only draw changed blocks of the screen each frame.
|
* Whether or not the engine will only draw changed blocks of the screen each frame.
|
||||||
*/
|
*/
|
||||||
DEF_DIRTY_OPTIMISATIONS = 1 << 0,
|
DEF_DIRTY_OPTIMISATIONS = 1 << 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The drawing engine is capable of processing the drawing in parallel.
|
||||||
|
*/
|
||||||
|
DEF_PARALLEL_DRAWING = 1 << 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rct_drawpixelinfo;
|
struct rct_drawpixelinfo;
|
||||||
@@ -66,7 +71,7 @@ namespace OpenRCT2::Drawing
|
|||||||
virtual void CopyRect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t dx, int32_t dy) abstract;
|
virtual void CopyRect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t dx, int32_t dy) abstract;
|
||||||
virtual std::string Screenshot() abstract;
|
virtual std::string Screenshot() abstract;
|
||||||
|
|
||||||
virtual IDrawingContext* GetDrawingContext(rct_drawpixelinfo* dpi) abstract;
|
virtual IDrawingContext* GetDrawingContext() abstract;
|
||||||
virtual rct_drawpixelinfo* GetDrawingPixelInfo() abstract;
|
virtual rct_drawpixelinfo* GetDrawingPixelInfo() abstract;
|
||||||
|
|
||||||
virtual DRAWING_ENGINE_FLAGS GetFlags() abstract;
|
virtual DRAWING_ENGINE_FLAGS GetFlags() abstract;
|
||||||
@@ -85,11 +90,9 @@ namespace OpenRCT2::Drawing
|
|||||||
|
|
||||||
struct IWeatherDrawer
|
struct IWeatherDrawer
|
||||||
{
|
{
|
||||||
virtual ~IWeatherDrawer()
|
virtual ~IWeatherDrawer() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
virtual void Draw(
|
virtual void Draw(
|
||||||
int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
|
rct_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;
|
const uint8_t* weatherpattern) abstract;
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Drawing
|
} // namespace OpenRCT2::Drawing
|
||||||
|
|||||||
@@ -165,8 +165,8 @@ void gfx_clear(rct_drawpixelinfo* dpi, uint8_t paletteIndex)
|
|||||||
auto drawingEngine = dpi->DrawingEngine;
|
auto drawingEngine = dpi->DrawingEngine;
|
||||||
if (drawingEngine != nullptr)
|
if (drawingEngine != nullptr)
|
||||||
{
|
{
|
||||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
IDrawingContext* dc = drawingEngine->GetDrawingContext();
|
||||||
dc->Clear(paletteIndex);
|
dc->Clear(dpi, paletteIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,8 +175,8 @@ void gfx_fill_rect(rct_drawpixelinfo* dpi, const ScreenRect& rect, int32_t colou
|
|||||||
auto drawingEngine = dpi->DrawingEngine;
|
auto drawingEngine = dpi->DrawingEngine;
|
||||||
if (drawingEngine != nullptr)
|
if (drawingEngine != nullptr)
|
||||||
{
|
{
|
||||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
IDrawingContext* dc = drawingEngine->GetDrawingContext();
|
||||||
dc->FillRect(colour, rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom());
|
dc->FillRect(dpi, colour, rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,8 +190,8 @@ void gfx_filter_rect(rct_drawpixelinfo* dpi, const ScreenRect& rect, FilterPalet
|
|||||||
auto drawingEngine = dpi->DrawingEngine;
|
auto drawingEngine = dpi->DrawingEngine;
|
||||||
if (drawingEngine != nullptr)
|
if (drawingEngine != nullptr)
|
||||||
{
|
{
|
||||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
IDrawingContext* dc = drawingEngine->GetDrawingContext();
|
||||||
dc->FilterRect(palette, rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom());
|
dc->FilterRect(dpi, palette, rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,8 +200,8 @@ void gfx_draw_line(rct_drawpixelinfo* dpi, const ScreenLine& line, int32_t colou
|
|||||||
auto drawingEngine = dpi->DrawingEngine;
|
auto drawingEngine = dpi->DrawingEngine;
|
||||||
if (drawingEngine != nullptr)
|
if (drawingEngine != nullptr)
|
||||||
{
|
{
|
||||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
IDrawingContext* dc = drawingEngine->GetDrawingContext();
|
||||||
dc->DrawLine(colour, line);
|
dc->DrawLine(dpi, colour, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,13 +227,13 @@ void gfx_draw_dashed_line(
|
|||||||
const int32_t lineYDist = std::abs(screenLine.GetY2() - screenLine.GetY1());
|
const int32_t lineYDist = std::abs(screenLine.GetY2() - screenLine.GetY1());
|
||||||
const int32_t dxPrecise = precisionFactor * lineXDist / lineSegmentCount / 2;
|
const int32_t dxPrecise = precisionFactor * lineXDist / lineSegmentCount / 2;
|
||||||
const int32_t dyPrecise = precisionFactor * lineYDist / lineSegmentCount / 2;
|
const int32_t dyPrecise = precisionFactor * lineYDist / lineSegmentCount / 2;
|
||||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
IDrawingContext* dc = drawingEngine->GetDrawingContext();
|
||||||
|
|
||||||
for (int32_t i = 0, x, y; i < lineSegmentCount; ++i)
|
for (int32_t i = 0, x, y; i < lineSegmentCount; ++i)
|
||||||
{
|
{
|
||||||
x = screenLine.GetX1() + dxPrecise * i * 2 / precisionFactor;
|
x = screenLine.GetX1() + dxPrecise * i * 2 / precisionFactor;
|
||||||
y = screenLine.GetY1() + dyPrecise * i * 2 / precisionFactor;
|
y = screenLine.GetY1() + dyPrecise * i * 2 / precisionFactor;
|
||||||
dc->DrawLine(color, { { x, y }, { x + dxPrecise / precisionFactor, y + dyPrecise / precisionFactor } });
|
dc->DrawLine(dpi, color, { { x, y }, { x + dxPrecise / precisionFactor, y + dyPrecise / precisionFactor } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,8 +248,8 @@ void FASTCALL gfx_draw_sprite(rct_drawpixelinfo* dpi, int32_t image, const Scree
|
|||||||
auto drawingEngine = dpi->DrawingEngine;
|
auto drawingEngine = dpi->DrawingEngine;
|
||||||
if (drawingEngine != nullptr)
|
if (drawingEngine != nullptr)
|
||||||
{
|
{
|
||||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
IDrawingContext* dc = drawingEngine->GetDrawingContext();
|
||||||
dc->DrawSprite(image, coords.x, coords.y, tertiary_colour);
|
dc->DrawSprite(dpi, image, coords.x, coords.y, tertiary_colour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,8 +258,8 @@ void FASTCALL gfx_draw_glyph(rct_drawpixelinfo* dpi, int32_t image, const Screen
|
|||||||
auto drawingEngine = dpi->DrawingEngine;
|
auto drawingEngine = dpi->DrawingEngine;
|
||||||
if (drawingEngine != nullptr)
|
if (drawingEngine != nullptr)
|
||||||
{
|
{
|
||||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
IDrawingContext* dc = drawingEngine->GetDrawingContext();
|
||||||
dc->DrawGlyph(image, coords.x, coords.y, paletteMap);
|
dc->DrawGlyph(dpi, image, coords.x, coords.y, paletteMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,8 +269,8 @@ void FASTCALL
|
|||||||
auto drawingEngine = dpi->DrawingEngine;
|
auto drawingEngine = dpi->DrawingEngine;
|
||||||
if (drawingEngine != nullptr)
|
if (drawingEngine != nullptr)
|
||||||
{
|
{
|
||||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
IDrawingContext* dc = drawingEngine->GetDrawingContext();
|
||||||
dc->DrawSpriteRawMasked(coords.x, coords.y, maskImage, colourImage);
|
dc->DrawSpriteRawMasked(dpi, coords.x, coords.y, maskImage, colourImage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,8 +279,8 @@ void FASTCALL gfx_draw_sprite_solid(rct_drawpixelinfo* dpi, int32_t image, const
|
|||||||
auto drawingEngine = dpi->DrawingEngine;
|
auto drawingEngine = dpi->DrawingEngine;
|
||||||
if (drawingEngine != nullptr)
|
if (drawingEngine != nullptr)
|
||||||
{
|
{
|
||||||
IDrawingContext* dc = drawingEngine->GetDrawingContext(dpi);
|
IDrawingContext* dc = drawingEngine->GetDrawingContext();
|
||||||
dc->DrawSpriteSolid(image, coords.x, coords.y, colour);
|
dc->DrawSpriteSolid(dpi, image, coords.x, coords.y, colour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,14 @@
|
|||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
using namespace OpenRCT2::Drawing;
|
using namespace OpenRCT2::Drawing;
|
||||||
|
|
||||||
static void DrawLightRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
static void DrawLightRain(
|
||||||
static void DrawHeavyRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
rct_drawpixelinfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
||||||
static void DrawLightSnow(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
static void DrawHeavyRain(
|
||||||
static void DrawHeavySnow(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
rct_drawpixelinfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
||||||
|
static void DrawLightSnow(
|
||||||
|
rct_drawpixelinfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
||||||
|
static void DrawHeavySnow(
|
||||||
|
rct_drawpixelinfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -76,59 +80,62 @@ void DrawWeather(rct_drawpixelinfo* dpi, IWeatherDrawer* weatherDrawer)
|
|||||||
*
|
*
|
||||||
* rct2: 0x00684114
|
* rct2: 0x00684114
|
||||||
*/
|
*/
|
||||||
static void DrawLightRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
|
static void DrawLightRain(
|
||||||
|
rct_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 x_start = -static_cast<int32_t>(gCurrentTicks) + 8;
|
||||||
int32_t y_start = (gCurrentTicks * 3) + 7;
|
int32_t y_start = (gCurrentTicks * 3) + 7;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, RainPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, RainPattern);
|
||||||
|
|
||||||
x_start = -static_cast<int32_t>(gCurrentTicks) + 0x18;
|
x_start = -static_cast<int32_t>(gCurrentTicks) + 0x18;
|
||||||
y_start = (gCurrentTicks * 4) + 0x0D;
|
y_start = (gCurrentTicks * 4) + 0x0D;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, RainPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, RainPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x0068416D
|
* rct2: 0x0068416D
|
||||||
*/
|
*/
|
||||||
static void DrawHeavyRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
|
static void DrawHeavyRain(
|
||||||
|
rct_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 x_start = -static_cast<int32_t>(gCurrentTicks);
|
||||||
int32_t y_start = gCurrentTicks * 5;
|
int32_t y_start = gCurrentTicks * 5;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, RainPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, RainPattern);
|
||||||
|
|
||||||
x_start = -static_cast<int32_t>(gCurrentTicks) + 0x10;
|
x_start = -static_cast<int32_t>(gCurrentTicks) + 0x10;
|
||||||
y_start = (gCurrentTicks * 6) + 5;
|
y_start = (gCurrentTicks * 6) + 5;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, RainPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, RainPattern);
|
||||||
|
|
||||||
x_start = -static_cast<int32_t>(gCurrentTicks) + 8;
|
x_start = -static_cast<int32_t>(gCurrentTicks) + 8;
|
||||||
y_start = (gCurrentTicks * 3) + 7;
|
y_start = (gCurrentTicks * 3) + 7;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, RainPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, RainPattern);
|
||||||
|
|
||||||
x_start = -static_cast<int32_t>(gCurrentTicks) + 0x18;
|
x_start = -static_cast<int32_t>(gCurrentTicks) + 0x18;
|
||||||
y_start = (gCurrentTicks * 4) + 0x0D;
|
y_start = (gCurrentTicks * 4) + 0x0D;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, RainPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, RainPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawLightSnow(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
|
static void DrawLightSnow(
|
||||||
|
rct_drawpixelinfo* dpi, IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
|
||||||
{
|
{
|
||||||
const uint32_t t = gCurrentTicks / 2;
|
const uint32_t t = gCurrentTicks / 2;
|
||||||
const int32_t negT = -static_cast<int32_t>(t);
|
const int32_t negT = -static_cast<int32_t>(t);
|
||||||
@@ -139,43 +146,44 @@ static void DrawLightSnow(IWeatherDrawer* weatherDrawer, int32_t left, int32_t t
|
|||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, SnowPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, SnowPattern);
|
||||||
|
|
||||||
x_start = negT + 16 + (cos(cosTick) * 6);
|
x_start = negT + 16 + (cos(cosTick) * 6);
|
||||||
y_start = t + 16;
|
y_start = t + 16;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, SnowPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, SnowPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawHeavySnow(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height)
|
static void DrawHeavySnow(
|
||||||
|
rct_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 x_start = -static_cast<int32_t>(gCurrentTicks * 3) + 1;
|
||||||
int32_t y_start = gCurrentTicks + 23;
|
int32_t y_start = gCurrentTicks + 23;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, SnowPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, SnowPattern);
|
||||||
|
|
||||||
x_start = -static_cast<int32_t>(gCurrentTicks * 4) + 6;
|
x_start = -static_cast<int32_t>(gCurrentTicks * 4) + 6;
|
||||||
y_start = gCurrentTicks + 5;
|
y_start = gCurrentTicks + 5;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, SnowPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, SnowPattern);
|
||||||
|
|
||||||
x_start = -static_cast<int32_t>(gCurrentTicks * 2) + 11;
|
x_start = -static_cast<int32_t>(gCurrentTicks * 2) + 11;
|
||||||
y_start = gCurrentTicks + 18;
|
y_start = gCurrentTicks + 18;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, SnowPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, SnowPattern);
|
||||||
|
|
||||||
x_start = -static_cast<int32_t>(gCurrentTicks * 3) + 17;
|
x_start = -static_cast<int32_t>(gCurrentTicks * 3) + 17;
|
||||||
y_start = gCurrentTicks + 11;
|
y_start = gCurrentTicks + 11;
|
||||||
y_start = -y_start;
|
y_start = -y_start;
|
||||||
x_start += left;
|
x_start += left;
|
||||||
y_start += top;
|
y_start += top;
|
||||||
weatherDrawer->Draw(left, top, width, height, x_start, y_start, SnowPattern);
|
weatherDrawer->Draw(dpi, left, top, width, height, x_start, y_start, SnowPattern);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,13 +43,9 @@ X8WeatherDrawer::~X8WeatherDrawer()
|
|||||||
delete[] _weatherPixels;
|
delete[] _weatherPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8WeatherDrawer::SetDPI(rct_drawpixelinfo* dpi)
|
|
||||||
{
|
|
||||||
_screenDPI = dpi;
|
|
||||||
}
|
|
||||||
|
|
||||||
void X8WeatherDrawer::Draw(
|
void X8WeatherDrawer::Draw(
|
||||||
int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart, const uint8_t* weatherpattern)
|
rct_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;
|
const uint8_t* pattern = weatherpattern;
|
||||||
auto patternXSpace = *pattern++;
|
auto patternXSpace = *pattern++;
|
||||||
@@ -58,10 +54,10 @@ void X8WeatherDrawer::Draw(
|
|||||||
uint8_t patternStartXOffset = xStart % patternXSpace;
|
uint8_t patternStartXOffset = xStart % patternXSpace;
|
||||||
uint8_t patternStartYOffset = yStart % patternYSpace;
|
uint8_t patternStartYOffset = yStart % patternYSpace;
|
||||||
|
|
||||||
uint32_t pixelOffset = (_screenDPI->pitch + _screenDPI->width) * y + x;
|
uint32_t pixelOffset = (dpi->pitch + dpi->width) * y + x;
|
||||||
uint8_t patternYPos = patternStartYOffset % patternYSpace;
|
uint8_t patternYPos = patternStartYOffset % patternYSpace;
|
||||||
|
|
||||||
uint8_t* screenBits = _screenDPI->bits;
|
uint8_t* screenBits = dpi->bits;
|
||||||
|
|
||||||
// Stores the colours of changed pixels
|
// Stores the colours of changed pixels
|
||||||
WeatherPixel* newPixels = &_weatherPixels[_weatherPixelsCount];
|
WeatherPixel* newPixels = &_weatherPixels[_weatherPixelsCount];
|
||||||
@@ -90,18 +86,18 @@ void X8WeatherDrawer::Draw(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pixelOffset += _screenDPI->pitch + _screenDPI->width;
|
pixelOffset += dpi->pitch + dpi->width;
|
||||||
patternYPos++;
|
patternYPos++;
|
||||||
patternYPos %= patternYSpace;
|
patternYPos %= patternYSpace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8WeatherDrawer::Restore()
|
void X8WeatherDrawer::Restore(rct_drawpixelinfo* dpi)
|
||||||
{
|
{
|
||||||
if (_weatherPixelsCount > 0)
|
if (_weatherPixelsCount > 0)
|
||||||
{
|
{
|
||||||
uint32_t numPixels = (_screenDPI->width + _screenDPI->pitch) * _screenDPI->height;
|
uint32_t numPixels = (dpi->width + dpi->pitch) * dpi->height;
|
||||||
uint8_t* bits = _screenDPI->bits;
|
uint8_t* bits = dpi->bits;
|
||||||
for (uint32_t i = 0; i < _weatherPixelsCount; i++)
|
for (uint32_t i = 0; i < _weatherPixelsCount; i++)
|
||||||
{
|
{
|
||||||
WeatherPixel weatherPixel = _weatherPixels[i];
|
WeatherPixel weatherPixel = _weatherPixels[i];
|
||||||
@@ -201,8 +197,7 @@ void X8DrawingEngine::BeginDraw()
|
|||||||
Resize(_width, _height);
|
Resize(_width, _height);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
_weatherDrawer.SetDPI(&_bitsDPI);
|
_weatherDrawer.Restore(&_bitsDPI);
|
||||||
_weatherDrawer.Restore();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,9 +266,8 @@ std::string X8DrawingEngine::Screenshot()
|
|||||||
return screenshot_dump_png(&_bitsDPI);
|
return screenshot_dump_png(&_bitsDPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
IDrawingContext* X8DrawingEngine::GetDrawingContext(rct_drawpixelinfo* dpi)
|
IDrawingContext* X8DrawingEngine::GetDrawingContext()
|
||||||
{
|
{
|
||||||
_drawingContext->SetDPI(dpi);
|
|
||||||
return _drawingContext;
|
return _drawingContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +278,7 @@ rct_drawpixelinfo* X8DrawingEngine::GetDrawingPixelInfo()
|
|||||||
|
|
||||||
DRAWING_ENGINE_FLAGS X8DrawingEngine::GetFlags()
|
DRAWING_ENGINE_FLAGS X8DrawingEngine::GetFlags()
|
||||||
{
|
{
|
||||||
return DEF_DIRTY_OPTIMISATIONS;
|
return static_cast<DRAWING_ENGINE_FLAGS>(DEF_DIRTY_OPTIMISATIONS | DEF_PARALLEL_DRAWING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingEngine::InvalidateImage([[maybe_unused]] uint32_t image)
|
void X8DrawingEngine::InvalidateImage([[maybe_unused]] uint32_t image)
|
||||||
@@ -466,10 +460,8 @@ IDrawingEngine* X8DrawingContext::GetEngine()
|
|||||||
return _engine;
|
return _engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingContext::Clear(uint8_t paletteIndex)
|
void X8DrawingContext::Clear(rct_drawpixelinfo* dpi, uint8_t paletteIndex)
|
||||||
{
|
{
|
||||||
rct_drawpixelinfo* dpi = _dpi;
|
|
||||||
|
|
||||||
int32_t w = dpi->width / dpi->zoom_level;
|
int32_t w = dpi->width / dpi->zoom_level;
|
||||||
int32_t h = dpi->height / dpi->zoom_level;
|
int32_t h = dpi->height / dpi->zoom_level;
|
||||||
uint8_t* ptr = dpi->bits;
|
uint8_t* ptr = dpi->bits;
|
||||||
@@ -529,10 +521,9 @@ static constexpr const uint16_t * Patterns[] = {
|
|||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
void X8DrawingContext::FillRect(uint32_t colour, int32_t left, int32_t top, int32_t right, int32_t bottom)
|
void X8DrawingContext::FillRect(
|
||||||
|
rct_drawpixelinfo* dpi, uint32_t colour, int32_t left, int32_t top, int32_t right, int32_t bottom)
|
||||||
{
|
{
|
||||||
rct_drawpixelinfo* dpi = _dpi;
|
|
||||||
|
|
||||||
if (left > right)
|
if (left > right)
|
||||||
return;
|
return;
|
||||||
if (top > bottom)
|
if (top > bottom)
|
||||||
@@ -650,10 +641,9 @@ void X8DrawingContext::FillRect(uint32_t colour, int32_t left, int32_t top, int3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingContext::FilterRect(FilterPaletteID palette, int32_t left, int32_t top, int32_t right, int32_t bottom)
|
void X8DrawingContext::FilterRect(
|
||||||
|
rct_drawpixelinfo* dpi, FilterPaletteID palette, int32_t left, int32_t top, int32_t right, int32_t bottom)
|
||||||
{
|
{
|
||||||
rct_drawpixelinfo* dpi = _dpi;
|
|
||||||
|
|
||||||
if (left > right)
|
if (left > right)
|
||||||
return;
|
return;
|
||||||
if (top > bottom)
|
if (top > bottom)
|
||||||
@@ -723,22 +713,23 @@ void X8DrawingContext::FilterRect(FilterPaletteID palette, int32_t left, int32_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingContext::DrawLine(uint32_t colour, const ScreenLine& line)
|
void X8DrawingContext::DrawLine(rct_drawpixelinfo* dpi, uint32_t colour, const ScreenLine& line)
|
||||||
{
|
{
|
||||||
gfx_draw_line_software(_dpi, line, colour);
|
gfx_draw_line_software(dpi, line, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingContext::DrawSprite(uint32_t image, int32_t x, int32_t y, uint32_t tertiaryColour)
|
void X8DrawingContext::DrawSprite(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, uint32_t tertiaryColour)
|
||||||
{
|
{
|
||||||
gfx_draw_sprite_software(_dpi, ImageId::FromUInt32(image, tertiaryColour), { x, y });
|
gfx_draw_sprite_software(dpi, ImageId::FromUInt32(image, tertiaryColour), { x, y });
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingContext::DrawSpriteRawMasked(int32_t x, int32_t y, uint32_t maskImage, uint32_t colourImage)
|
void X8DrawingContext::DrawSpriteRawMasked(
|
||||||
|
rct_drawpixelinfo* dpi, int32_t x, int32_t y, uint32_t maskImage, uint32_t colourImage)
|
||||||
{
|
{
|
||||||
gfx_draw_sprite_raw_masked_software(_dpi, { x, y }, maskImage, colourImage);
|
gfx_draw_sprite_raw_masked_software(dpi, { x, y }, maskImage, colourImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingContext::DrawSpriteSolid(uint32_t image, int32_t x, int32_t y, uint8_t colour)
|
void X8DrawingContext::DrawSpriteSolid(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, uint8_t colour)
|
||||||
{
|
{
|
||||||
uint8_t palette[256];
|
uint8_t palette[256];
|
||||||
std::fill_n(palette, sizeof(palette), colour);
|
std::fill_n(palette, sizeof(palette), colour);
|
||||||
@@ -746,15 +737,10 @@ void X8DrawingContext::DrawSpriteSolid(uint32_t image, int32_t x, int32_t y, uin
|
|||||||
|
|
||||||
const auto spriteCoords = ScreenCoordsXY{ x, y };
|
const auto spriteCoords = ScreenCoordsXY{ x, y };
|
||||||
gfx_draw_sprite_palette_set_software(
|
gfx_draw_sprite_palette_set_software(
|
||||||
_dpi, ImageId::FromUInt32((image & 0x7FFFF) | IMAGE_TYPE_REMAP), spriteCoords, PaletteMap(palette));
|
dpi, ImageId::FromUInt32((image & 0x7FFFF) | IMAGE_TYPE_REMAP), spriteCoords, PaletteMap(palette));
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingContext::DrawGlyph(uint32_t image, int32_t x, int32_t y, const PaletteMap& paletteMap)
|
void X8DrawingContext::DrawGlyph(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, const PaletteMap& paletteMap)
|
||||||
{
|
{
|
||||||
gfx_draw_sprite_palette_set_software(_dpi, ImageId::FromUInt32(image), { x, y }, paletteMap);
|
gfx_draw_sprite_palette_set_software(dpi, ImageId::FromUInt32(image), { x, y }, paletteMap);
|
||||||
}
|
|
||||||
|
|
||||||
void X8DrawingContext::SetDPI(rct_drawpixelinfo* dpi)
|
|
||||||
{
|
|
||||||
_dpi = dpi;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,16 +49,14 @@ namespace OpenRCT2
|
|||||||
size_t _weatherPixelsCapacity = MaxWeatherPixels;
|
size_t _weatherPixelsCapacity = MaxWeatherPixels;
|
||||||
uint32_t _weatherPixelsCount = 0;
|
uint32_t _weatherPixelsCount = 0;
|
||||||
WeatherPixel* _weatherPixels = nullptr;
|
WeatherPixel* _weatherPixels = nullptr;
|
||||||
rct_drawpixelinfo* _screenDPI = nullptr;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
X8WeatherDrawer();
|
X8WeatherDrawer();
|
||||||
~X8WeatherDrawer();
|
~X8WeatherDrawer();
|
||||||
void SetDPI(rct_drawpixelinfo* dpi);
|
|
||||||
void Draw(
|
void Draw(
|
||||||
int32_t x, int32_t y, int32_t width, int32_t height, int32_t xStart, int32_t yStart,
|
rct_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* weatherpattern) override;
|
||||||
void Restore();
|
void Restore(rct_drawpixelinfo* dpi);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __WARN_SUGGEST_FINAL_TYPES__
|
#ifdef __WARN_SUGGEST_FINAL_TYPES__
|
||||||
@@ -109,7 +107,7 @@ namespace OpenRCT2
|
|||||||
void PaintWeather() override;
|
void PaintWeather() override;
|
||||||
void CopyRect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t dx, int32_t dy) override;
|
void CopyRect(int32_t x, int32_t y, int32_t width, int32_t height, int32_t dx, int32_t dy) override;
|
||||||
std::string Screenshot() override;
|
std::string Screenshot() override;
|
||||||
IDrawingContext* GetDrawingContext(rct_drawpixelinfo* dpi) override;
|
IDrawingContext* GetDrawingContext() override;
|
||||||
rct_drawpixelinfo* GetDrawingPixelInfo() override;
|
rct_drawpixelinfo* GetDrawingPixelInfo() override;
|
||||||
DRAWING_ENGINE_FLAGS GetFlags() override;
|
DRAWING_ENGINE_FLAGS GetFlags() override;
|
||||||
void InvalidateImage(uint32_t image) override;
|
void InvalidateImage(uint32_t image) override;
|
||||||
@@ -135,26 +133,28 @@ namespace OpenRCT2
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
X8DrawingEngine* _engine = nullptr;
|
X8DrawingEngine* _engine = nullptr;
|
||||||
rct_drawpixelinfo* _dpi = nullptr;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit X8DrawingContext(X8DrawingEngine* engine);
|
explicit X8DrawingContext(X8DrawingEngine* engine);
|
||||||
|
|
||||||
IDrawingEngine* GetEngine() override;
|
IDrawingEngine* GetEngine() override;
|
||||||
|
|
||||||
void Clear(uint8_t paletteIndex) override;
|
void Clear(rct_drawpixelinfo* dpi, uint8_t paletteIndex) override;
|
||||||
void FillRect(uint32_t colour, int32_t x, int32_t y, int32_t w, int32_t h) override;
|
void FillRect(rct_drawpixelinfo* dpi, uint32_t colour, int32_t x, int32_t y, int32_t w, int32_t h) override;
|
||||||
void FilterRect(FilterPaletteID palette, int32_t left, int32_t top, int32_t right, int32_t bottom) override;
|
void FilterRect(
|
||||||
void DrawLine(uint32_t colour, const ScreenLine& line) override;
|
rct_drawpixelinfo* dpi, FilterPaletteID palette, int32_t left, int32_t top, int32_t right,
|
||||||
void DrawSprite(uint32_t image, int32_t x, int32_t y, uint32_t tertiaryColour) override;
|
int32_t bottom) override;
|
||||||
void DrawSpriteRawMasked(int32_t x, int32_t y, uint32_t maskImage, uint32_t colourImage) override;
|
void DrawLine(rct_drawpixelinfo* dpi, uint32_t colour, const ScreenLine& line) override;
|
||||||
void DrawSpriteSolid(uint32_t image, int32_t x, int32_t y, uint8_t colour) override;
|
void DrawSprite(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, uint32_t tertiaryColour) override;
|
||||||
void DrawGlyph(uint32_t image, int32_t x, int32_t y, const PaletteMap& paletteMap) override;
|
void DrawSpriteRawMasked(
|
||||||
void DrawBitmap(uint32_t image, const void* pixels, int32_t width, int32_t height, int32_t x, int32_t y) override
|
rct_drawpixelinfo* dpi, int32_t x, int32_t y, uint32_t maskImage, uint32_t colourImage) override;
|
||||||
|
void DrawSpriteSolid(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, uint8_t colour) override;
|
||||||
|
void DrawGlyph(rct_drawpixelinfo* dpi, uint32_t image, int32_t x, int32_t y, const PaletteMap& paletteMap) override;
|
||||||
|
void DrawBitmap(
|
||||||
|
rct_drawpixelinfo* dpi, uint32_t image, const void* pixels, int32_t width, int32_t height, int32_t x,
|
||||||
|
int32_t y) override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDPI(rct_drawpixelinfo* dpi);
|
|
||||||
};
|
};
|
||||||
} // namespace Drawing
|
} // namespace Drawing
|
||||||
} // namespace OpenRCT2
|
} // namespace OpenRCT2
|
||||||
|
|||||||
@@ -931,8 +931,6 @@ static void viewport_paint_column(paint_session* session)
|
|||||||
{
|
{
|
||||||
PaintDrawMoneyStructs(&session->DPI, session->PSStringHead);
|
PaintDrawMoneyStructs(&session->DPI, session->PSStringHead);
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintSessionFree(session);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -996,6 +994,12 @@ void viewport_paint(
|
|||||||
_paintJobs.reset();
|
_paintJobs.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool useParallelDrawing = false;
|
||||||
|
if (useMultithreading && (dpi->DrawingEngine->GetFlags() & DEF_PARALLEL_DRAWING))
|
||||||
|
{
|
||||||
|
useParallelDrawing = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Create space to record sessions and keep track which index is being drawn
|
// Create space to record sessions and keep track which index is being drawn
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
if (recorded_sessions != nullptr)
|
if (recorded_sessions != nullptr)
|
||||||
@@ -1005,7 +1009,7 @@ void viewport_paint(
|
|||||||
recorded_sessions->resize(columnCount);
|
recorded_sessions->resize(columnCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Splits the area into 32 pixel columns and renders them
|
// Generate and sort columns.
|
||||||
for (x = alignedX; x < rightBorder; x += 32, index++)
|
for (x = alignedX; x < rightBorder; x += 32, index++)
|
||||||
{
|
{
|
||||||
paint_session* session = PaintSessionAlloc(&dpi1, viewFlags);
|
paint_session* session = PaintSessionAlloc(&dpi1, viewFlags);
|
||||||
@@ -1046,9 +1050,27 @@ void viewport_paint(
|
|||||||
_paintJobs->Join();
|
_paintJobs->Join();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto column : _paintColumns)
|
// Paint columns.
|
||||||
|
for (auto* session : _paintColumns)
|
||||||
{
|
{
|
||||||
viewport_paint_column(column);
|
if (useParallelDrawing)
|
||||||
|
{
|
||||||
|
_paintJobs->AddTask([session]() -> void { viewport_paint_column(session); });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
viewport_paint_column(session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (useParallelDrawing)
|
||||||
|
{
|
||||||
|
_paintJobs->Join();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release resources.
|
||||||
|
for (auto* session : _paintColumns)
|
||||||
|
{
|
||||||
|
PaintSessionFree(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ namespace OpenRCT2
|
|||||||
struct IDrawingEngineFactory;
|
struct IDrawingEngineFactory;
|
||||||
struct IWeatherDrawer;
|
struct IWeatherDrawer;
|
||||||
using DrawWeatherFunc = void (*)(
|
using DrawWeatherFunc = void (*)(
|
||||||
OpenRCT2::Drawing::IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height);
|
rct_drawpixelinfo* dpi, OpenRCT2::Drawing::IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width,
|
||||||
|
int32_t height);
|
||||||
} // namespace Drawing
|
} // namespace Drawing
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
|
|||||||
Reference in New Issue
Block a user