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
+9 -9
View File
@@ -321,19 +321,19 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height,
Debug(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('{}')", pal);
}
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8_t colour)
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, PixelColour colour)
{
*((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
*((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour.p);
/* Set the colour in the anim-buffer too, if we are rendering to the screen */
if (_screen_disable_anim) return;
this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch] = colour.p | (DEFAULT_BRIGHTNESS << 8);
}
void Blitter_32bppAnim::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_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, PixelColour colour, int width, int dash)
{
const Colour c = LookupColourInPalette(colour);
const Colour c = LookupColourInPalette(colour.p);
if (_screen_disable_anim) {
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](int x, int y) {
@@ -341,7 +341,7 @@ void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int
});
} else {
uint16_t * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)video);
const uint16_t anim_colour = colour | (DEFAULT_BRIGHTNESS << 8);
const uint16_t anim_colour = colour.p | (DEFAULT_BRIGHTNESS << 8);
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](int x, int y) {
*((Colour *)video + x + y * _screen.pitch) = c;
offset_anim_buf[x + y * this->anim_buf_pitch] = anim_colour;
@@ -349,7 +349,7 @@ void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int
}
}
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8_t colour)
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, PixelColour colour)
{
if (_screen_disable_anim) {
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
@@ -357,7 +357,7 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8_t col
return;
}
Colour colour32 = LookupColourInPalette(colour);
Colour colour32 = LookupColourInPalette(colour.p);
uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->anim_buf;
do {
@@ -367,7 +367,7 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8_t col
for (int i = width; i > 0; i--) {
*dst = colour32;
/* Set the colour in the anim-buffer too */
*anim = colour | (DEFAULT_BRIGHTNESS << 8);
*anim = colour.p | (DEFAULT_BRIGHTNESS << 8);
dst++;
anim++;
}