Blitter: Use 32 bit memset where available
Fix Blitter_40bppAnim::SetRect
This commit is contained in:
@@ -212,12 +212,10 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
|
||||
|
||||
case BM_BLACK_REMAP:
|
||||
do {
|
||||
*dst++ = Colour(0, 0, 0);
|
||||
*anim++ = 0;
|
||||
src_px++;
|
||||
src_n++;
|
||||
} while (--n != 0);
|
||||
memset_colour(dst, _black_colour, n);
|
||||
memset(anim, 0, n * sizeof(*anim));
|
||||
src_px += n;
|
||||
src_n += n;
|
||||
break;
|
||||
|
||||
case BM_TRANSPARENT:
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "../zoom_func.h"
|
||||
#include "../settings_type.h"
|
||||
#include "32bpp_optimized.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
||||
@@ -181,12 +182,9 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
|
||||
break;
|
||||
|
||||
case BM_BLACK_REMAP:
|
||||
do {
|
||||
*dst = Colour(0, 0, 0);
|
||||
dst++;
|
||||
src_px++;
|
||||
src_n++;
|
||||
} while (--n != 0);
|
||||
memset_colour(dst, _black_colour, n);
|
||||
src_px += n;
|
||||
src_n += n;
|
||||
break;
|
||||
|
||||
case BM_TRANSPARENT:
|
||||
|
@@ -22,9 +22,6 @@
|
||||
/** Instantiation of the 40bpp with animation blitter factory. */
|
||||
static FBlitter_40bppAnim iFBlitter_40bppAnim;
|
||||
|
||||
/** Cached black value. */
|
||||
static const Colour _black_colour(0, 0, 0);
|
||||
|
||||
|
||||
void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
|
||||
{
|
||||
@@ -58,7 +55,7 @@ void Blitter_40bppAnim::SetRect(void *video, int x, int y, const uint8 *colours,
|
||||
Colour *dst = (Colour *)video + x + y * _screen.pitch;
|
||||
uint8 *dstanim = ((uint32 *)dst - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
|
||||
do {
|
||||
memset((uint32 *)dst, _black_colour.data, width * sizeof(uint32));
|
||||
memset_colour(dst, _black_colour, width);
|
||||
memcpy(dstanim, colours, width * sizeof(uint8));
|
||||
dst += _screen.pitch;
|
||||
dstanim += _screen.pitch;
|
||||
@@ -96,15 +93,9 @@ void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8 colou
|
||||
uint8 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
|
||||
|
||||
do {
|
||||
Colour *dst = (Colour *)video;
|
||||
uint8 *anim = anim_line;
|
||||
memset_colour((Colour *)video, _black_colour, width);
|
||||
memset(anim_line, colour, width);
|
||||
|
||||
for (int i = width; i > 0; i--) {
|
||||
*dst = _black_colour;
|
||||
*anim = colour;
|
||||
dst++;
|
||||
anim++;
|
||||
}
|
||||
video = (uint32 *)video + _screen.pitch;
|
||||
anim_line += _screen.pitch;
|
||||
} while (--height);
|
||||
|
@@ -14,6 +14,14 @@
|
||||
#include "../core/math_func.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <wchar.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
/** Cached black value. */
|
||||
static const Colour _black_colour(0, 0, 0);
|
||||
|
||||
template <typename SetPixelT>
|
||||
void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width, int screen_height, int width, int dash, SetPixelT set_pixel)
|
||||
@@ -192,4 +200,25 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width,
|
||||
}
|
||||
}
|
||||
|
||||
inline void memset_uint32(uint32 *s, uint32 c, size_t n)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
memset_pattern4(static_cast<void *>(s), static_cast<const void *>(&c), n * sizeof(uint32));
|
||||
#else
|
||||
if constexpr (sizeof(wchar_t) == sizeof(uint32)) {
|
||||
wmemset((wchar_t *)s, (wchar_t)c, n);
|
||||
} else {
|
||||
for (; n > 0; n--) {
|
||||
*s = c;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void memset_colour(Colour *s, Colour c, size_t n)
|
||||
{
|
||||
memset_uint32((uint32 *)s, c.data, n);
|
||||
}
|
||||
|
||||
#endif /* BLITTER_COMMON_HPP */
|
||||
|
Reference in New Issue
Block a user