diff options
author | Tobia Tesan | 2013-07-10 11:42:16 +0200 |
---|---|---|
committer | Tobia Tesan | 2013-08-01 00:04:21 +0200 |
commit | 9f97ad6a3e9e10fa7164a4e545c1705896f77925 (patch) | |
tree | 5e6990f84f185d2e635c81eb9c36eaa268c7da14 /engines/wintermute/graphics | |
parent | f014cccb94e0b3244a3e6dca91db7ca7552e6d79 (diff) | |
download | scummvm-rg350-9f97ad6a3e9e10fa7164a4e545c1705896f77925.tar.gz scummvm-rg350-9f97ad6a3e9e10fa7164a4e545c1705896f77925.tar.bz2 scummvm-rg350-9f97ad6a3e9e10fa7164a4e545c1705896f77925.zip |
WINTERMUTE: s/*transform/const &transform/
Diffstat (limited to 'engines/wintermute/graphics')
-rw-r--r-- | engines/wintermute/graphics/transform_tools.cpp | 20 | ||||
-rw-r--r-- | engines/wintermute/graphics/transform_tools.h | 2 | ||||
-rw-r--r-- | engines/wintermute/graphics/transparent_surface.cpp | 87 | ||||
-rw-r--r-- | engines/wintermute/graphics/transparent_surface.h | 4 |
4 files changed, 55 insertions, 58 deletions
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp index 0ab28eb275..194bedec64 100644 --- a/engines/wintermute/graphics/transform_tools.cpp +++ b/engines/wintermute/graphics/transform_tools.cpp @@ -40,9 +40,7 @@ namespace Wintermute { return newPoint; } - Rect32 TransformTools::newRect (Rect32 oldRect, TransformStruct *transform, Point32 *newHotspot) { - - assert (transform); + Rect32 TransformTools::newRect (Rect32 oldRect, const TransformStruct &transform, Point32 *newHotspot) { Point32 nw(oldRect.left, oldRect.top); Point32 ne(oldRect.right, oldRect.top); @@ -51,10 +49,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 +63,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 ae60e5ab32..fb165d7ec8 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, const 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 07c2537d0f..0ec0b84f25 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -496,10 +496,9 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p return retSize; } -TransparentSurface *TransparentSurface::rotoscale(TransformStruct *transform) const { +TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transform) const { - assert (transform); - assert (transform->_angle != 0); // This would not be ideal + assert (transform._angle != 0); // This would not be ideal Point32 newHotspot; Common::Rect srcRect(0, 0, (int16)w, (int16)h); @@ -514,43 +513,43 @@ TransparentSurface *TransparentSurface::rotoscale(TransformStruct *transform) co 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; float targY; - if (FAST_TRANSFORM) { - for (int y = 0; y < dstH; y++) { - for (int x = 0; x < dstW; x++) { - int x1 = x - newHotspot.x; - int y1 = y - newHotspot.y; +#if ENABLE_BILINEAR + for (int y = 0; y < dstH; y++) { + for (int x = 0; x < dstW; x++) { + 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); - } + copyPixelBilinear(targX, targY, x, y, srcRect, dstRect, this, target); } - } else { - for (int y = 0; y < dstH; y++) { - for (int x = 0; x < dstW; x++) { - int x1 = x - newHotspot.x; - int y1 = y - newHotspot.y; + } +#else + for (int y = 0; y < dstH; y++) { + for (int x = 0; x < dstW; x++) { + 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); - } + copyPixelNearestNeighbor(targX, targY, x, y, srcRect, dstRect, this, target); } } +#endif return target; } @@ -570,27 +569,27 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight) target->create((uint16)dstW, (uint16)dstH, this->format); - if (FAST_TRANSFORM) { - int projX; - int projY; - for (int y = 0; y < dstH; y++) { - for (int x = 0; x < dstW; x++) { - projX = x / dstW * srcW; - projY = y / dstH * srcH; - copyPixelNearestNeighbor(projX, projY, x, y, srcRect, dstRect, this, target); - } +#if ENABLE_BILINEAR + float projX; + float projY; + for (int y = 0; y < dstH; y++) { + for (int x = 0; x < dstW; x++) { + projX = x / (float)dstW * srcW; + projY = y / (float)dstH * srcH; + copyPixelBilinear(projX, projY, x, y, srcRect, dstRect, this, target); } - } else { - float projX; - float projY; - for (int y = 0; y < dstH; y++) { - for (int x = 0; x < dstW; x++) { - projX = x / (float)dstW * srcW; - projY = y / (float)dstH * srcH; - copyPixelBilinear(projX, projY, x, y, srcRect, dstRect, this, target); - } + } +#else + int projX; + int projY; + for (int y = 0; y < dstH; y++) { + for (int x = 0; x < dstW; x++) { + projX = x / dstW * srcW; + projY = y / dstH * srcH; + copyPixelNearestNeighbor(projX, projY, x, y, srcRect, dstRect, this, target); } } +#endif return target; } diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index 2798323379..71c139a76a 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -25,7 +25,7 @@ #include "graphics/surface.h" #include "engines/wintermute/graphics/transform_struct.h" -#define FAST_TRANSFORM 0 +#define ENABLE_BILINEAR 0 /* @@ -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 *rotoscale (TransformStruct *transform) const; + TransparentSurface *rotoscale (const TransformStruct &transform) const; static byte *_lookup; static void destroyLookup(); private: |