From f8193578c1f164a62c2dc1b84120d57c35a9a414 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 20 Jan 2018 01:58:28 +0000 Subject: [PATCH] Blitter: Performance adjustments to 32bpp anim non-SSE blitter --- src/blitter/32bpp_anim.cpp | 78 +++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp index a2b3e0709b..d6d936007a 100644 --- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -11,6 +11,7 @@ #include "../stdafx.h" #include "../video/video_driver.hpp" +#include "../zoom_func.h" #include "32bpp_anim.hpp" #include "../table/sprites.h" @@ -25,10 +26,11 @@ Blitter_32bppAnim::~Blitter_32bppAnim() free(this->anim_alloc); } -template +template inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom) { const SpriteData *src = (const SpriteData *)bp->sprite; + const BlitterSpriteFlags sprite_flags = src->flags; const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]); const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]); @@ -42,10 +44,15 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left; const byte *remap = bp->remap; // store so we don't have to access it via bp everytime + const int width = bp->width; + const int pitch = bp->pitch; + const int anim_pitch = this->anim_buf_pitch; + const int skip_left = bp->skip_left; + const int height = bp->height; - for (int y = 0; y < bp->height; y++) { - Colour *dst_ln = dst + bp->pitch; - uint16 *anim_ln = anim + this->anim_buf_pitch; + for (int y = 0; y < height; y++) { + Colour *dst_ln = dst + pitch; + uint16 *anim_ln = anim + anim_pitch; const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); src_px++; @@ -53,44 +60,52 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n); src_n += 2; - Colour *dst_end = dst + bp->skip_left; + Colour *dst_end = dst; uint n; - while (dst < dst_end) { - n = *src_n++; + if (!fast_path) { + dst_end += skip_left; - if (src_px->a == 0) { - dst += n; - src_px ++; - src_n++; + while (dst < dst_end) { + n = *src_n++; - if (dst > dst_end) anim += dst - dst_end; - } else { - if (dst + n > dst_end) { - uint d = dst_end - dst; - src_px += d; - src_n += d; + if (src_px->a == 0) { + dst += n; + src_px ++; + src_n++; - dst = dst_end - bp->skip_left; - dst_end = dst + bp->width; + if (dst > dst_end) anim += dst - dst_end; + } else { + if (dst + n > dst_end) { + uint d = dst_end - dst; + src_px += d; + src_n += d; - n = min(n - d, (uint)bp->width); - goto draw; + dst = dst_end - skip_left; + dst_end = dst + width; + + n = min(n - d, (uint)width); + goto draw; + } + dst += n; + src_px += n; + src_n += n; } - dst += n; - src_px += n; - src_n += n; } + + dst -= skip_left; + dst_end -= skip_left; } - dst -= bp->skip_left; - dst_end -= bp->skip_left; - - dst_end += bp->width; + dst_end += width; while (dst < dst_end) { - n = min(*src_n++, (uint)(dst_end - dst)); + if (fast_path) { + n = *src_n++; + } else { + n = min(*src_n++, (uint)(dst_end - dst)); + } if (src_px->a == 0) { anim += n; @@ -217,7 +232,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel break; default: - if (no_anim_translucent) { + if (fast_path || (src_px->a == 255 && (sprite_flags & SF_NO_ANIM))) { do { *anim++ = 0; *dst++ = src_px->data; @@ -280,7 +295,8 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL /* FALL THROUGH */ case BM_NORMAL: - if ((sprite_flags & SF_NO_ANIM) && !(sprite_flags & SF_TRANSLUCENT)) { + if ((sprite_flags & (SF_NO_ANIM | SF_TRANSLUCENT)) == SF_NO_ANIM && + bp->skip_left == 0 && bp->width == UnScaleByZoom(bp->sprite_width, zoom)) { Draw(bp, zoom); } else { Draw(bp, zoom);