[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libgeometry/snappingrange.h tes...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libgeometry/snappingrange.h tes... |
Date: |
Mon, 23 Apr 2007 10:19:48 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/04/23 10:19:48
Modified files:
. : ChangeLog
libgeometry : snappingrange.h
testsuite : MovieTester.cpp MovieTester.h
testsuite/libgeometry: snappingrangetest.cpp
testsuite/misc-ming.all: simple_loop_testrunner.cpp
Log message:
* libgeometry/snappingrange.h: add unconditional visitor; add
cast operator; add contains(Range2d); add scale(factor).
* testsuite/MovieTester.{cpp,h}: add a getInvalidatedRanges
function;
drop getInvalidatedBounds one.
* testsuite/libgeometry/snappingrangetest.cpp: test
contains(Range)
and cast to int.
* testsuite/misc-ming.all/simple_loop_testrunner.cpp: update
to use the new getInvalidatedRanges.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2965&r2=1.2966
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/snappingrange.h?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.h?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libgeometry/snappingrangetest.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/simple_loop_testrunner.cpp?cvsroot=gnash&r1=1.5&r2=1.6
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2965
retrieving revision 1.2966
diff -u -b -r1.2965 -r1.2966
--- ChangeLog 23 Apr 2007 09:29:53 -0000 1.2965
+++ ChangeLog 23 Apr 2007 10:19:47 -0000 1.2966
@@ -1,5 +1,16 @@
2007-04-23 Sandro Santilli <address@hidden>
+ * libgeometry/snappingrange.h: add unconditional visitor; add
+ cast operator; add contains(Range2d); add scale(factor).
+ * testsuite/MovieTester.{cpp,h}: add a getInvalidatedRanges function;
+ drop getInvalidatedBounds one.
+ * testsuite/libgeometry/snappingrangetest.cpp: test contains(Range)
+ and cast to int.
+ * testsuite/misc-ming.all/simple_loop_testrunner.cpp: update
+ to use the new getInvalidatedRanges.
+
+2007-04-23 Sandro Santilli <address@hidden>
+
* libgeometry/snappingrange.h: define the SnappingRanges2d<> in
the gnash::geometry namespace. Keep InvalidatedBounds in the
gnash namespace, for simplicity.
Index: libgeometry/snappingrange.h
===================================================================
RCS file: /sources/gnash/gnash/libgeometry/snappingrange.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- libgeometry/snappingrange.h 23 Apr 2007 09:29:53 -0000 1.16
+++ libgeometry/snappingrange.h 23 Apr 2007 10:19:47 -0000 1.17
@@ -15,7 +15,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: snappingrange.h,v 1.16 2007/04/23 09:29:53 strk Exp $
+// $Id: snappingrange.h,v 1.17 2007/04/23 10:19:47 strk Exp $
#ifndef GNASH_SNAPPINGRANGE_H
#define GNASH_SNAPPINGRANGE_H
@@ -90,6 +90,26 @@
{
}
+ /// Templated copy constructor, for casting between range types
+ template <typename U>
+ SnappingRanges2d(const SnappingRanges2d<U>& from)
+ {
+ if ( from.isWorld() ) {
+ setWorld();
+ } else if ( from.isNull() ) {
+ setNull();
+ } else {
+ // TODO: use visitor pattern !
+ unsigned rcount = from.size();
+ for (unsigned int rno=0; rno<rcount; rno++)
+ {
+ Range2d<U> r = from.getRange(rno);
+ RangeType rc(r);
+ add(rc);
+ }
+ }
+ }
+
/// Add a Range to the set, merging when possible and appropriate
void add(const RangeType& range) {
if (range.isWorld()) {
@@ -149,6 +169,20 @@
combine_ranges_lazy();
}
+ /// Scale all ranges by the specified factor
+ void scale(float factor) {
+
+ if (isWorld() || isNull())
+ return;
+
+ unsigned rcount = _ranges.size();
+
+ for (unsigned int rno=0; rno<rcount; rno++)
+ _ranges[rno].scale(factor);
+
+ combine_ranges_lazy();
+ }
+
/// Combines known ranges. Previously merged ranges may have come close
/// to other ranges. Algorithm could be optimized.
void combine_ranges() {
@@ -264,22 +298,14 @@
}
/// Returns the range at the specified index
+ //
+ /// TODO: return by reference ?
+ ///
RangeType getRange(unsigned int index) const {
finalize();
assert(index<size());
return _ranges[index];
-
- /*
- RangeList::iterator iter = _ranges.begin();
-
- while (index>0) {
- index--;
- iter++;
- }
-
- return *iter;
- */
}
/// Return a range that surrounds *all* added ranges. This is used
mainly
@@ -311,6 +337,19 @@
}
+ /// Returns true if any of the ranges contains the range
+ bool contains(RangeType r) const {
+
+ finalize();
+
+ for (unsigned rno=0, rcount=_ranges.size(); rno<rcount; rno++)
+ if (_ranges[rno].contains(r))
+ return true;
+
+ return false;
+
+ }
+
/// Visit the current Ranges set
//
@@ -336,6 +375,25 @@
}
}
+ /// Visit the current Ranges set
+ //
+ /// Visitor functor will be invoked inconditionally
+ /// for each RangeType in the current set.
+ ///
+ /// The visitor functor will receive a RangeType reference.
+ ///
+ template <class V>
+ inline void visitAll(V& visitor) const
+ {
+ for (typename RangeList::const_iterator
+ it = _ranges.begin(), itEnd = _ranges.end();
+ it != itEnd;
+ ++it)
+ {
+ visitor(*it);
+ }
+ }
+
private:
inline T absmin(T a, T b) {
Index: testsuite/MovieTester.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- testsuite/MovieTester.cpp 20 Apr 2007 16:42:43 -0000 1.29
+++ testsuite/MovieTester.cpp 23 Apr 2007 10:19:47 -0000 1.30
@@ -309,28 +309,20 @@
return _movie_root->isMouseOverActiveEntity();
}
-geometry::Range2d<int>
-MovieTester::getInvalidatedBounds() const
+geometry::SnappingRanges2d<int>
+MovieTester::getInvalidatedRanges() const
{
using namespace gnash::geometry;
- rect ret;
- assert(ret.is_null());
-
- // TODO: Support multiple bounds in testsuite
- ////_movie_root->get_invalidated_bounds(&ret, false);
- //InvalidatedRanges ranges;
- //_movie_root->add_invalidated_bounds(ranges, false);
-
- Range2d<float> range = _invalidatedBounds.getFullArea();
+ SnappingRanges2d<float> ranges = _invalidatedBounds;
// scale by 1/20 (twips to pixels)
- range.scale(1.0/20);
+ ranges.scale(1.0/20);
// Convert to integer range.
- Range2d<int> pixrange(range);
+ SnappingRanges2d<int> pixranges(ranges);
- return pixrange;
+ return pixranges;
}
Index: testsuite/MovieTester.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- testsuite/MovieTester.h 20 Apr 2007 16:42:43 -0000 1.17
+++ testsuite/MovieTester.h 23 Apr 2007 10:19:47 -0000 1.18
@@ -105,11 +105,11 @@
/// Advance the movie by one frame
void advance();
- /// Return the invalidated bounds in PIXELS
+ /// Return the invalidated ranges in PIXELS
//
/// This is to debug/test partial rendering
///
- geometry::Range2d<int> getInvalidatedBounds() const;
+ geometry::SnappingRanges2d<int> getInvalidatedRanges() const;
/// Find a character in the display list of a sprite by name.
//
Index: testsuite/libgeometry/snappingrangetest.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libgeometry/snappingrangetest.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- testsuite/libgeometry/snappingrangetest.cpp 2 Mar 2007 15:31:47 -0000
1.2
+++ testsuite/libgeometry/snappingrangetest.cpp 23 Apr 2007 10:19:47 -0000
1.3
@@ -151,6 +151,13 @@
check( ! irrSnap.contains( 15, 495) );
check( ! irrSnap.contains(495, 495) );
+ check( irrSnap.contains(horiz) );
+ check( irrSnap.contains(vert) );
+
+ SnappingRanges2d<int> irrIntSnap(irrSnap);
+ check( irrSnap.contains(Range2d<int>(horiz)) );
+ check( irrSnap.contains(Range2d<int>(vert)) );
+
}
Index: testsuite/misc-ming.all/simple_loop_testrunner.cpp
===================================================================
RCS file:
/sources/gnash/gnash/testsuite/misc-ming.all/simple_loop_testrunner.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- testsuite/misc-ming.all/simple_loop_testrunner.cpp 23 Apr 2007 08:53:47
-0000 1.5
+++ testsuite/misc-ming.all/simple_loop_testrunner.cpp 23 Apr 2007 10:19:47
-0000 1.6
@@ -38,6 +38,7 @@
int
main(int /*argc*/, char** /*argv*/)
{
+ typedef gnash::geometry::SnappingRanges2d<int> Ranges;
typedef gnash::geometry::Range2d<int> Bounds;
string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
@@ -46,7 +47,7 @@
gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
dbglogfile.setVerbosity(1);
- Bounds invalidated;
+ Ranges invalidated;
sprite_instance* root = tester.getRootMovie();
assert(root);
@@ -56,7 +57,7 @@
check_equals(root->get_play_state(), sprite_instance::PLAY);
check_equals(root->get_current_frame(), 0);
check_equals(root->getDisplayList().size(), 0); // no chars
- invalidated = tester.getInvalidatedBounds();
+ invalidated = tester.getInvalidatedRanges();
check( invalidated.isNull() );
tester.advance(); // FRAME 2/4
@@ -65,7 +66,7 @@
check_equals(root->get_current_frame(), 1);
check_equals(root->getDisplayList().size(), 1);
check( tester.findDisplayItemByDepth(*root,
2+character::staticDepthOffset) );
- invalidated = tester.getInvalidatedBounds();
+ invalidated = tester.getInvalidatedRanges();
check( invalidated.contains(Bounds(0, 0, 60, 60)) );
tester.advance(); // FRAME 3/4
@@ -75,7 +76,7 @@
check_equals(root->getDisplayList().size(), 2);
check( tester.findDisplayItemByDepth(*root,
2+character::staticDepthOffset) );
check( tester.findDisplayItemByDepth(*root,
3+character::staticDepthOffset) );
- invalidated = tester.getInvalidatedBounds();
+ invalidated = tester.getInvalidatedRanges();
check( invalidated.contains(Bounds(60, 0, 120, 60)) );
tester.advance(); // FRAME 4/4
@@ -86,7 +87,7 @@
check( tester.findDisplayItemByDepth(*root,
2+character::staticDepthOffset) );
check( tester.findDisplayItemByDepth(*root,
3+character::staticDepthOffset) );
check( tester.findDisplayItemByDepth(*root,
4+character::staticDepthOffset) );
- invalidated = tester.getInvalidatedBounds();
+ invalidated = tester.getInvalidatedRanges();
check( invalidated.contains(Bounds(120, 0, 180, 60)) );
tester.advance(); // FRAME 1/4 (loop back)
@@ -94,7 +95,7 @@
check_equals(root->get_play_state(), sprite_instance::PLAY);
check_equals(root->get_current_frame(), 0);
check_equals(root->getDisplayList().size(), 0);
- invalidated = tester.getInvalidatedBounds();
+ invalidated = tester.getInvalidatedRanges();
check( invalidated.contains(Bounds(0, 0, 180, 60)) );
tester.advance(); // FRAME 2/4
@@ -103,7 +104,7 @@
check_equals(root->get_current_frame(), 1);
check_equals(root->getDisplayList().size(), 1);
check( tester.findDisplayItemByDepth(*root,
2+character::staticDepthOffset) );
- invalidated = tester.getInvalidatedBounds();
+ invalidated = tester.getInvalidatedRanges();
check( invalidated.contains(Bounds(0, 0, 60, 60)) );
tester.advance(); // FRAME 3/4
@@ -113,7 +114,7 @@
check_equals(root->getDisplayList().size(), 2);
check( tester.findDisplayItemByDepth(*root,
2+character::staticDepthOffset) );
check( tester.findDisplayItemByDepth(*root,
3+character::staticDepthOffset) );
- invalidated = tester.getInvalidatedBounds();
+ invalidated = tester.getInvalidatedRanges();
check( invalidated.contains(Bounds(60, 0, 120, 60)) );
tester.advance(); // FRAME 4/4
@@ -124,7 +125,7 @@
check( tester.findDisplayItemByDepth(*root,
2+character::staticDepthOffset) );
check( tester.findDisplayItemByDepth(*root,
3+character::staticDepthOffset) );
check( tester.findDisplayItemByDepth(*root,
4+character::staticDepthOffset) );
- invalidated = tester.getInvalidatedBounds();
+ invalidated = tester.getInvalidatedRanges();
check( invalidated.contains(Bounds(120, 0, 180, 60)) );
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libgeometry/snappingrange.h tes...,
Sandro Santilli <=