[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/matrix.cpp server/matrix.h
From: |
Zou Lunkai |
Subject: |
[Gnash-commit] gnash ChangeLog server/matrix.cpp server/matrix.h |
Date: |
Thu, 12 Jun 2008 03:07:54 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Zou Lunkai <zoulunkai> 08/06/12 03:07:54
Modified files:
. : ChangeLog
server : matrix.cpp matrix.h
Log message:
* server/matrix.{h, cpp}: drop transform_by_inverse() and set_inverse(),
add a invert() methord for inverting the matrix. make the interfaces
clearer. cleanups.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6904&r2=1.6905
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.cpp?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.h?cvsroot=gnash&r1=1.25&r2=1.26
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6904
retrieving revision 1.6905
diff -u -b -r1.6904 -r1.6905
--- ChangeLog 11 Jun 2008 20:54:43 -0000 1.6904
+++ ChangeLog 12 Jun 2008 03:07:53 -0000 1.6905
@@ -1,3 +1,9 @@
+2008-06-12 Zou Lunkai <address@hidden>
+
+ * server/matrix.{h, cpp}: drop transform_by_inverse() and set_inverse(),
+ add a invert() methord for inverting the matrix. make the interfaces
+ clearer. cleanups.
+
2008-06-11 Benjamin Wolsey <address@hidden>
* testsuite/actionscript.all/Try.as: all my tests pass.
Index: server/matrix.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/matrix.cpp 10 Jun 2008 08:17:46 -0000 1.35
+++ server/matrix.cpp 12 Jun 2008 03:07:54 -0000 1.36
@@ -27,10 +27,8 @@
#include "matrix.h"
#include "stream.h" // for reading from SWF
-#include "types.h" // for TWIPS_TO_PIXEL define
- // (should probably not use it though)
-#include "log.h"
-#include "utility.h" // for utility::infinite_to_fzero, utility::isFinite
+#include "types.h" // for TWIPS_TO_PIXELS
+#include "utility.h"
namespace gnash {
@@ -86,10 +84,11 @@
bool
matrix::is_valid() const
{
+ // The integer matrix is always valid now from outside.
+ // swallow it if anything wrong inside this class.
return true;
}
-
void
matrix::set_identity()
// Set the matrix to identity.
@@ -247,66 +246,40 @@
r.expandTo(p3.x, p3.y);
}
-
-void
-matrix::transform_by_inverse(point* result, const point& p) const
-// Transform point 'p' by the inverse of our matrix. Put result in *result.
-{
- // @@ TODO optimize this!
- matrix m;
- m.set_inverse(*this);
- m.transform(result, p);
-}
-
-void
-matrix::transform_by_inverse(point& p) const
-// Transform point 'p' by the inverse of our matrix.
-{
- // @@ TODO optimize this!
- matrix m;
- m.set_inverse(*this);
- m.transform(p);
-}
-
-void
-matrix::transform_by_inverse(geometry::Range2d<float>& r) const
+const matrix&
+matrix::invert()
+// invert this matrix and return the result.
{
- // @@ TODO optimize this!
- matrix m;
- m.set_inverse(*this);
- m.transform(r);
-}
-
-
-void
-matrix::set_inverse(const matrix& m)
-// Set this matrix to the inverse of the given matrix.
-{
- assert(this != &m);
-
- boost::int64_t det = m.get_determinant();
- if (det == 0)
+ boost::int64_t det = determinant();
+ if(det == 0)
{
- // cann't invert this matrix, set it to identity.
- // this might happen when xscale == yscale == 0
+ // TODO: check this.
set_identity();
}
else
{
- double inv_det = 65536.0 * 65536.0 / det;
- sx = (boost::int32_t)(m.sy * inv_det);
- sy = (boost::int32_t)(m.sx * inv_det);
- shy = -(boost::int32_t)(m.shy * inv_det);
- shx = -(boost::int32_t)(m.shx * inv_det);
+ double d = 65536.0 * 65536.0 / det;
- tx = -( Fixed16Mul(sx, m.tx) + Fixed16Mul(shy, m.ty) );
- ty = -( Fixed16Mul(shx, m.tx) + Fixed16Mul(sy, m.ty) );
+ boost::int32_t d_fixed = DoubleToFixed16(d);
+ boost::int32_t t0, t4;
+
+ t0 = Fixed16Mul(sy, d_fixed);
+ sy = Fixed16Mul(sx, d_fixed);
+ shy = Fixed16Mul(-shy, d_fixed);
+ shx = Fixed16Mul(-shx, d_fixed);
+
+ t4 = - ( Fixed16Mul(tx, t0) + Fixed16Mul(ty, shy) );
+ ty = - ( Fixed16Mul(tx, shx)+ Fixed16Mul(ty, sy) );
+
+ sx = t0;
+ tx = t4;
}
-}
+ return *this;
+}
boost::int64_t
-matrix::get_determinant() const
+matrix::determinant() const
// Return the 32.32 fixed point determinant of this matrix.
{
return (boost::int64_t)sx * sy - (boost::int64_t)shx * shy;
@@ -327,7 +300,7 @@
float
matrix::get_rotation() const
{
- if (get_determinant() < 0)
+ if (determinant() < 0)
{
// TODO: check this.
return atan2f(shx, -sx);
Index: server/matrix.h
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/matrix.h 11 Jun 2008 03:31:44 -0000 1.25
+++ server/matrix.h 12 Jun 2008 03:07:54 -0000 1.26
@@ -150,23 +150,8 @@
///
void transform(geometry::Range2d<float>& r) const;
- /// Transform point 'p' by the inverse of our matrix.
- void transform_by_inverse(point& p) const;
-
- /// Transform point 'p' by the inverse of our matrix.
- //
- /// Put result in *result.
- ///
- void transform_by_inverse(point* result, const point& p) const;
-
- /// Transform Range2d<float> 'r' by the inverse our matrix.
- //
- /// NULL and WORLD ranges are untouched.
- ///
- void transform_by_inverse(geometry::Range2d<float>& r) const;
-
- /// Set this matrix to the inverse of the given matrix.
- void set_inverse(const matrix& m);
+ /// Invert this matrix and return the result.
+ const matrix& invert();
/// return the magnitude scale of our x coord output
float get_x_scale() const;
@@ -189,8 +174,9 @@
return ty;
}
+private:
/// Return the determinant of this matrix in 32.32 fixed point format.
- boost::int64_t get_determinant() const;
+ boost::int64_t determinant() const;
};
inline bool operator== (const matrix& a, const matrix& b)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/matrix.cpp server/matrix.h,
Zou Lunkai <=