diff options
author | smatz <smatz@openttd.org> | 2008-06-10 17:28:37 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-06-10 17:28:37 +0000 |
commit | 8123d4de115b66fb8c0ed4b167b5e186b841c39c (patch) | |
tree | 9b86c3dfce63438b38fa8e9dd9532b8880cf12bb | |
parent | 0900f3388a610d175129de0eed4db528285b5062 (diff) | |
download | openttd-8123d4de115b66fb8c0ed4b167b5e186b841c39c.tar.xz |
(svn r13445) -Codechange: make 32bpp_optimized blitter ~10-20% faster in drawing (depends on architecture and compiler)
-rw-r--r-- | src/blitter/32bpp_optimized.cpp | 23 | ||||
-rw-r--r-- | src/blitter/32bpp_optimized.hpp | 3 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/blitter/32bpp_optimized.cpp b/src/blitter/32bpp_optimized.cpp index c0958b0e9..b113ed0dc 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 <BlitterMode mode, ZoomLevel zoom> 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 <BlitterMode mode> inline void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, ZoomLevel zoom) +{ + switch (zoom) { + default: NOT_REACHED(); + case ZOOM_LVL_NORMAL: Draw<mode, ZOOM_LVL_NORMAL>(bp); return; + case ZOOM_LVL_OUT_2X: Draw<mode, ZOOM_LVL_OUT_2X>(bp); return; + case ZOOM_LVL_OUT_4X: Draw<mode, ZOOM_LVL_OUT_4X>(bp); return; + case ZOOM_LVL_OUT_8X: Draw<mode, ZOOM_LVL_OUT_8X>(bp); return; + } +} + +void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) +{ + switch (mode) { + default: NOT_REACHED(); + case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom); return; + case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return; + case BM_TRANSPARENT: Draw<BM_TRANSPARENT> (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 46c30ec25..099aaa159 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 <BlitterMode mode, ZoomLevel zoom> void Draw(Blitter::BlitterParams *bp); + template <BlitterMode mode> void Draw(Blitter::BlitterParams *bp, ZoomLevel zoom); }; class FBlitter_32bppOptimized: public BlitterFactory<FBlitter_32bppOptimized> { |