diff options
author | Alexander Tkachev | 2016-07-01 13:04:25 +0600 |
---|---|---|
committer | Eugene Sandulenko | 2016-07-03 12:24:11 +0200 |
commit | 6fd6043391d7faef569612797fb1c181c45a91dc (patch) | |
tree | f8a67787ea2ec688594fb831efcf7f076fdbf741 /graphics | |
parent | 4b87563792163d5fd538092b340500bccd20aa7b (diff) | |
download | scummvm-rg350-6fd6043391d7faef569612797fb1c181c45a91dc.tar.gz scummvm-rg350-6fd6043391d7faef569612797fb1c181c45a91dc.tar.bz2 scummvm-rg350-6fd6043391d7faef569612797fb1c181c45a91dc.zip |
GUI: Fix blitAlphaBitmapClip()
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/VectorRenderer.h | 1 | ||||
-rw-r--r-- | graphics/VectorRendererSpec.cpp | 54 | ||||
-rw-r--r-- | graphics/VectorRendererSpec.h | 1 |
3 files changed, 55 insertions, 1 deletions
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 78133b0e04..0352808706 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -480,6 +480,7 @@ public: * blitted into the active surface, at the position specified by "r". */ virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) = 0; + virtual void blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) = 0; virtual void blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r) = 0; virtual void blitAlphaBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) = 0; diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 32c2f06cc8..43ca2c40ad 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -797,6 +797,58 @@ blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) { template<typename PixelType> void VectorRendererSpec<PixelType>:: +blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping) { + if (clipping.isEmpty() || clipping.contains(r)) { + blitSubSurface(source, r); + return; + } + + int16 x = r.left; + int16 y = r.top; + + if (r.width() > source->w) + x = x + (r.width() >> 1) - (source->w >> 1); + + if (r.height() > source->h) + y = y + (r.height() >> 1) - (source->h >> 1); + + int w = source->w, h = source->h; + int usedW = w, usedH = h; + int offsetX = 0, offsetY = 0; + + if (x > clipping.right || x + w < clipping.left) return; + if (y > clipping.bottom || y + h < clipping.top) return; + if (x < clipping.left) { + offsetX = clipping.left - x; + usedW -= offsetX; + x = clipping.left; + } + if (y < clipping.top) { + offsetY = clipping.top - y; + usedH -= offsetY; + y = clipping.top; + } + if (usedW > clipping.width()) usedW = clipping.width(); + if (usedH > clipping.width()) usedH = clipping.height(); + + byte *dst_ptr = (byte *)_activeSurface->getBasePtr(x, y); + const byte *src_ptr = (const byte *)source->getBasePtr(offsetX, offsetY); + + const int dst_pitch = _activeSurface->pitch; + const int src_pitch = source->pitch; + + int lines = usedH; + const int sz = usedW * sizeof(PixelType); + + while (lines--) { + memcpy(dst_ptr, src_ptr, sz); + dst_ptr += dst_pitch; + src_ptr += src_pitch; + } +} + +template<typename PixelType> +void VectorRendererSpec<PixelType>:: blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r) { int16 x = r.left; int16 y = r.top; @@ -886,7 +938,7 @@ blitAlphaBitmapClip(const Graphics::Surface *source, const Common::Rect &r, cons } dst_ptr = dst_ptr - usedW + dst_pitch; - src_ptr = src_ptr - usedH + src_pitch; + src_ptr = src_ptr - usedW + src_pitch; } } diff --git a/graphics/VectorRendererSpec.h b/graphics/VectorRendererSpec.h index 5517555ede..bee6d4c425 100644 --- a/graphics/VectorRendererSpec.h +++ b/graphics/VectorRendererSpec.h @@ -92,6 +92,7 @@ public: void fillSurfaceClip(Common::Rect clipping); void blitSurface(const Graphics::Surface *source, const Common::Rect &r); void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r); + void blitSubSurfaceClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping); void blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r); void blitAlphaBitmapClip(const Graphics::Surface *source, const Common::Rect &r, const Common::Rect &clipping); |