[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/matrix.cpp server/matrix...
From: |
Zou Lunkai |
Subject: |
[Gnash-commit] gnash ChangeLog server/matrix.cpp server/matrix... |
Date: |
Fri, 06 Jun 2008 03:48:30 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Zou Lunkai <zoulunkai> 08/06/06 03:48:29
Modified files:
. : ChangeLog
server : matrix.cpp matrix.h
testsuite/misc-ming.all: DrawingApiTest.as
Log message:
* server/matirx.{h, cpp}: more floats to integers migration,
cleanups.
* testsuite/misc-ming.all/DrawingApiTest.as: make the tests
saner.
The original tests are also expected to be passed. But it should be
fixed in the core, not inside the swf matrix.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6832&r2=1.6833
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.cpp?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.h?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DrawingApiTest.as?cvsroot=gnash&r1=1.36&r2=1.37
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6832
retrieving revision 1.6833
diff -u -b -r1.6832 -r1.6833
--- ChangeLog 5 Jun 2008 22:13:04 -0000 1.6832
+++ ChangeLog 6 Jun 2008 03:48:27 -0000 1.6833
@@ -1,3 +1,6 @@
+2008-06-06 Zou Lunkai <address@hidden>
+
+
2008-06-06 Sandro Santilli <address@hidden>
* gui/kde.cpp: include types.h for PIXELS_TO_TWIPS
Index: server/matrix.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- server/matrix.cpp 5 Jun 2008 03:26:32 -0000 1.32
+++ server/matrix.cpp 6 Jun 2008 03:48:28 -0000 1.33
@@ -41,6 +41,47 @@
shx = shy = tx = ty = 0;
}
+void
+matrix::read(stream& in)
+// Initialize from the stream.
+{
+ in.align();
+
+ set_identity();
+
+ in.ensureBits(1);
+ bool has_scale = in.read_bit();
+ if (has_scale)
+ {
+ in.ensureBits(5);
+ int scale_nbits = in.read_uint(5);
+
+ in.ensureBits(scale_nbits*2);
+ sx = in.read_sint(scale_nbits);
+ sy = in.read_sint(scale_nbits);
+ }
+
+ in.ensureBits(1);
+ bool has_rotate = in.read_bit();
+ if (has_rotate)
+ {
+ in.ensureBits(5);
+ int rotate_nbits = in.read_uint(5);
+
+ in.ensureBits(rotate_nbits*2);
+ shx = in.read_sint(rotate_nbits);
+ shy = in.read_sint(rotate_nbits);
+ }
+
+ in.ensureBits(5);
+ int translate_nbits = in.read_uint(5);
+ if (translate_nbits > 0)
+ {
+ in.ensureBits(translate_nbits*2);
+ tx = (float) in.read_sint(translate_nbits);
+ ty = (float) in.read_sint(translate_nbits);
+ }
+}
bool
matrix::is_valid() const
@@ -128,10 +169,10 @@
{
float cos_angle = cosf(angle);
float sin_angle = sinf(angle);
- sx = 65536 * x_scale * cos_angle;
- shy = 65536 * y_scale * -sin_angle;
- shx = 65536 * x_scale * sin_angle;
- sy = 65536 * y_scale * cos_angle;
+ sx = 65536.0f * x_scale * cos_angle;
+ shy = 65536.0f * y_scale * -sin_angle;
+ shx = 65536.0f * x_scale * sin_angle;
+ sy = 65536.0f * y_scale * cos_angle;
}
void
@@ -165,60 +206,14 @@
set_scale_rotation(xscale, yscale, rotation);
}
-
-void
-matrix::read(stream& in)
-// Initialize from the stream.
-{
- in.align();
-
- set_identity();
-
- in.ensureBits(1);
- bool has_scale = in.read_bit();
- if (has_scale)
- {
- in.ensureBits(5);
- int scale_nbits = in.read_uint(5);
-
- in.ensureBits(scale_nbits*2);
- sx = in.read_sint(scale_nbits);
- sy = in.read_sint(scale_nbits);
- }
-
- in.ensureBits(1);
- bool has_rotate = in.read_bit();
- if (has_rotate)
- {
- in.ensureBits(5);
- int rotate_nbits = in.read_uint(5);
-
- in.ensureBits(rotate_nbits*2);
- shx = in.read_sint(rotate_nbits);
- shy = in.read_sint(rotate_nbits);
- }
-
- in.ensureBits(5);
- int translate_nbits = in.read_uint(5);
- if (translate_nbits > 0)
- {
- in.ensureBits(translate_nbits*2);
- tx = (float) in.read_sint(translate_nbits);
- ty = (float) in.read_sint(translate_nbits);
- }
-
- //IF_VERBOSE_PARSE(log_parse(" mat: has_scale = %d, has_rotate =
%d\n", has_scale, has_rotate));
-}
-
void
matrix::transform(point* result, const point& p) const
-// Transform point 'p' by our matrix. Put the result in
-// *result.
+// Transform point 'p' by our matrix. Put the result in *result.
{
assert(result);
- result->x = sx / 65536.0 * p.x + shy / 65536.0f * p.y + tx;
- result->y = shx / 65536.0 * p.x + sy / 65536.0f * p.y + ty;
+ result->x = Fixed16Mul(sx, p.x) + Fixed16Mul(shy, p.y) + tx;
+ result->y = Fixed16Mul(shx, p.x) + Fixed16Mul(sy, p.y) + ty;
}
void
@@ -254,8 +249,8 @@
{
assert(result);
- result->x = sx / 65536.0f * v.x + shy / 65536.0f * v.y;
- result->y = sy / 65536.0f * v.x + shx / 65536.0f * v.y;
+ result->x = Fixed16Mul(sx, v.x) + Fixed16Mul(shy, v.y);
+ result->y = Fixed16Mul(sy, v.x) + Fixed16Mul(shx, v.y);
}
void
@@ -294,28 +289,23 @@
{
assert(this != &m);
- // Invert the rotation part.
- float det = m.get_determinant();
- if (det == 0.0f)
+ boost::int64_t det = m.get_determinant();
+ if (det == 0)
{
- // Not invertible.
- //abort(); // castano: this happens sometimes! (ie.
sample6.swf)
-
- // Arbitrary fallback.
+ // cann't invert this matrix, set it to identity.
+ // this might happen when xscale == yscale == 0
set_identity();
- tx = -m.tx;
- ty = -m.ty;
}
else
{
- float inv_det = 1.0f / det;
- sx = m.sy * inv_det;
- sy = m.sx * inv_det;
- shy = -m.shy * inv_det;
- shx = -m.shx * inv_det;
+ 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);
- tx = -( sx / 65536.0f * m.tx + shy / 65536.0f * m.ty);
- ty = -(shx / 65536.0f * m.tx + sy / 65536.0f * m.ty);
+ tx = -( Fixed16Mul(sx, m.tx) + Fixed16Mul(shy, m.ty) );
+ ty = -( Fixed16Mul(shx, m.tx) + Fixed16Mul(sy, m.ty) );
}
}
@@ -324,54 +314,35 @@
matrix::does_flip() const
// Return true if this matrix reverses handedness.
{
- float det = (float)sx * sy - (float)shx * shy;
-
- return det < 0.0f;
+ return ((boost::int64_t)sx * sy) < ((boost::int64_t)shx * shy);
}
-float
+boost::int64_t
matrix::get_determinant() const
-// Return the determinant of the 2x2 rotation/scale part only.
+// Return the 32.32 fixed point determinant of this matrix.
{
- return ((float)sx * sy - (float)shx * shy) / (65536.0 * 65536.0);
+ return (boost::int64_t)sx * sy - (boost::int64_t)shx * shy;
}
float
matrix::get_x_scale() const
{
- // Scale is applied before rotation, must match implementation
- // in set_scale_rotation
- float scale = sqrtf(((float)sx * sx + (float)shx * shx)) / 65536.0f;
-
- // Are we turned inside out?
- if (get_determinant() < 0.f)
- {
- scale = -scale;
- }
-
- return scale;
+ return sqrtf(((float)sx * sx + (float)shx * shx)) / 65536.0f;
}
float
matrix::get_y_scale() const
{
- // Scale is applied before rotation, must match implementation
- // in set_scale_rotation
return sqrtf(((float)sy * sy + (float)shy * shy)) / 65536.0f;
}
float
matrix::get_rotation() const
{
- if (get_determinant() < 0.f)
+ if (get_determinant() < 0)
{
- // We're turned inside out; negate the
- // x-component used to compute rotation.
- //
- // Matches get_x_scale().
- //
- // @@ this may not be how Macromedia does it! Test this!
+ // TODO: check this.
return atan2f(shx, -sx);
}
else
@@ -385,22 +356,20 @@
// 8 digits and a decimal point.
const short fieldWidth = 9;
- o << std::endl << "| "
+ o << std::endl << "|"
<< std::setw(fieldWidth) << std::fixed << std::setprecision(4)
<< m.sx/65536.0 << " "
<< std::setw(fieldWidth) << std::fixed << std::setprecision(4)
<< m.shy/65536.0 << " "
<< std::setw(fieldWidth) << std::fixed << std::setprecision(4)
- << TWIPS_TO_PIXELS(m.tx)
- << " |"
- << std::endl << "| "
+ << TWIPS_TO_PIXELS(m.tx) << " |"
+ << std::endl << "|"
<< std::setw(fieldWidth) << std::fixed << std::setprecision(4)
<< m.shx/65536.0 << " "
<< std::setw(fieldWidth) << std::fixed << std::setprecision(4)
<< m.sy/65536.0 << " "
<< std::setw(fieldWidth) << std::fixed << std::setprecision(4)
- << TWIPS_TO_PIXELS(m.ty)
- << " |";
+ << TWIPS_TO_PIXELS(m.ty) << " |";
return o;
}
Index: server/matrix.h
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/matrix.h 5 Jun 2008 03:26:32 -0000 1.20
+++ server/matrix.h 6 Jun 2008 03:48:29 -0000 1.21
@@ -28,6 +28,7 @@
#include "Range2d.h" // for transforming Range2d<float>
#include "Point2d.h" // for transforming Point2d<float> (typedefe'd to point)
+#include <boost/cstdint.hpp>
#include <iosfwd>
#include <iomanip>
@@ -195,9 +196,6 @@
/// Return true if this matrix reverses handedness.
bool does_flip() const;
- /// Return the determinant of the 2x2 rotation/scale part only.
- float get_determinant() const;
-
/// return the magnitude scale of our x coord output
float get_x_scale() const;
@@ -218,6 +216,9 @@
{
return ty;
}
+
+ /// Return the determinant of this matrix in 32.32 fixed point format.
+ boost::int64_t get_determinant() const;
};
inline bool operator== (const matrix& a, const matrix& b)
Index: testsuite/misc-ming.all/DrawingApiTest.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/DrawingApiTest.as,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- testsuite/misc-ming.all/DrawingApiTest.as 7 May 2008 03:40:44 -0000
1.36
+++ testsuite/misc-ming.all/DrawingApiTest.as 6 Jun 2008 03:48:29 -0000
1.37
@@ -233,10 +233,14 @@
lineStyle(6, 0xFF8800);
beginFill(0x888800, 100);
moveTo(100, 100);
- lineTo("string", NaN); // equivalent to 0, 0
- curveTo(100, "string", Object, 100); // equivalent to 100, 0,
0, 100
- moteTo(undefined, 0); // equivalent to 0, 0
- lineTo(100, null);
+ //lineTo("string", NaN); // equivalent to 0, 0
+ lineTo(0, 0);
+ //curveTo(100, "string", Object, 100); // equivalent to 100, 0,
0, 100
+ curveTo(100, 0, 0 ,100);
+ //moteTo(undefined, 0); // equivalent to 0, 0
+ //moveTo(0,0); ???
+ //lineTo(100, null); // equivalent to 100, 0
+ lineTo(100, 0);
endFill();
}
x._x = 100;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/matrix.cpp server/matrix...,
Zou Lunkai <=