From 9d6e398e74348d397e99915b20d96cd06e69ed15 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 30 Jan 2011 20:36:17 +0000 Subject: SWORD25: Added alternative code for video frame blitting (currently disabled) svn-id: r55664 --- engines/sword25/gfx/dynamicbitmap.cpp | 17 +++++++++++++++++ engines/sword25/gfx/image/renderedimage.cpp | 24 ++++++++++++++++++++++++ engines/sword25/gfx/image/renderedimage.h | 3 +++ 3 files changed, 44 insertions(+) (limited to 'engines/sword25') diff --git a/engines/sword25/gfx/dynamicbitmap.cpp b/engines/sword25/gfx/dynamicbitmap.cpp index 55a3070acd..49dacc069e 100644 --- a/engines/sword25/gfx/dynamicbitmap.cpp +++ b/engines/sword25/gfx/dynamicbitmap.cpp @@ -81,10 +81,27 @@ bool DynamicBitmap::doRender() { // Draw the bitmap bool result; if (_scaleFactorX == 1.0f && _scaleFactorY == 1.0f) { +#if 1 + // This is what the game does originally, which can be + // a bit slow when drawing videos, but it's not the main + // bottleneck. result = _image->blit(_absoluteX, _absoluteY, (_flipV ? BitmapResource::FLIP_V : 0) | (_flipH ? BitmapResource::FLIP_H : 0), 0, _modulationColor, -1, -1); +#else + // WIP: A bit faster code + + // We don't need to check for transparency when drawing + // videos, thus just copy the buffer contents directly. + // This messes up the fire animation in the menu, for + // some odd reason. It also makes the video colors a + // bit lighter, resulting in a visible black border + // around the typed letters in the intro (which are + // drawn over a black border) + _image->copyDirectly(_absoluteX, _absoluteY); +#endif + return true; } else { result = _image->blit(_absoluteX, _absoluteY, (_flipV ? BitmapResource::FLIP_V : 0) | diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp index d4f493d43c..0d2ffb5aee 100644 --- a/engines/sword25/gfx/image/renderedimage.cpp +++ b/engines/sword25/gfx/image/renderedimage.cpp @@ -337,6 +337,30 @@ bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRe return true; } +void RenderedImage::copyDirectly(int posX, int posY) { + byte *data = _data; + int w = _width; + int h = _height; + + // Handle off-screen clipping + if (posY < 0) { + h = MAX(0, (int)_height - -posY); + data = (byte *)_data + _width * -posY; + posY = 0; + } + + if (posX < 0) { + w = MAX(0, (int)_width - -posX); + data = (byte *)_data + (-posX * 4); + posX = 0; + } + + w = CLIP((int)w, 0, (int)MAX((int)_backSurface->w - posX, 0)); + h = CLIP((int)h, 0, (int)MAX((int)_backSurface->h - posY, 0)); + + g_system->copyRectToScreen(data, _backSurface->pitch, posX, posY, w, h); +} + /** * Scales a passed surface, creating a new surface with the result * @param srcImage Source image to scale diff --git a/engines/sword25/gfx/image/renderedimage.h b/engines/sword25/gfx/image/renderedimage.h index a9f2f1823c..0375c7acbe 100644 --- a/engines/sword25/gfx/image/renderedimage.h +++ b/engines/sword25/gfx/image/renderedimage.h @@ -72,6 +72,8 @@ public: return GraphicEngine::CF_ARGB32; } + void copyDirectly(int posX, int posY); + virtual bool blit(int posX = 0, int posY = 0, int flipping = Image::FLIP_NONE, Common::Rect *pPartRect = NULL, @@ -105,6 +107,7 @@ public: } static Graphics::Surface *scale(const Graphics::Surface &srcImage, int xSize, int ySize); + private: byte *_data; int _width; -- cgit v1.2.3