Viewport: Cache landscape pixels in map mode
Avoid invalidating landscape pixels for non-landscape updates (vehicles, overlays, etc.)
This commit is contained in:
@@ -376,47 +376,58 @@ void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int
|
||||
}
|
||||
}
|
||||
|
||||
void Blitter_32bppAnim::SetLine(void *video, int x, int y, uint8 *colours, uint width)
|
||||
void Blitter_32bppAnim::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch)
|
||||
{
|
||||
Colour *dst = (Colour *)video + x + y * _screen.pitch;
|
||||
|
||||
if (_screen_disable_anim) {
|
||||
do {
|
||||
*dst = LookupColourInPalette(*colours);
|
||||
dst++;
|
||||
colours++;
|
||||
} while (--width);
|
||||
uint w = width;
|
||||
do {
|
||||
*dst = LookupColourInPalette(*colours);
|
||||
dst++;
|
||||
colours++;
|
||||
} while (--w);
|
||||
dst += _screen.pitch - width;
|
||||
colours += pitch - width;
|
||||
} while (--lines);
|
||||
} else {
|
||||
uint16 *dstanim = (uint16 *)(&this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch]);
|
||||
do {
|
||||
*dstanim = *colours | (DEFAULT_BRIGHTNESS << 8);
|
||||
*dst = LookupColourInPalette(*colours);
|
||||
dst++;
|
||||
dstanim++;
|
||||
colours++;
|
||||
} while (--width);
|
||||
uint w = width;
|
||||
do {
|
||||
*dstanim = *colours | (DEFAULT_BRIGHTNESS << 8);
|
||||
*dst = LookupColourInPalette(*colours);
|
||||
dst++;
|
||||
dstanim++;
|
||||
colours++;
|
||||
} while (--w);
|
||||
dst += _screen.pitch - width;
|
||||
dstanim += this->anim_buf_pitch - width;
|
||||
colours += pitch - width;
|
||||
} while (--lines);
|
||||
}
|
||||
}
|
||||
|
||||
void Blitter_32bppAnim::SetLine32(void *video, int x, int y, uint32 *colours, uint width)
|
||||
void Blitter_32bppAnim::SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch)
|
||||
{
|
||||
Colour *dst = (Colour *)video + x + y * _screen.pitch;
|
||||
uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
|
||||
|
||||
if (_screen_disable_anim) {
|
||||
do {
|
||||
*dst = *colours;
|
||||
dst++;
|
||||
colours++;
|
||||
} while (--width);
|
||||
memcpy(dst, colours, width * sizeof(uint32));
|
||||
dst += _screen.pitch;
|
||||
colours += pitch;
|
||||
} while (--lines);
|
||||
} else {
|
||||
uint16 *dstanim = (uint16 *)(&this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch]);
|
||||
do {
|
||||
*dstanim = 0;
|
||||
*dst = *colours;
|
||||
dst++;
|
||||
dstanim++;
|
||||
colours++;
|
||||
} while (--width);
|
||||
memcpy(dst, colours, width * sizeof(uint32));
|
||||
memset(dstanim, 0, width * sizeof(uint16));
|
||||
dst += _screen.pitch;
|
||||
dstanim += this->anim_buf_pitch;
|
||||
colours += pitch;
|
||||
} while (--lines);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -39,8 +39,8 @@ public:
|
||||
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
|
||||
void SetPixel(void *video, int x, int y, uint8 colour) override;
|
||||
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
|
||||
void SetLine(void *video, int x, int y, uint8 *colours, uint width) override;
|
||||
void SetLine32(void *video, int x, int y, uint32 *colours, uint width) override;
|
||||
void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override;
|
||||
void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override;
|
||||
void DrawRect(void *video, int width, int height, uint8 colour) override;
|
||||
void CopyFromBuffer(void *video, const void *src, int width, int height) override;
|
||||
void CopyToBuffer(const void *video, void *dst, int width, int height) override;
|
||||
|
@@ -31,24 +31,29 @@ void Blitter_32bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int
|
||||
});
|
||||
}
|
||||
|
||||
void Blitter_32bppBase::SetLine(void *video, int x, int y, uint8 *colours, uint width)
|
||||
void Blitter_32bppBase::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch)
|
||||
{
|
||||
Colour *dst = (Colour *)video + x + y * _screen.pitch;
|
||||
do {
|
||||
*dst = LookupColourInPalette(*colours);
|
||||
dst++;
|
||||
colours++;
|
||||
} while (--width);
|
||||
uint w = width;
|
||||
do {
|
||||
*dst = LookupColourInPalette(*colours);
|
||||
dst++;
|
||||
colours++;
|
||||
} while (--w);
|
||||
dst += _screen.pitch - width;
|
||||
colours += pitch - width;
|
||||
} while (--lines);
|
||||
}
|
||||
|
||||
void Blitter_32bppBase::SetLine32(void *video, int x, int y, uint32 *colours, uint width)
|
||||
void Blitter_32bppBase::SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch)
|
||||
{
|
||||
Colour *dst = (Colour *)video + x + y * _screen.pitch;
|
||||
uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
|
||||
do {
|
||||
*dst = *colours;
|
||||
dst++;
|
||||
colours++;
|
||||
} while (--width);
|
||||
memcpy(dst, colours, width * sizeof(uint32));
|
||||
dst += _screen.pitch;
|
||||
colours += pitch;
|
||||
} while (--lines);
|
||||
}
|
||||
|
||||
void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8 colour)
|
||||
|
@@ -22,8 +22,8 @@ public:
|
||||
void *MoveTo(void *video, int x, int y) override;
|
||||
void SetPixel(void *video, int x, int y, uint8 colour) override;
|
||||
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
|
||||
void SetLine(void *video, int x, int y, uint8 *colours, uint width) override;
|
||||
void SetLine32(void *video, int x, int y, uint32 *colours, uint width) override;
|
||||
void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override;
|
||||
void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override;
|
||||
void DrawRect(void *video, int width, int height, uint8 colour) override;
|
||||
void CopyFromBuffer(void *video, const void *src, int width, int height) override;
|
||||
void CopyToBuffer(const void *video, void *dst, int width, int height) override;
|
||||
|
@@ -41,9 +41,14 @@ void Blitter_8bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int s
|
||||
});
|
||||
}
|
||||
|
||||
void Blitter_8bppBase::SetLine(void *video, int x, int y, uint8 *colours, uint width)
|
||||
void Blitter_8bppBase::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch)
|
||||
{
|
||||
memcpy((uint8 *)video + x + y * _screen.pitch, colours, width * sizeof(uint8));
|
||||
uint8 *dst = (uint8 *)video + x + y * _screen.pitch;
|
||||
do {
|
||||
memcpy(dst, colours, width * sizeof(uint8));
|
||||
dst += _screen.pitch;
|
||||
colours += pitch;
|
||||
} while (--lines);
|
||||
}
|
||||
|
||||
void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8 colour)
|
||||
|
@@ -20,7 +20,7 @@ public:
|
||||
void *MoveTo(void *video, int x, int y) override;
|
||||
void SetPixel(void *video, int x, int y, uint8 colour) override;
|
||||
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
|
||||
void SetLine(void *video, int x, int y, uint8 *colours, uint width) override;
|
||||
void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override;
|
||||
void DrawRect(void *video, int width, int height, uint8 colour) override;
|
||||
void CopyFromBuffer(void *video, const void *src, int width, int height) override;
|
||||
void CopyToBuffer(const void *video, void *dst, int width, int height) override;
|
||||
|
@@ -115,24 +115,28 @@ public:
|
||||
virtual void SetPixel(void *video, int x, int y, uint8 colour) = 0;
|
||||
|
||||
/**
|
||||
* Draw a sequence of pixels on the video-buffer.
|
||||
* Draw a rectangle of pixels on the video-buffer.
|
||||
* @param video The destination pointer (video-buffer).
|
||||
* @param x The x position within video-buffer.
|
||||
* @param y The y position within video-buffer.
|
||||
* @param colours A 8bpp colour mapping buffer.
|
||||
* @param width The length of the line.
|
||||
* @param lines The number of lines.
|
||||
* @param width The length of the lines.
|
||||
* @param pitch The pitch of the colours buffer
|
||||
*/
|
||||
virtual void SetLine(void *video, int x, int y, uint8 *colours, uint width) = 0;
|
||||
virtual void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) = 0;
|
||||
|
||||
/**
|
||||
* Draw a sequence of pixels on the video-buffer (no LookupColourInPalette).
|
||||
* Draw a rectangle of pixels on the video-buffer (no LookupColourInPalette).
|
||||
* @param video The destination pointer (video-buffer).
|
||||
* @param x The x position within video-buffer.
|
||||
* @param y The y position within video-buffer.
|
||||
* @param colours A 32bpp colour buffer.
|
||||
* @param width The length of the line.
|
||||
* @param lines The number of lines.
|
||||
* @param width The length of the lines.
|
||||
* @param pitch The pitch of the colours buffer.
|
||||
*/
|
||||
virtual void SetLine32(void *video, int x, int y, uint32 *colours, uint width) { NOT_REACHED(); };
|
||||
virtual void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) { NOT_REACHED(); };
|
||||
|
||||
/**
|
||||
* Make a single horizontal line in a single colour on the video-buffer.
|
||||
|
@@ -23,8 +23,8 @@ public:
|
||||
void SetPixel(void *video, int x, int y, uint8 colour) override {};
|
||||
void DrawRect(void *video, int width, int height, uint8 colour) override {};
|
||||
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override {};
|
||||
void SetLine(void *video, int x, int y, uint8 *colours, uint width) override {};
|
||||
void SetLine32(void *video, int x, int y, uint32 *colours, uint width) override {};
|
||||
void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override {};
|
||||
void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override {};
|
||||
void CopyFromBuffer(void *video, const void *src, int width, int height) override {};
|
||||
void CopyToBuffer(const void *video, void *dst, int width, int height) override {};
|
||||
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override {};
|
||||
|
Reference in New Issue
Block a user