1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-30 23:54:35 +01:00

Codechange: Add distinct type to hold pixel drawing colour. (#14457)

This is used for individual pixels as well as line drawing.
This commit is contained in:
Peter Nelson
2025-07-20 22:57:55 +01:00
committed by GitHub
parent 821784004d
commit 8e2df7809b
49 changed files with 246 additions and 234 deletions

View File

@@ -29,23 +29,23 @@ void *Blitter_8bppBase::MoveTo(void *video, int x, int y)
return (uint8_t *)video + x + y * _screen.pitch;
}
void Blitter_8bppBase::SetPixel(void *video, int x, int y, uint8_t colour)
void Blitter_8bppBase::SetPixel(void *video, int x, int y, PixelColour colour)
{
*((uint8_t *)video + x + y * _screen.pitch) = colour;
*((uint8_t *)video + x + y * _screen.pitch) = colour.p;
}
void Blitter_8bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
void Blitter_8bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, PixelColour colour, int width, int dash)
{
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
*((uint8_t *)video + x + y * _screen.pitch) = colour;
*((uint8_t *)video + x + y * _screen.pitch) = colour.p;
});
}
void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8_t colour)
void Blitter_8bppBase::DrawRect(void *video, int width, int height, PixelColour colour)
{
std::byte *p = static_cast<std::byte *>(video);
do {
std::fill_n(p, width, static_cast<std::byte>(colour));
std::fill_n(p, width, static_cast<std::byte>(colour.p));
p += _screen.pitch;
} while (--height);
}