diff options
author | Peter Kohaut | 2019-09-04 17:22:35 +0200 |
---|---|---|
committer | Peter Kohaut | 2019-09-04 17:59:29 +0200 |
commit | 4355c42044493249cfc2562e190e66f7226a4829 (patch) | |
tree | 5a961a26b2e1da65e4093946e2ab87c02158426d /engines/bladerunner | |
parent | a7e30d0e7f62aad9aceadd674f1b51146f20958d (diff) | |
download | scummvm-rg350-4355c42044493249cfc2562e190e66f7226a4829.tar.gz scummvm-rg350-4355c42044493249cfc2562e190e66f7226a4829.tar.bz2 scummvm-rg350-4355c42044493249cfc2562e190e66f7226a4829.zip |
BLADERUNNER: Performance fixes
Pixel format functions and CLIP functions are too slow in debug builds,
replacing them with static code makes debug builds faster.
Diffstat (limited to 'engines/bladerunner')
-rw-r--r-- | engines/bladerunner/bladerunner.h | 12 | ||||
-rw-r--r-- | engines/bladerunner/font.cpp | 2 | ||||
-rw-r--r-- | engines/bladerunner/shape.cpp | 2 | ||||
-rw-r--r-- | engines/bladerunner/vqa_decoder.cpp | 6 |
4 files changed, 18 insertions, 4 deletions
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index ebc8bd06b2..5b59a09206 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -329,6 +329,18 @@ static inline const Graphics::PixelFormat gameDataPixelFormat() { return Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15); } +static inline void getGameDataColor(uint16 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) { + // gameDataPixelFormat().colorToARGB(vqaColor, a, r, g, b); + // using pixel format functions is too slow on some ports because of runtime checks + uint8 r5 = (color >> 10) & 0x1F; + uint8 g5 = (color >> 5) & 0x1F; + uint8 b5 = (color ) & 0x1F; + a = color >> 15; + r = (r5 << 3) | (r5 >> 2); + g = (g5 << 3) | (g5 >> 2); + b = (b5 << 3) | (b5 >> 2); +} + static inline const Graphics::PixelFormat screenPixelFormat() { return ((BladeRunnerEngine*)g_engine)->_screenPixelFormat; } diff --git a/engines/bladerunner/font.cpp b/engines/bladerunner/font.cpp index 8ab205eea1..62b771fd66 100644 --- a/engines/bladerunner/font.cpp +++ b/engines/bladerunner/font.cpp @@ -140,7 +140,7 @@ void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 col int endX = width + x - 1; while (currentX <= endX && currentX < dst->w) { uint8 a, r, g, b; - gameDataPixelFormat().colorToARGB(*srcPtr, a, r, g, b); + getGameDataColor(*srcPtr, a, r, g, b); if (!a) { // Alpha is inversed uint32 outColor = color; if (_useFontColor) { diff --git a/engines/bladerunner/shape.cpp b/engines/bladerunner/shape.cpp index 60fa869fc1..c844a57b45 100644 --- a/engines/bladerunner/shape.cpp +++ b/engines/bladerunner/shape.cpp @@ -111,7 +111,7 @@ void Shape::draw(Graphics::Surface &surface, int x, int y) const { src_p += 2; uint8 a, r, g, b; - gameDataPixelFormat().colorToARGB(shpColor, a, r, g, b); + getGameDataColor(shpColor, a, r, g, b); if (!a) { // Ignore the alpha in the output as it is inversed in the input diff --git a/engines/bladerunner/vqa_decoder.cpp b/engines/bladerunner/vqa_decoder.cpp index d3250577c2..769a314f82 100644 --- a/engines/bladerunner/vqa_decoder.cpp +++ b/engines/bladerunner/vqa_decoder.cpp @@ -834,10 +834,12 @@ void VQADecoder::VQAVideoTrack::VPTRWriteBlock(Graphics::Surface *surface, unsig src_p += 2; uint8 a, r, g, b; - gameDataPixelFormat().colorToARGB(vqaColor, a, r, g, b); + getGameDataColor(vqaColor, a, r, g, b); if (!(alpha && a)) { - void* dstPtr = surface->getBasePtr(CLIP(dst_x + x, (uint32)0, (uint32)(surface->w - 1)), CLIP(dst_y + y, (uint32)0, (uint32)(surface->h - 1))); + // clip is too slow and it is not needed + // void* dstPtr = surface->getBasePtr(CLIP(dst_x + x, (uint32)0, (uint32)(surface->w - 1)), CLIP(dst_y + y, (uint32)0, (uint32)(surface->h - 1))); + void* dstPtr = surface->getBasePtr(dst_x + x, dst_y + y); // Ignore the alpha in the output as it is inversed in the input drawPixel(*surface, dstPtr, surface->format.RGBToColor(r, g, b)); } |