[Scummvm-git-logs] scummvm master -> d6db4c27ad39543ae846f3cb1d06f4f1be1d1673
criezy
criezy at scummvm.org
Sat Mar 6 00:52:07 UTC 2021
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:
d6db4c27ad AGS: Fix off by one error in clipping rect and drawing rect
Commit: d6db4c27ad39543ae846f3cb1d06f4f1be1d1673
https://github.com/scummvm/scummvm/commit/d6db4c27ad39543ae846f3cb1d06f4f1be1d1673
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-06T00:51:58Z
Commit Message:
AGS: Fix off by one error in clipping rect and drawing rect
In allegro both the top-left and bottom-right corners are
included in the rect, but in Common::Rect the bottom-righ
corner is excluded. So we need to add one when creating the
Common::Rect.
Changed paths:
engines/ags/lib/allegro/gfx.cpp
engines/ags/lib/allegro/surface.cpp
diff --git a/engines/ags/lib/allegro/gfx.cpp b/engines/ags/lib/allegro/gfx.cpp
index ccee91ef17..6ca6f6352b 100644
--- a/engines/ags/lib/allegro/gfx.cpp
+++ b/engines/ags/lib/allegro/gfx.cpp
@@ -327,7 +327,7 @@ void rect(BITMAP *bmp, int x1, int y1, int x2, int y2, int color) {
SWAP(x1, x2);
if (y1 > y2)
SWAP(y1, y2);
- surf.frameRect(Common::Rect(x1, y1, x2, y2), color);
+ surf.frameRect(Common::Rect(x1, y1, x2 + 1, y2 + 1), color);
}
void rectfill(BITMAP *bmp, int x1, int y1, int x2, int y2, int color) {
@@ -336,7 +336,7 @@ void rectfill(BITMAP *bmp, int x1, int y1, int x2, int y2, int color) {
SWAP(x1, x2);
if (y1 > y2)
SWAP(y1, y2);
- surf.fillRect(Common::Rect(x1, y1, x2, y2), color);
+ surf.fillRect(Common::Rect(x1, y1, x2 + 1, y2 + 1), color);
}
void triangle(BITMAP *bmp, int x1, int y1, int x2, int y2, int x3, int y3, int color) {
diff --git a/engines/ags/lib/allegro/surface.cpp b/engines/ags/lib/allegro/surface.cpp
index fd32f252b3..7657dd12af 100644
--- a/engines/ags/lib/allegro/surface.cpp
+++ b/engines/ags/lib/allegro/surface.cpp
@@ -31,7 +31,7 @@ namespace AGS3 {
BITMAP::BITMAP(Graphics::ManagedSurface *owner) : _owner(owner),
w(owner->w), h(owner->h), pitch(owner->pitch), format(owner->format),
- clip(false), ct(0), cl(0), cr(owner->w), cb(owner->h) {
+ clip(false), ct(0), cl(0), cr(owner->w - 1), cb(owner->h - 1) {
line.resize(h);
for (uint y = 0; y < h; ++y)
line[y] = (byte *)_owner->getBasePtr(0, y);
@@ -101,9 +101,14 @@ void BITMAP::draw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
assert(format.bytesPerPixel == 2 || format.bytesPerPixel == 4 ||
(format.bytesPerPixel == 1 && srcBitmap->format.bytesPerPixel == 1));
+ // Allegro disables draw when the clipping rect has negative width/height.
+ // Common::Rect instead asserts, which we don't want.
+ if (cr < cl || cb < ct)
+ return;
+
// Figure out the dest area that will be updated
Common::Rect destRect = dstRect.findIntersectingRect(
- Common::Rect(cl, ct, cr, cb));
+ Common::Rect(cl, ct, cr + 1, cb + 1));
if (destRect.isEmpty())
// Area is entirely outside the clipping area, so nothing to draw
return;
More information about the Scummvm-git-logs
mailing list