aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-08-22 20:41:50 -0400
committerPaul Gilbert2015-08-22 20:41:50 -0400
commitc6633404c9580aab1c312d8ad1adadcaf4797a8d (patch)
tree24b34b87ef24c91b561e2c61dc44306d7227d950 /engines
parent1659e357c2aa3f051cb3baa20bbb0a4282948048 (diff)
downloadscummvm-rg350-c6633404c9580aab1c312d8ad1adadcaf4797a8d.tar.gz
scummvm-rg350-c6633404c9580aab1c312d8ad1adadcaf4797a8d.tar.bz2
scummvm-rg350-c6633404c9580aab1c312d8ad1adadcaf4797a8d.zip
SHERLOCK: RT: Simplified implementation of transBlitFrom
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/surface.cpp79
-rw-r--r--engines/sherlock/surface.h11
2 files changed, 27 insertions, 63 deletions
diff --git a/engines/sherlock/surface.cpp b/engines/sherlock/surface.cpp
index 3545dcfff9..b56692c704 100644
--- a/engines/sherlock/surface.cpp
+++ b/engines/sherlock/surface.cpp
@@ -101,78 +101,47 @@ void Surface::blitFrom(const Surface &src, const Common::Point &pt, const Common
void Surface::transBlitFrom(const ImageFrame &src, const Common::Point &pt,
bool flipped, int overrideColor, int scaleVal) {
- // Since a frame with offsets needs to have the offsets scaled as well, set up a srcBounds that has
- // the offset as negative left and top amounts accordingly, so the actual frame will be draw at
- // the correct scaled starting position
- Common::Rect srcBounds(-src._offset.x, -src._offset.y, src._width, src._height);
- transBlitFrom(src._frame, pt, srcBounds, flipped, overrideColor, scaleVal);
+ Common::Point drawPt(pt.x + src.sDrawXOffset(scaleVal), pt.y + src.sDrawYOffset(scaleVal));
+ transBlitFrom(src._frame, drawPt, flipped, overrideColor, scaleVal);
}
void Surface::transBlitFrom(const Surface &src, const Common::Point &pt,
bool flipped, int overrideColor, int scaleVal) {
const Graphics::Surface &s = src._surface;
- transBlitFrom(s, pt, Common::Rect(0, 0, src.w(), src.h()), flipped, overrideColor, scaleVal);
+ transBlitFrom(s, pt, flipped, overrideColor, scaleVal);
}
void Surface::transBlitFrom(const Graphics::Surface &src, const Common::Point &pt,
bool flipped, int overrideColor, int scaleVal) {
- transBlitFrom(src, pt, Common::Rect(0, 0, src.w, src.h), flipped, overrideColor, scaleVal);
-}
-
-void Surface::transBlitFrom(const Graphics::Surface &src, const Common::Point &destPos,
- const Common::Rect &srcBounds, bool flipped, int overrideColor, int scaleVal) {
if (scaleVal == SCALE_THRESHOLD) {
- transBlitFromUnscaled(src, Common::Point(destPos.x - srcBounds.left, destPos.y - srcBounds.top),
- flipped, overrideColor);
+ transBlitFromUnscaled(src, pt, flipped, overrideColor);
return;
}
- int scaleX = SCALE_THRESHOLD * SCALE_THRESHOLD / scaleVal;
- int scaleY = scaleX;
- int scaleXCtr = 0, scaleYCtr = 0;
- int destX, destY;
- int xCtr, yCtr;
- int maxX = destPos.x;
-
- for (yCtr = srcBounds.top, destY = destPos.y; yCtr < srcBounds.bottom && destY < this->h(); ++yCtr) {
- // Handle skipping lines if Y scaling
- scaleYCtr += scaleY;
-
- while (scaleYCtr >= SCALE_THRESHOLD && destY < this->h()) {
- scaleYCtr -= SCALE_THRESHOLD;
-
- if (destY >= 0 && yCtr >= 0 && yCtr < src.h) {
- // Handle drawing the line
- const byte *pSrc = (const byte *)src.getBasePtr(flipped ? srcBounds.right - 1 : srcBounds.left, yCtr);
- byte *pDest = (byte *)getBasePtr(destPos.x, destY);
- scaleXCtr = 0;
-
- for (xCtr = srcBounds.left, destX = destPos.x; xCtr < src.w && destX < this->w(); ++xCtr) {
- // Handle horizontal scaling
- scaleXCtr += scaleX;
-
- while (scaleXCtr >= SCALE_THRESHOLD && destX < this->w()) {
- scaleXCtr -= SCALE_THRESHOLD;
-
- // Only handle on-screen pixels
- if (destX >= 0 && xCtr >= 0 && xCtr < src.w && *pSrc != TRANSPARENCY)
- *pDest = *pSrc;
-
- ++pDest;
- ++destX;
- }
-
- maxX = MAX(maxX, destX);
- pSrc = pSrc + (flipped ? -1 : 1);
- }
- }
-
- ++destY;
+ int destWidth = src.w * SCALE_THRESHOLD / scaleVal;
+ int destHeight = src.h * SCALE_THRESHOLD / scaleVal;
+
+ // Loop through drawing output lines
+ for (int destY = pt.y, scaleYCtr = 0; destY < (pt.y + destHeight); ++destY, scaleYCtr += scaleVal) {
+ if (destY < 0 || destY >= this->h())
+ continue;
+ const byte *srcLine = (const byte *)src.getBasePtr(0, scaleYCtr / SCALE_THRESHOLD);
+ byte *destLine = (byte *)getBasePtr(pt.x, destY);
+
+ // Loop through drawing individual rows
+ for (int xCtr = 0, scaleXCtr = 0; xCtr < destWidth; ++xCtr, scaleXCtr += scaleVal) {
+ int destX = pt.x + xCtr;
+ if (destX < 0 || destX >= this->w())
+ continue;
+
+ byte srcVal = srcLine[flipped ? src.w - scaleXCtr / SCALE_THRESHOLD - 1 : scaleXCtr / SCALE_THRESHOLD];
+ if (srcVal != TRANSPARENCY)
+ destLine[xCtr] = srcVal;
}
}
// Mark the affected area
- addDirtyRect(Common::Rect(destPos.x, destPos.y, maxX, destY));
+ addDirtyRect(Common::Rect(pt.x, pt.y, pt.x + destWidth, pt.y + destHeight));
}
void Surface::transBlitFromUnscaled(const Graphics::Surface &src, const Common::Point &pt,
diff --git a/engines/sherlock/surface.h b/engines/sherlock/surface.h
index 7d8b2819b0..385fb1793e 100644
--- a/engines/sherlock/surface.h
+++ b/engines/sherlock/surface.h
@@ -60,11 +60,6 @@ private:
void transBlitFromUnscaled(const Graphics::Surface &src, const Common::Point &pt, bool flipped,
int overrideColor);
- /**
- * Draws a surface at a given position within this surface with transparency
- */
- void transBlitFrom(const Graphics::Surface &src, const Common::Point &destPos, const Common::Rect &srcBounds,
- bool flipped = false, int overrideColor = 0, int scaleVal = SCALE_THRESHOLD);
protected:
Graphics::Surface _surface;
@@ -121,19 +116,19 @@ public:
* Draws an image frame at a given position within this surface with transparency
*/
void transBlitFrom(const ImageFrame &src, const Common::Point &pt,
- bool flipped = false, int overrideColor = 0, int scaleVal = SCALE_THRESHOLD);
+ bool flipped = false, int overrideColor = 0, int scaleVal = 256);
/**
* Draws a surface at a given position within this surface with transparency
*/
void transBlitFrom(const Surface &src, const Common::Point &pt,
- bool flipped = false, int overrideColor = 0, int scaleVal = SCALE_THRESHOLD);
+ bool flipped = false, int overrideColor = 0, int scaleVal = 256);
/**
* Draws a surface at a given position within this surface with transparency
*/
void transBlitFrom(const Graphics::Surface &src, const Common::Point &pt,
- bool flipped = false, int overrideColor = 0, int scaleVal = SCALE_THRESHOLD);
+ bool flipped = false, int overrideColor = 0, int scaleVal = 256);
/**
* Fill a given area of the surface with a given color