[Scummvm-git-logs] scummvm master -> b632dc41e69387e139c3a64627c0c442071ce17b
OMGPizzaGuy
48367439+OMGPizzaGuy at users.noreply.github.com
Thu Aug 13 02:40:38 UTC 2020
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:
b632dc41e6 ULTIMA8: clean up Ultima8::Rect Intersect and rename to clip to match Common::Rect
Commit: b632dc41e69387e139c3a64627c0c442071ce17b
https://github.com/scummvm/scummvm/commit/b632dc41e69387e139c3a64627c0c442071ce17b
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-08-12T21:39:32-05:00
Commit Message:
ULTIMA8: clean up Ultima8::Rect Intersect and rename to clip to match Common::Rect
Changed paths:
engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
engines/ultima/ultima8/graphics/soft_render_surface.cpp
engines/ultima/ultima8/gumps/gump.cpp
engines/ultima/ultima8/misc/rect.h
diff --git a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
index 796d14b38b..d6b8bee248 100644
--- a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
@@ -461,7 +461,7 @@ void BaseSoftRenderSurface::GetClippingRect(Rect &r) const {
void BaseSoftRenderSurface::SetClippingRect(const Rect &r) {
// What we need to do is to clip the clipping rect to the phyiscal screen
_clipWindow = r;
- _clipWindow.Intersect(-_ox, -_oy, _width, _height);
+ _clipWindow.clip(Rect(-_ox, -_oy, -_ox + _width, -_oy + _height));
}
//
@@ -474,7 +474,7 @@ void BaseSoftRenderSurface::SetClippingRect(const Rect &r) {
//
int16 BaseSoftRenderSurface::CheckClipped(const Rect &c) const {
Rect r = c;
- r.Intersect(_clipWindow);
+ r.clip(_clipWindow);
// Clipped away to the void
if (!r.IsValid()) return -1;
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.cpp b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
index 5b477c3b74..75296d63a1 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
@@ -98,7 +98,13 @@ template<class uintX> void SoftRenderSurface<uintX>::Fill8(uint8 /*index*/, int3
//
template<class uintX> void SoftRenderSurface<uintX>::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) {
- _clipWindow.IntersectOther(sx, sy, w, h);
+ Rect rect(sx, sy, sx + w, sy + h);
+ rect.clip(_clipWindow);
+ sx = rect.left;
+ sy = rect.top;
+ w = rect.width();
+ h = rect.height();
+
if (!w || !h) return;
// An optimization.
@@ -128,7 +134,13 @@ template<class uintX> void SoftRenderSurface<uintX>::Fill32(uint32 rgb, int32 sx
// 16 bit version
template<> void SoftRenderSurface<uint16>::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) {
- _clipWindow.IntersectOther(sx, sy, w, h);
+ Rect rect(sx, sy, sx + w, sy + h);
+ rect.clip(_clipWindow);
+ sx = rect.left;
+ sy = rect.top;
+ w = rect.width();
+ h = rect.height();
+
if (!w || !h) return;
// An optimization.
@@ -150,7 +162,13 @@ template<> void SoftRenderSurface<uint16>::Fill32(uint32 rgb, int32 sx, int32 sy
// 32 bit version
template<> void SoftRenderSurface<uint32>::Fill32(uint32 rgb, int32 sx, int32 sy, int32 w, int32 h) {
- _clipWindow.IntersectOther(sx, sy, w, h);
+ Rect rect(sx, sy, sx + w, sy + h);
+ rect.clip(_clipWindow);
+ sx = rect.left;
+ sy = rect.top;
+ w = rect.width();
+ h = rect.height();
+
if (!w || !h) return;
// An optimization.
@@ -180,7 +198,13 @@ template<> void SoftRenderSurface<uint32>::Fill32(uint32 rgb, int32 sx, int32 sy
//#define CHECK_ALPHA_FILLS
template<class uintX> void SoftRenderSurface<uintX>::FillAlpha(uint8 alpha, int32 sx, int32 sy, int32 w, int32 h) {
- _clipWindow.IntersectOther(sx, sy, w, h);
+ Rect rect(sx, sy, sx + w, sy + h);
+ rect.clip(_clipWindow);
+ sx = rect.left;
+ sy = rect.top;
+ w = rect.width();
+ h = rect.height();
+
if (!w || !h || !RenderSurface::_format.aMask) return;
// An optimization.
@@ -232,7 +256,13 @@ template<class uintX> void SoftRenderSurface<uintX>::FillBlended(uint32 rgba, in
return;
}
- _clipWindow.IntersectOther(sx, sy, w, h);
+ Rect rect(sx, sy, sx + w, sy + h);
+ rect.clip(_clipWindow);
+ sx = rect.left;
+ sy = rect.top;
+ w = rect.width();
+ h = rect.height();
+
if (!w || !h) return;
// An optimization.
@@ -348,7 +378,13 @@ template<class uintX> void SoftRenderSurface<uintX>::Blit(Texture *_tex, int32 s
// Clip to window
int px = dx, py = dy;
- _clipWindow.IntersectOther(dx, dy, w, h);
+ Rect rect(dx, dy, dx + w, dy + h);
+ rect.clip(_clipWindow);
+ dx = rect.left;
+ dy = rect.top;
+ w = rect.width();
+ h = rect.height();
+
if (!w || !h) return;
// Adjust source x and y
@@ -428,7 +464,14 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(Texture *_tex, in
// Clip to window
int px = dx, py = dy;
- _clipWindow.IntersectOther(dx, dy, w, h);
+
+ Rect rect(dx, dy, dx + w, dy + h);
+ rect.clip(_clipWindow);
+ dx = rect.left;
+ dy = rect.top;
+ w = rect.width();
+ h = rect.height();
+
if (!w || !h) return;
// Adjust source x and y
@@ -538,7 +581,14 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(Texture *_tex, i
// Clip to window
int px = dx, py = dy;
- _clipWindow.IntersectOther(dx, dy, w, h);
+
+ Rect rect(dx, dy, dx + w, dy + h);
+ rect.clip(_clipWindow);
+ dx = rect.left;
+ dy = rect.top;
+ w = rect.width();
+ h = rect.height();
+
if (!w || !h)
return;
diff --git a/engines/ultima/ultima8/gumps/gump.cpp b/engines/ultima/ultima8/gumps/gump.cpp
index b8a10795d0..332af08c12 100644
--- a/engines/ultima/ultima8/gumps/gump.cpp
+++ b/engines/ultima/ultima8/gumps/gump.cpp
@@ -237,7 +237,7 @@ void Gump::Paint(RenderSurface *surf, int32 lerp_factor, bool scaled) {
// Set new clipping rect
Rect new_rect = _dims;
- new_rect.Intersect(old_rect);
+ new_rect.clip(old_rect);
surf->SetClippingRect(new_rect);
// Paint This
@@ -309,7 +309,7 @@ void Gump::PaintCompositing(RenderSurface *surf, int32 lerp_factor,
// Set new clipping rect
Rect new_rect(_dims);
GumpRectToScreenSpace(new_rect, ROUND_OUTSIDE);
- new_rect.Intersect(old_rect);
+ new_rect.clip(old_rect);
surf->SetClippingRect(new_rect);
// Iterate all children
diff --git a/engines/ultima/ultima8/misc/rect.h b/engines/ultima/ultima8/misc/rect.h
index 1b7db07014..418c506b97 100644
--- a/engines/ultima/ultima8/misc/rect.h
+++ b/engines/ultima/ultima8/misc/rect.h
@@ -93,52 +93,18 @@ struct Rect {
bottom = top + nh;
}
- // Intersect/Clip this rect with another
- void Intersect(int ox, int oy, int ow, int oh) {
- int x2 = right, y2 = bottom;
- int ox2 = ox + ow, oy2 = oy + oh;
-
- if (left < ox) left = ox;
- else if (left > ox2) left = ox2;
-
- if (x2 < ox) x2 = ox;
- else if (x2 > ox2) x2 = ox2;
-
- if (top < oy) top = oy;
- else if (top > oy2) top = oy2;
+ void clip(const Rect &r) {
+ if (top < r.top) top = r.top;
+ else if (top > r.bottom) top = r.bottom;
- if (y2 < oy) y2 = oy;
- else if (y2 > oy2) y2 = oy2;
-
- right = x2;
- bottom = y2;
- }
+ if (left < r.left) left = r.left;
+ else if (left > r.right) left = r.right;
- // Intersect/Clip this another with this
- template<typename T>
- void IntersectOther(T &ox, T &oy, T &ow, T &oh) const {
- int x2 = right, y2 = bottom;
- int ox2 = ox + ow, oy2 = oy + oh;
-
- if (ox < left) ox = left;
- else if (ox > x2) ox = x2;
-
- if (ox2 < left) ox2 = left;
- else if (ox2 > x2) ox2 = x2;
-
- if (oy < top) oy = top;
- else if (oy > y2) oy = y2;
-
- if (oy2 < top) oy2 = top;
- else if (oy2 > y2) oy2 = y2;
-
- ow = ox2 - ox;
- oh = oy2 - oy;
- }
+ if (bottom < r.top) bottom = r.bottom;
+ else if (bottom > r.bottom) bottom = r.bottom;
- // Intersect/Clip this rect with another
- void Intersect(const Rect &o) {
- Intersect(o.left, o.top, o.width(), o.height());
+ if (right < r.left) right = r.left;
+ else if (right > r.right) right = r.right;
}
// Union/Add this rect with another
More information about the Scummvm-git-logs
mailing list