[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10542: New tests and fix for hitTes
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10542: New tests and fix for hitTest. |
Date: |
Wed, 14 Jan 2009 12:27:58 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10542
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2009-01-14 12:27:58 +0100
message:
New tests and fix for hitTest.
added:
testsuite/actionscript.all/HitTest.as
modified:
libcore/character.cpp
libcore/character.h
testsuite/actionscript.all/Makefile.am
------------------------------------------------------------
revno: 10541.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-01-14 08:35:42 +0100
message:
New HitTest test in actionscript.all.
modified:
testsuite/actionscript.all/Makefile.am
------------------------------------------------------------
revno: 10541.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-01-14 09:50:47 +0100
message:
Ignore _root transform for getWorldMatrix when doing pointInBounds test.
Do this by supplying an extra argument to getWorldMatrix (default true)
for
whether to concatenate the Stage transform.
Add new HitTest tests. Gnash now passes most, and bowman.swf works
(bug #21588 fixed).
modified:
libcore/character.cpp
libcore/character.h
------------------------------------------------------------
revno: 10541.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Wed 2009-01-14 10:27:41 +0100
message:
Add the HitTests test.
added:
testsuite/actionscript.all/HitTest.as
=== modified file 'libcore/character.cpp'
--- a/libcore/character.cpp 2008-12-28 09:40:28 +0000
+++ b/libcore/character.cpp 2009-01-14 08:50:47 +0000
@@ -104,14 +104,14 @@
SWFMatrix
-character::getWorldMatrix() const
+character::getWorldMatrix(bool includeRoot) const
{
SWFMatrix m;
- if (m_parent != NULL)
+ if (m_parent)
{
- m = m_parent->getWorldMatrix();
+ m = m_parent->getWorldMatrix(includeRoot);
}
- m.concatenate(getMatrix());
+ if (m_parent || includeRoot) m.concatenate(getMatrix());
return m;
}
=== modified file 'libcore/character.h'
--- a/libcore/character.h 2008-12-17 07:27:15 +0000
+++ b/libcore/character.h 2009-01-14 08:50:47 +0000
@@ -363,7 +363,11 @@
///
/// Maps from our local space into "world" space
/// (i.e. root movie space).
- virtual SWFMatrix getWorldMatrix() const;
+ //
+ /// @param includeRoot Whether the transform of the Stage (_root)
+ /// should be concatenated. This is required to be
+ /// false for pointInBounds.
+ SWFMatrix getWorldMatrix(bool includeRoot = true) const;
/// \brief
/// Get our concatenated color transform (all our ancestor transforms,
@@ -443,12 +447,14 @@
/// Return true if the given point falls in this character's bounds
//
- /// Point coordinates are in world TWIPS
- ///
+ /// @param x Point x coordinate in world space
+ /// @param y Point y coordinate in world space
+ /// @return Whether (x, y) is within the character's bounds. This
+ /// ignores _root's transform.
bool pointInBounds(boost::int32_t x, boost::int32_t y) const
{
rect bounds = getBounds();
- SWFMatrix wm = getWorldMatrix();
+ SWFMatrix wm = getWorldMatrix(false);
wm.transform(bounds);
return bounds.point_test(x, y);
}
=== added file 'testsuite/actionscript.all/HitTest.as'
--- a/testsuite/actionscript.all/HitTest.as 1970-01-01 00:00:00 +0000
+++ b/testsuite/actionscript.all/HitTest.as 2009-01-14 09:27:41 +0000
@@ -0,0 +1,167 @@
+//
+// Copyright (C) 2008 Free Software Foundation, Inc.
+//
+// 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 3 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+
+// This counts calls to toString() and valueOf() regularly to check that native
+// methods are correctly applied. So it saves much effort if new tests are
added
+// after the end of the present ones.
+
+rcsid="$Id: HitTest.as,v 1.8 2008/04/29 10:23:50 bwy Exp $";
+
+#include "check.as"
+
+#if OUTPUT_VERSION > 5
+
+ createEmptyMovieClip("a", 5);
+ a.beginFill(0xff00ff);
+ a.moveTo(20, 20);
+ a.lineTo(20, 60);
+ a.lineTo(60, 60);
+ a.lineTo(60, 20);
+ a.lineTo(20, 20);
+
+ check_equals(a.hitTest(19, 19, false), false);
+ check_equals(a.hitTest(20, 20, false), true);
+ check_equals(a.hitTest(21, 21, false), true);
+ check_equals(a.hitTest(25, 25, false), true);
+ check_equals(a.hitTest(60, 60, false), true);
+ check_equals(a.hitTest(61, 61, false), false);
+
+ check_equals(a.hitTest(19, 19, true), false);
+#if OUTPUT_VERSION < 8
+ check_equals(a.hitTest(20, 20, true), true);
+#else
+ xcheck_equals(a.hitTest(20, 20, true), false);
+#endif
+ check_equals(a.hitTest(21, 21, true), true);
+ check_equals(a.hitTest(25, 25, true), true);
+ check_equals(a.hitTest(60, 60, true), false);
+ check_equals(a.hitTest(61, 61, true), false);
+
+ _x = 30;
+ check_equals(a.hitTest(25, 25, false), true);
+ check_equals(a.hitTest(85, 25, false), false);
+ xcheck_equals(a.hitTest(25, 25, true), true);
+ xcheck_equals(a.hitTest(85, 25, true), false);
+ _x = 0;
+
+ backup = _width;
+
+ _width = 50;
+ check_equals(a.hitTest(25, 25, false), true);
+ check_equals(a.hitTest(41, 25, false), true);
+ check_equals(a.hitTest(25, 25, true), false);
+ check_equals(a.hitTest(41, 25, true), false);
+ _width = backup;
+
+ _xscale = 50;
+ check_equals(a.hitTest(25, 25, false), true);
+ check_equals(a.hitTest(41, 25, false), true);
+ xcheck_equals(a.hitTest(25, 25, true), false);
+#if OUTPUT_VERSION < 8
+ xcheck_equals(a.hitTest(41, 25, true), true);
+#else
+ check_equals(a.hitTest(41, 25, true), false);
+#endif
+ _xscale = 100;
+
+ b = a.createEmptyMovieClip("b", 10);
+ b.beginFill(0x0000ff);
+ b.moveTo(100, 100);
+ b.lineTo(150, 100);
+ b.lineTo(150, 150);
+ b.lineTo(100, 150);
+ b.lineTo(100, 100);
+
+ check_equals(b.hitTest(99, 99, false), false);
+ check_equals(b.hitTest(100, 100, false), true);
+ check_equals(b.hitTest(101, 101, false), true);
+ check_equals(b.hitTest(120, 120, false), true);
+ check_equals(b.hitTest(110, 110, false), true);
+ check_equals(b.hitTest(151, 150, false), false);
+ check_equals(b.hitTest(151, 151, false), false);
+ check_equals(b.hitTest(151, 152, false), false);
+
+ check_equals(b.hitTest(99, 99, true), false);
+ xcheck_equals(b.hitTest(100, 100, true), false);
+ check_equals(b.hitTest(101, 101, true), true);
+ check_equals(b.hitTest(120, 120, true), true);
+ check_equals(b.hitTest(110, 110, true), true);
+ check_equals(b.hitTest(151, 150, true), false);
+ check_equals(b.hitTest(151, 151, true), false);
+ check_equals(b.hitTest(151, 152, true), false);
+
+ /// Altering a's properties changes the hitTest for b.
+ a._y = 100;
+
+ /// Test where it was before
+ check_equals(b.hitTest(99, 99, false), false);
+ check_equals(b.hitTest(100, 100, false), false);
+ check_equals(b.hitTest(101, 101, false), false);
+ check_equals(b.hitTest(120, 120, false), false);
+ check_equals(b.hitTest(110, 110, false), false);
+ check_equals(b.hitTest(151, 150, false), false);
+
+ check_equals(b.hitTest(99, 99, true), false);
+ check_equals(b.hitTest(100, 100, true), false);
+ check_equals(b.hitTest(101, 101, true), false);
+ check_equals(b.hitTest(120, 120, true), false);
+ check_equals(b.hitTest(110, 110, true), false);
+ check_equals(b.hitTest(151, 150, true), false);
+
+ /// Test new position
+ check_equals(b.hitTest(99, 199, false), false);
+ check_equals(b.hitTest(100, 200, false), true);
+ check_equals(b.hitTest(101, 201, false), true);
+ check_equals(b.hitTest(120, 220, false), true);
+ check_equals(b.hitTest(110, 210, false), true);
+ check_equals(b.hitTest(151, 250, false), false);
+ check_equals(b.hitTest(151, 251, false), false);
+ check_equals(b.hitTest(151, 252, false), false);
+
+ /// (Where is it?!)
+ check_equals(b.hitTest(99, 199, true), false);
+ xcheck_equals(b.hitTest(100, 200, true), false);
+ xcheck_equals(b.hitTest(101, 201, true), false);
+ xcheck_equals(b.hitTest(120, 220, true), false);
+ xcheck_equals(b.hitTest(110, 210, true), false);
+ check_equals(b.hitTest(151, 250, true), false);
+ check_equals(b.hitTest(151, 251, true), false);
+ check_equals(b.hitTest(151, 252, true), false);
+
+ /// Changing _root's matrix does nothing.
+ _y = -100;
+ _xscale = 0.5;
+
+ check_equals(b.hitTest(99, 99, false), false);
+ check_equals(b.hitTest(100, 100, false), false);
+ check_equals(b.hitTest(101, 101, false), false);
+ check_equals(b.hitTest(120, 120, false), false);
+ check_equals(b.hitTest(110, 110, false), false);
+ check_equals(b.hitTest(151, 150, false), false);
+
+ check_equals(b.hitTest(99, 199, false), false);
+ check_equals(b.hitTest(100, 200, false), true);
+ check_equals(b.hitTest(101, 201, false), true);
+ check_equals(b.hitTest(120, 220, false), true);
+ check_equals(b.hitTest(110, 210, false), true);
+ xcheck_equals(b.hitTest(151, 250, false), true);
+ check_equals(b.hitTest(151, 251, false), false);
+ check_equals(b.hitTest(151, 252, false), false);
+
+totals(82);
+
+#endif
=== modified file 'testsuite/actionscript.all/Makefile.am'
--- a/testsuite/actionscript.all/Makefile.am 2008-12-16 20:14:16 +0000
+++ b/testsuite/actionscript.all/Makefile.am 2009-01-14 07:35:42 +0000
@@ -91,6 +91,7 @@
ExternalInterface.as \
Function.as \
Global.as \
+ HitTest.as \
Inheritance.as \
Instance.as \
Key.as \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10542: New tests and fix for hitTest.,
Benjamin Wolsey <=