gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog libgeometry/snappingrange.h


From: Udo Giacomozzi
Subject: [Gnash-commit] gnash ChangeLog libgeometry/snappingrange.h
Date: Tue, 06 Mar 2007 15:23:38 +0000

CVSROOT:        /cvsroot/gnash
Module name:    gnash
Changes by:     Udo Giacomozzi <udog>   07/03/06 15:23:38

Modified files:
        .              : ChangeLog 
        libgeometry    : snappingrange.h 

Log message:
        avoid excessive calls to combine_ranges()

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2553&r2=1.2554
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/snappingrange.h?cvsroot=gnash&r1=1.12&r2=1.13

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnash/gnash/ChangeLog,v
retrieving revision 1.2553
retrieving revision 1.2554
diff -u -b -r1.2553 -r1.2554
--- ChangeLog   6 Mar 2007 15:14:51 -0000       1.2553
+++ ChangeLog   6 Mar 2007 15:23:38 -0000       1.2554
@@ -1,3 +1,8 @@
+2007-03-06 Udo Giacomozzi <address@hidden>
+
+       * libgeometry/snappingrange2d.h: do not call combine_ranges() too 
+         often 
+
 2007-03-06 Sandro Santilli <address@hidden>
 
        * server/vm/ASHandlers.cpp (ActionCallMethod): when method name

Index: libgeometry/snappingrange.h
===================================================================
RCS file: /cvsroot/gnash/gnash/libgeometry/snappingrange.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- libgeometry/snappingrange.h 6 Mar 2007 14:27:22 -0000       1.12
+++ libgeometry/snappingrange.h 6 Mar 2007 15:23:38 -0000       1.13
@@ -15,7 +15,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 // 
-// $Id: snappingrange.h,v 1.12 2007/03/06 14:27:22 udog Exp $
+// $Id: snappingrange.h,v 1.13 2007/03/06 15:23:38 udog Exp $
 
 #ifndef GNASH_SNAPPINGRANGE_H
 #define GNASH_SNAPPINGRANGE_H
@@ -81,7 +81,8 @@
        SnappingRanges2d() 
                :
                snap_distance(0),
-               single_mode(false)
+               single_mode(false),
+               _combine_counter(0)
        {
        }
        
@@ -119,7 +120,7 @@
                        // reached this point we need a new range 
                        _ranges.push_back(range);
                        
-                       combine_ranges();
+                       combine_ranges_lazy();
                }
        }
        
@@ -141,7 +142,7 @@
                for (unsigned int rno=0; rno<rcount; rno++)
                        _ranges[rno].growBy(amount);
                        
-               combine_ranges();
+               combine_ranges_lazy();
        }
        
        /// Combines known ranges. Previously merged ranges may have come close
@@ -153,6 +154,8 @@
        
                bool restart=true;
                
+               _combine_counter=0;
+               
                while (restart) {
                
                        int rcount = _ranges.size();
@@ -185,6 +188,15 @@
        
        }
        
+       
+       /// Calls combine_ranges() once in a while, but not always. Avoids too 
many
+       /// combine_ranges() checks, which could slow down everything.
+       void combine_ranges_lazy() {
+               _combine_counter++;
+               if (_combine_counter > 5) 
+                       combine_ranges();
+       }
+                       
        /// returns true, when two ranges should be merged together
        inline bool snaptest(const RangeType& range1, const RangeType& range2) {
        
@@ -243,11 +255,13 @@
        
        /// Returns the number of ranges in the list
        size_type size() const {
+               finalize();
                return _ranges.size();
        }
        
        /// Returns the range at the specified index
        RangeType getRange(unsigned int index) const {
+               finalize();
                assert(index<size());
                
                return _ranges[index];
@@ -283,6 +297,8 @@
        /// Returns true if any of the ranges contains the point
        bool contains(T x, T y) const {
        
+               finalize();
+       
                for (unsigned rno=0, rcount=_ranges.size(); rno<rcount; rno++) 
                if (_ranges[rno].contains(x,y))
                        return true;
@@ -323,9 +339,19 @@
                return min(a,b);
        }
                
+       void finalize() const {
+               if (_combine_counter > 0) {
+                       SnappingRanges2d<T>* me_nonconst = const_cast< 
SnappingRanges2d<T>* > (this); 
+                       me_nonconst->combine_ranges();
+               }
+       } 
+       
+               
        // The current Ranges list
        RangeList _ranges;
        
+       unsigned int _combine_counter;
+       
 }; //class SnappingRanges2d
 
 /// Standard snapping 2d ranges type for invalidated bounds calculation  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]