[Scummvm-git-logs] scummvm master -> 4355c42044493249cfc2562e190e66f7226a4829
peterkohaut
peterkohaut at users.noreply.github.com
Wed Sep 4 18:00:16 CEST 2019
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4355c42044 BLADERUNNER: Performance fixes
Commit: 4355c42044493249cfc2562e190e66f7226a4829
https://github.com/scummvm/scummvm/commit/4355c42044493249cfc2562e190e66f7226a4829
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2019-09-04T17:59:29+02:00
Commit Message:
BLADERUNNER: Performance fixes
Pixel format functions and CLIP functions are too slow in debug builds,
replacing them with static code makes debug builds faster.
Changed paths:
engines/bladerunner/bladerunner.h
engines/bladerunner/font.cpp
engines/bladerunner/shape.cpp
engines/bladerunner/vqa_decoder.cpp
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h
index ebc8bd0..5b59a09 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 8ab205e..62b771f 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 60fa869..c844a57 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 d325057..769a314 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));
}
More information about the Scummvm-git-logs
mailing list