aboutsummaryrefslogtreecommitdiff
path: root/graphics/transparent_surface.cpp
diff options
context:
space:
mode:
authorSimei Yin2017-08-03 12:50:16 +0200
committerEugene Sandulenko2017-08-12 00:48:47 +0200
commit7d60ccc46345c3ae80721fe3ba5e4a92245d1b81 (patch)
tree1afcc6a8190f5166aea82d8c6d2360db7506ab84 /graphics/transparent_surface.cpp
parentbb5864758817548268b9c48ce62e243100384b71 (diff)
downloadscummvm-rg350-7d60ccc46345c3ae80721fe3ba5e4a92245d1b81.tar.gz
scummvm-rg350-7d60ccc46345c3ae80721fe3ba5e4a92245d1b81.tar.bz2
scummvm-rg350-7d60ccc46345c3ae80721fe3ba5e4a92245d1b81.zip
GRAPHICS: Consider flip mode when handling off-screen clipping
Diffstat (limited to 'graphics/transparent_surface.cpp')
-rw-r--r--graphics/transparent_surface.cpp40
1 files changed, 32 insertions, 8 deletions
diff --git a/graphics/transparent_surface.cpp b/graphics/transparent_surface.cpp
index 83869cef30..48176f7fcc 100644
--- a/graphics/transparent_surface.cpp
+++ b/graphics/transparent_surface.cpp
@@ -400,19 +400,31 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
// Handle off-screen clipping
if (posY < 0) {
img->h = MAX(0, (int)img->h - -posY);
- img->setPixels((byte *)img->getBasePtr(0, -posY));
+ if (!(flipping & FLIP_V))
+ img->setPixels((byte *)img->getBasePtr(0, -posY));
posY = 0;
}
if (posX < 0) {
img->w = MAX(0, (int)img->w - -posX);
- img->setPixels((byte *)img->getBasePtr(-posX, 0));
+ if (!(flipping & FLIP_H))
+ img->setPixels((byte *)img->getBasePtr(-posX, 0));
posX = 0;
}
- img->w = CLIP((int)img->w, 0, (int)MAX((int)target.w - posX, 0));
- img->h = CLIP((int)img->h, 0, (int)MAX((int)target.h - posY, 0));
+ if (img->w > target.w - posX) {
+ if (flipping & FLIP_H)
+ img->setPixels((byte *)img->getBasePtr(img->w - target.w + posX, 0));
+ img->w = CLIP((int)img->w, 0, (int)MAX((int)target.w - posX, 0));
+ }
+
+ if (img->h > target.h - posY) {
+ if (flipping & FLIP_V)
+ img->setPixels((byte *)img->getBasePtr(0, img->h - target.h + posY));
+ img->h = CLIP((int)img->h, 0, (int)MAX((int)target.h - posY, 0));
+ }
+ // Flip surface
if ((img->w > 0) && (img->h > 0)) {
int xp = 0, yp = 0;
@@ -533,19 +545,31 @@ Common::Rect TransparentSurface::blitClip(Graphics::Surface &target, Common::Rec
// Handle off-screen clipping
if (posY < clippingArea.top) {
img->h = MAX(0, (int)img->h - (clippingArea.top - posY));
- img->setPixels((byte *)img->getBasePtr(0, clippingArea.top - posY));
+ if (!(flipping & FLIP_V))
+ img->setPixels((byte *)img->getBasePtr(0, clippingArea.top - posY));
posY = clippingArea.top;
}
if (posX < clippingArea.left) {
img->w = MAX(0, (int)img->w - (clippingArea.left - posX));
- img->setPixels((byte *)img->getBasePtr(clippingArea.left - posX, 0));
+ if (!(flipping & FLIP_H))
+ img->setPixels((byte *)img->getBasePtr(clippingArea.left - posX, 0));
posX = clippingArea.left;
}
- img->w = CLIP((int)img->w, 0, (int)MAX((int)clippingArea.right - posX, 0));
- img->h = CLIP((int)img->h, 0, (int)MAX((int)clippingArea.bottom - posY, 0));
+ if (img->w > clippingArea.right - posX) {
+ if (flipping & FLIP_H)
+ img->setPixels((byte *)img->getBasePtr(img->w - clippingArea.right + posX, 0));
+ img->w = CLIP((int)img->w, 0, (int)MAX((int)clippingArea.right - posX, 0));
+ }
+
+ if (img->h > clippingArea.bottom - posY) {
+ if (flipping & FLIP_V)
+ img->setPixels((byte *)img->getBasePtr(0, img->h - clippingArea.bottom + posY));
+ img->h = CLIP((int)img->h, 0, (int)MAX((int)clippingArea.bottom - posY, 0));
+ }
+ // Flip surface
if ((img->w > 0) && (img->h > 0)) {
int xp = 0, yp = 0;