aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/graphics
diff options
context:
space:
mode:
authorTobia Tesan2013-07-09 20:57:03 +0200
committerTobia Tesan2013-08-01 00:03:46 +0200
commitb34d7b753912af6dd971872cd702d489974606ff (patch)
tree621c07f2ce02c9be03a9d1787398314b5a1621bb /engines/wintermute/graphics
parent0b21d6dca2ad5be41fa2aa4c2bed2cb694fba4d1 (diff)
downloadscummvm-rg350-b34d7b753912af6dd971872cd702d489974606ff.tar.gz
scummvm-rg350-b34d7b753912af6dd971872cd702d489974606ff.tar.bz2
scummvm-rg350-b34d7b753912af6dd971872cd702d489974606ff.zip
WINTERMUTE: *transform as pointer in transform_tools
Diffstat (limited to 'engines/wintermute/graphics')
-rw-r--r--engines/wintermute/graphics/transform_tools.cpp21
-rw-r--r--engines/wintermute/graphics/transform_tools.h2
-rw-r--r--engines/wintermute/graphics/transparent_surface.cpp23
-rw-r--r--engines/wintermute/graphics/transparent_surface.h2
4 files changed, 27 insertions, 21 deletions
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index f0a092a31b..2388b88236 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -43,7 +43,10 @@ namespace Wintermute {
return newPoint;
}
- Rect32 TransformTools::newRect (Rect32 oldRect, TransformStruct transform, Point32 *newHotspot) {
+ Rect32 TransformTools::newRect (Rect32 oldRect, TransformStruct *transform, Point32 *newHotspot) {
+
+ assert (transform);
+
Point32 nw(oldRect.left, oldRect.top);
Point32 ne(oldRect.right, oldRect.top);
Point32 sw(oldRect.left, oldRect.bottom);
@@ -51,10 +54,10 @@ namespace Wintermute {
FloatPoint nw1, ne1, sw1, se1;
- nw1 = transformPoint(nw - transform._hotspot, transform._angle, transform._zoom);
- ne1 = transformPoint(ne - transform._hotspot, transform._angle, transform._zoom);
- sw1 = transformPoint(sw - transform._hotspot, transform._angle, transform._zoom);
- se1 = transformPoint(se - transform._hotspot, transform._angle, transform._zoom);
+ nw1 = transformPoint(nw - transform->_hotspot, transform->_angle, transform->_zoom);
+ ne1 = transformPoint(ne - transform->_hotspot, transform->_angle, transform->_zoom);
+ sw1 = transformPoint(sw - transform->_hotspot, transform->_angle, transform->_zoom);
+ se1 = transformPoint(se - transform->_hotspot, transform->_angle, transform->_zoom);
float top = MIN(nw1.y, MIN(ne1.y, MIN(sw1.y, se1.y)));
float bottom = MAX(nw1.y, MAX(ne1.y, MAX(sw1.y, se1.y)));
@@ -65,10 +68,10 @@ namespace Wintermute {
newHotspot->y = -floor(top);
newHotspot->x = -floor(left);
- res.top = floor(top) + transform._hotspot.y;
- res.bottom = ceil(bottom) + transform._hotspot.y;
- res.left = floor(left) + transform._hotspot.x;
- res.right = ceil(right) + transform._hotspot.x;
+ res.top = floor(top) + transform->_hotspot.y;
+ res.bottom = ceil(bottom) + transform->_hotspot.y;
+ res.left = floor(left) + transform->_hotspot.x;
+ res.right = ceil(right) + transform->_hotspot.x;
return res;
}
diff --git a/engines/wintermute/graphics/transform_tools.h b/engines/wintermute/graphics/transform_tools.h
index fbc0653e64..ae60e5ab32 100644
--- a/engines/wintermute/graphics/transform_tools.h
+++ b/engines/wintermute/graphics/transform_tools.h
@@ -41,7 +41,7 @@ public:
* and, as a side-effect, "newHotspot" will tell you where the hotspot will
* have ended up in the new rect, for centering.
*/
- static Rect32 newRect (Rect32 oldRect, TransformStruct transform, Point32 *newHotspot);
+ static Rect32 newRect (Rect32 oldRect, TransformStruct *transform, Point32 *newHotspot);
};
} // end of namespace Wintermute
#endif
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 5606d41ae6..1139b08199 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -496,7 +496,10 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
return retSize;
}
-TransparentSurface *TransparentSurface::rotate(TransformStruct transform) const {
+TransparentSurface *TransparentSurface::rotate(TransformStruct *transform) const {
+
+ assert (transform);
+
Point32 newHotspot;
Common::Rect srcRect(0, 0, (int16)w, (int16)h);
Rect32 rect = TransformTools::newRect(Rect32 (srcRect), transform, &newHotspot);
@@ -510,7 +513,7 @@ TransparentSurface *TransparentSurface::rotate(TransformStruct transform) const
target->create((uint16)dstW, (uint16)dstH, this->format);
- uint32 invAngle = (360 - transform._angle) % 360;
+ uint32 invAngle = (360 - transform->_angle) % 360;
float invCos = cos(invAngle * M_PI / 180.0);
float invSin = sin(invAngle * M_PI / 180.0);
float targX;
@@ -522,11 +525,11 @@ TransparentSurface *TransparentSurface::rotate(TransformStruct transform) const
int x1 = x - newHotspot.x;
int y1 = y - newHotspot.y;
- targX = ((x1 * invCos - y1 * invSin)) * 100.0 / transform._zoom.x + srcRect.left;
- targY = ((x1 * invSin + y1 * invCos)) * 100.0 / transform._zoom.y + srcRect.top;
+ targX = ((x1 * invCos - y1 * invSin)) * 100.0 / transform->_zoom.x + srcRect.left;
+ targY = ((x1 * invSin + y1 * invCos)) * 100.0 / transform->_zoom.y + srcRect.top;
- targX += transform._hotspot.x;
- targY += transform._hotspot.y;
+ targX += transform->_hotspot.x;
+ targY += transform->_hotspot.y;
copyPixelNearestNeighbor(targX, targY, x, y, srcRect, dstRect, this, target);
}
@@ -537,11 +540,11 @@ TransparentSurface *TransparentSurface::rotate(TransformStruct transform) const
int x1 = x - newHotspot.x;
int y1 = y - newHotspot.y;
- targX = ((x1 * invCos - y1 * invSin)) * 100.0 / transform._zoom.x + srcRect.left;
- targY = ((x1 * invSin + y1 * invCos)) * 100.0 / transform._zoom.y + srcRect.top;
+ targX = ((x1 * invCos - y1 * invSin)) * 100.0 / transform->_zoom.x + srcRect.left;
+ targY = ((x1 * invSin + y1 * invCos)) * 100.0 / transform->_zoom.y + srcRect.top;
- targX += transform._hotspot.x;
- targY += transform._hotspot.y;
+ targX += transform->_hotspot.x;
+ targY += transform->_hotspot.y;
copyPixelBilinear(targX, targY, x, y, srcRect, dstRect, this, target);
}
diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h
index f9486d1b25..c01b10d96f 100644
--- a/engines/wintermute/graphics/transparent_surface.h
+++ b/engines/wintermute/graphics/transparent_surface.h
@@ -111,7 +111,7 @@ struct TransparentSurface : public Graphics::Surface {
void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false);
TransparentSurface *scale (uint16 newWidth, uint16 newHeight) const;
- TransparentSurface *rotate(TransformStruct transform) const;
+ TransparentSurface *rotate(TransformStruct *transform) const;
static byte *_lookup;
static void destroyLookup();
private: