[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r9762: More tests for matrix to cach
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r9762: More tests for matrix to caches, fix computation of matrix caches |
Date: |
Wed, 17 Sep 2008 11:53:11 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9762
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Wed 2008-09-17 11:53:11 +0200
message:
More tests for matrix to caches, fix computation of matrix caches
in button instances, minor cleanup
modified:
libcore/button_character_instance.cpp
libcore/matrix.cpp
libcore/sprite_instance.cpp
testsuite/misc-ming.all/matrix_test.c
------------------------------------------------------------
revno: 9760.1.1
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Wed 2008-09-17 09:43:20 +0200
message:
Update cached matrix parameters of button records on instantiation
(doesn't fix any existing testcase, we should add one)
modified:
libcore/button_character_instance.cpp
------------------------------------------------------------
revno: 9760.1.2
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Wed 2008-09-17 10:27:34 +0200
message:
drop UNUSED macro for an actually used thing
modified:
libcore/sprite_instance.cpp
------------------------------------------------------------
revno: 9760.1.3
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Wed 2008-09-17 11:29:45 +0200
message:
Add more tests for matrix to caches, initial tests for hitTest over them
modified:
testsuite/misc-ming.all/matrix_test.c
------------------------------------------------------------
revno: 9760.1.4
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Wed 2008-09-17 11:30:49 +0200
message:
log an error when not inverting a matrix due to determinant==0
modified:
libcore/matrix.cpp
=== modified file 'libcore/button_character_instance.cpp'
--- a/libcore/button_character_instance.cpp 2008-09-16 19:00:59 +0000
+++ b/libcore/button_character_instance.cpp 2008-09-17 07:43:20 +0000
@@ -726,7 +726,7 @@
int ch_id = bdef.m_character_id;
character* ch =
bdef.m_character_def->create_character_instance(this, ch_id);
- ch->set_matrix(mat);
+ ch->set_matrix(mat, true); // update caches
ch->set_cxform(cx);
ch->set_depth(ch_depth);
assert(ch->get_parent() == this);
@@ -883,7 +883,7 @@
int ch_id = bdef.m_character_id;
character* ch =
bdef.m_character_def->create_character_instance(this, ch_id);
- ch->set_matrix(mat);
+ ch->set_matrix(mat, true); // update caches
ch->set_cxform(cx); // TODO: who cares about color ?
ch->set_depth(ch_depth); // TODO: check if we care about depth,
and why ...
assert(ch->get_parent() == this);
@@ -914,7 +914,7 @@
int ch_id = bdef.m_character_id;
character* ch =
bdef.m_character_def->create_character_instance(this, ch_id);
- ch->set_matrix(mat);
+ ch->set_matrix(mat, true); // update caches
ch->set_cxform(cx);
ch->set_depth(ch_depth);
assert(ch->get_parent() == this);
=== modified file 'libcore/matrix.cpp'
--- a/libcore/matrix.cpp 2008-09-17 09:30:25 +0000
+++ b/libcore/matrix.cpp 2008-09-17 09:53:11 +0000
@@ -271,6 +271,7 @@
boost::int64_t det = determinant();
if(det == 0)
{
+ log_error("Matrix not invertible, setting to identity on invert
request");
// TODO: check this.
set_identity();
}
=== modified file 'libcore/sprite_instance.cpp'
--- a/libcore/sprite_instance.cpp 2008-09-15 09:59:50 +0000
+++ b/libcore/sprite_instance.cpp 2008-09-17 08:27:34 +0000
@@ -832,7 +832,6 @@
static as_value sprite_hit_test(const fn_call& fn)
{
boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
- UNUSED(sprite);
switch (fn.nargs)
{
=== modified file 'testsuite/misc-ming.all/matrix_test.c'
--- a/testsuite/misc-ming.all/matrix_test.c 2008-09-03 11:42:35 +0000
+++ b/testsuite/misc-ming.all/matrix_test.c 2008-09-17 09:29:45 +0000
@@ -108,6 +108,25 @@
check_equals(mo, "staticmc._width", "60.1");
check_equals(mo, "staticmc._height", "60.1");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'19.95,269.95 80.05,330.05'");
+
+ // X: 19.95 .. 80.05
+ // Y: 269.95 .. 330.05
+
+ check(mo, "staticmc.hitTest(30, 300, true)"); // in hittable shape
+ xcheck(mo, "!staticmc.hitTest(20, 300, true)"); // rounding makes 20
be too on the left for a shape test
+ check(mo, "staticmc.hitTest(20, 300, false)"); // but is fine for a
boundary test
+
+ check(mo, "staticmc.hitTest(75, 300, true)"); // in hittable shape
+ xcheck(mo, "!staticmc.hitTest(80, 300, true)"); // rounding makes 80
be too on the right for a shape test
+ check(mo, "staticmc.hitTest(80, 300, false)"); // but is fine for a
boundary test
+
+ check(mo, "staticmc.hitTest(25, 330, true)"); // in hittable shape
+ check(mo, "staticmc.hitTest(75, 330, true)"); // in hittable shape
+
+ check(mo, "staticmc.hitTest(25, 270, true)"); // in hittable shape
+ check(mo, "staticmc.hitTest(75, 270, true)"); // in hittable shape
+
SWFMovie_nextFrame(mo);
SWFDisplayItem_rotateTo(it, -45);
@@ -136,6 +155,26 @@
check_equals(mo, "staticmc._width", "212.5");
check_equals(mo, "staticmc._height", "212.5");
+ check(mo, "staticmc.hitTest(-56, 194, false)"); // in boundaries
+ check(mo, "staticmc.hitTest(-56, 406, false)"); // in boundaries
+ check(mo, "staticmc.hitTest(156, 194, false)"); // in boundaries
+ check(mo, "staticmc.hitTest(156, 406, false)"); // in boundaries
+
+ // X: -56.25 156.25
+ // Y: 193.75 406.25
+ //check(mo, "staticmc.hitTest(0, 300, true)"); // in hittable shape
(why no hit?)
+ //check(mo, "staticmc.hitTest(0, 0, true)"); // in hittable shape (why
no hit?)
+
+ check(mo, "!staticmc.hitTest(-57, 194, true)");
+ check(mo, "!staticmc.hitTest(-57, 406, true)");
+ check(mo, "!staticmc.hitTest(157, 194, true)");
+ check(mo, "!staticmc.hitTest(157, 406, true)");
+ check(mo, "!staticmc.hitTest(-56, 193, true)");
+ check(mo, "!staticmc.hitTest(-56, 407, true)");
+ check(mo, "!staticmc.hitTest(156, 193, true)");
+ check(mo, "!staticmc.hitTest(156, 407, true)");
+
+
SWFMovie_nextFrame(mo);
SWFDisplayItem_skewXTo(it, 2);
@@ -259,6 +298,162 @@
check_equals(mo, "staticmc._width", "60.1");
check_equals(mo, "staticmc._height", "60.1");
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, -1, -45, 0, 1, 50, 300); // negative x
scale and some negative skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "Math.round(staticmc._xscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._yscale", "100");
+ check_equals(mo, "Math.round(staticmc._rotation)", "-91"); // let's
tollerate precision for now
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'19.95,-1082.3 80.05,1682.3'");
+ check_equals(mo, "staticmc._width", "60.1");
+ check_equals(mo, "staticmc._height", "2764.6");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, -1, 45, 0, 1, 50, 300); // negative x
scale and some positive skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "Math.round(staticmc._xscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._yscale", "100");
+ check_equals(mo, "Math.round(staticmc._rotation)", "91"); // let's
tollerate precision for now
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'19.95,-1082.3 80.05,1682.3'");
+ check_equals(mo, "staticmc._width", "60.1");
+ check_equals(mo, "staticmc._height", "2764.6");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, 1, -45, 0, -1, 50, 300); // negative x
scale and some negative skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "Math.round(staticmc._xscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._yscale", "100");
+ check_equals(mo, "Math.round(staticmc._rotation)", "-89"); // let's
tollerate precision for now
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'19.95,-1082.3 80.05,1682.3'");
+ check_equals(mo, "staticmc._width", "60.1");
+ check_equals(mo, "staticmc._height", "2764.6");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, 1, 45, 0, -1, 50, 300); // negative x
scale and some positive skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "Math.round(staticmc._xscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._yscale", "100");
+ check_equals(mo, "Math.round(staticmc._rotation)", "89"); // let's
tollerate precision for now
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'19.95,-1082.3 80.05,1682.3'");
+ check_equals(mo, "staticmc._width", "60.1");
+ check_equals(mo, "staticmc._height", "2764.6");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, -1, 45, 0, -1, 50, 300); // negative x
scale and some positive skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "Math.round(staticmc._xscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._yscale", "100");
+ check_equals(mo, "Math.round(staticmc._rotation)", "91"); // let's
tollerate precision for now
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'19.95,-1082.3 80.05,1682.3'");
+ check_equals(mo, "staticmc._width", "60.1");
+ check_equals(mo, "staticmc._height", "2764.6");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, -1, -45, 0, -1, 50, 300); // negative x
scale and some positive skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "Math.round(staticmc._xscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._yscale", "100");
+ check_equals(mo, "Math.round(staticmc._rotation)", "-91"); // let's
tollerate precision for now
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'19.95,-1082.3 80.05,1682.3'");
+ check_equals(mo, "staticmc._width", "60.1");
+ check_equals(mo, "staticmc._height", "2764.6");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, -1, 0, -45, 1, 50, 300); // negative x
scale and some negative skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "staticmc._xscale", "100");
+ check_equals(mo, "Math.round(staticmc._yscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._rotation", "180");
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'-1332.3,269.95 1432.3,330.05'");
+ check_equals(mo, "staticmc._width", "2764.6");
+ check_equals(mo, "staticmc._height", "60.1");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, -1, 0, 45, 1, 50, 300); // negative x
scale and some positive skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "staticmc._xscale", "100");
+ check_equals(mo, "Math.round(staticmc._yscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._rotation", "180");
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'-1332.3,269.95 1432.3,330.05'");
+ check_equals(mo, "staticmc._width", "2764.6");
+ check_equals(mo, "staticmc._height", "60.1");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, 1, 0, -45, -1, 50, 300); // negative x
scale and some negative skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "staticmc._xscale", "100");
+ check_equals(mo, "Math.round(staticmc._yscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._rotation", "0");
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'-1332.3,269.95 1432.3,330.05'");
+ check_equals(mo, "staticmc._width", "2764.6");
+ check_equals(mo, "staticmc._height", "60.1");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, 1, 0, 45, -1, 50, 300); // negative x
scale and some positive skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "staticmc._xscale", "100");
+ check_equals(mo, "Math.round(staticmc._yscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._rotation", "0");
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'-1332.3,269.95 1432.3,330.05'");
+ check_equals(mo, "staticmc._width", "2764.6");
+ check_equals(mo, "staticmc._height", "60.1");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, -1, 0, 45, -1, 50, 300); // negative x
scale and some positive skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "staticmc._xscale", "100");
+ check_equals(mo, "Math.round(staticmc._yscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._rotation", "180");
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'-1332.3,269.95 1432.3,330.05'");
+ check_equals(mo, "staticmc._width", "2764.6");
+ check_equals(mo, "staticmc._height", "60.1");
+
+ SWFMovie_nextFrame(mo);
+ SWFDisplayItem_setMatrix(it, -1, 0, -45, -1, 50, 300); // negative x
scale and some positive skew
+
+ check_equals(mo, "staticmc._x", "50");
+ check_equals(mo, "staticmc._y", "300");
+ check_equals(mo, "staticmc._xscale", "100");
+ check_equals(mo, "Math.round(staticmc._yscale)", "4501"); // let's
tollerate precision for now
+ check_equals(mo, "staticmc._rotation", "180");
+ check_equals(mo, "printBounds(staticmc.getBounds())", "'-30.05,-30.05
30.05,30.05'");
+ check_equals(mo, "printBounds(staticmc.getBounds(_root))",
"'-1332.3,269.95 1432.3,330.05'");
+ check_equals(mo, "staticmc._width", "2764.6");
+ check_equals(mo, "staticmc._height", "60.1");
+
// TODO:
// - test more rotations and scales (corner cases too!)
@@ -266,7 +461,7 @@
SWFMovie_nextFrame(mo);
- add_actions(mo, "_root.totals(107); stop();");
+ add_actions(mo, "_root.totals(238); stop();");
SWFMovie_nextFrame(mo);
//Output movie
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r9762: More tests for matrix to caches, fix computation of matrix caches,
Sandro Santilli <=