[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog gui/gui.cpp libgeometry/Range2d...
From: |
Udo Giacomozzi |
Subject: |
[Gnash-commit] gnash ChangeLog gui/gui.cpp libgeometry/Range2d... |
Date: |
Tue, 06 Nov 2007 15:43:41 +0000 |
CVSROOT: /cvsroot/gnash
Module name: gnash
Changes by: Udo Giacomozzi <udog> 07/11/06 15:43:41
Modified files:
. : ChangeLog
gui : gui.cpp
libgeometry : Range2d.h snappingrange.h
Log message:
* libgeometry/snappingrange.h: replace the distance method with a
more efficient area before/after comparison method; make
snap_factor and single_mode private members and provide access
methods
* libgeometry/Range2d.h: new getArea() function
* gui/gui.cpp, server/character.cpp: apply snappingrange changes
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4782&r2=1.4783
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.113&r2=1.114
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/Range2d.h?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/snappingrange.h?cvsroot=gnash&r1=1.26&r2=1.27
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnash/gnash/ChangeLog,v
retrieving revision 1.4782
retrieving revision 1.4783
diff -u -b -r1.4782 -r1.4783
--- ChangeLog 6 Nov 2007 15:25:09 -0000 1.4782
+++ ChangeLog 6 Nov 2007 15:43:40 -0000 1.4783
@@ -1,3 +1,12 @@
+2007-11-06 Udo Giacomozzi <address@hidden>
+
+ * libgeometry/snappingrange.h: replace the distance method with a
+ more efficient area before/after comparison method; make
+ snap_factor and single_mode private members and provide access
+ methods
+ * libgeometry/Range2d.h: new getArea() function
+ * gui/gui.cpp, server/character.cpp: apply snappingrange changes
+
2007-11-06 Sandro Santilli <address@hidden>
* testsuite/misc-ming.all/DrawingApiTest.as: add self-contained test
Index: gui/gui.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -b -r1.113 -r1.114
--- gui/gui.cpp 2 Nov 2007 18:25:34 -0000 1.113
+++ gui/gui.cpp 6 Nov 2007 15:43:41 -0000 1.114
@@ -61,7 +61,7 @@
/// debug the GUI part, however (see if blitting the region works), then you
/// probably won't define this.
#ifdef ENABLE_REGION_UPDATES_DEBUGGING
-#define REGION_UPDATES_DEBUGGING_FULL_REDRAW 1
+//#define REGION_UPDATES_DEBUGGING_FULL_REDRAW 1
#endif
#ifdef ENABLE_REGION_UPDATES_DEBUGGING
@@ -525,15 +525,12 @@
//
if (!redraw_flag) {
- // Choose distance (note these are TWIPS!)
- // 10% of normalized stage size
- changed_ranges.snap_distance = sqrt(
- m->get_movie_definition()->get_width_pixels() * 20.0 *
- m->get_movie_definition()->get_height_pixels() * 20.0)
* 0.10;
+ // choose snapping ranges factor
+ changed_ranges.setSnapFactor(1.3f);
// Use multi ranges only when GUI/Renderer supports it
// (Useless CPU overhead, otherwise)
- changed_ranges.single_mode = !want_multiple_regions();
+ changed_ranges.setSingleMode(!want_multiple_regions());
// scan through all sprites to compute invalidated bounds
m->add_invalidated_bounds(changed_ranges, false);
Index: libgeometry/Range2d.h
===================================================================
RCS file: /cvsroot/gnash/gnash/libgeometry/Range2d.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- libgeometry/Range2d.h 1 Jul 2007 10:54:11 -0000 1.17
+++ libgeometry/Range2d.h 6 Nov 2007 15:43:41 -0000 1.18
@@ -20,7 +20,7 @@
//
-/* $Id: Range2d.h,v 1.17 2007/07/01 10:54:11 bjacques Exp $ */
+/* $Id: Range2d.h,v 1.18 2007/11/06 15:43:41 udog Exp $ */
#ifndef GNASH_RANGE2D_H
#define GNASH_RANGE2D_H
@@ -653,6 +653,18 @@
return _ymax;
}
+
+ /// Get area (width*height)
+ ///
+ T getArea() const
+ {
+ assert ( !isWorld() );
+ if ( isNull() ) return 0;
+ return (_xmax - _xmin) * (_ymax - _ymin);
+ // this implementation is for float types, see specialization below
+ // for ints...
+ }
+
/// Expand this range to include the given Range2d
//
/// WORLD ranges force result to be the WORLD range.
@@ -814,6 +826,29 @@
return static_cast<unsigned int>(ceil((float)max));
}
+/// Specialization of area value for int type.
+//
+/// Add one.
+///
+template <> inline int
+Range2d<int>::getArea() const
+{
+ assert ( !isWorld() );
+ if ( isNull() ) return 0;
+ return (_xmax - _xmin + 1) * (_ymax - _ymin + 1);
+}
+
+/// Specialization of area value for unsigned int type.
+//
+/// Add one.
+///
+template <> inline unsigned int
+Range2d<unsigned int>::getArea() const
+{
+ assert ( isFinite() );
+ return (_xmax - _xmin + 1) * (_ymax - _ymin + 1);
+}
+
} // namespace gnash::geometry
} // namespace gnash
Index: libgeometry/snappingrange.h
===================================================================
RCS file: /cvsroot/gnash/gnash/libgeometry/snappingrange.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- libgeometry/snappingrange.h 24 Oct 2007 12:16:39 -0000 1.26
+++ libgeometry/snappingrange.h 6 Nov 2007 15:43:41 -0000 1.27
@@ -16,7 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: snappingrange.h,v 1.26 2007/10/24 12:16:39 udog Exp $
+// $Id: snappingrange.h,v 1.27 2007/11/06 15:43:41 udog Exp $
#ifndef GNASH_SNAPPINGRANGE_H
#define GNASH_SNAPPINGRANGE_H
@@ -39,14 +39,19 @@
/// bounds calculation.
//
/// Additionally to merge intersecting ranges this class also "snaps" ranges
-/// together which are very close to each other. The "snap_distance" property
-/// (which *must* be initialized before using the class!) decides below what
-/// distance ranges are being snapped. The "distance" is /not/ the closest
-/// distance between two edges. Instead, it's the sum of the X and Y minimum
-/// distance between any edge. It's similar to the distance between the two
-/// nearest /edges/, but it's not the same.
-/// This has the advantage that very irregular ranges (a tight vertical one
-/// and a wide horizontal one) are not combined:
+/// together which "probably" would be rendered in one single step. When the
+/// area of the potential merged range is not much greater than the sum of
+/// two single range areas, then these two ranges are merged together to one
+/// single range. The "snap factor" defines how much bigger the merged area
+/// can become to be a snap candidate (it's the maximum allowed factor that
+/// the merged area can be greater than the sum).
+///
+/// Optimally the factor 1.0 would be best, but multiple snapping ranges also
+/// increase rendering preprocessing overhead and the factor tries to equalize
+/// this. The default value is usually fine for most situations.
+///
+/// The factor method makes sure that very close, but also very different
+/// shapes, don't get merged, like in the following example:
///
/// +---+
/// | |
@@ -59,10 +64,11 @@
/// | |
/// +-----------------------------------+
///
-/// The above example shows that the combination of the two ranges would
-/// cover a much bigger area. It's better to keep two distinct ranges even
-/// if they nearly touch each other.
+/// Merging these two ranges would create a much bigger range which in some
+/// situations means that rendering is notably slower (for example, when
+/// there is a scaled bitmap behind these shapes).
///
+
template <typename T>
class SnappingRanges2d
{
@@ -74,16 +80,9 @@
template <typename U>
friend std::ostream& operator<< (std::ostream& os, const
SnappingRanges2d<U>& r);
- /// distance (horizontally *plus* vertically) below ranges are snapped
- /// You should initialize this when single_mode=false!
- T snap_distance;
-
- /// if set, only a single, outer range is maintained (extended).
- bool single_mode;
-
SnappingRanges2d()
:
- snap_distance(0),
+ snap_factor(1.3f),
single_mode(false),
_combine_counter(0)
{
@@ -93,7 +92,7 @@
template <typename U>
SnappingRanges2d(const SnappingRanges2d<U>& from)
:
- snap_distance(T(from.snap_distance)), // does it make sense ?
+ snap_factor(T(from.snap_factor)), // does it make sense ?
single_mode(from.single_mode),
_combine_counter(0)
{
@@ -117,10 +116,22 @@
}
}
+ /// Sets the snapping factor (which must be > 1.0). Higher factors make
+ /// the ranges more attractive for snapping. A good value is usually 1.3.
+ void setSnapFactor(float factor) {
+ assert(factor > 1.0f);
+ snap_factor = factor;
+ }
+
+ /// if mode==true, then the snapping ranges will act like a normal Range2d
+ void setSingleMode(bool mode) {
+ single_mode = mode;
+ }
+
/// Copy the snapping settings from another ranges list, without
/// copying the ranges itself
void inheritConfig(const SnappingRanges2d<T>& from) {
- snap_distance = from.snap_distance;
+ snap_factor = from.snap_factor;
single_mode = from.single_mode;
}
@@ -253,10 +264,14 @@
inline bool snaptest(const RangeType& range1, const RangeType& range2) {
// when they intersect anyway, they should of course be merged!
+ // TODO: not really, a "+" style ranges list might be worth to
+ // remain unmerged (but needs special handling, i.e. create three
+ // ranges out of two)...
if (range1.intersects(range2))
return true;
// simply search for the minimum x or y distances
+ /*
T xdist = 99999999;
T ydist = 99999999;
@@ -280,6 +295,12 @@
ydist = absmin(ydist, yb1-yb2);
return (xdist + ydist) <= snap_distance;
+ */
+
+ RangeType temp = range1;
+ temp.expandTo(range2);
+
+ return (range1.getArea() + range2.getArea()) * snap_factor >
temp.getArea();
}
@@ -562,6 +583,12 @@
// The current Ranges list
RangeList _ranges;
+ /// snapping factor - see setSnapFactor()
+ float snap_factor;
+
+ /// if set, only a single, outer range is maintained (extended).
+ bool single_mode;
+
unsigned int _combine_counter;
}; //class SnappingRanges2d
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog gui/gui.cpp libgeometry/Range2d...,
Udo Giacomozzi <=