[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/asobj/flash/geom/Matrix_...
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] gnash ChangeLog server/asobj/flash/geom/Matrix_... |
Date: |
Tue, 10 Jun 2008 05:25:59 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Benjamin Wolsey <bwy> 08/06/10 05:25:59
Modified files:
. : ChangeLog
server/asobj/flash/geom: Matrix_as.cpp
Log message:
* server/asobj/flash/geom/Matrix_as.cpp: add optional debugging
output;
lu_factorize's failure to notice that some matrices aren't
invertible
is a known problem with that solving method. Add a try/catch
to handle
the exception. As the exception is only thrown when NDEBUG is
defined,
I'll find a more reliable solver. Gnash is about 60-70%
faster than
the PP for flash.geom.Matrix operations in a loop, despite
being
almost 50% slower executing the loop itself...
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6876&r2=1.6877
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/flash/geom/Matrix_as.cpp?cvsroot=gnash&r1=1.10&r2=1.11
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6876
retrieving revision 1.6877
diff -u -b -r1.6876 -r1.6877
--- ChangeLog 10 Jun 2008 01:03:20 -0000 1.6876
+++ ChangeLog 10 Jun 2008 05:25:58 -0000 1.6877
@@ -1,3 +1,13 @@
+2008-06-10 Benjamin Wolsey <address@hidden>
+
+ * server/asobj/flash/geom/Matrix_as.cpp: add optional debugging output;
+ lu_factorize's failure to notice that some matrices aren't invertible
+ is a known problem with that solving method. Add a try/catch to handle
+ the exception. As the exception is only thrown when NDEBUG is defined,
+ I'll find a more reliable solver. Gnash is about 60-70% faster than
+ the PP for flash.geom.Matrix operations in a loop, despite being
+ almost 50% slower executing the loop itself...
+
2008-06-09 Rob Savoye <address@hidden>
* libamf/element.cpp: Actually calculate the size of the output
Index: server/asobj/flash/geom/Matrix_as.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/flash/geom/Matrix_as.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/asobj/flash/geom/Matrix_as.cpp 9 Jun 2008 20:22:54 -0000
1.10
+++ server/asobj/flash/geom/Matrix_as.cpp 10 Jun 2008 05:25:58 -0000
1.11
@@ -17,10 +17,6 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
#include "Matrix_as.h"
#include "as_object.h" // for inheritance
#include "log.h"
@@ -47,8 +43,12 @@
// A transformation matrix for affine transformations:
// a c tx
// b d ty
-// 0 0 1
-// The matrix can only operate in 2d space.
+// u v w
+// The matrix can only operate in 2d space. The bottom row is immutable
+// as 0 0 1.
+
+// Define this to get verbose debugging messages for matrix calculations
+//#define GNASH_DEBUG_GEOM_MATRIX 1
namespace gnash {
@@ -218,12 +218,22 @@
boost::numeric::ublas::c_matrix<double, 3, 3> concatMatrix;
fillMatrix(concatMatrix, obj);
+
// Current ('this') Matrix
boost::numeric::ublas::c_matrix<double, 3, 3> currentMatrix;
fillMatrix(currentMatrix, ptr.get());
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.concat) This matrix (pre-transform): %s",
currentMatrix);
+ log_debug("(Matrix.concat) Transform matrix: %s", concatMatrix);
+#endif
+
currentMatrix = boost::numeric::ublas::prod(concatMatrix, currentMatrix);
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.concat) This matrix (post-transform): %s",
currentMatrix);
+#endif
+
// Set values of current matrix
ptr->set_member(NSV::PROP_A, as_value(currentMatrix(0, 0)));
ptr->set_member(NSV::PROP_B, as_value(currentMatrix(1, 0)));
@@ -321,9 +331,18 @@
point(0) = x.to_number();
point(1) = y.to_number();
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.deltaTransformPoint) This matrix: %s", transformMatrix);
+ log_debug("(Matrix.deltaTransformPoint) Point vector (pre-transform): %s",
point);
+#endif
+
// Transform
point = boost::numeric::ublas::prod(point, transformMatrix);
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.deltaTransformPoint) Point vector (post-transform):
%s", point);
+#endif
+
// Get an auto_ptr to a Point and pretend to keep alive.
boost::intrusive_ptr<as_object> ret = init_Point_instance().release();
ret->set_member(NSV::PROP_X, point(0));
@@ -382,15 +401,40 @@
ublas::c_matrix<double, 3, 3> currentMatrix;
fillMatrix(currentMatrix, ptr.get());
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.invert) This matrix (pre-transform): %s",
currentMatrix);
+#endif
+
ublas::permutation_matrix<double> pm(currentMatrix.size1());
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.invert) Permutation matrix: %s", pm);
+#endif
+
int valid = ublas::lu_factorize<ublas::c_matrix<double, 3, 3>
>(currentMatrix, pm);
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.invert) Factorized matrix (return %f): %s", valid, pm);
+#endif
+
if( valid == 0 )
{
- // We can invert.
+ try
+ {
+ // We can probably invert, but the validity check above fails on
+ // some machines. We can get an exception from boost::ublas
ublas::lu_substitute<ublas::c_matrix<double, 3, 3> >(currentMatrix,
pm, inverseMatrix);
}
+ catch (ublas::internal_logic &e)
+ {
+
+ }
+
+ }
+
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.invert) Inverse matrix: %s", inverseMatrix);
+#endif
// Returns the identity matrix if unsuccessful.
ptr->set_member(NSV::PROP_A, as_value(inverseMatrix(0, 0)));
@@ -437,11 +481,17 @@
currentMatrix(1, 0) = c.to_number();
currentMatrix(1, 1) = d.to_number();
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.rotate) This matrix (pre-transform): %s",
currentMatrix);
+#endif
+
// Apply rotation to current matrix.
currentMatrix = boost::numeric::ublas::prod(currentMatrix,
transformMatrix);
- log_debug("Modified matrix: %s", currentMatrix);
- log_debug("Transformation matrix%s", transformMatrix);
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.rotate) Transformation matrix: %s",
transformMatrix);
+ log_debug("(Matrix.rotate) This matrix (post-transform): %s",
currentMatrix);
+#endif
ptr->set_member(NSV::PROP_A, as_value(currentMatrix(0, 0)));
ptr->set_member(NSV::PROP_B, as_value(currentMatrix(0, 1)));
@@ -496,11 +546,18 @@
currentMatrix(1, 0) = c.to_number();
currentMatrix(1, 1) = d.to_number();
- log_debug("%s - %s", currentMatrix, transformMatrix);
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.scale) This matrix (pre-transform): %s",
currentMatrix);
+#endif
// Apply scale to current matrix.
currentMatrix = boost::numeric::ublas::prod(currentMatrix,
transformMatrix);
+#ifdef GNASH_DEBUG_GEOM_MATRIX
+ log_debug("(Matrix.scale) Transformation matrix: %s", transformMatrix);
+ log_debug("(Matrix.scale) This matrix (post-transform): %s",
currentMatrix);
+#endif
+
ptr->set_member(NSV::PROP_A, as_value(currentMatrix(0, 0)));
ptr->set_member(NSV::PROP_B, as_value(currentMatrix(0, 1)));
ptr->set_member(NSV::PROP_C, as_value(currentMatrix(1, 0)));