[Scummvm-git-logs] scummvm master -> 4ba746f6a0f89d523b9eeef55d6ff033d67de0ab
sev-
noreply at scummvm.org
Mon Oct 16 15:33:37 UTC 2023
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:
4ba746f6a0 COMPOSER: Optimize sprite drawing
Commit: 4ba746f6a0f89d523b9eeef55d6ff033d67de0ab
https://github.com/scummvm/scummvm/commit/4ba746f6a0f89d523b9eeef55d6ff033d67de0ab
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2023-10-16T17:33:33+02:00
Commit Message:
COMPOSER: Optimize sprite drawing
Changed paths:
engines/composer/graphics.cpp
diff --git a/engines/composer/graphics.cpp b/engines/composer/graphics.cpp
index a49bb761017..ed6873df706 100644
--- a/engines/composer/graphics.cpp
+++ b/engines/composer/graphics.cpp
@@ -813,6 +813,8 @@ bool ComposerEngine::initSprite(Sprite &sprite) {
if (width > 0 && height > 0) {
sprite._surface.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
decompressBitmap(type, stream, (byte *)sprite._surface.getPixels(), size, width, height);
+ // sprite is BMP-style (bottom-up), so flip it
+ sprite._surface.flipVertical(Common::Rect(width, height));
} else {
// there are some sprites (e.g. a -998x-998 one in Gregory's title screen)
// which have an invalid size, but the original engine doesn't notice for
@@ -828,22 +830,17 @@ bool ComposerEngine::initSprite(Sprite &sprite) {
}
void ComposerEngine::drawSprite(const Sprite &sprite) {
- int x = sprite._pos.x;
- int y = sprite._pos.y;
+ Common::Rect srcRect(sprite._surface.w, sprite._surface.h);
+ Common::Rect dstRect(
+ sprite._pos.x,
+ sprite._pos.y,
+ sprite._pos.x + sprite._surface.w,
+ sprite._pos.y + sprite._surface.h);
+
+ if (!_screen.clip(srcRect, dstRect))
+ return;
- // incoming data is BMP-style (bottom-up), so flip it
- byte *pixels = (byte *)_screen.getPixels();
- for (int j = 0; j < sprite._surface.h; j++) {
- if (j + y < 0)
- continue;
- if (j + y >= _screen.h)
- break;
- const byte *in = (const byte *)sprite._surface.getBasePtr(0, sprite._surface.h - j - 1);
- byte *out = pixels + ((j + y) * _screen.w) + x;
- for (int i = 0; i < sprite._surface.w; i++)
- if ((x + i >= 0) && (x + i < _screen.w) && in[i])
- out[i] = in[i];
- }
+ _screen.copyRectToSurfaceWithKey(sprite._surface, dstRect.left, dstRect.top, srcRect, 0x00);
}
} // End of namespace Composer
More information about the Scummvm-git-logs
mailing list