[Scummvm-git-logs] scummvm master -> f09cca7ac9dc7f5606a63d12ad996693a1bd6785
criezy
criezy at scummvm.org
Sun Mar 7 01:08:37 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:
f09cca7ac9 AGS: Fix issues with BITMAP clipping rect
Commit: f09cca7ac9dc7f5606a63d12ad996693a1bd6785
https://github.com/scummvm/scummvm/commit/f09cca7ac9dc7f5606a63d12ad996693a1bd6785
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-07T01:08:21Z
Commit Message:
AGS: Fix issues with BITMAP clipping rect
Allegro API to set or get the clipping rect include both the
top-left and bottom-right corners. But internally in the
BITMAP the bottom-right corner is excluded, and is thus one
more that the one in the API functions.
Also ensure that the clipping rect is used by setting the clip
flag to true. The Allegro documentation indicates that it can
be set to false to get better performances, but will result in
your program dying a horrible death if you try to draw beyond
the edges of the bitmap. And by default clip is on. AGS never
turns it off, so just ensure it is set to on in the constructor.
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 6ca6f6352b..f61beb3159 100644
--- a/engines/ags/lib/allegro/gfx.cpp
+++ b/engines/ags/lib/allegro/gfx.cpp
@@ -56,10 +56,12 @@ int set_gfx_mode(int card, int w, int h, int v_w, int v_h) {
}
void set_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2) {
+ // The rect passed to the function in inclusive-inclusive, but
+ // internally the clipping rect in BITMAP is inclusive-exclusive.
bitmap->cl = x1;
bitmap->ct = y1;
- bitmap->cr = x2;
- bitmap->cb = y2;
+ bitmap->cr = x2 + 1;
+ bitmap->cb = y2 + 1;
}
void get_clip_rect(BITMAP *bitmap, int *x1, int *y1, int *x2, int *y2) {
@@ -68,9 +70,9 @@ void get_clip_rect(BITMAP *bitmap, int *x1, int *y1, int *x2, int *y2) {
if (y1)
*y1 = bitmap->ct;
if (x2)
- *x2 = bitmap->cr;
+ *x2 = bitmap->cr - 1;
if (y2)
- *y2 = bitmap->cb;
+ *y2 = bitmap->cb - 1;
}
void acquire_bitmap(BITMAP *bitmap) {
diff --git a/engines/ags/lib/allegro/surface.cpp b/engines/ags/lib/allegro/surface.cpp
index 7657dd12af..2888d5d76c 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 - 1), cb(owner->h - 1) {
+ clip(true), ct(0), cl(0), cr(owner->w), cb(owner->h) {
line.resize(h);
for (uint y = 0; y < h; ++y)
line[y] = (byte *)_owner->getBasePtr(0, y);
@@ -103,12 +103,12 @@ void BITMAP::draw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
// 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)
+ 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 + 1, cb + 1));
+ Common::Rect(cl, ct, cr, cb));
if (destRect.isEmpty())
// Area is entirely outside the clipping area, so nothing to draw
return;
More information about the Scummvm-git-logs
mailing list