[Scummvm-cvs-logs] scummvm master -> 9fb15a909c964c607110d29b15074c4a0269baae
somaen
einarjohants at gmail.com
Thu Aug 1 11:10:14 CEST 2013
This automated email contains information about 53 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
03c4b7a240 WINTERMUTE: Introduce TransformStruct and FloatPoint; add operators to Point32
3c0089e31e WINTERMUTE: Introduce TransformTools
66ba2ea455 WINTERMUTE: Refactor some bits to use TransformStruct
384dd8da7e WINTERMUTE: Bilinear scaling.
cced42a765 WINTERMUTE: Add cast op Common::Rect => Rect32
58e096de97 WINTERMUTE: Add rotation
321c7f0716 WINTERMUTE: Removed useless argument from rotate()
e30ab15bb0 WINTERMUTE: Move if() outside transform loop
e47deb0e0e WINTERMUTE: Rename pixel copy functions
d2a249384e WINTERMUTE: Partial fix for mirrored sprites
b788ae7f38 WINTERMUTE: Swap flip bits
8bed134ad6 WINTERMUTE: Force angle normalization
0b21d6dca2 WINTERMUTE: Fix alpha bug in engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
b34d7b7539 WINTERMUTE: *transform as pointer in transform_tools
285ed18979 WINTERMUTE: Rename rotate() -> rotoscale() for consistency
ae589c41ff WINTERMUTE: Deprecate setAlphaMod, setColorMod
b6ed5ee816 WINTERMUTE: Reinstate rgbaMod comparisons for compare-tickets
1b9967400d WINTERMUTE: Use constants from transform_tools for consistency
dafcef5c9f WINTERMUTE: Replace normalization loop with if() for legibility
0153f762b1 WINTERMUTE: Defaults -> float
f014cccb94 WINTERMUTE: Formatting
9f97ad6a3e WINTERMUTE: s/*transform/const &transform/
a0561f1aa5 WINTERMUTE: Fix calculation of inverse angles
ab022b1798 WINTERMUTE: // End of namespace Wintermute
163cd6a528 WINTERMUTE: Constants
6f03fbac84 WINTERMUTE: Pass structs by const reference
5a9e917a60 WINTERMUTE: Fix operator precedence in scale()
4405a534e5 WINTERMUTE: Remove set[Color|Alpha]Mod altogether
9cfea04846 WINTERMUTE: Formatting
9d4def3bfd WINTERMUTE: Fix alpha bug in BaseRenderOSystem::fadeToColor
64db90ed67 WINTERMUTE: TransformStruct by reference in engines/wintermute/base/gfx/osystem/base_render_osystem.h
286b1d11ca WINTERMUTE: Use Rect::width() and height() in base_surface_osystem.cpp
06ec006766 WINTERMUTE: Remove redeclaration in render_ticket.cpp
63b8132ea3 WINTERMUTE: Remove single-argument zoom, rename mirrorX => getMirrorX() in transform_struct.h
d2d72c0110 WINTERMUTE: #define to const for TransformStruct defaults
0d407fd206 WINTERMUTE: Express 180.0f as float in TransformTools
aeb4c09538 WINTERMUTE: Doxygen comments in TransformStruct
1ecdd2d61a WINTERMUTE: #define to const for TransformStruct defaults
f872d31678 WINTERMUTE: Fix type-related warnings in base_surface_osystem.cpp
566495de3b WINTERMUTE: Remove unused variable in transparent_surface.cpp
567cd1eb12 WINTERMUTE: zoom parameter in display*** is now integer
381df0c64a WINTERMUTE: Various explicit casts
86c8d238a4 WINTERMUTE: const Common::Rect rect& in rect32.h
1a8a9bab86 WINTERMUTE: Compile bilinear copy only if needed
14d151ab31 WINTERMUTE: Fix #ifdef in transparent_surface.[h|cpp]
d83e4e1268 WINTERMUTE: FActor out TransformStruc initialization in repeatLastDraw loop
56aa1297d1 WINTERMUTE: Bring consts inside namespace in transform_struct.h
b5adcda947 WINTERMUTE: s/WINTERMUTE_TRANSFORMTOOLS_H/WINTERMUTE_TRANSFORM_TOOLS_H/
1c25eb2490 WINTERMUTE: Formatting
204c75bc27 WINTERMUTE: s/255,255,255,255/kDefaultMod/
e3381cff0d WINTERMUTE: #ifdef ENABLE_BILINEAR -> #if ENBABLE_BILINEAR
c32769e0b7 WINTERMUTE; Indentation in transform_*
9fb15a909c Merge pull request #354 from tobiatesan/wintermute_rotozoom_3
Commit: 03c4b7a240d53b36c86aea564fb8ae0b0a747604
https://github.com/scummvm/scummvm/commit/03c4b7a240d53b36c86aea564fb8ae0b0a747604
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T14:26:09-07:00
Commit Message:
WINTERMUTE: Introduce TransformStruct and FloatPoint; add operators to Point32
Changed paths:
A engines/wintermute/graphics/transform_struct.cpp
A engines/wintermute/graphics/transform_struct.h
A engines/wintermute/math/floatrect.h
engines/wintermute/math/rect32.h
engines/wintermute/module.mk
diff --git a/engines/wintermute/graphics/transform_struct.cpp b/engines/wintermute/graphics/transform_struct.cpp
new file mode 100644
index 0000000..9a11aa9
--- /dev/null
+++ b/engines/wintermute/graphics/transform_struct.cpp
@@ -0,0 +1,127 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "engines/wintermute/graphics/transform_struct.h"
+#include "engines/wintermute/graphics/transparent_surface.h"
+
+namespace Wintermute {
+void TransformStruct::init(Point32 zoom, uint32 angle, Point32 hotspot, bool alphaDisable, TSpriteBlendMode blendMode, uint32 rgbaMod, bool mirrorX, bool mirrorY, Point32 offset) {
+ _zoom = zoom;
+ _angle = angle;
+ _hotspot = hotspot;
+ _blendMode = blendMode;
+ _rgbaMod = rgbaMod;
+ _alphaDisable = alphaDisable;
+ _flip = 0;
+ _flip += TransparentSurface::FLIP_H * mirrorX;
+ _flip += TransparentSurface::FLIP_V * mirrorY;
+ _offset = offset;
+}
+
+
+TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX, int32 hotspotY, TSpriteBlendMode blendMode, uint32 rgbaMod, bool mirrorX, bool mirrorY, int32 offsetX, int32 offsetY) {
+ init(Point32(zoomX, zoomY),
+ angle,
+ Point32(hotspotX, hotspotY),
+ false,
+ blendMode,
+ rgbaMod,
+ mirrorX, mirrorY,
+ Point32(offsetX, offsetY));
+}
+
+TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, TSpriteBlendMode blendMode, uint32 rgbaMod, bool mirrorX, bool mirrorY) {
+ init(Point32(zoomX, zoomY),
+ DEFAULT_ANGLE,
+ Point32(DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y),
+ false,
+ blendMode,
+ rgbaMod,
+ mirrorX,
+ mirrorY,
+ Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
+}
+
+TransformStruct::TransformStruct(int32 zoom, TSpriteBlendMode blendMode, uint32 rgbaMod, bool mirrorX, bool mirrorY) {
+ init(Point32(zoom, zoom),
+ DEFAULT_ANGLE,
+ Point32(DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y),
+ false,
+ blendMode,
+ rgbaMod,
+ mirrorX, mirrorY,
+ Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
+}
+
+TransformStruct::TransformStruct(int32 zoom, bool mirrorX, bool mirrorY) {
+ init(Point32(zoom, zoom),
+ DEFAULT_ANGLE,
+ Point32(DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y),
+ true,
+ BLEND_NORMAL,
+ DEFAULT_RGBAMOD,
+ mirrorX, mirrorY,
+ Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
+}
+
+TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX, int32 hotspotY) {
+ init(Point32(zoomX, zoomY),
+ angle,
+ Point32(hotspotX, hotspotY),
+ true,
+ BLEND_NORMAL,
+ DEFAULT_RGBAMOD,
+ false, false,
+ Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
+}
+
+TransformStruct::TransformStruct(int32 zoom) {
+ init(Point32(zoom, zoom),
+ DEFAULT_ANGLE,
+ Point32(DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y),
+ true,
+ BLEND_NORMAL,
+ DEFAULT_RGBAMOD,
+ false, false,
+ Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
+}
+
+TransformStruct::TransformStruct() {
+ init(Point32(DEFAULT_ZOOM_X, DEFAULT_ZOOM_Y),
+ DEFAULT_ANGLE,
+ Point32(DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y),
+ true,
+ BLEND_NORMAL,
+ DEFAULT_RGBAMOD,
+ false, false,
+ Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
+}
+
+bool TransformStruct::mirrorX() const {
+ return (bool)(_flip & TransparentSurface::FLIP_H);
+}
+
+bool TransformStruct::mirrorY() const {
+ return (bool)(_flip & TransparentSurface::FLIP_V);
+}
+
+}
diff --git a/engines/wintermute/graphics/transform_struct.h b/engines/wintermute/graphics/transform_struct.h
new file mode 100644
index 0000000..9a28a48
--- /dev/null
+++ b/engines/wintermute/graphics/transform_struct.h
@@ -0,0 +1,87 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GRAPHICS_TRANSFORM_STRUCT_H
+#define GRAPHICS_TRANSFORM_STRUCT_H
+
+#include "engines/wintermute/math/rect32.h"
+#include "engines/wintermute/dctypes.h"
+
+#define DEFAULT_ZOOM_X 100
+#define DEFAULT_ZOOM_Y 100
+#define DEFAULT_RGBAMOD 0xFFFFFFFF
+#define DEFAULT_HOTSPOT_X 0
+#define DEFAULT_HOTSPOT_Y 0
+#define DEFAULT_OFFSET_X 0
+#define DEFAULT_OFFSET_Y 0
+#define DEFAULT_ANGLE 0
+
+namespace Wintermute {
+/**
+ * Contains all the required information that define a transform.
+ * Same source sprite + same TransformStruct = Same resulting sprite.
+ * Has a number of overloaded constructors to accomodate various argument lists.
+ */
+struct TransformStruct {
+private:
+ void init(Point32 zoom, uint32 angle, Point32 hotspot, bool alphaDisable, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX, bool mirrorY, Point32 offset);
+
+public:
+ TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX, int32 hotspotY, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX = false, bool mirrorY = false, int32 offsetX = 0, int32 offsetY = 0);
+ TransformStruct(int32 zoomX, int32 zoomY, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX = false, bool mirrorY = false);
+ TransformStruct(int32 zoom, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX, bool mirrorY);
+ TransformStruct(int32 zoom, bool mirrorX, bool mirrorY);
+ TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX = 0, int32 hotspotY = 0);
+ TransformStruct(int32 zoom);
+ TransformStruct();
+
+ Point32 _zoom; ///< Zoom; 100 = no zoom
+ Point32 _hotspot; ///< Position of the hotspot
+ uint32 _angle; ///< Rotation angle, in degrees
+ byte _flip; ///< Bitflag: see TransparentSurface::FLIP_XXX
+ bool _alphaDisable;
+ TSpriteBlendMode _blendMode;
+ uint32 _rgbaMod; ///< RGBa
+ Point32 _offset;
+
+ bool mirrorX() const;
+ bool mirrorY() const;
+
+ bool operator==(const TransformStruct &compare) const {
+ return (compare._angle == _angle &&
+ compare._flip == _flip &&
+ compare._zoom == _zoom &&
+ compare._offset == _offset &&
+ compare._alphaDisable == _alphaDisable &&
+ compare._rgbaMod == _rgbaMod &&
+ compare._blendMode == _blendMode
+ );
+ }
+
+ bool operator!=(const TransformStruct &compare) const {
+ return !(compare == *this);
+ }
+};
+
+}
+
+#endif
diff --git a/engines/wintermute/math/floatrect.h b/engines/wintermute/math/floatrect.h
new file mode 100644
index 0000000..f8eb382
--- /dev/null
+++ b/engines/wintermute/math/floatrect.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WINTERMUTE_FLOATRECT_H
+#define WINTERMUTE_FLOATRECT_H
+
+namespace Wintermute {
+
+struct FloatPoint {
+ float x;
+ float y;
+ FloatPoint() : x(0), y(0) {}
+ FloatPoint(float x1, float y1) : x(x1), y(y1) {}
+ bool operator==(const FloatPoint &p) const { return x == p.x && y == p.y; }
+ bool operator!=(const FloatPoint &p) const { return x != p.x || y != p.y; }
+ FloatPoint operator+(const FloatPoint &delta) const { return FloatPoint (x + delta.x, y + delta.y); }
+ FloatPoint operator-(const FloatPoint &delta) const { return FloatPoint (x - delta.x, y - delta.y); }
+
+ FloatPoint& operator+=(const FloatPoint &delta) {
+ x += delta.x;
+ y += delta.y;
+ return *this;
+ }
+ FloatPoint& operator-=(const FloatPoint &delta) {
+ x -= delta.x;
+ y -= delta.y;
+ return *this;
+ }
+};
+
+} // end of namespace Wintermute
+
+#endif
diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h
index 190c113..6618a51 100644
--- a/engines/wintermute/math/rect32.h
+++ b/engines/wintermute/math/rect32.h
@@ -24,14 +24,38 @@
#define WINTERMUTE_RECT32_H
#include "common/system.h"
+#include "engines/wintermute/math/floatrect.h"
namespace Wintermute {
struct Point32 {
int32 x;
int32 y;
-};
+ Point32() : x(0), y(0) {}
+ Point32(int32 x1, int32 y1) : x(x1), y(y1) {}
+ bool operator==(const Point32 &p) const { return x == p.x && y == p.y; }
+ bool operator!=(const Point32 &p) const { return x != p.x || y != p.y; }
+ Point32 operator+(const Point32 &delta) const { return Point32(x + delta.x, y + delta.y); }
+ Point32 operator-(const Point32 &delta) const { return Point32(x - delta.x, y - delta.y); }
+
+ Point32 &operator+=(const Point32 &delta) {
+ x += delta.x;
+ y += delta.y;
+ return *this;
+ }
+ Point32 &operator-=(const Point32 &delta) {
+ x -= delta.x;
+ y -= delta.y;
+ return *this;
+ }
+
+ operator FloatPoint() {
+ return FloatPoint(x,y);
+ }
+
+
+};
struct Rect32 {
int32 top, left; ///< The point at the top left of the rectangle (part of the rect).
int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect).
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index 32931bf..d1edced 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -89,6 +89,7 @@ MODULE_OBJS := \
base/save_thumb_helper.o \
base/timer.o \
detection.o \
+ graphics/transform_struct.o \
graphics/transparent_surface.o \
math/math_util.o \
math/matrix4.o \
Commit: 3c0089e31e1392f38cfb0e13d7c4d395bad4f949
https://github.com/scummvm/scummvm/commit/3c0089e31e1392f38cfb0e13d7c4d395bad4f949
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T14:47:57-07:00
Commit Message:
WINTERMUTE: Introduce TransformTools
Changed paths:
A engines/wintermute/graphics/transform_tools.cpp
A engines/wintermute/graphics/transform_tools.h
A engines/wintermute/math/floatpoint.h
R engines/wintermute/math/floatrect.h
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/math/rect32.h
engines/wintermute/module.mk
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index d93cf66..d9620d3 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -38,6 +38,8 @@
#include "engines/wintermute/base/gfx/base_renderer.h"
#include "engines/wintermute/base/scriptables/script_value.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
+#include "engines/wintermute/graphics/transform_tools.h"
+#include "engines/wintermute/graphics/transform_struct.h"
namespace Wintermute {
@@ -256,6 +258,15 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
}
if (rotate != 0.0f) {
+ Point32 boxOffset, rotatedHotspot, hotspotOffset, newOrigin;
+ Point32 origin(x, y);
+ Rect32 oldRect = getRect();
+ Point32 newHotspot;
+ TransformStruct transform = TransformStruct(zoomX, zoomY, rotate, _hotspotX, _hotspotY, blendMode, alpha, _mirrorX, _mirrorY, 0, 0);
+ Rect32 newRect = TransformTools::newRect (oldRect, transform, &newHotspot);
+ newOrigin = origin - newHotspot;
+ // When the transform functions are refactored to use TransformStruct this will be like:
+ // res = _surface->displayTransform(newOrigin.x, newOrigin.y, oldRect, newRect, transformStruct);
res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, getRect(), zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY);
} else {
if (zoomX == 100 && zoomY == 100) {
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
new file mode 100644
index 0000000..2390b86
--- /dev/null
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -0,0 +1,75 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include "engines/wintermute/graphics/transform_tools.h"
+#include <math.h>
+
+namespace Wintermute {
+
+ FloatPoint TransformTools::transformPoint(FloatPoint point, float rotate, Point32 zoom, bool mirrorX, bool mirrorY) {
+ /*
+ * Returns the coordinates for a point after rotation
+ */
+ float rotateRad = rotate * M_PI / 180;
+ FloatPoint newPoint;
+ newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad))*zoom.x/100;
+ newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad))*zoom.y/100;
+ if (mirrorX) newPoint.x *= -1;
+ if (mirrorY) newPoint.y *= -1;
+ /*
+ * I apply the textbook formula, but first I reverse the Y-axis, otherwise
+ * I'd be performing a rotation in the wrong direction
+ */
+ return newPoint;
+ }
+
+ Rect32 TransformTools::newRect (Rect32 oldRect, TransformStruct transform, Point32 *newHotspot) {
+ Point32 nw(oldRect.left, oldRect.top);
+ Point32 ne(oldRect.right, oldRect.top);
+ Point32 sw(oldRect.left, oldRect.bottom);
+ Point32 se(oldRect.right, oldRect.bottom);
+
+ 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);
+
+ 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)));
+ float left = MIN(nw1.x, MIN(ne1.x, MIN(sw1.x, se1.x)));
+ float right = MAX(nw1.x, MAX(ne1.x, MAX(sw1.x, se1.x)));
+
+ Rect32 res;
+ 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;
+
+ return res;
+ }
+}
diff --git a/engines/wintermute/graphics/transform_tools.h b/engines/wintermute/graphics/transform_tools.h
new file mode 100644
index 0000000..fbc0653
--- /dev/null
+++ b/engines/wintermute/graphics/transform_tools.h
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WINTERMUTE_TRANSFORMTOOLS_H
+#define WINTERMUTE_TRANSFORMTOOLS_H
+
+#include "engines/wintermute/math/rect32.h"
+#include "engines/wintermute/math/floatpoint.h"
+#include "engines/wintermute/graphics/transform_struct.h"
+
+namespace Wintermute {
+class TransformTools {
+public:
+ /**
+ * Basic transform (scale + rotate) for a single point
+ */
+ static FloatPoint transformPoint(FloatPoint point, float rotate, Point32 zoom, bool mirrorX = false, bool mirrorY = false);
+
+ /**
+ * Takes a rectangle, a transform and a pointer to a point, "newHotspot".
+ * In return you get the smallest rect that can contain the transformed sprite
+ * 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);
+};
+} // end of namespace Wintermute
+#endif
diff --git a/engines/wintermute/math/floatpoint.h b/engines/wintermute/math/floatpoint.h
new file mode 100644
index 0000000..bf194d8
--- /dev/null
+++ b/engines/wintermute/math/floatpoint.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WINTERMUTE_FLOATPOINT_H
+#define WINTERMUTE_FLOATPOINT_H
+
+namespace Wintermute {
+
+struct FloatPoint {
+ float x;
+ float y;
+ FloatPoint() : x(0), y(0) {}
+ FloatPoint(float x1, float y1) : x(x1), y(y1) {}
+ bool operator==(const FloatPoint &p) const { return x == p.x && y == p.y; }
+ bool operator!=(const FloatPoint &p) const { return x != p.x || y != p.y; }
+ FloatPoint operator+(const FloatPoint &delta) const { return FloatPoint (x + delta.x, y + delta.y); }
+ FloatPoint operator-(const FloatPoint &delta) const { return FloatPoint (x - delta.x, y - delta.y); }
+
+ FloatPoint& operator+=(const FloatPoint &delta) {
+ x += delta.x;
+ y += delta.y;
+ return *this;
+ }
+ FloatPoint& operator-=(const FloatPoint &delta) {
+ x -= delta.x;
+ y -= delta.y;
+ return *this;
+ }
+};
+
+} // end of namespace Wintermute
+
+#endif
diff --git a/engines/wintermute/math/floatrect.h b/engines/wintermute/math/floatrect.h
deleted file mode 100644
index f8eb382..0000000
--- a/engines/wintermute/math/floatrect.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef WINTERMUTE_FLOATRECT_H
-#define WINTERMUTE_FLOATRECT_H
-
-namespace Wintermute {
-
-struct FloatPoint {
- float x;
- float y;
- FloatPoint() : x(0), y(0) {}
- FloatPoint(float x1, float y1) : x(x1), y(y1) {}
- bool operator==(const FloatPoint &p) const { return x == p.x && y == p.y; }
- bool operator!=(const FloatPoint &p) const { return x != p.x || y != p.y; }
- FloatPoint operator+(const FloatPoint &delta) const { return FloatPoint (x + delta.x, y + delta.y); }
- FloatPoint operator-(const FloatPoint &delta) const { return FloatPoint (x - delta.x, y - delta.y); }
-
- FloatPoint& operator+=(const FloatPoint &delta) {
- x += delta.x;
- y += delta.y;
- return *this;
- }
- FloatPoint& operator-=(const FloatPoint &delta) {
- x -= delta.x;
- y -= delta.y;
- return *this;
- }
-};
-
-} // end of namespace Wintermute
-
-#endif
diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h
index 6618a51..d446553 100644
--- a/engines/wintermute/math/rect32.h
+++ b/engines/wintermute/math/rect32.h
@@ -24,7 +24,8 @@
#define WINTERMUTE_RECT32_H
#include "common/system.h"
-#include "engines/wintermute/math/floatrect.h"
+#include "engines/wintermute/math/floatpoint.h"
+#include "common/rect.h"
namespace Wintermute {
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index d1edced..95f9ba2 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -90,6 +90,7 @@ MODULE_OBJS := \
base/timer.o \
detection.o \
graphics/transform_struct.o \
+ graphics/transform_tools.o \
graphics/transparent_surface.o \
math/math_util.o \
math/matrix4.o \
Commit: 66ba2ea4558bab4583a7d7bb27e1e254c34f579f
https://github.com/scummvm/scummvm/commit/66ba2ea4558bab4583a7d7bb27e1e254c34f579f
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T14:52:12-07:00
Commit Message:
WINTERMUTE: Refactor some bits to use TransformStruct
Changed paths:
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/base/gfx/base_surface.cpp
engines/wintermute/base/gfx/base_surface.h
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.h
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index d9620d3..b51b723 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -265,9 +265,7 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
TransformStruct transform = TransformStruct(zoomX, zoomY, rotate, _hotspotX, _hotspotY, blendMode, alpha, _mirrorX, _mirrorY, 0, 0);
Rect32 newRect = TransformTools::newRect (oldRect, transform, &newHotspot);
newOrigin = origin - newHotspot;
- // When the transform functions are refactored to use TransformStruct this will be like:
- // res = _surface->displayTransform(newOrigin.x, newOrigin.y, oldRect, newRect, transformStruct);
- res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, getRect(), zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY);
+ res = _surface->displayTransform(newOrigin.x, newOrigin.y, oldRect, newRect, transform);
} else {
if (zoomX == 100 && zoomY == 100) {
res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, getRect(), alpha, blendMode, _mirrorX, _mirrorY);
diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp
index 2002463..7457e34 100644
--- a/engines/wintermute/base/gfx/base_surface.cpp
+++ b/engines/wintermute/base/gfx/base_surface.cpp
@@ -75,8 +75,8 @@ bool BaseSurface::displayHalfTrans(int x, int y, Rect32 rect) {
}
//////////////////////////////////////////////////////////////////////////
-bool BaseSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
- return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY);
+bool BaseSurface::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, TransformStruct transform) {
+ return displayTransform(x, y, rect, newRect, transform);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h
index b83efa0..be7a5c1 100644
--- a/engines/wintermute/base/gfx/base_surface.h
+++ b/engines/wintermute/base/gfx/base_surface.h
@@ -32,6 +32,7 @@
#include "engines/wintermute/base/base.h"
#include "engines/wintermute/math/rect32.h"
#include "graphics/surface.h"
+#include "engines/wintermute/graphics/transform_struct.h"
namespace Wintermute {
@@ -53,8 +54,8 @@ public:
virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0;
virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
+ virtual bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, TransformStruct transform) = 0;
virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
- virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
virtual bool repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) = 0;
virtual bool restore();
virtual bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0;
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index 0572ef2..5a12ad9 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -52,6 +52,7 @@ BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) {
_lockPixels = nullptr;
_lockPitch = 0;
_loaded = false;
+ _rotation = 0;
}
//////////////////////////////////////////////////////////////////////////
@@ -319,39 +320,56 @@ bool BaseSurfaceOSystem::endPixelOp() {
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
- return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY);
+ _rotation = 0;
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(100, mirrorX, mirrorY));
}
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
- return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY);
+ _rotation = 0;
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(100, blendMode, 0xFFFFFFFF, mirrorX, mirrorY));
}
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) {
- return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY);
+ _rotation = 0;
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(100, 100, 0, 0, 0, blendMode, alpha, mirrorX, mirrorY, offsetX, offsetY));
}
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
- return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY);
+ _rotation = 0;
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(zoomX, zoomY, blendMode, alpha, mirrorX, mirrorY));
}
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
- return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !transparent, blendMode, mirrorX, mirrorY);
+ _rotation = 0;
+ TransformStruct transform;
+ if (transparent) {
+ transform = TransformStruct(zoomX, zoomY, 0, 0, 0, blendMode, alpha, mirrorX, mirrorY);
+ } else {
+ transform = TransformStruct(zoomX, zoomY, mirrorX, mirrorY);
+ }
+ return drawSprite(x, y, &rect, nullptr, transform);
}
//////////////////////////////////////////////////////////////////////////
-bool BaseSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
- return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY);
+bool BaseSurfaceOSystem::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, TransformStruct transform) {
+ _rotation = (uint32)transform._angle;
+ if (transform._angle < 0.0f) {
+ warning("Negative rotation: %f %d", transform._angle, _rotation);
+ _rotation = (uint32)(360.0f + transform._angle);
+ warning("Negative post rotation: %f %d", transform._angle, _rotation);
+ }
+ return drawSprite(x, y, &rect, &newRect, transform);
}
//////////////////////////////////////////////////////////////////////////
-bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) {
+bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, TransformStruct transform) {
BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer);
if (!_loaded) {
@@ -359,13 +377,13 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo
}
if (renderer->_forceAlphaColor != 0) {
- alpha = renderer->_forceAlphaColor;
+ transform._rgbaMod = renderer->_forceAlphaColor;
}
- byte r = RGBCOLGetR(alpha);
- byte g = RGBCOLGetG(alpha);
- byte b = RGBCOLGetB(alpha);
- byte a = RGBCOLGetA(alpha);
+ byte r = RGBCOLGetR(transform._rgbaMod);
+ byte g = RGBCOLGetG(transform._rgbaMod);
+ byte b = RGBCOLGetB(transform._rgbaMod);
+ byte a = RGBCOLGetA(transform._rgbaMod);
renderer->setAlphaMod(a);
renderer->setColorMod(r, g, b);
@@ -386,8 +404,8 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo
srcRect.setHeight(rect->bottom - rect->top);
Common::Rect position;
- position.left = x + offsetX;
- position.top = y + offsetY;
+ position.left = x + transform._offset.x;
+ position.top = y + transform._offset.y;
// Crop off-by-ones:
if (position.left == -1) {
@@ -396,30 +414,35 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo
if (position.top == -1) {
position.top = 0; // TODO: Something is wrong
}
-
- position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f));
- position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f));
-
+ if (newRect) {
+ position.top = y;
+ position.left = x;
+ position.right = x + (newRect->right - newRect->left);
+ position.bottom = y + (newRect->top - newRect->bottom);
+ position.setWidth(newRect->right - newRect->left);
+ position.setHeight(newRect->bottom - newRect->top);
+ } else {
+ position.setWidth((int16)((float)srcRect.width() * transform._zoom.x / 100.f));
+ position.setHeight((int16)((float)srcRect.height() * transform._zoom.y / 100.f));
+ }
renderer->modTargetRect(&position);
- /* position.left += offsetX;
- position.top += offsetY;*/
-
// TODO: This actually requires us to have the SAME source-offsets every time,
// But no checking is in place for that yet.
// TODO: Optimize by not doing alpha-blits if we lack or disable alpha
bool hasAlpha;
- if (_hasAlpha && !alphaDisable) {
+ if (_hasAlpha && !transform._alphaDisable) {
hasAlpha = true;
} else {
hasAlpha = false;
}
- if (alphaDisable) {
+ if (transform._alphaDisable) {
warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored");
}
-
- renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, !hasAlpha);
+ bool mirrorX = transform._flip && TransparentSurface::FLIP_H;
+ bool mirrorY = transform._flip && TransparentSurface::FLIP_V;
+ renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, transform._alphaDisable);
return STATUS_OK;
}
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
index 9091ec6..b6978d5 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
@@ -56,7 +56,7 @@ public:
bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override;
bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
- bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
+ bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, TransformStruct transform) override;
bool repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) override;
virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override;
/* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
@@ -85,10 +85,11 @@ private:
Graphics::Surface *_surface;
bool _loaded;
bool finishLoad();
- bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0);
+ bool drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, TransformStruct transformStruct);
void genAlphaMask(Graphics::Surface *surface);
uint32 getPixelAt(Graphics::Surface *surface, int x, int y);
+ uint32 _rotation;
bool _hasAlpha;
void *_lockPixels;
int _lockPitch;
Commit: 384dd8da7ef8cc7660607301c36b52645942faf0
https://github.com/scummvm/scummvm/commit/384dd8da7ef8cc7660607301c36b52645942faf0
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T14:58:23-07:00
Commit Message:
WINTERMUTE: Bilinear scaling.
Refactor scale(), factor out actual mapping algorithm, add bilinear
scaling
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index dcdcbf2..f68259f 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -29,6 +29,117 @@
namespace Wintermute {
+void TransparentSurface::nearestCopy(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
+ int srcW = srcRect.width();
+ int srcH = srcRect.height();
+ int dstW = dstRect.width();
+ int dstH = dstRect.height();
+
+ assert(dstX >= 0 && dstX < dstW);
+ assert(dstY >= 0 && dstY < dstH);
+
+ uint32 color;
+
+ if (projX >= srcW || projX < 0 || projY >= srcH || projY < 0) {
+ color = 0;
+ } else {
+ color = READ_UINT32((const byte *)src->getBasePtr(projX, projY));
+ }
+
+ WRITE_UINT32((byte *)dst->getBasePtr(dstX, dstY), color);
+}
+
+void TransparentSurface::bilinearCopy(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
+
+ int srcW = srcRect.width();
+ int srcH = srcRect.height();
+ int dstW = dstRect.width();
+ int dstH = dstRect.height();
+
+ assert(dstX >= 0 && dstX < dstW);
+ assert(dstY >= 0 && dstY < dstH);
+
+ float x1 = floor(projX);
+ float x2 = ceil(projX);
+ float y1 = floor(projY);
+ float y2 = ceil(projY);
+
+ uint32 Q11, Q12, Q21, Q22;
+
+ if (x1 >= srcW || x1 < 0 || y1 >= srcH || y1 < 0) {
+ Q11 = 0;
+ } else {
+ Q11 = READ_UINT32((const byte *)src->getBasePtr(x1 + srcRect.left, y1 + srcRect.top));
+ }
+
+ if (x1 >= srcW || x1 < 0 || y2 >= srcH || y2 < 0) {
+ Q12 = 0;
+ } else {
+ Q12 = READ_UINT32((const byte *)src->getBasePtr(x1 + srcRect.left, y2 + srcRect.top));
+ }
+
+ if (x2 >= srcW || x2 < 0 || y1 >= srcH || y1 < 0) {
+ Q21 = 0;
+ } else {
+ Q21 = READ_UINT32((const byte *)src->getBasePtr(x2 + srcRect.left, y1 + srcRect.top));
+ }
+
+ if (x2 >= srcW || x2 < 0 || y2 >= srcH || y2 < 0) {
+ Q22 = 0;
+ } else {
+ Q22 = READ_UINT32((const byte *)src->getBasePtr(x2 + srcRect.left, y2 + srcRect.top));
+ }
+
+ byte *Q11s = (byte *)&Q11;
+ byte *Q12s = (byte *)&Q12;
+ byte *Q21s = (byte *)&Q21;
+ byte *Q22s = (byte *)&Q22;
+
+ uint32 color;
+ byte *dest = (byte *)&color;
+
+ float q11x = (x2 - projX);
+ float q11y = (y2 - projY);
+ float q21x = (projX - x1);
+ float q21y = (y2 - projY);
+ float q12x = (x2 - projX);
+ float q12y = (projY - y1);
+ float q22x = (projX - x1);
+ float q22y = (projY - y1);
+
+ if (x1 == x2 && y1 == y2) {
+ for (int c = 0; c < 4; c++) {
+ dest[c] = ((float)Q11s[c]);
+ }
+ } else {
+
+ if (x1 == x2) {
+ q11x = 0.5;
+ q12x = 0.5;
+ q21x = 0.5;
+ q22x = 0.5;
+ } else if (y1 == y2) {
+ q11y = 0.5;
+ q12y = 0.5;
+ q21y = 0.5;
+ q22y = 0.5;
+ }
+
+ for (int c = 0; c < 4; c++) {
+ dest[c] = (
+ ((float)Q11s[c]) * q11x * q11y +
+ ((float)Q21s[c]) * q21x * q21y +
+ ((float)Q12s[c]) * q12x * q12y +
+ ((float)Q22s[c]) * (1.0 -
+ q11x * q11y -
+ q21x * q21y -
+ q12x * q12y)
+ );
+ }
+ }
+ WRITE_UINT32((byte *)dst->getBasePtr(dstX + dstRect.left, dstY + dstRect.top), color);
+}
+
byte *TransparentSurface::_lookup = nullptr;
void TransparentSurface::destroyLookup() {
@@ -386,13 +497,7 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight) const {
Common::Rect srcRect(0, 0, (int16)w, (int16)h);
Common::Rect dstRect(0, 0, (int16)newWidth, (int16)newHeight);
- return scale(srcRect, dstRect);
-}
-
-// Copied from clone2727's https://github.com/clone2727/scummvm/blob/pegasus/engines/pegasus/surface.cpp#L247
-TransparentSurface *TransparentSurface::scale(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
- // I'm doing simple linear scaling here
- // dstRect(x, y) = srcRect(x * srcW / dstW, y * srcH / dstH);
+
TransparentSurface *target = new TransparentSurface();
assert(format.bytesPerPixel == 4);
@@ -406,9 +511,13 @@ TransparentSurface *TransparentSurface::scale(const Common::Rect &srcRect, const
for (int y = 0; y < dstH; y++) {
for (int x = 0; x < dstW; x++) {
- uint32 color = READ_UINT32((const byte *)getBasePtr(x * srcW / dstW + srcRect.left,
- y * srcH / dstH + srcRect.top));
- WRITE_UINT32((byte *)target->getBasePtr(x + dstRect.left, y + dstRect.top), color);
+ float projX = x / (float)dstW * srcW;
+ float projY = y / (float)dstH * srcH;
+ if (FAST_TRANSFORM) {
+ nearestCopy(projX, projY, x, y, srcRect, dstRect, this, target);
+ } else {
+ bilinearCopy(projX, projY, x, y, srcRect, dstRect, this, target);
+ }
}
}
return target;
diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h
index dc079a1..0f48054 100644
--- a/engines/wintermute/graphics/transparent_surface.h
+++ b/engines/wintermute/graphics/transparent_surface.h
@@ -24,6 +24,10 @@
#include "graphics/surface.h"
+
+#define FAST_TRANSFORM 0
+
+
/*
* This code is based on Broken Sword 2.5 engine
*
@@ -49,6 +53,9 @@ struct TransparentSurface : public Graphics::Surface {
void setColorKey(char r, char g, char b);
void disableColorKey();
+ static void bilinearCopy(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst);
+ static void nearestCopy(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst);
+
// Enums
/**
@brief The possible flipping parameters for the blit methode.
@@ -102,9 +109,8 @@ struct TransparentSurface : public Graphics::Surface {
uint color = BS_ARGB(255, 255, 255, 255),
int width = -1, int height = -1);
void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false);
- // The following scale-code supports arbitrary scaling (i.e. no repeats of column 0 at the end of lines)
- TransparentSurface *scale(uint16 newWidth, uint16 newHeight) const;
- TransparentSurface *scale(const Common::Rect &srcRect, const Common::Rect &dstRect) const;
+
+ TransparentSurface *scale (uint16 newWidth, uint16 newHeight) const;
static byte *_lookup;
static void destroyLookup();
private:
Commit: cced42a765cff0ad89490ebc0e70a7e00b8a2f4f
https://github.com/scummvm/scummvm/commit/cced42a765cff0ad89490ebc0e70a7e00b8a2f4f
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:02:36-07:00
Commit Message:
WINTERMUTE: Add cast op Common::Rect => Rect32
Changed paths:
engines/wintermute/math/rect32.h
diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h
index d446553..821df18 100644
--- a/engines/wintermute/math/rect32.h
+++ b/engines/wintermute/math/rect32.h
@@ -57,12 +57,14 @@ struct Point32 {
};
+
struct Rect32 {
int32 top, left; ///< The point at the top left of the rectangle (part of the rect).
int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect).
Rect32() : top(0), left(0), bottom(0), right(0) {}
Rect32(int32 w, int32 h) : top(0), left(0), bottom(h), right(w) {}
+ Rect32(Common::Rect rect) : top(rect.top), left(rect.left), bottom(rect.bottom), right(rect.right) {}
Rect32(int32 x1, int32 y1, int32 x2, int32 y2) : top(y1), left(x1), bottom(y2), right(x2) {
assert(isValidRect());
}
Commit: 58e096de97d7b8a0c09f5ac0bd6ff65853669a80
https://github.com/scummvm/scummvm/commit/58e096de97d7b8a0c09f5ac0bd6ff65853669a80
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:02:47-07:00
Commit Message:
WINTERMUTE: Add rotation
Add actual rotation code, make ticket-system transformStruct-aware
Changed paths:
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
engines/wintermute/base/gfx/osystem/base_render_osystem.h
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/base/gfx/osystem/render_ticket.h
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index e1424ce..e36eeb3 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -256,7 +256,6 @@ void BaseRenderOSystem::fade(uint16 alpha) {
return fadeToColor(0, 0, 0, dwAlpha);
}
-
//////////////////////////////////////////////////////////////////////////
void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) {
Common::Rect fillRect;
@@ -286,7 +285,7 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect
Common::Rect sizeRect(fillRect);
sizeRect.translate(-fillRect.top, -fillRect.left);
surf.fillRect(fillRect, col);
- drawSurface(nullptr, &surf, &sizeRect, &fillRect, false, false);
+ drawSurface(nullptr, &surf, &sizeRect, &fillRect, TransformStruct());
surf.free();
//SDL_SetRenderDrawColor(_renderer, r, g, b, a);
@@ -298,16 +297,18 @@ Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const {
return _renderSurface->format;
}
-void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) {
+void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct transform) {
+
if (_tempDisableDirtyRects || _disableDirtyRects) {
- RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha);
- ticket->_colorMod = _colorMod;
+ RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, transform);
+ ticket->_transform._rgbaMod = _colorMod;
ticket->_wantsDraw = true;
_renderQueue.push_back(ticket);
_previousTicket = ticket;
drawFromSurface(ticket);
return;
}
+
// Start searching from the beginning for the first and second items (since it's empty the first time around
// then keep incrementing the start-position, to avoid comparing against already used tickets.
if (_drawNum == 0 || _drawNum == 1) {
@@ -320,12 +321,11 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S
}
if (owner) { // Fade-tickets are owner-less
- RenderTicket compare(owner, nullptr, srcRect, dstRect, mirrorX, mirrorY, disableAlpha);
+ RenderTicket compare(owner, nullptr, srcRect, dstRect, transform);
compare._batchNum = _batchNum;
if (_spriteBatch) {
_batchNum++;
}
- compare._colorMod = _colorMod;
RenderQueueIterator it;
// Avoid calling end() and operator* every time, when potentially going through
// LOTS of tickets.
@@ -334,7 +334,6 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S
for (it = _lastAddedTicket; it != endIterator; ++it) {
compareTicket = *it;
if (*(compareTicket) == compare && compareTicket->_isValid) {
- compareTicket->_colorMod = _colorMod;
if (_disableDirtyRects) {
drawFromSurface(compareTicket);
} else {
@@ -349,8 +348,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S
}
}
}
- RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha);
- ticket->_colorMod = _colorMod;
+ RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, transform);
if (!_disableDirtyRects) {
drawFromTicket(ticket);
_previousTicket = ticket;
@@ -390,7 +388,7 @@ void BaseRenderOSystem::repeatLastDraw(int offsetX, int offsetY, int numTimesX,
dstRect.translate(offsetX, 0);
}
for (int j = (i == 0 ? 1 : 0); j < numTimesX; j++) {
- drawSurface(origTicket->_owner, origTicket->getSurface(), &srcRect, &dstRect, false, false);
+ drawSurface(origTicket->_owner, origTicket->getSurface(), &srcRect, &dstRect, TransformStruct());
dstRect.translate(offsetX, 0);
}
dstRect.left = initLeft;
@@ -535,7 +533,6 @@ void BaseRenderOSystem::drawTickets() {
// convert from screen-coords to surface-coords.
dstClip.translate(-offsetX, -offsetY);
- _colorMod = ticket->_colorMod;
drawFromSurface(ticket, &pos, &dstClip);
_needsFlip = true;
}
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
index 3cb0fa8..b3483f0 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
@@ -33,6 +33,7 @@
#include "common/rect.h"
#include "graphics/surface.h"
#include "common/list.h"
+#include "engines/wintermute/graphics/transform_struct.h"
namespace Wintermute {
class BaseSurfaceOSystem;
@@ -80,7 +81,7 @@ public:
virtual bool startSpriteBatch() override;
virtual bool endSpriteBatch() override;
void endSaveLoad();
- void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha = false) ;
+ void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct transform);
void repeatLastDraw(int offsetX, int offsetY, int numTimesX, int numTimesY);
BaseSurface *createSurface() override;
private:
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index 5a12ad9..e134872 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -440,10 +440,7 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect,
if (transform._alphaDisable) {
warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored");
}
- bool mirrorX = transform._flip && TransparentSurface::FLIP_H;
- bool mirrorY = transform._flip && TransparentSurface::FLIP_V;
- renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, transform._alphaDisable);
-
+ renderer->drawSurface(this, _surface, &srcRect, &position, transform);
return STATUS_OK;
}
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index 36c5d7b..23cf5c3 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -26,22 +26,22 @@
* Copyright (c) 2011 Jan Nedoma
*/
-#include "engines/wintermute/graphics/transparent_surface.h"
+
#include "engines/wintermute/base/gfx/osystem/render_ticket.h"
+#include "engines/wintermute/graphics/transform_tools.h"
+#include "common/textconsole.h"
namespace Wintermute {
-RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) : _owner(owner),
-_srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(!disableAlpha) {
- _colorMod = 0;
+RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct transform) :
+ _owner(owner),
+ _srcRect(*srcRect),
+ _dstRect(*dstRect),
+ _drawNum(0),
+ _isValid(true),
+ _wantsDraw(true),
+ _transform(transform) {
_batchNum = 0;
- _mirror = TransparentSurface::FLIP_NONE;
- if (mirrorX) {
- _mirror |= TransparentSurface::FLIP_V;
- }
- if (mirrorY) {
- _mirror |= TransparentSurface::FLIP_H;
- }
if (surf) {
_surface = new Graphics::Surface();
_surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format);
@@ -51,7 +51,14 @@ _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(
memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel);
}
// Then scale it if necessary
- if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) {
+ if (_transform._angle != 0) {
+ TransparentSurface src(*_surface, false);
+ Common::Rect srcRect_1(srcRect->left, srcRect->top, srcRect->right, srcRect->bottom);
+ Graphics::Surface *temp = src.rotate(srcRect_1, transform);
+ _surface->free();
+ delete _surface;
+ _surface = temp;
+ } else if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) {
TransparentSurface src(*_surface, false);
Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height());
_surface->free();
@@ -60,6 +67,14 @@ _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(
}
} else {
_surface = nullptr;
+
+ if (transform._angle != 0) { // Make sure comparison-tickets get the correct width
+ Rect32 dstRect;
+ Point32 newHotspot;
+ dstRect = TransformTools::newRect(_srcRect, transform, &newHotspot);
+ _dstRect.setWidth(dstRect.right-dstRect.left);
+ _dstRect.setHeight(dstRect.bottom-dstRect.top);
+ }
}
}
@@ -70,32 +85,31 @@ RenderTicket::~RenderTicket() {
}
}
-bool RenderTicket::operator==(RenderTicket &t) {
+bool RenderTicket::operator==(const RenderTicket &t) const {
if ((t._owner != _owner) ||
(t._batchNum != _batchNum) ||
- (t._hasAlpha != _hasAlpha) ||
- (t._mirror != _mirror) ||
- (t._colorMod != _colorMod) ||
+ (t._transform != _transform) ||
(t._dstRect != _dstRect) ||
- (t._srcRect != _srcRect)) {
+ (t._srcRect != _srcRect)
+ ) {
return false;
}
return true;
}
// Replacement for SDL2's SDL_RenderCopy
-void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) {
+void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const {
TransparentSurface src(*getSurface(), false);
Common::Rect clipRect;
clipRect.setWidth(getSurface()->w);
clipRect.setHeight(getSurface()->h);
- src._enableAlphaBlit = _hasAlpha;
- src.blit(*_targetSurface, _dstRect.left, _dstRect.top, _mirror, &clipRect, _colorMod, clipRect.width(), clipRect.height());
+ src._enableAlphaBlit = !_transform._alphaDisable;
+ src.blit(*_targetSurface, _dstRect.left, _dstRect.top, _transform._flip, &clipRect, _transform._rgbaMod, clipRect.width(), clipRect.height());
}
-void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) {
+void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const {
TransparentSurface src(*getSurface(), false);
bool doDelete = false;
if (!clipRect) {
@@ -105,8 +119,8 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect
clipRect->setHeight(getSurface()->h);
}
- src._enableAlphaBlit = _hasAlpha;
- src.blit(*_targetSurface, dstRect->left, dstRect->top, _mirror, clipRect, _colorMod, clipRect->width(), clipRect->height());
+ src._enableAlphaBlit = !_transform._alphaDisable;
+ src.blit(*_targetSurface, dstRect->left, dstRect->top, _transform._flip, clipRect, _transform._rgbaMod, clipRect->width(), clipRect->height());
if (doDelete) {
delete clipRect;
}
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.h b/engines/wintermute/base/gfx/osystem/render_ticket.h
index 968b42b..c294cb3 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.h
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.h
@@ -29,6 +29,7 @@
#ifndef WINTERMUTE_RENDER_TICKET_H
#define WINTERMUTE_RENDER_TICKET_H
+#include "engines/wintermute/graphics/transparent_surface.h"
#include "graphics/surface.h"
#include "common/rect.h"
@@ -37,14 +38,14 @@ namespace Wintermute {
class BaseSurfaceOSystem;
class RenderTicket {
public:
- RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false, bool disableAlpha = false);
- RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {}
+ RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, TransformStruct transform);
+ RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0), _transform(TransformStruct()) {}
~RenderTicket();
- const Graphics::Surface *getSurface() { return _surface; }
+ const Graphics::Surface *getSurface() const { return _surface; }
// Non-dirty-rects:
- void drawToSurface(Graphics::Surface *_targetSurface);
+ void drawToSurface(Graphics::Surface *_targetSurface) const;
// Dirty-rects:
- void drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect);
+ void drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const;
Common::Rect _dstRect;
uint32 _batchNum;
@@ -52,16 +53,15 @@ public:
bool _isValid;
bool _wantsDraw;
uint32 _drawNum;
- uint32 _colorMod;
+ TransformStruct _transform;
+
BaseSurfaceOSystem *_owner;
- bool operator==(RenderTicket &a);
- const Common::Rect *getSrcRect() { return &_srcRect; }
+ bool operator==(const RenderTicket &a) const;
+ const Common::Rect *getSrcRect() const { return &_srcRect; }
private:
Graphics::Surface *_surface;
Common::Rect _srcRect;
- bool _hasAlpha;
- uint32 _mirror;
};
} // end of namespace Wintermute
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index f68259f..87cb143 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -23,9 +23,11 @@
#include "common/endian.h"
#include "common/util.h"
#include "common/rect.h"
+#include "common/math.h"
#include "common/textconsole.h"
#include "graphics/primitives.h"
#include "engines/wintermute/graphics/transparent_surface.h"
+#include "engines/wintermute/graphics/transform_tools.h"
namespace Wintermute {
@@ -494,6 +496,45 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
return retSize;
}
+TransparentSurface *TransparentSurface::rotate(Common::Rect aSrcRect, TransformStruct transform) const {
+ Point32 newHotspot;
+ Rect32 rect = TransformTools::newRect(Rect32 (aSrcRect), transform, &newHotspot);
+ Common::Rect srcRect(0, 0, (int16)(aSrcRect.right - aSrcRect.left), (int16)(aSrcRect.bottom - aSrcRect.top));
+ Common::Rect dstRect(0, 0, (int16)(rect.right - rect.left), (int16)(rect.bottom - rect.top));
+
+ TransparentSurface *target = new TransparentSurface();
+ assert(format.bytesPerPixel == 4);
+
+ int dstW = dstRect.width();
+ int dstH = dstRect.height();
+
+ target->create((uint16)dstW, (uint16)dstH, this->format);
+
+ uint32 invAngle = (360 - transform._angle) % 360;
+ float invCos = cos(invAngle * M_PI / 180.0);
+ float invSin = sin(invAngle * M_PI / 180.0);
+
+ for (int y = 0; y < dstH; y++) {
+ for (int x = 0; x < dstW; x++) {
+ int x1 = x - newHotspot.x;
+ int y1 = y - newHotspot.y;
+
+ float targX = ((x1 * invCos - y1 * invSin)) * 100.0 / transform._zoom.x + srcRect.left;
+ float targY = ((x1 * invSin + y1 * invCos)) * 100.0 / transform._zoom.y + srcRect.top;
+
+ targX += transform._hotspot.x;
+ targY += transform._hotspot.y;
+
+ if (FAST_TRANSFORM) {
+ bilinearCopy(targX, targY, x, y, srcRect, dstRect, this, target);
+ } else {
+ bilinearCopy(targX, targY, x, y, srcRect, dstRect, this, target);
+ }
+ }
+ }
+ return target;
+}
+
TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight) const {
Common::Rect srcRect(0, 0, (int16)w, (int16)h);
Common::Rect dstRect(0, 0, (int16)newWidth, (int16)newHeight);
diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h
index 0f48054..b81dbe8 100644
--- a/engines/wintermute/graphics/transparent_surface.h
+++ b/engines/wintermute/graphics/transparent_surface.h
@@ -23,7 +23,7 @@
#define GRAPHICS_TRANSPARENTSURFACE_H
#include "graphics/surface.h"
-
+#include "engines/wintermute/graphics/transform_struct.h"
#define FAST_TRANSFORM 0
@@ -111,6 +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(Common::Rect srcRect, TransformStruct transform) const;
static byte *_lookup;
static void destroyLookup();
private:
Commit: 321c7f071668025b1c9bb16e28a70c29843e45de
https://github.com/scummvm/scummvm/commit/321c7f071668025b1c9bb16e28a70c29843e45de
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:02:47-07:00
Commit Message:
WINTERMUTE: Removed useless argument from rotate()
Changed paths:
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index 23cf5c3..3f94c2e 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -53,8 +53,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
// Then scale it if necessary
if (_transform._angle != 0) {
TransparentSurface src(*_surface, false);
- Common::Rect srcRect_1(srcRect->left, srcRect->top, srcRect->right, srcRect->bottom);
- Graphics::Surface *temp = src.rotate(srcRect_1, transform);
+ Graphics::Surface *temp = src.rotate(transform);
_surface->free();
delete _surface;
_surface = temp;
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 87cb143..3f64305 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -496,10 +496,10 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
return retSize;
}
-TransparentSurface *TransparentSurface::rotate(Common::Rect aSrcRect, TransformStruct transform) const {
+TransparentSurface *TransparentSurface::rotate(TransformStruct transform) const {
Point32 newHotspot;
- Rect32 rect = TransformTools::newRect(Rect32 (aSrcRect), transform, &newHotspot);
- Common::Rect srcRect(0, 0, (int16)(aSrcRect.right - aSrcRect.left), (int16)(aSrcRect.bottom - aSrcRect.top));
+ Common::Rect srcRect(0, 0, (int16)w, (int16)h);
+ Rect32 rect = TransformTools::newRect(Rect32 (srcRect), transform, &newHotspot);
Common::Rect dstRect(0, 0, (int16)(rect.right - rect.left), (int16)(rect.bottom - rect.top));
TransparentSurface *target = new TransparentSurface();
@@ -526,7 +526,7 @@ TransparentSurface *TransparentSurface::rotate(Common::Rect aSrcRect, TransformS
targY += transform._hotspot.y;
if (FAST_TRANSFORM) {
- bilinearCopy(targX, targY, x, y, srcRect, dstRect, this, target);
+ nearestCopy(targX, targY, x, y, srcRect, dstRect, this, target);
} else {
bilinearCopy(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 b81dbe8..474b10a 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(Common::Rect srcRect, TransformStruct transform) const;
+ TransparentSurface *rotate(TransformStruct transform) const;
static byte *_lookup;
static void destroyLookup();
private:
Commit: e30ab15bb0f21a77f8e1752745cd6ec954661d83
https://github.com/scummvm/scummvm/commit/e30ab15bb0f21a77f8e1752745cd6ec954661d83
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:02:48-07:00
Commit Message:
WINTERMUTE: Move if() outside transform loop
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 3f64305..403ce89 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -513,25 +513,41 @@ TransparentSurface *TransparentSurface::rotate(TransformStruct transform) const
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;
- 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 (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;
- float targX = ((x1 * invCos - y1 * invSin)) * 100.0 / transform._zoom.x + srcRect.left;
- float 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;
- if (FAST_TRANSFORM) {
nearestCopy(targX, targY, x, y, srcRect, dstRect, this, target);
- } else {
- bilinearCopy(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;
+
+ 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;
+
+ bilinearCopy(targX, targY, x, y, srcRect, dstRect, this, target);
}
}
}
+
return target;
}
@@ -550,13 +566,23 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
target->create((uint16)dstW, (uint16)dstH, this->format);
- for (int y = 0; y < dstH; y++) {
- for (int x = 0; x < dstW; x++) {
- float projX = x / (float)dstW * srcW;
- float projY = y / (float)dstH * srcH;
- if (FAST_TRANSFORM) {
+ 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;
nearestCopy(projX, projY, x, y, srcRect, dstRect, this, target);
- } else {
+ }
+ }
+ } 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;
bilinearCopy(projX, projY, x, y, srcRect, dstRect, this, target);
}
}
Commit: e47deb0e0e02f8ab288c21a33f5ec6187ab15e71
https://github.com/scummvm/scummvm/commit/e47deb0e0e02f8ab288c21a33f5ec6187ab15e71
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:02:48-07:00
Commit Message:
WINTERMUTE: Rename pixel copy functions
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 403ce89..bdf074f 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -31,7 +31,7 @@
namespace Wintermute {
-void TransparentSurface::nearestCopy(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
+void TransparentSurface::copyPixelNearestNeighbor(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
int srcW = srcRect.width();
int srcH = srcRect.height();
int dstW = dstRect.width();
@@ -51,7 +51,7 @@ void TransparentSurface::nearestCopy(float projX, float projY, int dstX, int dst
WRITE_UINT32((byte *)dst->getBasePtr(dstX, dstY), color);
}
-void TransparentSurface::bilinearCopy(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
+void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
int srcW = srcRect.width();
int srcH = srcRect.height();
@@ -528,7 +528,7 @@ TransparentSurface *TransparentSurface::rotate(TransformStruct transform) const
targX += transform._hotspot.x;
targY += transform._hotspot.y;
- nearestCopy(targX, targY, x, y, srcRect, dstRect, this, target);
+ copyPixelNearestNeighbor(targX, targY, x, y, srcRect, dstRect, this, target);
}
}
} else {
@@ -543,7 +543,7 @@ TransparentSurface *TransparentSurface::rotate(TransformStruct transform) const
targX += transform._hotspot.x;
targY += transform._hotspot.y;
- bilinearCopy(targX, targY, x, y, srcRect, dstRect, this, target);
+ copyPixelBilinear(targX, targY, x, y, srcRect, dstRect, this, target);
}
}
}
@@ -573,7 +573,7 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
for (int x = 0; x < dstW; x++) {
projX = x / dstW * srcW;
projY = y / dstH * srcH;
- nearestCopy(projX, projY, x, y, srcRect, dstRect, this, target);
+ copyPixelNearestNeighbor(projX, projY, x, y, srcRect, dstRect, this, target);
}
}
} else {
@@ -583,7 +583,7 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
for (int x = 0; x < dstW; x++) {
projX = x / (float)dstW * srcW;
projY = y / (float)dstH * srcH;
- bilinearCopy(projX, projY, x, y, srcRect, dstRect, this, target);
+ copyPixelBilinear(projX, projY, x, y, srcRect, dstRect, this, target);
}
}
}
diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h
index 474b10a..f9486d1 100644
--- a/engines/wintermute/graphics/transparent_surface.h
+++ b/engines/wintermute/graphics/transparent_surface.h
@@ -53,8 +53,8 @@ struct TransparentSurface : public Graphics::Surface {
void setColorKey(char r, char g, char b);
void disableColorKey();
- static void bilinearCopy(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst);
- static void nearestCopy(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst);
+ static void copyPixelBilinear(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst);
+ static void copyPixelNearestNeighbor(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst);
// Enums
/**
Commit: d2a249384eed076195b86f24ae1a041a93b3cd89
https://github.com/scummvm/scummvm/commit/d2a249384eed076195b86f24ae1a041a93b3cd89
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:02:49-07:00
Commit Message:
WINTERMUTE: Partial fix for mirrored sprites
Still weird with rotated + mirrored + scaled sprites. Offset.
Changed paths:
engines/wintermute/graphics/transform_tools.cpp
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index 2390b86..f0a092a 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -32,8 +32,8 @@ namespace Wintermute {
*/
float rotateRad = rotate * M_PI / 180;
FloatPoint newPoint;
- newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad))*zoom.x/100;
- newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad))*zoom.y/100;
+ newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad))*zoom.x/100.0;
+ newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad))*zoom.y/100.0;
if (mirrorX) newPoint.x *= -1;
if (mirrorY) newPoint.y *= -1;
/*
Commit: b788ae7f382ca05cecdf0eba5bfb176279299416
https://github.com/scummvm/scummvm/commit/b788ae7f382ca05cecdf0eba5bfb176279299416
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:02:49-07:00
Commit Message:
WINTERMUTE: Swap flip bits
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index bdf074f..5606d41 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -363,12 +363,12 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
int inStep = 4;
int inoStep = img->pitch;
- if (flipping & TransparentSurface::FLIP_V) {
+ if (flipping & TransparentSurface::FLIP_H) {
inStep = -inStep;
xp = img->w - 1;
}
- if (flipping & TransparentSurface::FLIP_H) {
+ if (flipping & TransparentSurface::FLIP_V) {
inoStep = -inoStep;
yp = img->h - 1;
}
Commit: 8bed134ad6a155ec6b35e3cba4a212e016bf3c90
https://github.com/scummvm/scummvm/commit/8bed134ad6a155ec6b35e3cba4a212e016bf3c90
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:02:57-07:00
Commit Message:
WINTERMUTE: Force angle normalization
This fixes the issues in J.U.L.I.A.
Changed paths:
engines/wintermute/base/base_sub_frame.cpp
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index b51b723..eb1c859 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -235,6 +235,12 @@ const char* BaseSubFrame::getSurfaceFilename() {
//////////////////////////////////////////////////////////////////////
bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) {
+
+ while (rotate < 0) {
+ rotate += 360.0f;
+ }
+ rotate = fmod(rotate, 360.0f);
+
if (!_surface) {
return STATUS_OK;
}
Commit: 0b21d6dca2ad5be41fa2aa4c2bed2cb694fba4d1
https://github.com/scummvm/scummvm/commit/0b21d6dca2ad5be41fa2aa4c2bed2cb694fba4d1
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:03:43-07:00
Commit Message:
WINTERMUTE: Fix alpha bug in engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
This fixes the "TV static" bug in J.U.L.I.A.
Changed paths:
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index e134872..adbef55 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -328,7 +328,7 @@ bool BaseSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode ble
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
_rotation = 0;
- return drawSprite(x, y, &rect, nullptr, TransformStruct(100, blendMode, 0xFFFFFFFF, mirrorX, mirrorY));
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(100, blendMode, alpha, mirrorX, mirrorY));
}
//////////////////////////////////////////////////////////////////////////
Commit: b34d7b753912af6dd971872cd702d489974606ff
https://github.com/scummvm/scummvm/commit/b34d7b753912af6dd971872cd702d489974606ff
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:03:46-07:00
Commit Message:
WINTERMUTE: *transform as pointer in transform_tools
Changed paths:
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/graphics/transform_tools.cpp
engines/wintermute/graphics/transform_tools.h
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index eb1c859..dbf46ea 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -269,7 +269,7 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
Rect32 oldRect = getRect();
Point32 newHotspot;
TransformStruct transform = TransformStruct(zoomX, zoomY, rotate, _hotspotX, _hotspotY, blendMode, alpha, _mirrorX, _mirrorY, 0, 0);
- Rect32 newRect = TransformTools::newRect (oldRect, transform, &newHotspot);
+ Rect32 newRect = TransformTools::newRect (oldRect, &transform, &newHotspot);
newOrigin = origin - newHotspot;
res = _surface->displayTransform(newOrigin.x, newOrigin.y, oldRect, newRect, transform);
} else {
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index 3f94c2e..8ea4f18 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -53,7 +53,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
// Then scale it if necessary
if (_transform._angle != 0) {
TransparentSurface src(*_surface, false);
- Graphics::Surface *temp = src.rotate(transform);
+ Graphics::Surface *temp = src.rotate(&transform);
_surface->free();
delete _surface;
_surface = temp;
@@ -70,7 +70,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
if (transform._angle != 0) { // Make sure comparison-tickets get the correct width
Rect32 dstRect;
Point32 newHotspot;
- dstRect = TransformTools::newRect(_srcRect, transform, &newHotspot);
+ dstRect = TransformTools::newRect(_srcRect, &transform, &newHotspot);
_dstRect.setWidth(dstRect.right-dstRect.left);
_dstRect.setHeight(dstRect.bottom-dstRect.top);
}
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index f0a092a..2388b88 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 fbc0653..ae60e5a 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 5606d41..1139b08 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 f9486d1..c01b10d 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:
Commit: 285ed18979a470c458654f9f0c42ca02aa927f80
https://github.com/scummvm/scummvm/commit/285ed18979a470c458654f9f0c42ca02aa927f80
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:03:47-07:00
Commit Message:
WINTERMUTE: Rename rotate() -> rotoscale() for consistency
Changed paths:
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index 8ea4f18..2049d3e 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -53,7 +53,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
// Then scale it if necessary
if (_transform._angle != 0) {
TransparentSurface src(*_surface, false);
- Graphics::Surface *temp = src.rotate(&transform);
+ Graphics::Surface *temp = src.rotoscale(&transform);
_surface->free();
delete _surface;
_surface = temp;
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 1139b08..07c2537 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -496,9 +496,10 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
return retSize;
}
-TransparentSurface *TransparentSurface::rotate(TransformStruct *transform) const {
+TransparentSurface *TransparentSurface::rotoscale(TransformStruct *transform) const {
assert (transform);
+ assert (transform->_angle != 0); // This would not be ideal
Point32 newHotspot;
Common::Rect srcRect(0, 0, (int16)w, (int16)h);
diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h
index c01b10d..2798323 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 *rotoscale (TransformStruct *transform) const;
static byte *_lookup;
static void destroyLookup();
private:
Commit: ae589c41ff869bb7e2352a2a60764b46bd80b72c
https://github.com/scummvm/scummvm/commit/ae589c41ff869bb7e2352a2a60764b46bd80b72c
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:03:47-07:00
Commit Message:
WINTERMUTE: Deprecate setAlphaMod, setColorMod
Changed paths:
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index e36eeb3..143879c 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -60,8 +60,7 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) {
_borderLeft = _borderRight = _borderTop = _borderBottom = 0;
_ratioX = _ratioY = 1.0f;
- setAlphaMod(255);
- setColorMod(255, 255, 255);
+ _colorMod = 0xFFFFFFFF;
_dirtyRect = nullptr;
_disableDirtyRects = false;
_tempDisableDirtyRects = 0;
@@ -151,15 +150,11 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) {
}
void BaseRenderOSystem::setAlphaMod(byte alpha) {
- byte r = RGBCOLGetR(_colorMod);
- byte g = RGBCOLGetB(_colorMod);
- byte b = RGBCOLGetB(_colorMod);
- _colorMod = BS_ARGB(alpha, r, g, b);
+ error("DEPRECATED: BaseRenderOSystem::setAlphaMod(byte alpha)");
}
void BaseRenderOSystem::setColorMod(byte r, byte g, byte b) {
- byte alpha = RGBCOLGetA(_colorMod);
- _colorMod = BS_ARGB(alpha, r, g, b);
+ error("DEPRECATED: void BaseRenderOSystem::setColorMod(byte r, byte g, byte b)");
}
bool BaseRenderOSystem::indicatorFlip() {
@@ -278,8 +273,6 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect
//TODO: This is only here until I'm sure about the final pixelformat
uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b);
- setAlphaMod(255);
- setColorMod(255, 255, 255);
Graphics::Surface surf;
surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format);
Common::Rect sizeRect(fillRect);
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index adbef55..a786647 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -380,14 +380,6 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect,
transform._rgbaMod = renderer->_forceAlphaColor;
}
- byte r = RGBCOLGetR(transform._rgbaMod);
- byte g = RGBCOLGetG(transform._rgbaMod);
- byte b = RGBCOLGetB(transform._rgbaMod);
- byte a = RGBCOLGetA(transform._rgbaMod);
-
- renderer->setAlphaMod(a);
- renderer->setColorMod(r, g, b);
-
#if 0 // These are kept for reference if BlendMode is reimplemented at some point.
if (alphaDisable) {
SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE);
Commit: b6ed5ee816e7bb23e21acfaee56835e167c6025f
https://github.com/scummvm/scummvm/commit/b6ed5ee816e7bb23e21acfaee56835e167c6025f
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:03:47-07:00
Commit Message:
WINTERMUTE: Reinstate rgbaMod comparisons for compare-tickets
Changed paths:
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 143879c..e647b0e 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -327,6 +327,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S
for (it = _lastAddedTicket; it != endIterator; ++it) {
compareTicket = *it;
if (*(compareTicket) == compare && compareTicket->_isValid) {
+ compareTicket->_transform._rgbaMod = transform._rgbaMod;
if (_disableDirtyRects) {
drawFromSurface(compareTicket);
} else {
@@ -526,6 +527,7 @@ void BaseRenderOSystem::drawTickets() {
// convert from screen-coords to surface-coords.
dstClip.translate(-offsetX, -offsetY);
+ _colorMod = ticket->_transform._rgbaMod;
drawFromSurface(ticket, &pos, &dstClip);
_needsFlip = true;
}
Commit: 1b9967400dbf28fa34dde175fdb4ad88c39ea623
https://github.com/scummvm/scummvm/commit/1b9967400dbf28fa34dde175fdb4ad88c39ea623
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:03:48-07:00
Commit Message:
WINTERMUTE: Use constants from transform_tools for consistency
Changed paths:
engines/wintermute/base/base_sprite.h
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.h
diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h
index 05cb9fc..6badffa 100644
--- a/engines/wintermute/base/base_sprite.h
+++ b/engines/wintermute/base/base_sprite.h
@@ -32,6 +32,7 @@
#include "engines/wintermute/coll_templ.h"
#include "engines/wintermute/base/base_script_holder.h"
+#include "engines/wintermute/graphics/transform_tools.h"
namespace Wintermute {
class BaseFrame;
@@ -44,17 +45,17 @@ public:
void setDefaults();
DECLARE_PERSISTENT(BaseSprite, BaseScriptHolder)
- bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100);
+ bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = DEFAULT_ZOOM_X, float scaleY = DEFAULT_ZOOM_Y);
int32 _moveY;
int32 _moveX;
- bool display(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL);
- bool getCurrentFrame(float zoomX = 100, float zoomY = 100);
+ bool display(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = DEFAULT_ZOOM_X, float zoomY = DEFAULT_ZOOM_Y, uint32 alpha = DEFAULT_RGBAMOD, float rotate = DEFAULT_ANGLE, TSpriteBlendMode blendMode = BLEND_NORMAL);
+ bool getCurrentFrame(float zoomX = DEFAULT_ZOOM_X, float zoomY = DEFAULT_ZOOM_Y);
void reset();
bool isChanged();
bool isFinished();
bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL);
bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL);
- bool draw(int x, int y, BaseObject *Register = nullptr, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF);
+ bool draw(int x, int y, BaseObject *Register = nullptr, float zoomX = DEFAULT_ZOOM_X, float zoomY = DEFAULT_ZOOM_Y, uint32 alpha = DEFAULT_RGBAMOD);
bool _looping;
int32 _currentFrame;
bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = nullptr);
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index dbf46ea..0028de1 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -48,8 +48,9 @@ IMPLEMENT_PERSISTENT(BaseSubFrame, false)
//////////////////////////////////////////////////////////////////////////
BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) {
_surface = nullptr;
- _hotspotX = _hotspotY = 0;
- _alpha = 0xFFFFFFFF;
+ _hotspotX = DEFAULT_HOTSPOT_X;
+ _hotspotY = DEFAULT_HOTSPOT_Y;
+ _alpha = DEFAULT_RGBAMOD;
_transparent = 0xFFFF00FF;
_wantsDefaultRect = false;
@@ -246,7 +247,7 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
}
if (registerOwner != nullptr && !_decoration) {
- if (zoomX == 100 && zoomY == 100) {
+ if (zoomX == DEFAULT_ZOOM_X && zoomY == DEFAULT_ZOOM_Y) {
BaseEngine::getRenderer()->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + getRect().left, y - _hotspotY + getRect().top, getRect().right - getRect().left, getRect().bottom - getRect().top, zoomX, zoomY, precise));
} else {
BaseEngine::getRenderer()->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + getRect().left) * (zoomX / 100)), (int)(y - (_hotspotY + getRect().top) * (zoomY / 100)), (int)((getRect().right - getRect().left) * (zoomX / 100)), (int)((getRect().bottom - getRect().top) * (zoomY / 100)), zoomX, zoomY, precise));
@@ -259,11 +260,11 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
bool res;
//if (Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha)
- if (_alpha != 0xFFFFFFFF) {
+ if (_alpha != DEFAULT_RGBAMOD) {
alpha = _alpha;
}
- if (rotate != 0.0f) {
+ if (rotate != DEFAULT_ANGLE) {
Point32 boxOffset, rotatedHotspot, hotspotOffset, newOrigin;
Point32 origin(x, y);
Rect32 oldRect = getRect();
@@ -273,10 +274,10 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
newOrigin = origin - newHotspot;
res = _surface->displayTransform(newOrigin.x, newOrigin.y, oldRect, newRect, transform);
} else {
- if (zoomX == 100 && zoomY == 100) {
+ if (zoomX == DEFAULT_ZOOM_X && zoomY == DEFAULT_ZOOM_Y) {
res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, getRect(), alpha, blendMode, _mirrorX, _mirrorY);
} else {
- res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY);
+ res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / DEFAULT_ZOOM_X)), (int)(y - _hotspotY * (zoomY / DEFAULT_ZOOM_Y)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY);
}
}
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
index b6978d5..7eef416 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
@@ -51,11 +51,11 @@ public:
bool endPixelOp() override;
- bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
- bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
- bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override;
+ bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = DEFAULT_RGBAMOD, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
+ bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = DEFAULT_RGBAMOD, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
+ bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = DEFAULT_RGBAMOD, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override;
bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
- bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
+ bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = DEFAULT_RGBAMOD, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, TransformStruct transform) override;
bool repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) override;
virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override;
Commit: dafcef5c9f5ddc27ca804ea1da0ab37720b103c8
https://github.com/scummvm/scummvm/commit/dafcef5c9f5ddc27ca804ea1da0ab37720b103c8
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:03:49-07:00
Commit Message:
WINTERMUTE: Replace normalization loop with if() for legibility
Changed paths:
engines/wintermute/base/base_sub_frame.cpp
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index 0028de1..6f79d7f 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -237,11 +237,11 @@ const char* BaseSubFrame::getSurfaceFilename() {
//////////////////////////////////////////////////////////////////////
bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) {
- while (rotate < 0) {
+ rotate = fmod(rotate, 360.0f);
+ if (rotate < 0) {
rotate += 360.0f;
}
- rotate = fmod(rotate, 360.0f);
-
+
if (!_surface) {
return STATUS_OK;
}
Commit: 0153f762b16d33c350cde5f472bba42733f18dc7
https://github.com/scummvm/scummvm/commit/0153f762b16d33c350cde5f472bba42733f18dc7
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:03:49-07:00
Commit Message:
WINTERMUTE: Defaults -> float
Changed paths:
engines/wintermute/graphics/transform_struct.h
diff --git a/engines/wintermute/graphics/transform_struct.h b/engines/wintermute/graphics/transform_struct.h
index 9a28a48..ed30044 100644
--- a/engines/wintermute/graphics/transform_struct.h
+++ b/engines/wintermute/graphics/transform_struct.h
@@ -26,8 +26,8 @@
#include "engines/wintermute/math/rect32.h"
#include "engines/wintermute/dctypes.h"
-#define DEFAULT_ZOOM_X 100
-#define DEFAULT_ZOOM_Y 100
+#define DEFAULT_ZOOM_X 100.0
+#define DEFAULT_ZOOM_Y 100.0
#define DEFAULT_RGBAMOD 0xFFFFFFFF
#define DEFAULT_HOTSPOT_X 0
#define DEFAULT_HOTSPOT_Y 0
Commit: f014cccb94e0b3244a3e6dca91db7ca7552e6d79
https://github.com/scummvm/scummvm/commit/f014cccb94e0b3244a3e6dca91db7ca7552e6d79
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:03:50-07:00
Commit Message:
WINTERMUTE: Formatting
Changed paths:
engines/wintermute/graphics/transform_tools.cpp
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index 2388b88..0ab28eb 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -27,19 +27,16 @@
namespace Wintermute {
FloatPoint TransformTools::transformPoint(FloatPoint point, float rotate, Point32 zoom, bool mirrorX, bool mirrorY) {
- /*
- * Returns the coordinates for a point after rotation
- */
float rotateRad = rotate * M_PI / 180;
FloatPoint newPoint;
- newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad))*zoom.x/100.0;
- newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad))*zoom.y/100.0;
- if (mirrorX) newPoint.x *= -1;
- if (mirrorY) newPoint.y *= -1;
- /*
- * I apply the textbook formula, but first I reverse the Y-axis, otherwise
- * I'd be performing a rotation in the wrong direction
- */
+ newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad))*zoom.x/DEFAULT_ZOOM_X;
+ newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad))*zoom.y/DEFAULT_ZOOM_Y;
+ if (mirrorX) {
+ newPoint.x *= -1;
+ }
+ if (mirrorY) {
+ newPoint.y *= -1;
+ }
return newPoint;
}
Commit: 9f97ad6a3e9e10fa7164a4e545c1705896f77925
https://github.com/scummvm/scummvm/commit/9f97ad6a3e9e10fa7164a4e545c1705896f77925
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:04:21-07:00
Commit Message:
WINTERMUTE: s/*transform/const &transform/
Changed paths:
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/graphics/transform_tools.cpp
engines/wintermute/graphics/transform_tools.h
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index 6f79d7f..f8c4000 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -270,7 +270,7 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
Rect32 oldRect = getRect();
Point32 newHotspot;
TransformStruct transform = TransformStruct(zoomX, zoomY, rotate, _hotspotX, _hotspotY, blendMode, alpha, _mirrorX, _mirrorY, 0, 0);
- Rect32 newRect = TransformTools::newRect (oldRect, &transform, &newHotspot);
+ Rect32 newRect = TransformTools::newRect (oldRect, transform, &newHotspot);
newOrigin = origin - newHotspot;
res = _surface->displayTransform(newOrigin.x, newOrigin.y, oldRect, newRect, transform);
} else {
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index 2049d3e..b11e072 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -53,7 +53,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
// Then scale it if necessary
if (_transform._angle != 0) {
TransparentSurface src(*_surface, false);
- Graphics::Surface *temp = src.rotoscale(&transform);
+ Graphics::Surface *temp = src.rotoscale(transform);
_surface->free();
delete _surface;
_surface = temp;
@@ -70,7 +70,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
if (transform._angle != 0) { // Make sure comparison-tickets get the correct width
Rect32 dstRect;
Point32 newHotspot;
- dstRect = TransformTools::newRect(_srcRect, &transform, &newHotspot);
+ dstRect = TransformTools::newRect(_srcRect, transform, &newHotspot);
_dstRect.setWidth(dstRect.right-dstRect.left);
_dstRect.setHeight(dstRect.bottom-dstRect.top);
}
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index 0ab28eb..194bede 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 ae60e5a..fb165d7 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 07c2537..0ec0b84 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 2798323..71c139a 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:
Commit: a0561f1aa52b31feff468dc53b6556a683b6a819
https://github.com/scummvm/scummvm/commit/a0561f1aa52b31feff468dc53b6556a683b6a819
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:36-07:00
Commit Message:
WINTERMUTE: Fix calculation of inverse angles
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 0ec0b84..a0d4723 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -513,7 +513,7 @@ TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transfo
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;
Commit: ab022b179897153b1be97804502f5ece24931e56
https://github.com/scummvm/scummvm/commit/ab022b179897153b1be97804502f5ece24931e56
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:37-07:00
Commit Message:
WINTERMUTE: // End of namespace Wintermute
Changed paths:
engines/wintermute/graphics/transform_struct.cpp
engines/wintermute/graphics/transform_struct.h
engines/wintermute/graphics/transform_tools.cpp
engines/wintermute/graphics/transform_tools.h
engines/wintermute/math/floatpoint.h
diff --git a/engines/wintermute/graphics/transform_struct.cpp b/engines/wintermute/graphics/transform_struct.cpp
index 9a11aa9..dc5e45f 100644
--- a/engines/wintermute/graphics/transform_struct.cpp
+++ b/engines/wintermute/graphics/transform_struct.cpp
@@ -123,5 +123,4 @@ bool TransformStruct::mirrorX() const {
bool TransformStruct::mirrorY() const {
return (bool)(_flip & TransparentSurface::FLIP_V);
}
-
-}
+} // End of namespace Wintermute
diff --git a/engines/wintermute/graphics/transform_struct.h b/engines/wintermute/graphics/transform_struct.h
index ed30044..1f7d556 100644
--- a/engines/wintermute/graphics/transform_struct.h
+++ b/engines/wintermute/graphics/transform_struct.h
@@ -81,7 +81,5 @@ public:
return !(compare == *this);
}
};
-
-}
-
+} // End of namespace Wintermute
#endif
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index 194bede..9e73636 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -70,4 +70,4 @@ namespace Wintermute {
return res;
}
-}
+} // End of namespace Wintermute
diff --git a/engines/wintermute/graphics/transform_tools.h b/engines/wintermute/graphics/transform_tools.h
index fb165d7..ee4d16a 100644
--- a/engines/wintermute/graphics/transform_tools.h
+++ b/engines/wintermute/graphics/transform_tools.h
@@ -43,5 +43,5 @@ public:
*/
static Rect32 newRect (Rect32 oldRect, const TransformStruct &transform, Point32 *newHotspot);
};
-} // end of namespace Wintermute
+} // End of namespace Wintermute
#endif
diff --git a/engines/wintermute/math/floatpoint.h b/engines/wintermute/math/floatpoint.h
index bf194d8..0c47ef0 100644
--- a/engines/wintermute/math/floatpoint.h
+++ b/engines/wintermute/math/floatpoint.h
@@ -47,6 +47,6 @@ struct FloatPoint {
}
};
-} // end of namespace Wintermute
+} // End of namespace Wintermute
#endif
Commit: 163cd6a5284a352225fbfa621a1e7152d0e5f8e0
https://github.com/scummvm/scummvm/commit/163cd6a5284a352225fbfa621a1e7152d0e5f8e0
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:37-07:00
Commit Message:
WINTERMUTE: Constants
Changed paths:
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index a786647..d218c91 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -334,7 +334,7 @@ bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, T
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) {
_rotation = 0;
- return drawSprite(x, y, &rect, nullptr, TransformStruct(100, 100, 0, 0, 0, blendMode, alpha, mirrorX, mirrorY, offsetX, offsetY));
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(DEFAULT_ZOOM_X, DEFAULT_ZOOM_Y, DEFAULT_ANGLE, DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y, blendMode, alpha, mirrorX, mirrorY, offsetX, offsetY));
}
//////////////////////////////////////////////////////////////////////////
@@ -349,7 +349,7 @@ bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, flo
_rotation = 0;
TransformStruct transform;
if (transparent) {
- transform = TransformStruct(zoomX, zoomY, 0, 0, 0, blendMode, alpha, mirrorX, mirrorY);
+ transform = TransformStruct(zoomX, zoomY, DEFAULT_ANGLE, DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y, blendMode, alpha, mirrorX, mirrorY);
} else {
transform = TransformStruct(zoomX, zoomY, mirrorX, mirrorY);
}
@@ -414,8 +414,8 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect,
position.setWidth(newRect->right - newRect->left);
position.setHeight(newRect->bottom - newRect->top);
} else {
- position.setWidth((int16)((float)srcRect.width() * transform._zoom.x / 100.f));
- position.setHeight((int16)((float)srcRect.height() * transform._zoom.y / 100.f));
+ position.setWidth((int16)((float)srcRect.width() * transform._zoom.x / DEFAULT_ZOOM_X));
+ position.setHeight((int16)((float)srcRect.height() * transform._zoom.y / DEFAULT_ZOOM_Y));
}
renderer->modTargetRect(&position);
Commit: 6f03fbac843410f457115bd075a6926ed3924ce0
https://github.com/scummvm/scummvm/commit/6f03fbac843410f457115bd075a6926ed3924ce0
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:38-07:00
Commit Message:
WINTERMUTE: Pass structs by const reference
Changed paths:
engines/wintermute/base/gfx/base_surface.cpp
engines/wintermute/base/gfx/base_surface.h
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.h
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/graphics/transform_tools.cpp
engines/wintermute/graphics/transform_tools.h
diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp
index 7457e34..42ec51f 100644
--- a/engines/wintermute/base/gfx/base_surface.cpp
+++ b/engines/wintermute/base/gfx/base_surface.cpp
@@ -75,7 +75,7 @@ bool BaseSurface::displayHalfTrans(int x, int y, Rect32 rect) {
}
//////////////////////////////////////////////////////////////////////////
-bool BaseSurface::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, TransformStruct transform) {
+bool BaseSurface::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) {
return displayTransform(x, y, rect, newRect, transform);
}
diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h
index be7a5c1..016831f 100644
--- a/engines/wintermute/base/gfx/base_surface.h
+++ b/engines/wintermute/base/gfx/base_surface.h
@@ -54,7 +54,7 @@ public:
virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0;
virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
- virtual bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, TransformStruct transform) = 0;
+ virtual bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) = 0;
virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
virtual bool repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) = 0;
virtual bool restore();
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index d218c91..8ec60bf 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -358,7 +358,7 @@ bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, flo
//////////////////////////////////////////////////////////////////////////
-bool BaseSurfaceOSystem::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, TransformStruct transform) {
+bool BaseSurfaceOSystem::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) {
_rotation = (uint32)transform._angle;
if (transform._angle < 0.0f) {
warning("Negative rotation: %f %d", transform._angle, _rotation);
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
index 7eef416..2e2da3c 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
@@ -56,7 +56,7 @@ public:
bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = DEFAULT_RGBAMOD, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override;
bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = DEFAULT_RGBAMOD, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
- bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, TransformStruct transform) override;
+ bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) override;
bool repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) override;
virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override;
/* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index b11e072..d510d97 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -51,7 +51,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel);
}
// Then scale it if necessary
- if (_transform._angle != 0) {
+ if (_transform._angle != DEFAULT_ANGLE) {
TransparentSurface src(*_surface, false);
Graphics::Surface *temp = src.rotoscale(transform);
_surface->free();
@@ -67,7 +67,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
} else {
_surface = nullptr;
- if (transform._angle != 0) { // Make sure comparison-tickets get the correct width
+ if (transform._angle != DEFAULT_ANGLE) { // Make sure comparison-tickets get the correct width
Rect32 dstRect;
Point32 newHotspot;
dstRect = TransformTools::newRect(_srcRect, transform, &newHotspot);
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index 9e73636..01e8b48 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -26,7 +26,7 @@
namespace Wintermute {
- FloatPoint TransformTools::transformPoint(FloatPoint point, float rotate, Point32 zoom, bool mirrorX, bool mirrorY) {
+ FloatPoint TransformTools::transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX, const bool mirrorY) {
float rotateRad = rotate * M_PI / 180;
FloatPoint newPoint;
newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad))*zoom.x/DEFAULT_ZOOM_X;
@@ -40,7 +40,7 @@ namespace Wintermute {
return newPoint;
}
- Rect32 TransformTools::newRect (Rect32 oldRect, const TransformStruct &transform, Point32 *newHotspot) {
+ Rect32 TransformTools::newRect (const Rect32 &oldRect, const TransformStruct &transform, Point32 *newHotspot) {
Point32 nw(oldRect.left, oldRect.top);
Point32 ne(oldRect.right, oldRect.top);
diff --git a/engines/wintermute/graphics/transform_tools.h b/engines/wintermute/graphics/transform_tools.h
index ee4d16a..a9eabff 100644
--- a/engines/wintermute/graphics/transform_tools.h
+++ b/engines/wintermute/graphics/transform_tools.h
@@ -33,7 +33,7 @@ public:
/**
* Basic transform (scale + rotate) for a single point
*/
- static FloatPoint transformPoint(FloatPoint point, float rotate, Point32 zoom, bool mirrorX = false, bool mirrorY = false);
+ static FloatPoint transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX = false, const bool mirrorY = false);
/**
* Takes a rectangle, a transform and a pointer to a point, "newHotspot".
@@ -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, const TransformStruct &transform, Point32 *newHotspot);
+ static Rect32 newRect (const Rect32 &oldRect, const TransformStruct &transform, Point32 *newHotspot);
};
} // End of namespace Wintermute
#endif
Commit: 5a9e917a600eb47dd420f5efd2d52005b68a151c
https://github.com/scummvm/scummvm/commit/5a9e917a600eb47dd420f5efd2d52005b68a151c
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:38-07:00
Commit Message:
WINTERMUTE: Fix operator precedence in scale()
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index a0d4723..e20f97b 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -584,8 +584,8 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
int projY;
for (int y = 0; y < dstH; y++) {
for (int x = 0; x < dstW; x++) {
- projX = x / dstW * srcW;
- projY = y / dstH * srcH;
+ projX = x / (float)dstW * srcW;
+ projY = y / (float)dstH * srcH;
copyPixelNearestNeighbor(projX, projY, x, y, srcRect, dstRect, this, target);
}
}
Commit: 4405a534e5470cb2f14baad7d76f109f379023cf
https://github.com/scummvm/scummvm/commit/4405a534e5470cb2f14baad7d76f109f379023cf
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:38-07:00
Commit Message:
WINTERMUTE: Remove set[Color|Alpha]Mod altogether
Changed paths:
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
engines/wintermute/base/gfx/osystem/base_render_osystem.h
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index e647b0e..c81ea14 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -149,14 +149,6 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) {
return STATUS_OK;
}
-void BaseRenderOSystem::setAlphaMod(byte alpha) {
- error("DEPRECATED: BaseRenderOSystem::setAlphaMod(byte alpha)");
-}
-
-void BaseRenderOSystem::setColorMod(byte r, byte g, byte b) {
- error("DEPRECATED: void BaseRenderOSystem::setColorMod(byte r, byte g, byte b)");
-}
-
bool BaseRenderOSystem::indicatorFlip() {
g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_indicatorX, _indicatorY), _renderSurface->pitch, _indicatorX, _indicatorY, _indicatorWidthDrawn, _indicatorHeight);
g_system->updateScreen();
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
index b3483f0..6396728 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
@@ -57,8 +57,6 @@ public:
BaseImage *takeScreenshot() override;
- void setAlphaMod(byte alpha);
- void setColorMod(byte r, byte g, byte b);
void invalidateTicket(RenderTicket *renderTicket);
void invalidateTicketsFromSurface(BaseSurfaceOSystem *surf);
void drawFromTicket(RenderTicket *renderTicket);
Commit: 9cfea04846b19f17c8c68c9e19a044c1b48c0f7f
https://github.com/scummvm/scummvm/commit/9cfea04846b19f17c8c68c9e19a044c1b48c0f7f
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:39-07:00
Commit Message:
WINTERMUTE: Formatting
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index e20f97b..48d550c 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -498,8 +498,8 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p
TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transform) const {
- assert (transform._angle != 0); // This would not be ideal
-
+ assert(transform._angle != 0); // This would not be ideal; rotoscale() should never be called in conditional branches where angle = 0 anyway.
+
Point32 newHotspot;
Common::Rect srcRect(0, 0, (int16)w, (int16)h);
Rect32 rect = TransformTools::newRect(Rect32 (srcRect), transform, &newHotspot);
Commit: 9d4def3bfd541cd95ce62e18fa18d90799fcd791
https://github.com/scummvm/scummvm/commit/9d4def3bfd541cd95ce62e18fa18d90799fcd791
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:39-07:00
Commit Message:
WINTERMUTE: Fix alpha bug in BaseRenderOSystem::fadeToColor
Introduced in 37b1ff3, broke fade-in/fade-outs
Changed paths:
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index c81ea14..2aae973 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -270,7 +270,9 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect
Common::Rect sizeRect(fillRect);
sizeRect.translate(-fillRect.top, -fillRect.left);
surf.fillRect(fillRect, col);
- drawSurface(nullptr, &surf, &sizeRect, &fillRect, TransformStruct());
+ TransformStruct temp = TransformStruct();
+ temp._alphaDisable = false;
+ drawSurface(nullptr, &surf, &sizeRect, &fillRect, temp);
surf.free();
//SDL_SetRenderDrawColor(_renderer, r, g, b, a);
Commit: 64db90ed67e385a7ba8ca18faa0da345987201db
https://github.com/scummvm/scummvm/commit/64db90ed67e385a7ba8ca18faa0da345987201db
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:40-07:00
Commit Message:
WINTERMUTE: TransformStruct by reference in engines/wintermute/base/gfx/osystem/base_render_osystem.h
Changed paths:
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
engines/wintermute/base/gfx/osystem/base_render_osystem.h
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 2aae973..06cf531 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -284,7 +284,7 @@ Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const {
return _renderSurface->format;
}
-void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct transform) {
+void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct &transform) {
if (_tempDisableDirtyRects || _disableDirtyRects) {
RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, transform);
@@ -376,7 +376,8 @@ void BaseRenderOSystem::repeatLastDraw(int offsetX, int offsetY, int numTimesX,
dstRect.translate(offsetX, 0);
}
for (int j = (i == 0 ? 1 : 0); j < numTimesX; j++) {
- drawSurface(origTicket->_owner, origTicket->getSurface(), &srcRect, &dstRect, TransformStruct());
+ TransformStruct temp = TransformStruct();
+ drawSurface(origTicket->_owner, origTicket->getSurface(), &srcRect, &dstRect, temp);
dstRect.translate(offsetX, 0);
}
dstRect.left = initLeft;
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
index 6396728..5531961 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
@@ -79,7 +79,7 @@ public:
virtual bool startSpriteBatch() override;
virtual bool endSpriteBatch() override;
void endSaveLoad();
- void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct transform);
+ void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct &transform);
void repeatLastDraw(int offsetX, int offsetY, int numTimesX, int numTimesY);
BaseSurface *createSurface() override;
private:
Commit: 286b1d11ca798249d412adb52e453404de7b727e
https://github.com/scummvm/scummvm/commit/286b1d11ca798249d412adb52e453404de7b727e
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:40-07:00
Commit Message:
WINTERMUTE: Use Rect::width() and height() in base_surface_osystem.cpp
Changed paths:
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index 8ec60bf..6db4818 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -409,10 +409,10 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect,
if (newRect) {
position.top = y;
position.left = x;
- position.right = x + (newRect->right - newRect->left);
- position.bottom = y + (newRect->top - newRect->bottom);
- position.setWidth(newRect->right - newRect->left);
- position.setHeight(newRect->bottom - newRect->top);
+ position.right = x + newRect->width();
+ position.bottom = y + newRect->height();
+ position.setWidth(newRect->width());
+ position.setHeight(newRect->height());
} else {
position.setWidth((int16)((float)srcRect.width() * transform._zoom.x / DEFAULT_ZOOM_X));
position.setHeight((int16)((float)srcRect.height() * transform._zoom.y / DEFAULT_ZOOM_Y));
Commit: 06ec0067665c4aa2369ea0b3b451ca0e7b2951c1
https://github.com/scummvm/scummvm/commit/06ec0067665c4aa2369ea0b3b451ca0e7b2951c1
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:06:41-07:00
Commit Message:
WINTERMUTE: Remove redeclaration in render_ticket.cpp
Changed paths:
engines/wintermute/base/gfx/osystem/render_ticket.cpp
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index d510d97..7f141aa 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -68,11 +68,11 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
_surface = nullptr;
if (transform._angle != DEFAULT_ANGLE) { // Make sure comparison-tickets get the correct width
- Rect32 dstRect;
+ Rect32 newDstRect;
Point32 newHotspot;
- dstRect = TransformTools::newRect(_srcRect, transform, &newHotspot);
- _dstRect.setWidth(dstRect.right-dstRect.left);
- _dstRect.setHeight(dstRect.bottom-dstRect.top);
+ newDstRect = TransformTools::newRect(_srcRect, transform, &newHotspot);
+ _dstRect.setWidth(newDstRect.right - newDstRect.left);
+ _dstRect.setHeight(newDstRect.bottom - newDstRect.top);
}
}
}
Commit: 63b8132ea3ec6fe6bcfcb43d1e0c9baf481eab1e
https://github.com/scummvm/scummvm/commit/63b8132ea3ec6fe6bcfcb43d1e0c9baf481eab1e
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:14:29-07:00
Commit Message:
WINTERMUTE: Remove single-argument zoom, rename mirrorX => getMirrorX() in transform_struct.h
Changed paths:
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
engines/wintermute/graphics/transform_struct.cpp
engines/wintermute/graphics/transform_struct.h
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index 6db4818..02f7f99 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -321,14 +321,14 @@ bool BaseSurfaceOSystem::endPixelOp() {
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
_rotation = 0;
- return drawSprite(x, y, &rect, nullptr, TransformStruct(100, mirrorX, mirrorY));
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(DEFAULT_ZOOM_X, DEFAULT_ZOOM_Y, mirrorX, mirrorY));
}
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
_rotation = 0;
- return drawSprite(x, y, &rect, nullptr, TransformStruct(100, blendMode, alpha, mirrorX, mirrorY));
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(DEFAULT_ZOOM_X, DEFAULT_ZOOM_Y, blendMode, alpha, mirrorX, mirrorY));
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/graphics/transform_struct.cpp b/engines/wintermute/graphics/transform_struct.cpp
index dc5e45f..c179d42 100644
--- a/engines/wintermute/graphics/transform_struct.cpp
+++ b/engines/wintermute/graphics/transform_struct.cpp
@@ -61,28 +61,6 @@ TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, TSpriteBlendMode blen
Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
}
-TransformStruct::TransformStruct(int32 zoom, TSpriteBlendMode blendMode, uint32 rgbaMod, bool mirrorX, bool mirrorY) {
- init(Point32(zoom, zoom),
- DEFAULT_ANGLE,
- Point32(DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y),
- false,
- blendMode,
- rgbaMod,
- mirrorX, mirrorY,
- Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
-}
-
-TransformStruct::TransformStruct(int32 zoom, bool mirrorX, bool mirrorY) {
- init(Point32(zoom, zoom),
- DEFAULT_ANGLE,
- Point32(DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y),
- true,
- BLEND_NORMAL,
- DEFAULT_RGBAMOD,
- mirrorX, mirrorY,
- Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
-}
-
TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX, int32 hotspotY) {
init(Point32(zoomX, zoomY),
angle,
@@ -94,17 +72,6 @@ TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 h
Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
}
-TransformStruct::TransformStruct(int32 zoom) {
- init(Point32(zoom, zoom),
- DEFAULT_ANGLE,
- Point32(DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y),
- true,
- BLEND_NORMAL,
- DEFAULT_RGBAMOD,
- false, false,
- Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
-}
-
TransformStruct::TransformStruct() {
init(Point32(DEFAULT_ZOOM_X, DEFAULT_ZOOM_Y),
DEFAULT_ANGLE,
@@ -116,11 +83,11 @@ TransformStruct::TransformStruct() {
Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
}
-bool TransformStruct::mirrorX() const {
+bool TransformStruct::getMirrorX() const {
return (bool)(_flip & TransparentSurface::FLIP_H);
}
-bool TransformStruct::mirrorY() const {
+bool TransformStruct::getMirrorY() const {
return (bool)(_flip & TransparentSurface::FLIP_V);
}
} // End of namespace Wintermute
diff --git a/engines/wintermute/graphics/transform_struct.h b/engines/wintermute/graphics/transform_struct.h
index 1f7d556..6b021b5 100644
--- a/engines/wintermute/graphics/transform_struct.h
+++ b/engines/wintermute/graphics/transform_struct.h
@@ -48,10 +48,7 @@ private:
public:
TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX, int32 hotspotY, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX = false, bool mirrorY = false, int32 offsetX = 0, int32 offsetY = 0);
TransformStruct(int32 zoomX, int32 zoomY, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX = false, bool mirrorY = false);
- TransformStruct(int32 zoom, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX, bool mirrorY);
- TransformStruct(int32 zoom, bool mirrorX, bool mirrorY);
TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX = 0, int32 hotspotY = 0);
- TransformStruct(int32 zoom);
TransformStruct();
Point32 _zoom; ///< Zoom; 100 = no zoom
@@ -63,8 +60,8 @@ public:
uint32 _rgbaMod; ///< RGBa
Point32 _offset;
- bool mirrorX() const;
- bool mirrorY() const;
+ bool getMirrorX() const;
+ bool getMirrorY() const;
bool operator==(const TransformStruct &compare) const {
return (compare._angle == _angle &&
Commit: d2d72c0110e4e2c265fcc1413958540f182d4353
https://github.com/scummvm/scummvm/commit/d2d72c0110e4e2c265fcc1413958540f182d4353
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:21:25-07:00
Commit Message:
WINTERMUTE: #define to const for TransformStruct defaults
Changed paths:
engines/wintermute/base/base_sprite.h
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.h
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/graphics/transform_struct.cpp
engines/wintermute/graphics/transform_struct.h
engines/wintermute/graphics/transform_tools.cpp
diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h
index 6badffa..d464899 100644
--- a/engines/wintermute/base/base_sprite.h
+++ b/engines/wintermute/base/base_sprite.h
@@ -45,17 +45,17 @@ public:
void setDefaults();
DECLARE_PERSISTENT(BaseSprite, BaseScriptHolder)
- bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = DEFAULT_ZOOM_X, float scaleY = DEFAULT_ZOOM_Y);
+ bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = kDefaultZoomX, float scaleY = kDefaultZoomY);
int32 _moveY;
int32 _moveX;
- bool display(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = DEFAULT_ZOOM_X, float zoomY = DEFAULT_ZOOM_Y, uint32 alpha = DEFAULT_RGBAMOD, float rotate = DEFAULT_ANGLE, TSpriteBlendMode blendMode = BLEND_NORMAL);
- bool getCurrentFrame(float zoomX = DEFAULT_ZOOM_X, float zoomY = DEFAULT_ZOOM_Y);
+ bool display(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = kDefaultZoomX, float zoomY = kDefaultZoomY, uint32 alpha = kDefaultRgbaMod, float rotate = kDefaultAngle, TSpriteBlendMode blendMode = BLEND_NORMAL);
+ bool getCurrentFrame(float zoomX = kDefaultZoomX, float zoomY = kDefaultZoomY);
void reset();
bool isChanged();
bool isFinished();
bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL);
bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL);
- bool draw(int x, int y, BaseObject *Register = nullptr, float zoomX = DEFAULT_ZOOM_X, float zoomY = DEFAULT_ZOOM_Y, uint32 alpha = DEFAULT_RGBAMOD);
+ bool draw(int x, int y, BaseObject *Register = nullptr, float zoomX = kDefaultZoomX, float zoomY = kDefaultZoomY, uint32 alpha = kDefaultRgbaMod);
bool _looping;
int32 _currentFrame;
bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = nullptr);
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index f8c4000..7012c28 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -48,9 +48,9 @@ IMPLEMENT_PERSISTENT(BaseSubFrame, false)
//////////////////////////////////////////////////////////////////////////
BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) {
_surface = nullptr;
- _hotspotX = DEFAULT_HOTSPOT_X;
- _hotspotY = DEFAULT_HOTSPOT_Y;
- _alpha = DEFAULT_RGBAMOD;
+ _hotspotX = kDefaultHotspotX;
+ _hotspotY = kDefaultHotspotY;
+ _alpha = kDefaultRgbaMod;
_transparent = 0xFFFF00FF;
_wantsDefaultRect = false;
@@ -247,7 +247,7 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
}
if (registerOwner != nullptr && !_decoration) {
- if (zoomX == DEFAULT_ZOOM_X && zoomY == DEFAULT_ZOOM_Y) {
+ if (zoomX == kDefaultZoomX && zoomY == kDefaultZoomY) {
BaseEngine::getRenderer()->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + getRect().left, y - _hotspotY + getRect().top, getRect().right - getRect().left, getRect().bottom - getRect().top, zoomX, zoomY, precise));
} else {
BaseEngine::getRenderer()->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + getRect().left) * (zoomX / 100)), (int)(y - (_hotspotY + getRect().top) * (zoomY / 100)), (int)((getRect().right - getRect().left) * (zoomX / 100)), (int)((getRect().bottom - getRect().top) * (zoomY / 100)), zoomX, zoomY, precise));
@@ -260,11 +260,11 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
bool res;
//if (Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha)
- if (_alpha != DEFAULT_RGBAMOD) {
+ if (_alpha != kDefaultRgbaMod) {
alpha = _alpha;
}
- if (rotate != DEFAULT_ANGLE) {
+ if (rotate != kDefaultAngle) {
Point32 boxOffset, rotatedHotspot, hotspotOffset, newOrigin;
Point32 origin(x, y);
Rect32 oldRect = getRect();
@@ -274,10 +274,10 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
newOrigin = origin - newHotspot;
res = _surface->displayTransform(newOrigin.x, newOrigin.y, oldRect, newRect, transform);
} else {
- if (zoomX == DEFAULT_ZOOM_X && zoomY == DEFAULT_ZOOM_Y) {
+ if (zoomX == kDefaultZoomX && zoomY == kDefaultZoomY) {
res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, getRect(), alpha, blendMode, _mirrorX, _mirrorY);
} else {
- res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / DEFAULT_ZOOM_X)), (int)(y - _hotspotY * (zoomY / DEFAULT_ZOOM_Y)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY);
+ res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / kDefaultZoomX)), (int)(y - _hotspotY * (zoomY / kDefaultZoomY)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY);
}
}
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index 02f7f99..e01a669 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -321,20 +321,20 @@ bool BaseSurfaceOSystem::endPixelOp() {
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
_rotation = 0;
- return drawSprite(x, y, &rect, nullptr, TransformStruct(DEFAULT_ZOOM_X, DEFAULT_ZOOM_Y, mirrorX, mirrorY));
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(kDefaultZoomX, kDefaultZoomY, mirrorX, mirrorY));
}
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
_rotation = 0;
- return drawSprite(x, y, &rect, nullptr, TransformStruct(DEFAULT_ZOOM_X, DEFAULT_ZOOM_Y, blendMode, alpha, mirrorX, mirrorY));
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(kDefaultZoomX, kDefaultZoomY, blendMode, alpha, mirrorX, mirrorY));
}
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) {
_rotation = 0;
- return drawSprite(x, y, &rect, nullptr, TransformStruct(DEFAULT_ZOOM_X, DEFAULT_ZOOM_Y, DEFAULT_ANGLE, DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y, blendMode, alpha, mirrorX, mirrorY, offsetX, offsetY));
+ return drawSprite(x, y, &rect, nullptr, TransformStruct(kDefaultZoomX, kDefaultZoomY, kDefaultAngle, kDefaultHotspotX, kDefaultHotspotY, blendMode, alpha, mirrorX, mirrorY, offsetX, offsetY));
}
//////////////////////////////////////////////////////////////////////////
@@ -349,7 +349,7 @@ bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, flo
_rotation = 0;
TransformStruct transform;
if (transparent) {
- transform = TransformStruct(zoomX, zoomY, DEFAULT_ANGLE, DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y, blendMode, alpha, mirrorX, mirrorY);
+ transform = TransformStruct(zoomX, zoomY, kDefaultAngle, kDefaultHotspotX, kDefaultHotspotY, blendMode, alpha, mirrorX, mirrorY);
} else {
transform = TransformStruct(zoomX, zoomY, mirrorX, mirrorY);
}
@@ -414,8 +414,8 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect,
position.setWidth(newRect->width());
position.setHeight(newRect->height());
} else {
- position.setWidth((int16)((float)srcRect.width() * transform._zoom.x / DEFAULT_ZOOM_X));
- position.setHeight((int16)((float)srcRect.height() * transform._zoom.y / DEFAULT_ZOOM_Y));
+ position.setWidth((int16)((float)srcRect.width() * transform._zoom.x / kDefaultZoomX));
+ position.setHeight((int16)((float)srcRect.height() * transform._zoom.y / kDefaultZoomY));
}
renderer->modTargetRect(&position);
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
index 2e2da3c..8f38128 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
@@ -51,11 +51,11 @@ public:
bool endPixelOp() override;
- bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = DEFAULT_RGBAMOD, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
- bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = DEFAULT_RGBAMOD, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
- bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = DEFAULT_RGBAMOD, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override;
+ bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
+ bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
+ bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override;
bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
- bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = DEFAULT_RGBAMOD, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
+ bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = kDefaultRgbaMod, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) override;
bool repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) override;
virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override;
diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
index 7f141aa..091bb6e 100644
--- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp
+++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp
@@ -51,7 +51,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel);
}
// Then scale it if necessary
- if (_transform._angle != DEFAULT_ANGLE) {
+ if (_transform._angle != kDefaultAngle) {
TransparentSurface src(*_surface, false);
Graphics::Surface *temp = src.rotoscale(transform);
_surface->free();
@@ -67,7 +67,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
} else {
_surface = nullptr;
- if (transform._angle != DEFAULT_ANGLE) { // Make sure comparison-tickets get the correct width
+ if (transform._angle != kDefaultAngle) { // Make sure comparison-tickets get the correct width
Rect32 newDstRect;
Point32 newHotspot;
newDstRect = TransformTools::newRect(_srcRect, transform, &newHotspot);
diff --git a/engines/wintermute/graphics/transform_struct.cpp b/engines/wintermute/graphics/transform_struct.cpp
index c179d42..8edbf76 100644
--- a/engines/wintermute/graphics/transform_struct.cpp
+++ b/engines/wintermute/graphics/transform_struct.cpp
@@ -51,14 +51,14 @@ TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 h
TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, TSpriteBlendMode blendMode, uint32 rgbaMod, bool mirrorX, bool mirrorY) {
init(Point32(zoomX, zoomY),
- DEFAULT_ANGLE,
- Point32(DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y),
+ kDefaultAngle,
+ Point32(kDefaultHotspotX, kDefaultHotspotY),
false,
blendMode,
rgbaMod,
mirrorX,
mirrorY,
- Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
+ Point32(kDefaultOffsetX, kDefaultOffsetY));
}
TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 hotspotX, int32 hotspotY) {
@@ -67,20 +67,20 @@ TransformStruct::TransformStruct(int32 zoomX, int32 zoomY, uint32 angle, int32 h
Point32(hotspotX, hotspotY),
true,
BLEND_NORMAL,
- DEFAULT_RGBAMOD,
+ kDefaultRgbaMod,
false, false,
- Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
+ Point32(kDefaultOffsetX, kDefaultOffsetY));
}
TransformStruct::TransformStruct() {
- init(Point32(DEFAULT_ZOOM_X, DEFAULT_ZOOM_Y),
- DEFAULT_ANGLE,
- Point32(DEFAULT_HOTSPOT_X, DEFAULT_HOTSPOT_Y),
+ init(Point32(kDefaultZoomX, kDefaultZoomY),
+ kDefaultAngle,
+ Point32(kDefaultHotspotX, kDefaultHotspotY),
true,
BLEND_NORMAL,
- DEFAULT_RGBAMOD,
+ kDefaultRgbaMod,
false, false,
- Point32(DEFAULT_OFFSET_X, DEFAULT_OFFSET_Y));
+ Point32(kDefaultOffsetX, kDefaultOffsetY));
}
bool TransformStruct::getMirrorX() const {
diff --git a/engines/wintermute/graphics/transform_struct.h b/engines/wintermute/graphics/transform_struct.h
index 6b021b5..3fec9c0 100644
--- a/engines/wintermute/graphics/transform_struct.h
+++ b/engines/wintermute/graphics/transform_struct.h
@@ -20,21 +20,21 @@
*
*/
-#ifndef GRAPHICS_TRANSFORM_STRUCT_H
-#define GRAPHICS_TRANSFORM_STRUCT_H
+#ifndef WINTERMUTE_TRANSFORM_STRUCT_H
+#define WINTERMUTE_TRANSFORM_STRUCT_H
#include "engines/wintermute/math/rect32.h"
#include "engines/wintermute/dctypes.h"
-#define DEFAULT_ZOOM_X 100.0
-#define DEFAULT_ZOOM_Y 100.0
-#define DEFAULT_RGBAMOD 0xFFFFFFFF
-#define DEFAULT_HOTSPOT_X 0
-#define DEFAULT_HOTSPOT_Y 0
-#define DEFAULT_OFFSET_X 0
-#define DEFAULT_OFFSET_Y 0
-#define DEFAULT_ANGLE 0
-
+const float kDefaultZoomX = 100.0;
+const float kDefaultZoomY = 100.0;
+const uint32 kDefaultRgbaMod = 0xFFFFFFFF;
+const int32 kDefaultHotspotX = 0;
+const int32 kDefaultHotspotY = 0;
+const int32 kDefaultOffsetX = 0;
+const int32 kDefaultOffsetY = 0;
+const int32 kDefaultAngle = 0;
+
namespace Wintermute {
/**
* Contains all the required information that define a transform.
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index 01e8b48..1ba4843 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -29,8 +29,8 @@ namespace Wintermute {
FloatPoint TransformTools::transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX, const bool mirrorY) {
float rotateRad = rotate * M_PI / 180;
FloatPoint newPoint;
- newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad))*zoom.x/DEFAULT_ZOOM_X;
- newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad))*zoom.y/DEFAULT_ZOOM_Y;
+ newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad))*zoom.x/kDefaultZoomX;
+ newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad))*zoom.y/kDefaultZoomY;
if (mirrorX) {
newPoint.x *= -1;
}
Commit: 0d407fd2066fb94d19e7fd7e4bf703dd68d34ec9
https://github.com/scummvm/scummvm/commit/0d407fd2066fb94d19e7fd7e4bf703dd68d34ec9
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:21:35-07:00
Commit Message:
WINTERMUTE: Express 180.0f as float in TransformTools
Changed paths:
engines/wintermute/graphics/transform_tools.cpp
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index 1ba4843..52e6a51 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -27,7 +27,7 @@
namespace Wintermute {
FloatPoint TransformTools::transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX, const bool mirrorY) {
- float rotateRad = rotate * M_PI / 180;
+ float rotateRad = rotate * M_PI / 180.0f;
FloatPoint newPoint;
newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad))*zoom.x/kDefaultZoomX;
newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad))*zoom.y/kDefaultZoomY;
Commit: aeb4c0953805185ab70ceecb8e38b3b47c4322d9
https://github.com/scummvm/scummvm/commit/aeb4c0953805185ab70ceecb8e38b3b47c4322d9
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:21:36-07:00
Commit Message:
WINTERMUTE: Doxygen comments in TransformStruct
Changed paths:
engines/wintermute/graphics/transform_tools.h
diff --git a/engines/wintermute/graphics/transform_tools.h b/engines/wintermute/graphics/transform_tools.h
index a9eabff..0d81fb6 100644
--- a/engines/wintermute/graphics/transform_tools.h
+++ b/engines/wintermute/graphics/transform_tools.h
@@ -36,8 +36,12 @@ public:
static FloatPoint transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX = false, const bool mirrorY = false);
/**
- * Takes a rectangle, a transform and a pointer to a point, "newHotspot".
- * In return you get the smallest rect that can contain the transformed sprite
+ * @param &point the point on which the transform is to be applied
+ * @param rotate the angle in degrees
+ * @param &zoom zoom x,y in percent
+ * @param mirrorX flip along the vertical axis?
+ * @param mirrorY flip along the horizontal axis?
+ * @return the smallest rect that can contain the transformed sprite
* and, as a side-effect, "newHotspot" will tell you where the hotspot will
* have ended up in the new rect, for centering.
*/
Commit: 1ecdd2d61ad6dcf809c0cfaa37e7d9bbceb6bad3
https://github.com/scummvm/scummvm/commit/1ecdd2d61ad6dcf809c0cfaa37e7d9bbceb6bad3
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:23:51-07:00
Commit Message:
WINTERMUTE: #define to const for TransformStruct defaults
Changed paths:
engines/wintermute/graphics/transform_struct.h
engines/wintermute/graphics/transform_tools.cpp
diff --git a/engines/wintermute/graphics/transform_struct.h b/engines/wintermute/graphics/transform_struct.h
index 3fec9c0..0ca7e91 100644
--- a/engines/wintermute/graphics/transform_struct.h
+++ b/engines/wintermute/graphics/transform_struct.h
@@ -26,8 +26,8 @@
#include "engines/wintermute/math/rect32.h"
#include "engines/wintermute/dctypes.h"
-const float kDefaultZoomX = 100.0;
-const float kDefaultZoomY = 100.0;
+const uint32 kDefaultZoomX = 100;
+const uint32 kDefaultZoomY = 100;
const uint32 kDefaultRgbaMod = 0xFFFFFFFF;
const int32 kDefaultHotspotX = 0;
const int32 kDefaultHotspotY = 0;
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index 52e6a51..73f4840 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -29,8 +29,8 @@ namespace Wintermute {
FloatPoint TransformTools::transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX, const bool mirrorY) {
float rotateRad = rotate * M_PI / 180.0f;
FloatPoint newPoint;
- newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad))*zoom.x/kDefaultZoomX;
- newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad))*zoom.y/kDefaultZoomY;
+ newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad)) * zoom.x / kDefaultZoomX;
+ newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad)) * zoom.y / kDefaultZoomY;
if (mirrorX) {
newPoint.x *= -1;
}
Commit: f872d316784b43e394e3c7c3490181fd465b7ba0
https://github.com/scummvm/scummvm/commit/f872d316784b43e394e3c7c3490181fd465b7ba0
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:24:43-07:00
Commit Message:
WINTERMUTE: Fix type-related warnings in base_surface_osystem.cpp
Changed paths:
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index e01a669..e90df52 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -361,9 +361,9 @@ bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, flo
bool BaseSurfaceOSystem::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) {
_rotation = (uint32)transform._angle;
if (transform._angle < 0.0f) {
- warning("Negative rotation: %f %d", transform._angle, _rotation);
+ warning("Negative rotation: %d %d", transform._angle, _rotation);
_rotation = (uint32)(360.0f + transform._angle);
- warning("Negative post rotation: %f %d", transform._angle, _rotation);
+ warning("Negative post rotation: %d %d", transform._angle, _rotation);
}
return drawSprite(x, y, &rect, &newRect, transform);
}
@@ -423,12 +423,13 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect,
// But no checking is in place for that yet.
// TODO: Optimize by not doing alpha-blits if we lack or disable alpha
- bool hasAlpha;
+
+ bool hasAlpha = false;
+
if (_hasAlpha && !transform._alphaDisable) {
hasAlpha = true;
- } else {
- hasAlpha = false;
- }
+ }
+
if (transform._alphaDisable) {
warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored");
}
Commit: 566495de3b62c135767a3bf473e5a52d190caa15
https://github.com/scummvm/scummvm/commit/566495de3b62c135767a3bf473e5a52d190caa15
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:24:43-07:00
Commit Message:
WINTERMUTE: Remove unused variable in transparent_surface.cpp
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 48d550c..7aa25d1 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -106,8 +106,6 @@ void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, i
float q21y = (y2 - projY);
float q12x = (x2 - projX);
float q12y = (projY - y1);
- float q22x = (projX - x1);
- float q22y = (projY - y1);
if (x1 == x2 && y1 == y2) {
for (int c = 0; c < 4; c++) {
@@ -119,12 +117,10 @@ void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, i
q11x = 0.5;
q12x = 0.5;
q21x = 0.5;
- q22x = 0.5;
} else if (y1 == y2) {
q11y = 0.5;
q12y = 0.5;
q21y = 0.5;
- q22y = 0.5;
}
for (int c = 0; c < 4; c++) {
Commit: 567cd1eb123357fe474066fd73328bb2aeab42ca
https://github.com/scummvm/scummvm/commit/567cd1eb123357fe474066fd73328bb2aeab42ca
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T15:24:44-07:00
Commit Message:
WINTERMUTE: zoom parameter in display*** is now integer
Changed paths:
engines/wintermute/base/gfx/base_surface.h
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.h
diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h
index 016831f..e308b29 100644
--- a/engines/wintermute/base/gfx/base_surface.h
+++ b/engines/wintermute/base/gfx/base_surface.h
@@ -50,12 +50,12 @@ public:
virtual bool displayHalfTrans(int x, int y, Rect32 rect);
virtual bool isTransparentAt(int x, int y);
- virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
+ virtual bool displayTransZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0;
virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
virtual bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) = 0;
- virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
+ virtual bool displayZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0;
virtual bool repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) = 0;
virtual bool restore();
virtual bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0;
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index e90df52..e0b7aea 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -338,14 +338,14 @@ bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 al
}
//////////////////////////////////////////////////////////////////////////
-bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
+bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
_rotation = 0;
return drawSprite(x, y, &rect, nullptr, TransformStruct(zoomX, zoomY, blendMode, alpha, mirrorX, mirrorY));
}
//////////////////////////////////////////////////////////////////////////
-bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
+bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha, bool transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) {
_rotation = 0;
TransformStruct transform;
if (transparent) {
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
index 8f38128..5290170 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h
@@ -51,11 +51,11 @@ public:
bool endPixelOp() override;
- bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
+ bool displayTransZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override;
bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
- bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = kDefaultRgbaMod, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
+ bool displayZoom(int x, int y, Rect32 rect, int32 zoomX, int32 zoomY, uint32 alpha = kDefaultRgbaMod, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override;
bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) override;
bool repeatLastDisplayOp(int offsetX, int offsetY, int numTimesX, int numTimesY) override;
virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override;
Commit: 381df0c64ac88a704f931b0011d7f3f730c5caba
https://github.com/scummvm/scummvm/commit/381df0c64ac88a704f931b0011d7f3f730c5caba
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:10:42-07:00
Commit Message:
WINTERMUTE: Various explicit casts
* for floor/ceil output in transform_tools.cpp
* for projX/Y in transparent_surface.cpp
* in transpaprent_surface.cpp
Changed paths:
engines/wintermute/graphics/transform_tools.cpp
engines/wintermute/graphics/transparent_surface.cpp
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index 73f4840..ff90707 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -60,13 +60,13 @@ namespace Wintermute {
float right = MAX(nw1.x, MAX(ne1.x, MAX(sw1.x, se1.x)));
Rect32 res;
- newHotspot->y = -floor(top);
- newHotspot->x = -floor(left);
+ newHotspot->y = (uint32)(-floor(top));
+ newHotspot->x = (uint32)(-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 = (int32)(floor(top)) + transform._hotspot.y;
+ res.bottom = (int32)(ceil(bottom)) + transform._hotspot.y;
+ res.left = (int32)(floor(left)) + transform._hotspot.x;
+ res.right = (int32)(ceil(right)) + transform._hotspot.x;
return res;
}
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 7aa25d1..49ac2bd 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -45,7 +45,7 @@ void TransparentSurface::copyPixelNearestNeighbor(float projX, float projY, int
if (projX >= srcW || projX < 0 || projY >= srcH || projY < 0) {
color = 0;
} else {
- color = READ_UINT32((const byte *)src->getBasePtr(projX, projY));
+ color = READ_UINT32((const byte *)src->getBasePtr((int)projX, (int)projY));
}
WRITE_UINT32((byte *)dst->getBasePtr(dstX, dstY), color);
@@ -71,25 +71,25 @@ void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, i
if (x1 >= srcW || x1 < 0 || y1 >= srcH || y1 < 0) {
Q11 = 0;
} else {
- Q11 = READ_UINT32((const byte *)src->getBasePtr(x1 + srcRect.left, y1 + srcRect.top));
+ Q11 = READ_UINT32((const byte *)src->getBasePtr((int)(x1 + srcRect.left),(int)(y1 + srcRect.top)));
}
if (x1 >= srcW || x1 < 0 || y2 >= srcH || y2 < 0) {
Q12 = 0;
} else {
- Q12 = READ_UINT32((const byte *)src->getBasePtr(x1 + srcRect.left, y2 + srcRect.top));
+ Q12 = READ_UINT32((const byte *)src->getBasePtr((int)(x1 + srcRect.left), (int)(y2 + srcRect.top)));
}
if (x2 >= srcW || x2 < 0 || y1 >= srcH || y1 < 0) {
Q21 = 0;
} else {
- Q21 = READ_UINT32((const byte *)src->getBasePtr(x2 + srcRect.left, y1 + srcRect.top));
+ Q21 = READ_UINT32((const byte *)src->getBasePtr((int)(x2 + srcRect.left), (int)(y1 + srcRect.top)));
}
if (x2 >= srcW || x2 < 0 || y2 >= srcH || y2 < 0) {
Q22 = 0;
} else {
- Q22 = READ_UINT32((const byte *)src->getBasePtr(x2 + srcRect.left, y2 + srcRect.top));
+ Q22 = READ_UINT32((const byte *)src->getBasePtr((int)(x2 + srcRect.left), (int)(y2 + srcRect.top)));
}
byte *Q11s = (byte *)&Q11;
@@ -124,7 +124,7 @@ void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, i
}
for (int c = 0; c < 4; c++) {
- dest[c] = (
+ dest[c] = (byte)(
((float)Q11s[c]) * q11x * q11y +
((float)Q21s[c]) * q21x * q21y +
((float)Q12s[c]) * q12x * q12y +
@@ -580,8 +580,8 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
int 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;
+ projX = (int)(x / (float)dstW * srcW);
+ projY = (int)(y / (float)dstH * srcH);
copyPixelNearestNeighbor(projX, projY, x, y, srcRect, dstRect, this, target);
}
}
Commit: 86c8d238a4c14dd26b251a1662473b38cfaa1cdc
https://github.com/scummvm/scummvm/commit/86c8d238a4c14dd26b251a1662473b38cfaa1cdc
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:15:01-07:00
Commit Message:
WINTERMUTE: const Common::Rect rect& in rect32.h
Changed paths:
engines/wintermute/math/rect32.h
diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h
index 821df18..79d6e80 100644
--- a/engines/wintermute/math/rect32.h
+++ b/engines/wintermute/math/rect32.h
@@ -64,7 +64,7 @@ struct Rect32 {
Rect32() : top(0), left(0), bottom(0), right(0) {}
Rect32(int32 w, int32 h) : top(0), left(0), bottom(h), right(w) {}
- Rect32(Common::Rect rect) : top(rect.top), left(rect.left), bottom(rect.bottom), right(rect.right) {}
+ Rect32(const Common::Rect &rect) : top(rect.top), left(rect.left), bottom(rect.bottom), right(rect.right) {}
Rect32(int32 x1, int32 y1, int32 x2, int32 y2) : top(y1), left(x1), bottom(y2), right(x2) {
assert(isValidRect());
}
Commit: 1a8a9bab861402e81dd2e5407182f3c0a7cc479b
https://github.com/scummvm/scummvm/commit/1a8a9bab861402e81dd2e5407182f3c0a7cc479b
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:17:25-07:00
Commit Message:
WINTERMUTE: Compile bilinear copy only if needed
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 49ac2bd..534e516 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -31,6 +31,8 @@
namespace Wintermute {
+
+#ifndef ENABLE_BILINEAR
void TransparentSurface::copyPixelNearestNeighbor(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
int srcW = srcRect.width();
int srcH = srcRect.height();
@@ -50,7 +52,9 @@ void TransparentSurface::copyPixelNearestNeighbor(float projX, float projY, int
WRITE_UINT32((byte *)dst->getBasePtr(dstX, dstY), color);
}
+#endif
+#ifdef ENABLE_BILINEAR
void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
int srcW = srcRect.width();
@@ -137,6 +141,7 @@ void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, i
}
WRITE_UINT32((byte *)dst->getBasePtr(dstX + dstRect.left, dstY + dstRect.top), color);
}
+#endif
byte *TransparentSurface::_lookup = nullptr;
Commit: 14d151ab31d8163f3e7dc943be191c3a98bd4f6b
https://github.com/scummvm/scummvm/commit/14d151ab31d8163f3e7dc943be191c3a98bd4f6b
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:17:25-07:00
Commit Message:
WINTERMUTE: Fix #ifdef in transparent_surface.[h|cpp]
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 534e516..4eabc35 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -32,28 +32,6 @@
namespace Wintermute {
-#ifndef ENABLE_BILINEAR
-void TransparentSurface::copyPixelNearestNeighbor(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
- int srcW = srcRect.width();
- int srcH = srcRect.height();
- int dstW = dstRect.width();
- int dstH = dstRect.height();
-
- assert(dstX >= 0 && dstX < dstW);
- assert(dstY >= 0 && dstY < dstH);
-
- uint32 color;
-
- if (projX >= srcW || projX < 0 || projY >= srcH || projY < 0) {
- color = 0;
- } else {
- color = READ_UINT32((const byte *)src->getBasePtr((int)projX, (int)projY));
- }
-
- WRITE_UINT32((byte *)dst->getBasePtr(dstX, dstY), color);
-}
-#endif
-
#ifdef ENABLE_BILINEAR
void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
@@ -141,6 +119,26 @@ void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, i
}
WRITE_UINT32((byte *)dst->getBasePtr(dstX + dstRect.left, dstY + dstRect.top), color);
}
+#else
+void TransparentSurface::copyPixelNearestNeighbor(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
+ int srcW = srcRect.width();
+ int srcH = srcRect.height();
+ int dstW = dstRect.width();
+ int dstH = dstRect.height();
+
+ assert(dstX >= 0 && dstX < dstW);
+ assert(dstY >= 0 && dstY < dstH);
+
+ uint32 color;
+
+ if (projX >= srcW || projX < 0 || projY >= srcH || projY < 0) {
+ color = 0;
+ } else {
+ color = READ_UINT32((const byte *)src->getBasePtr((int)projX, (int)projY));
+ }
+
+ WRITE_UINT32((byte *)dst->getBasePtr(dstX, dstY), color);
+}
#endif
byte *TransparentSurface::_lookup = nullptr;
@@ -520,7 +518,7 @@ TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transfo
float targX;
float targY;
-#if ENABLE_BILINEAR
+#ifdef ENABLE_BILINEAR
for (int y = 0; y < dstH; y++) {
for (int x = 0; x < dstW; x++) {
int x1 = x - newHotspot.x;
@@ -570,7 +568,7 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
target->create((uint16)dstW, (uint16)dstH, this->format);
-#if ENABLE_BILINEAR
+#ifdef ENABLE_BILINEAR
float projX;
float projY;
for (int y = 0; y < dstH; y++) {
diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h
index 71c139a..7182967 100644
--- a/engines/wintermute/graphics/transparent_surface.h
+++ b/engines/wintermute/graphics/transparent_surface.h
@@ -53,9 +53,11 @@ struct TransparentSurface : public Graphics::Surface {
void setColorKey(char r, char g, char b);
void disableColorKey();
+#ifdef ENABLE_BILINEAR
static void copyPixelBilinear(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst);
+#else
static void copyPixelNearestNeighbor(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst);
-
+#endif
// Enums
/**
@brief The possible flipping parameters for the blit methode.
Commit: d83e4e1268e7422abd6f00463065f6e12fea15f7
https://github.com/scummvm/scummvm/commit/d83e4e1268e7422abd6f00463065f6e12fea15f7
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:17:28-07:00
Commit Message:
WINTERMUTE: FActor out TransformStruc initialization in repeatLastDraw loop
Changed paths:
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 06cf531..58bd8d3 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -371,12 +371,13 @@ void BaseRenderOSystem::repeatLastDraw(int offsetX, int offsetY, int numTimesX,
int initLeft = dstRect.left;
int initRight = dstRect.right;
+ TransformStruct temp = TransformStruct(kDefaultZoomX, kDefaultZoomY, kDefaultAngle, kDefaultHotspotX, kDefaultHotspotY, BLEND_NORMAL, kDefaultRgbaMod, false, false, kDefaultOffsetX, kDefaultOffsetY);
+
for (int i = 0; i < numTimesY; i++) {
if (i == 0) {
dstRect.translate(offsetX, 0);
}
for (int j = (i == 0 ? 1 : 0); j < numTimesX; j++) {
- TransformStruct temp = TransformStruct();
drawSurface(origTicket->_owner, origTicket->getSurface(), &srcRect, &dstRect, temp);
dstRect.translate(offsetX, 0);
}
Commit: 56aa1297d13304666aa91cc57a5da88f3aa20b5f
https://github.com/scummvm/scummvm/commit/56aa1297d13304666aa91cc57a5da88f3aa20b5f
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:17:29-07:00
Commit Message:
WINTERMUTE: Bring consts inside namespace in transform_struct.h
Changed paths:
engines/wintermute/graphics/transform_struct.h
diff --git a/engines/wintermute/graphics/transform_struct.h b/engines/wintermute/graphics/transform_struct.h
index 0ca7e91..acde410 100644
--- a/engines/wintermute/graphics/transform_struct.h
+++ b/engines/wintermute/graphics/transform_struct.h
@@ -26,6 +26,13 @@
#include "engines/wintermute/math/rect32.h"
#include "engines/wintermute/dctypes.h"
+namespace Wintermute {
+/**
+ * Contains all the required information that define a transform.
+ * Same source sprite + same TransformStruct = Same resulting sprite.
+ * Has a number of overloaded constructors to accomodate various argument lists.
+ */
+
const uint32 kDefaultZoomX = 100;
const uint32 kDefaultZoomY = 100;
const uint32 kDefaultRgbaMod = 0xFFFFFFFF;
@@ -35,12 +42,6 @@ const int32 kDefaultOffsetX = 0;
const int32 kDefaultOffsetY = 0;
const int32 kDefaultAngle = 0;
-namespace Wintermute {
-/**
- * Contains all the required information that define a transform.
- * Same source sprite + same TransformStruct = Same resulting sprite.
- * Has a number of overloaded constructors to accomodate various argument lists.
- */
struct TransformStruct {
private:
void init(Point32 zoom, uint32 angle, Point32 hotspot, bool alphaDisable, TSpriteBlendMode blendMode, uint32 alpha, bool mirrorX, bool mirrorY, Point32 offset);
Commit: b5adcda94719792c15a2cb72e9c0ad191f8fa224
https://github.com/scummvm/scummvm/commit/b5adcda94719792c15a2cb72e9c0ad191f8fa224
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:17:30-07:00
Commit Message:
WINTERMUTE: s/WINTERMUTE_TRANSFORMTOOLS_H/WINTERMUTE_TRANSFORM_TOOLS_H/
Changed paths:
engines/wintermute/graphics/transform_tools.h
diff --git a/engines/wintermute/graphics/transform_tools.h b/engines/wintermute/graphics/transform_tools.h
index 0d81fb6..77b41a9 100644
--- a/engines/wintermute/graphics/transform_tools.h
+++ b/engines/wintermute/graphics/transform_tools.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef WINTERMUTE_TRANSFORMTOOLS_H
-#define WINTERMUTE_TRANSFORMTOOLS_H
+#ifndef WINTERMUTE_TRANSFORM_TOOLS_H
+#define WINTERMUTE_TRANSFORM_TOOLS_H
#include "engines/wintermute/math/rect32.h"
#include "engines/wintermute/math/floatpoint.h"
Commit: 1c25eb24900445ba704e759239572a86ea88c3e1
https://github.com/scummvm/scummvm/commit/1c25eb24900445ba704e759239572a86ea88c3e1
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:17:31-07:00
Commit Message:
WINTERMUTE: Formatting
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 4eabc35..3c64930 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -518,38 +518,24 @@ TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transfo
float targX;
float targY;
-#ifdef 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)) * kDefaultZoomX / transform._zoom.x + srcRect.left;
+ targY = ((x1 * invSin + y1 * invCos)) * kDefaultZoomY / transform._zoom.y + srcRect.top;
targX += transform._hotspot.x;
targY += transform._hotspot.y;
+#ifdef ENABLE_BILINEAR
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;
-
- 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;
-
copyPixelNearestNeighbor(targX, targY, x, y, srcRect, dstRect, this, target);
+#endif
}
}
-#endif
-
return target;
}
@@ -568,27 +554,20 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
target->create((uint16)dstW, (uint16)dstH, this->format);
-#ifdef 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;
+#ifdef ENABLE_BILINEAR
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 = (int)(x / (float)dstW * srcW);
- projY = (int)(y / (float)dstH * srcH);
copyPixelNearestNeighbor(projX, projY, x, y, srcRect, dstRect, this, target);
+#endif
}
}
-#endif
return target;
}
Commit: 204c75bc2733fb5b4251e73d6859398dd50f942a
https://github.com/scummvm/scummvm/commit/204c75bc2733fb5b4251e73d6859398dd50f942a
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:17:31-07:00
Commit Message:
WINTERMUTE: s/255,255,255,255/kDefaultMod/
Changed paths:
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 58bd8d3..866a8a1 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -60,7 +60,7 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) {
_borderLeft = _borderRight = _borderTop = _borderBottom = 0;
_ratioX = _ratioY = 1.0f;
- _colorMod = 0xFFFFFFFF;
+ _colorMod = kDefaultRgbaMod;
_dirtyRect = nullptr;
_disableDirtyRects = false;
_tempDisableDirtyRects = 0;
Commit: e3381cff0db4ebc8be62a2f7f2b228cd55cd23bc
https://github.com/scummvm/scummvm/commit/e3381cff0db4ebc8be62a2f7f2b228cd55cd23bc
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:17:32-07:00
Commit Message:
WINTERMUTE: #ifdef ENABLE_BILINEAR -> #if ENBABLE_BILINEAR
Changed paths:
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp
index 3c64930..5b7c416 100644
--- a/engines/wintermute/graphics/transparent_surface.cpp
+++ b/engines/wintermute/graphics/transparent_surface.cpp
@@ -32,7 +32,7 @@
namespace Wintermute {
-#ifdef ENABLE_BILINEAR
+#if ENABLE_BILINEAR
void TransparentSurface::copyPixelBilinear(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst) {
int srcW = srcRect.width();
@@ -529,7 +529,7 @@ TransparentSurface *TransparentSurface::rotoscale(const TransformStruct &transfo
targX += transform._hotspot.x;
targY += transform._hotspot.y;
-#ifdef ENABLE_BILINEAR
+#if ENABLE_BILINEAR
copyPixelBilinear(targX, targY, x, y, srcRect, dstRect, this, target);
#else
copyPixelNearestNeighbor(targX, targY, x, y, srcRect, dstRect, this, target);
@@ -561,7 +561,7 @@ TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight)
for (int x = 0; x < dstW; x++) {
projX = x / (float)dstW * srcW;
projY = y / (float)dstH * srcH;
-#ifdef ENABLE_BILINEAR
+#if ENABLE_BILINEAR
copyPixelBilinear(projX, projY, x, y, srcRect, dstRect, this, target);
#else
copyPixelNearestNeighbor(projX, projY, x, y, srcRect, dstRect, this, target);
diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h
index 7182967..7b5579f 100644
--- a/engines/wintermute/graphics/transparent_surface.h
+++ b/engines/wintermute/graphics/transparent_surface.h
@@ -53,7 +53,7 @@ struct TransparentSurface : public Graphics::Surface {
void setColorKey(char r, char g, char b);
void disableColorKey();
-#ifdef ENABLE_BILINEAR
+#if ENABLE_BILINEAR
static void copyPixelBilinear(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst);
#else
static void copyPixelNearestNeighbor(float projX, float projY, int dstX, int dstY, const Common::Rect &srcRect, const Common::Rect &dstRect, const TransparentSurface *src, TransparentSurface *dst);
Commit: c32769e0b7e63e9e9b8bf0fc7d4caa91554fa8ad
https://github.com/scummvm/scummvm/commit/c32769e0b7e63e9e9b8bf0fc7d4caa91554fa8ad
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2013-07-31T17:51:40-07:00
Commit Message:
WINTERMUTE; Indentation in transform_*
Changed paths:
engines/wintermute/graphics/transform_tools.cpp
engines/wintermute/graphics/transform_tools.h
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index ff90707..4f05e19 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -26,48 +26,49 @@
namespace Wintermute {
- FloatPoint TransformTools::transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX, const bool mirrorY) {
- float rotateRad = rotate * M_PI / 180.0f;
- FloatPoint newPoint;
- newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad)) * zoom.x / kDefaultZoomX;
- newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad)) * zoom.y / kDefaultZoomY;
- if (mirrorX) {
- newPoint.x *= -1;
- }
- if (mirrorY) {
- newPoint.y *= -1;
- }
- return newPoint;
+FloatPoint TransformTools::transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX, const bool mirrorY) {
+ float rotateRad = rotate * M_PI / 180.0f;
+ FloatPoint newPoint;
+ newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad)) * zoom.x / kDefaultZoomX;
+ newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad)) * zoom.y / kDefaultZoomY;
+ if (mirrorX) {
+ newPoint.x *= -1;
}
+ if (mirrorY) {
+ newPoint.y *= -1;
+ }
+ return newPoint;
+}
- Rect32 TransformTools::newRect (const Rect32 &oldRect, const TransformStruct &transform, Point32 *newHotspot) {
+Rect32 TransformTools::newRect (const Rect32 &oldRect, const TransformStruct &transform, Point32 *newHotspot) {
- Point32 nw(oldRect.left, oldRect.top);
- Point32 ne(oldRect.right, oldRect.top);
- Point32 sw(oldRect.left, oldRect.bottom);
- Point32 se(oldRect.right, oldRect.bottom);
+ Point32 nw(oldRect.left, oldRect.top);
+ Point32 ne(oldRect.right, oldRect.top);
+ Point32 sw(oldRect.left, oldRect.bottom);
+ Point32 se(oldRect.right, oldRect.bottom);
- FloatPoint nw1, ne1, sw1, se1;
+ 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)));
- float left = MIN(nw1.x, MIN(ne1.x, MIN(sw1.x, se1.x)));
- float right = MAX(nw1.x, MAX(ne1.x, MAX(sw1.x, se1.x)));
+ 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)));
+ float left = MIN(nw1.x, MIN(ne1.x, MIN(sw1.x, se1.x)));
+ float right = MAX(nw1.x, MAX(ne1.x, MAX(sw1.x, se1.x)));
- Rect32 res;
- newHotspot->y = (uint32)(-floor(top));
- newHotspot->x = (uint32)(-floor(left));
+ Rect32 res;
+ newHotspot->y = (uint32)(-floor(top));
+ newHotspot->x = (uint32)(-floor(left));
- res.top = (int32)(floor(top)) + transform._hotspot.y;
- res.bottom = (int32)(ceil(bottom)) + transform._hotspot.y;
- res.left = (int32)(floor(left)) + transform._hotspot.x;
- res.right = (int32)(ceil(right)) + transform._hotspot.x;
+ res.top = (int32)(floor(top)) + transform._hotspot.y;
+ res.bottom = (int32)(ceil(bottom)) + transform._hotspot.y;
+ res.left = (int32)(floor(left)) + transform._hotspot.x;
+ res.right = (int32)(ceil(right)) + transform._hotspot.x;
+
+ return res;
+}
- return res;
- }
} // End of namespace Wintermute
diff --git a/engines/wintermute/graphics/transform_tools.h b/engines/wintermute/graphics/transform_tools.h
index 77b41a9..e59c472 100644
--- a/engines/wintermute/graphics/transform_tools.h
+++ b/engines/wintermute/graphics/transform_tools.h
@@ -28,6 +28,7 @@
#include "engines/wintermute/graphics/transform_struct.h"
namespace Wintermute {
+
class TransformTools {
public:
/**
@@ -47,5 +48,6 @@ public:
*/
static Rect32 newRect (const Rect32 &oldRect, const TransformStruct &transform, Point32 *newHotspot);
};
+
} // End of namespace Wintermute
#endif
Commit: 9fb15a909c964c607110d29b15074c4a0269baae
https://github.com/scummvm/scummvm/commit/9fb15a909c964c607110d29b15074c4a0269baae
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2013-08-01T02:08:21-07:00
Commit Message:
Merge pull request #354 from tobiatesan/wintermute_rotozoom_3
WINTERMUTE: Wintermute rotozoom 3
Changed paths:
A engines/wintermute/graphics/transform_struct.cpp
A engines/wintermute/graphics/transform_struct.h
A engines/wintermute/graphics/transform_tools.cpp
A engines/wintermute/graphics/transform_tools.h
A engines/wintermute/math/floatpoint.h
engines/wintermute/base/base_sprite.h
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/base/gfx/base_surface.cpp
engines/wintermute/base/gfx/base_surface.h
engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
engines/wintermute/base/gfx/osystem/base_render_osystem.h
engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
engines/wintermute/base/gfx/osystem/base_surface_osystem.h
engines/wintermute/base/gfx/osystem/render_ticket.cpp
engines/wintermute/base/gfx/osystem/render_ticket.h
engines/wintermute/graphics/transparent_surface.cpp
engines/wintermute/graphics/transparent_surface.h
engines/wintermute/math/rect32.h
engines/wintermute/module.mk
More information about the Scummvm-git-logs
mailing list