New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAPHICS: Consider flip mode when handling off-screen clipping #979

Merged
merged 1 commit into from Aug 11, 2017
Jump to file or symbol
Failed to load files and symbols.
+32 −8
Diff settings

Always

Just for now

GRAPHICS: Consider flip mode when handling off-screen clipping

  • Loading branch information...
yinsimei committed Aug 3, 2017
commit f9ade10948a1c9814ae185d42f30843656047f6d
@@ -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;