mirror of https://github.com/OpenTTD/OpenTTD
(svn r26252) -Codechange: deduplicate code for margin case (MJP)
parent
9a90bed79b
commit
7f6e837b3a
|
@ -30,12 +30,12 @@ IGNORE_UNINITIALIZED_WARNING_START
|
|||
template <BlitterMode mode, Blitter_32bppSSE2::ReadMode read_mode, Blitter_32bppSSE2::BlockType bt_last>
|
||||
inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
||||
{
|
||||
const byte * const remap = bp->remap;
|
||||
Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
|
||||
uint16 *anim_line = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left;
|
||||
int effective_width = bp->width;
|
||||
|
||||
/* Find where to start reading in the source sprite. */
|
||||
const byte * const remap = bp->remap;
|
||||
const Blitter_32bppSSE_Base::SpriteData * const sd = (const Blitter_32bppSSE_Base::SpriteData *) bp->sprite;
|
||||
const SpriteInfo * const si = &sd->infos[zoom];
|
||||
const MapValue *src_mv_line = (const MapValue *) &sd->data[si->mv_offset] + bp->skip_top * si->sprite_width;
|
||||
|
@ -45,6 +45,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL
|
|||
src_rgba_line += bp->skip_left;
|
||||
src_mv_line += bp->skip_left;
|
||||
}
|
||||
const MapValue *src_mv = src_mv_line;
|
||||
|
||||
/* Load these variables into register before loop. */
|
||||
const __m128i a_cm = ALPHA_CONTROL_MASK;
|
||||
|
@ -59,27 +60,24 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL
|
|||
for (int y = bp->height; y != 0; y--) {
|
||||
Colour *dst = dst_line;
|
||||
const Colour *src = src_rgba_line + META_LENGTH;
|
||||
const MapValue *src_mv = src_mv_line;
|
||||
if (mode != BM_TRANSPARENT) src_mv = src_mv_line;
|
||||
uint16 *anim = anim_line;
|
||||
|
||||
switch (mode) {
|
||||
default: {
|
||||
switch (read_mode) {
|
||||
case RM_WITH_MARGIN: {
|
||||
if (read_mode == RM_WITH_MARGIN) {
|
||||
anim += src_rgba_line[0].data;
|
||||
src += src_rgba_line[0].data;
|
||||
dst += src_rgba_line[0].data;
|
||||
src_mv += src_rgba_line[0].data;
|
||||
anim += src_rgba_line[0].data;
|
||||
if (mode != BM_TRANSPARENT) src_mv += src_rgba_line[0].data;
|
||||
const int width_diff = si->sprite_width - bp->width;
|
||||
effective_width = bp->width - (int) src_rgba_line[0].data;
|
||||
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
|
||||
const int new_width = effective_width - (delta_diff & ~1);
|
||||
const int new_width = effective_width - delta_diff;
|
||||
effective_width = delta_diff > 0 ? new_width : effective_width;
|
||||
if (effective_width <= 0) break;
|
||||
/* FALLTHROUGH */
|
||||
if (effective_width <= 0) goto next_line;
|
||||
}
|
||||
|
||||
case RM_WITH_SKIP: {
|
||||
switch (mode) {
|
||||
default:
|
||||
for (uint x = (uint) effective_width/2; x != 0; x--) {
|
||||
uint32 mvX2 = *((uint32 *) const_cast<MapValue *>(src_mv));
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
|
@ -155,30 +153,8 @@ bmno_full_transparency:
|
|||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BM_COLOUR_REMAP: {
|
||||
switch (read_mode) {
|
||||
case RM_WITH_MARGIN: {
|
||||
src += src_rgba_line[0].data;
|
||||
src_mv += src_rgba_line[0].data;
|
||||
dst += src_rgba_line[0].data;
|
||||
anim += src_rgba_line[0].data;
|
||||
const int width_diff = si->sprite_width - bp->width;
|
||||
effective_width = bp->width - (int) src_rgba_line[0].data;
|
||||
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
|
||||
const int new_width = effective_width - delta_diff;
|
||||
effective_width = delta_diff > 0 ? new_width : effective_width;
|
||||
if (effective_width <= 0) break;
|
||||
/* FALLTHROUGH */
|
||||
}
|
||||
|
||||
case RM_WITH_SKIP: {
|
||||
case BM_COLOUR_REMAP:
|
||||
for (uint x = (uint) effective_width / 2; x != 0; x--) {
|
||||
uint32 mvX2 = *((uint32 *) const_cast<MapValue *>(src_mv));
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
|
@ -278,14 +254,8 @@ bmcr_alpha_blend_single:
|
|||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BM_TRANSPARENT: {
|
||||
case BM_TRANSPARENT:
|
||||
/* Make the current colour a bit more black, so it looks like this image is transparent. */
|
||||
for (uint x = (uint) bp->width / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
|
@ -298,6 +268,7 @@ bmcr_alpha_blend_single:
|
|||
if (src[-2].a) anim[-2] = 0;
|
||||
if (src[-1].a) anim[-1] = 0;
|
||||
}
|
||||
|
||||
if ((bt_last == BT_NONE && bp->width & 1) || bt_last == BT_ODD) {
|
||||
__m128i srcABCD = _mm_cvtsi32_si128(src->data);
|
||||
__m128i dstABCD = _mm_cvtsi32_si128(dst->data);
|
||||
|
@ -307,9 +278,9 @@ bmcr_alpha_blend_single:
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
src_mv_line += si->sprite_width;
|
||||
next_line:
|
||||
if (mode != BM_TRANSPARENT) src_mv_line += si->sprite_width;
|
||||
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
|
||||
dst_line += bp->pitch;
|
||||
anim_line += this->anim_buf_width;
|
||||
|
@ -328,19 +299,15 @@ void Blitter_32bppSSE4_Anim::Draw(Blitter::BlitterParams *bp, BlitterMode mode,
|
|||
{
|
||||
switch (mode) {
|
||||
case BM_NORMAL: {
|
||||
const BlockType bt_last = (BlockType) (bp->width & 1);
|
||||
if (bp->skip_left != 0 || bp->width <= MARGIN_NORMAL_THRESHOLD) {
|
||||
const BlockType bt_last = (BlockType) (bp->width & 1);
|
||||
switch (bt_last) {
|
||||
case BT_EVEN: Draw<BM_NORMAL, RM_WITH_SKIP, BT_EVEN>(bp, zoom); return;
|
||||
case BT_ODD: Draw<BM_NORMAL, RM_WITH_SKIP, BT_ODD>(bp, zoom); return;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
} else {
|
||||
switch (bt_last) {
|
||||
case BT_EVEN: Draw<BM_NORMAL, RM_WITH_MARGIN, BT_EVEN>(bp, zoom); return;
|
||||
case BT_ODD: Draw<BM_NORMAL, RM_WITH_MARGIN, BT_ODD>(bp, zoom); return;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
Draw<BM_NORMAL, RM_WITH_MARGIN, BT_NONE>(bp, zoom); return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ IGNORE_UNINITIALIZED_WARNING_START
|
|||
template <BlitterMode mode, Blitter_32bppSSE2::ReadMode read_mode, Blitter_32bppSSE2::BlockType bt_last>
|
||||
inline void Blitter_32bppSSE2::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
||||
{
|
||||
const byte *remap = bp->remap;
|
||||
Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
|
||||
int effective_width = bp->width;
|
||||
|
||||
|
@ -43,6 +44,7 @@ inline void Blitter_32bppSSE2::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
src_rgba_line += bp->skip_left;
|
||||
src_mv_line += bp->skip_left;
|
||||
}
|
||||
const MapValue *src_mv = src_mv_line;
|
||||
|
||||
/* Load these variables into register before loop. */
|
||||
const __m128i clear_hi = CLEAR_HIGH_BYTE_MASK;
|
||||
|
@ -51,24 +53,22 @@ inline void Blitter_32bppSSE2::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
for (int y = bp->height; y != 0; y--) {
|
||||
Colour *dst = dst_line;
|
||||
const Colour *src = src_rgba_line + META_LENGTH;
|
||||
const MapValue *src_mv = src_mv_line;
|
||||
if (mode == BM_COLOUR_REMAP) src_mv = src_mv_line;
|
||||
|
||||
switch (mode) {
|
||||
default: {
|
||||
switch (read_mode) {
|
||||
case RM_WITH_MARGIN: {
|
||||
if (read_mode == RM_WITH_MARGIN) {
|
||||
src += src_rgba_line[0].data;
|
||||
dst += src_rgba_line[0].data;
|
||||
if (mode == BM_COLOUR_REMAP) src_mv += src_rgba_line[0].data;
|
||||
const int width_diff = si->sprite_width - bp->width;
|
||||
effective_width = bp->width - (int) src_rgba_line[0].data;
|
||||
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
|
||||
const int new_width = effective_width - (delta_diff & ~1);
|
||||
const int new_width = effective_width - delta_diff;
|
||||
effective_width = delta_diff > 0 ? new_width : effective_width;
|
||||
if (effective_width <= 0) break;
|
||||
/* FALLTHROUGH */
|
||||
if (effective_width <= 0) goto next_line;
|
||||
}
|
||||
|
||||
case RM_WITH_SKIP: {
|
||||
switch (mode) {
|
||||
default:
|
||||
for (uint x = (uint) effective_width / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
|
||||
|
@ -77,6 +77,7 @@ inline void Blitter_32bppSSE2::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
|
||||
if ((bt_last == BT_NONE && effective_width & 1) || bt_last == BT_ODD) {
|
||||
__m128i srcABCD = _mm_cvtsi32_si128(src->data);
|
||||
__m128i dstABCD = _mm_cvtsi32_si128(dst->data);
|
||||
|
@ -84,29 +85,8 @@ inline void Blitter_32bppSSE2::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
dst->data = _mm_cvtsi128_si32(srcABCD);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BM_COLOUR_REMAP: {
|
||||
switch (read_mode) {
|
||||
case RM_WITH_MARGIN: {
|
||||
src += src_rgba_line[0].data;
|
||||
src_mv += src_rgba_line[0].data;
|
||||
dst += src_rgba_line[0].data;
|
||||
const int width_diff = si->sprite_width - bp->width;
|
||||
effective_width = bp->width - (int) src_rgba_line[0].data;
|
||||
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
|
||||
const int new_width = effective_width - delta_diff;
|
||||
effective_width = delta_diff > 0 ? new_width : effective_width;
|
||||
if (effective_width <= 0) break;
|
||||
/* FALLTHROUGH */
|
||||
}
|
||||
|
||||
case RM_WITH_SKIP: {
|
||||
const byte *remap = bp->remap;
|
||||
case BM_COLOUR_REMAP:
|
||||
for (uint x = (uint) effective_width; x != 0; x--) {
|
||||
/* In case the m-channel is zero, do not remap this pixel in any way. */
|
||||
__m128i srcABCD;
|
||||
|
@ -136,14 +116,8 @@ bmcr_alpha_blend_single:
|
|||
src++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
src_mv_line += si->sprite_width;
|
||||
break;
|
||||
}
|
||||
case BM_TRANSPARENT: {
|
||||
case BM_TRANSPARENT:
|
||||
/* Make the current colour a bit more black, so it looks like this image is transparent. */
|
||||
for (uint x = (uint) bp->width / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
|
@ -153,6 +127,7 @@ bmcr_alpha_blend_single:
|
|||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
|
||||
if ((bt_last == BT_NONE && bp->width & 1) || bt_last == BT_ODD) {
|
||||
__m128i srcABCD = _mm_cvtsi32_si128(src->data);
|
||||
__m128i dstABCD = _mm_cvtsi32_si128(dst->data);
|
||||
|
@ -161,8 +136,9 @@ bmcr_alpha_blend_single:
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
next_line:
|
||||
if (mode == BM_COLOUR_REMAP) src_mv_line += si->sprite_width;
|
||||
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
|
||||
dst_line += bp->pitch;
|
||||
}
|
||||
|
@ -180,19 +156,15 @@ void Blitter_32bppSSE2::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
|
|||
{
|
||||
switch (mode) {
|
||||
case BM_NORMAL: {
|
||||
const BlockType bt_last = (BlockType) (bp->width & 1);
|
||||
if (bp->skip_left != 0 || bp->width <= MARGIN_NORMAL_THRESHOLD) {
|
||||
const BlockType bt_last = (BlockType) (bp->width & 1);
|
||||
switch (bt_last) {
|
||||
case BT_EVEN: Draw<BM_NORMAL, RM_WITH_SKIP, BT_EVEN>(bp, zoom); return;
|
||||
case BT_ODD: Draw<BM_NORMAL, RM_WITH_SKIP, BT_ODD>(bp, zoom); return;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
} else {
|
||||
switch (bt_last) {
|
||||
case BT_EVEN: Draw<BM_NORMAL, RM_WITH_MARGIN, BT_EVEN>(bp, zoom); return;
|
||||
case BT_ODD: Draw<BM_NORMAL, RM_WITH_MARGIN, BT_ODD>(bp, zoom); return;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
Draw<BM_NORMAL, RM_WITH_MARGIN, BT_NONE>(bp, zoom); return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
src_rgba_line += bp->skip_left;
|
||||
src_mv_line += bp->skip_left;
|
||||
}
|
||||
const MapValue *src_mv = src_mv_line;
|
||||
|
||||
/* Load these variables into register before loop. */
|
||||
const __m128i a_cm = ALPHA_CONTROL_MASK;
|
||||
|
@ -58,24 +59,22 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
for (int y = bp->height; y != 0; y--) {
|
||||
const Colour *src = src_rgba_line + META_LENGTH;
|
||||
Colour *dst = dst_line;
|
||||
const MapValue *src_mv = src_mv_line;
|
||||
if (mode == BM_COLOUR_REMAP) src_mv = src_mv_line;
|
||||
|
||||
switch (mode) {
|
||||
default: {
|
||||
switch (read_mode) {
|
||||
case RM_WITH_MARGIN: {
|
||||
if (read_mode == RM_WITH_MARGIN) {
|
||||
src += src_rgba_line[0].data;
|
||||
dst += src_rgba_line[0].data;
|
||||
if (mode == BM_COLOUR_REMAP) src_mv += src_rgba_line[0].data;
|
||||
const int width_diff = si->sprite_width - bp->width;
|
||||
effective_width = bp->width - (int) src_rgba_line[0].data;
|
||||
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
|
||||
const int new_width = effective_width - (delta_diff & ~1);
|
||||
const int new_width = effective_width - delta_diff;
|
||||
effective_width = delta_diff > 0 ? new_width : effective_width;
|
||||
if (effective_width <= 0) break;
|
||||
/* FALLTHROUGH */
|
||||
if (effective_width <= 0) goto next_line;
|
||||
}
|
||||
|
||||
case RM_WITH_SKIP: {
|
||||
switch (mode) {
|
||||
default:
|
||||
for (uint x = (uint) effective_width / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
|
||||
|
@ -84,6 +83,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
|
||||
if ((bt_last == BT_NONE && effective_width & 1) || bt_last == BT_ODD) {
|
||||
__m128i srcABCD = _mm_cvtsi32_si128(src->data);
|
||||
__m128i dstABCD = _mm_cvtsi32_si128(dst->data);
|
||||
|
@ -91,29 +91,8 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
dst->data = _mm_cvtsi128_si32(srcABCD);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BM_COLOUR_REMAP: {
|
||||
switch (read_mode) {
|
||||
case RM_WITH_MARGIN: {
|
||||
src += src_rgba_line[0].data;
|
||||
src_mv += src_rgba_line[0].data;
|
||||
dst += src_rgba_line[0].data;
|
||||
const int width_diff = si->sprite_width - bp->width;
|
||||
effective_width = bp->width - (int) src_rgba_line[0].data;
|
||||
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
|
||||
const int new_width = effective_width - delta_diff;
|
||||
effective_width = delta_diff > 0 ? new_width : effective_width;
|
||||
if (effective_width <= 0) break;
|
||||
/* FALLTHROUGH */
|
||||
}
|
||||
|
||||
case RM_WITH_SKIP: {
|
||||
case BM_COLOUR_REMAP:
|
||||
for (uint x = (uint) effective_width / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
|
||||
|
@ -179,15 +158,8 @@ bmcr_alpha_blend_single:
|
|||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
src_mv_line += si->sprite_width;
|
||||
break;
|
||||
}
|
||||
|
||||
case BM_TRANSPARENT: {
|
||||
case BM_TRANSPARENT:
|
||||
/* Make the current colour a bit more black, so it looks like this image is transparent. */
|
||||
for (uint x = (uint) bp->width / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
|
@ -197,17 +169,18 @@ bmcr_alpha_blend_single:
|
|||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
|
||||
if ((bt_last == BT_NONE && bp->width & 1) || bt_last == BT_ODD) {
|
||||
__m128i srcABCD = _mm_cvtsi32_si128(src->data);
|
||||
__m128i dstABCD = _mm_cvtsi32_si128(dst->data);
|
||||
DARKEN_2();
|
||||
dst->data = _mm_cvtsi128_si32(dstAB);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
next_line:
|
||||
if (mode == BM_COLOUR_REMAP) src_mv_line += si->sprite_width;
|
||||
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
|
||||
dst_line += bp->pitch;
|
||||
}
|
||||
|
@ -223,21 +196,17 @@ IGNORE_UNINITIALIZED_WARNING_STOP
|
|||
*/
|
||||
void Blitter_32bppSSE4::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
|
||||
{
|
||||
const BlockType bt_last = (BlockType) (bp->width & 1);
|
||||
switch (mode) {
|
||||
case BM_NORMAL: {
|
||||
if (bp->skip_left != 0 || bp->width <= MARGIN_NORMAL_THRESHOLD) {
|
||||
const BlockType bt_last = (BlockType) (bp->width & 1);
|
||||
switch (bt_last) {
|
||||
case BT_EVEN: Draw<BM_NORMAL, RM_WITH_SKIP, BT_EVEN>(bp, zoom); return;
|
||||
case BT_ODD: Draw<BM_NORMAL, RM_WITH_SKIP, BT_ODD>(bp, zoom); return;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
} else {
|
||||
switch (bt_last) {
|
||||
case BT_EVEN: Draw<BM_NORMAL, RM_WITH_MARGIN, BT_EVEN>(bp, zoom); return;
|
||||
case BT_ODD: Draw<BM_NORMAL, RM_WITH_MARGIN, BT_ODD>(bp, zoom); return;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
Draw<BM_NORMAL, RM_WITH_MARGIN, BT_NONE>(bp, zoom); return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
src_rgba_line += bp->skip_left;
|
||||
src_mv_line += bp->skip_left;
|
||||
}
|
||||
const MapValue *src_mv = src_mv_line;
|
||||
|
||||
/* Load these variables into register before loop. */
|
||||
const __m128i a_cm = ALPHA_CONTROL_MASK;
|
||||
|
@ -58,24 +59,22 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
for (int y = bp->height; y != 0; y--) {
|
||||
Colour *dst = dst_line;
|
||||
const Colour *src = src_rgba_line + META_LENGTH;
|
||||
const MapValue *src_mv = src_mv_line;
|
||||
if (mode == BM_COLOUR_REMAP) src_mv = src_mv_line;
|
||||
|
||||
switch (mode) {
|
||||
default: {
|
||||
switch (read_mode) {
|
||||
case RM_WITH_MARGIN: {
|
||||
if (read_mode == RM_WITH_MARGIN) {
|
||||
src += src_rgba_line[0].data;
|
||||
dst += src_rgba_line[0].data;
|
||||
if (mode == BM_COLOUR_REMAP) src_mv += src_rgba_line[0].data;
|
||||
const int width_diff = si->sprite_width - bp->width;
|
||||
effective_width = bp->width - (int) src_rgba_line[0].data;
|
||||
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
|
||||
const int new_width = effective_width - (delta_diff & ~1);
|
||||
const int new_width = effective_width - delta_diff;
|
||||
effective_width = delta_diff > 0 ? new_width : effective_width;
|
||||
if (effective_width <= 0) break;
|
||||
/* FALLTHROUGH */
|
||||
if (effective_width <= 0) goto next_line;
|
||||
}
|
||||
|
||||
case RM_WITH_SKIP: {
|
||||
switch (mode) {
|
||||
default:
|
||||
for (uint x = (uint) effective_width / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
|
||||
|
@ -84,6 +83,7 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
|
||||
if ((bt_last == BT_NONE && effective_width & 1) || bt_last == BT_ODD) {
|
||||
__m128i srcABCD = _mm_cvtsi32_si128(src->data);
|
||||
__m128i dstABCD = _mm_cvtsi32_si128(dst->data);
|
||||
|
@ -91,29 +91,8 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
dst->data = _mm_cvtsi128_si32(srcABCD);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BM_COLOUR_REMAP: {
|
||||
switch (read_mode) {
|
||||
case RM_WITH_MARGIN: {
|
||||
src += src_rgba_line[0].data;
|
||||
src_mv += src_rgba_line[0].data;
|
||||
dst += src_rgba_line[0].data;
|
||||
const int width_diff = si->sprite_width - bp->width;
|
||||
effective_width = bp->width - (int) src_rgba_line[0].data;
|
||||
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
|
||||
const int new_width = effective_width - delta_diff;
|
||||
effective_width = delta_diff > 0 ? new_width : effective_width;
|
||||
if (effective_width <= 0) break;
|
||||
/* FALLTHROUGH */
|
||||
}
|
||||
|
||||
case RM_WITH_SKIP: {
|
||||
case BM_COLOUR_REMAP:
|
||||
for (uint x = (uint) effective_width / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
|
||||
|
@ -179,15 +158,8 @@ bmcr_alpha_blend_single:
|
|||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
src_mv_line += si->sprite_width;
|
||||
break;
|
||||
}
|
||||
|
||||
case BM_TRANSPARENT: {
|
||||
case BM_TRANSPARENT:
|
||||
/* Make the current colour a bit more black, so it looks like this image is transparent. */
|
||||
for (uint x = (uint) bp->width / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
|
@ -197,6 +169,7 @@ bmcr_alpha_blend_single:
|
|||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
|
||||
if ((bt_last == BT_NONE && bp->width & 1) || bt_last == BT_ODD) {
|
||||
__m128i srcABCD = _mm_cvtsi32_si128(src->data);
|
||||
__m128i dstABCD = _mm_cvtsi32_si128(dst->data);
|
||||
|
@ -205,8 +178,9 @@ bmcr_alpha_blend_single:
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
next_line:
|
||||
if (mode == BM_COLOUR_REMAP) src_mv_line += si->sprite_width;
|
||||
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
|
||||
dst_line += bp->pitch;
|
||||
}
|
||||
|
@ -224,19 +198,15 @@ void Blitter_32bppSSSE3::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
|
|||
{
|
||||
switch (mode) {
|
||||
case BM_NORMAL: {
|
||||
const BlockType bt_last = (BlockType) (bp->width & 1);
|
||||
if (bp->skip_left != 0 || bp->width <= MARGIN_NORMAL_THRESHOLD) {
|
||||
const BlockType bt_last = (BlockType) (bp->width & 1);
|
||||
switch (bt_last) {
|
||||
case BT_EVEN: Draw<BM_NORMAL, RM_WITH_SKIP, BT_EVEN>(bp, zoom); return;
|
||||
case BT_ODD: Draw<BM_NORMAL, RM_WITH_SKIP, BT_ODD>(bp, zoom); return;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
} else {
|
||||
switch (bt_last) {
|
||||
case BT_EVEN: Draw<BM_NORMAL, RM_WITH_MARGIN, BT_EVEN>(bp, zoom); return;
|
||||
case BT_ODD: Draw<BM_NORMAL, RM_WITH_MARGIN, BT_ODD>(bp, zoom); return;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
Draw<BM_NORMAL, RM_WITH_MARGIN, BT_NONE>(bp, zoom); return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue