Codechange: [Blitter] Change DrawLine to be templated
This is remove per-pixel overheads due to use of the SetPixel virtual method. These overheads included: * expensive virtual method call which prevents inlining * palette lookup for every pixel * branch on whether palette animation is enabled on every pixel Regenerate project files.
This commit is contained in:

committed by
PeterN

parent
ed325ada88
commit
db924a4681
@@ -12,6 +12,7 @@
|
||||
#include "../stdafx.h"
|
||||
#include "../video/video_driver.hpp"
|
||||
#include "32bpp_anim.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
#include "../table/sprites.h"
|
||||
|
||||
@@ -321,6 +322,24 @@ void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
|
||||
this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
|
||||
}
|
||||
|
||||
void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
|
||||
{
|
||||
const Colour c = LookupColourInPalette(colour);
|
||||
|
||||
if (_screen_disable_anim) {
|
||||
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](int x, int y) {
|
||||
*((Colour *)video + x + y * _screen.pitch) = c;
|
||||
});
|
||||
} else {
|
||||
uint16 * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset((uint32 *)video);
|
||||
const uint16 anim_colour = colour | (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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colour)
|
||||
{
|
||||
if (_screen_disable_anim) {
|
||||
|
Reference in New Issue
Block a user