From 4ce73a679c850a77238fbcfe8a32df97e1fd3e58 Mon Sep 17 00:00:00 2001 From: smatz Date: Tue, 10 Jun 2008 17:28:37 +0000 Subject: [PATCH] (svn r13445) -Codechange: make 32bpp_optimized blitter ~10-20% faster in drawing (depends on architecture and compiler) --- src/blitter/32bpp_optimized.cpp | 23 ++++++++++++++++++++++- src/blitter/32bpp_optimized.hpp | 3 +++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/blitter/32bpp_optimized.cpp b/src/blitter/32bpp_optimized.cpp index c0958b0e97..b113ed0dc2 100644 --- a/src/blitter/32bpp_optimized.cpp +++ b/src/blitter/32bpp_optimized.cpp @@ -10,7 +10,7 @@ static FBlitter_32bppOptimized iFBlitter_32bppOptimized; -void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) +template inline void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp) { const SpriteLoader::CommonPixel *src, *src_line; uint32 *dst, *dst_line; @@ -66,6 +66,27 @@ void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, } } +template inline void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, ZoomLevel zoom) +{ + switch (zoom) { + default: NOT_REACHED(); + case ZOOM_LVL_NORMAL: Draw(bp); return; + case ZOOM_LVL_OUT_2X: Draw(bp); return; + case ZOOM_LVL_OUT_4X: Draw(bp); return; + case ZOOM_LVL_OUT_8X: Draw(bp); return; + } +} + +void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) +{ + switch (mode) { + default: NOT_REACHED(); + case BM_NORMAL: Draw (bp, zoom); return; + case BM_COLOUR_REMAP: Draw(bp, zoom); return; + case BM_TRANSPARENT: Draw (bp, zoom); return; + } +} + Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) { Sprite *dest_sprite; diff --git a/src/blitter/32bpp_optimized.hpp b/src/blitter/32bpp_optimized.hpp index 46c30ec252..099aaa159f 100644 --- a/src/blitter/32bpp_optimized.hpp +++ b/src/blitter/32bpp_optimized.hpp @@ -14,6 +14,9 @@ public: /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); /* virtual */ const char *GetName() { return "32bpp-optimized"; } + + template void Draw(Blitter::BlitterParams *bp); + template void Draw(Blitter::BlitterParams *bp, ZoomLevel zoom); }; class FBlitter_32bppOptimized: public BlitterFactory {