gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog backend/render_handler_agg.cpp ...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog backend/render_handler_agg.cpp ...
Date: Sat, 02 Dec 2006 23:13:38 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/12/02 23:13:38

Modified files:
        .              : ChangeLog 
        backend        : render_handler_agg.cpp 
        gui            : gtk.cpp 
        libgeometry    : Range2d.h 

Log message:
                * libgeometry/Range2d.h: Add growBy() and shrinkBy() methods.
                  Make all mutators return a reference to *this (nicer use 
sytax).
                * backend/render_handler_agg.cpp, gui/gtk.cpp: set back the
                  drawn bounds 2 pixel grow needed for antialiasing.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1848&r2=1.1849
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk.cpp?cvsroot=gnash&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/Range2d.h?cvsroot=gnash&r1=1.1&r2=1.2

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1848
retrieving revision 1.1849
diff -u -b -r1.1848 -r1.1849
--- ChangeLog   2 Dec 2006 21:45:20 -0000       1.1848
+++ ChangeLog   2 Dec 2006 23:13:38 -0000       1.1849
@@ -1,3 +1,10 @@
+2006-12-02 Sandro Santilli <address@hidden>
+
+       * libgeometry/Range2d.h: Add growBy() and shrinkBy() methods.
+         Make all mutators return a reference to *this (nicer use sytax).
+       * backend/render_handler_agg.cpp, gui/gtk.cpp: set back the
+         drawn bounds 2 pixel grow needed for antialiasing.
+
 2006-12-02 John Franklin <address@hidden>
 
        * backend/render_handler_agg.cpp (render_handler_agg ctor):

Index: backend/render_handler_agg.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_agg.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- backend/render_handler_agg.cpp      2 Dec 2006 21:45:20 -0000       1.50
+++ backend/render_handler_agg.cpp      2 Dec 2006 23:13:38 -0000       1.51
@@ -16,7 +16,7 @@
 
  
 
-/* $Id: render_handler_agg.cpp,v 1.50 2006/12/02 21:45:20 strk Exp $ */
+/* $Id: render_handler_agg.cpp,v 1.51 2006/12/02 23:13:38 strk Exp $ */
 
 // Original version by Udo Giacomozzi and Hannes Mayr, 
 // INDUNET GmbH (www.indunet.it)
@@ -1380,8 +1380,8 @@
         // negative pixels seems ok here... we don't 
        // clip to valid range, use world_to_pixel(rect&)
        // and Intersect() against valid range instead.
-       x = (world_x * xscale);
-       y = (world_y * yscale);
+       x = (int)(world_x * xscale);
+       y = (int)(world_y * yscale);
   }
 
   geometry::Range2d<int> world_to_pixel(const rect& wb)
@@ -1406,11 +1406,8 @@
     
       Range2d<int> pixbounds = world_to_pixel(bounds);
       
-      // TODO: add 2 pixels (GUI does that too)
-      //m_clip_xmin -= 2;
-      //m_clip_ymin -= 2;
-      //m_clip_xmax += 2;
-      //m_clip_ymax += 2;
+      // add 2 pixels (GUI does that too)
+      pixbounds.growBy(2);
   
       // TODO: cache 'visiblerect' and maintain in sync with
       //       xres/yres.

Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- gui/gtk.cpp 2 Dec 2006 21:28:06 -0000       1.51
+++ gui/gtk.cpp 2 Dec 2006 23:13:38 -0000       1.52
@@ -248,10 +248,10 @@
        // be rerendered (??)
        //
        _drawbounds = Intersection(
-                       _renderer->world_to_pixel(bounds),
+                       // add two pixels because of anti-aliasing...
+                       _renderer->world_to_pixel(bounds).growBy(2),
                        _validbounds);
 
-       // TODO: add two pixels because of anti-aliasing...
 #endif
 }
 

Index: libgeometry/Range2d.h
===================================================================
RCS file: /sources/gnash/gnash/libgeometry/Range2d.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libgeometry/Range2d.h       1 Dec 2006 15:38:18 -0000       1.1
+++ libgeometry/Range2d.h       2 Dec 2006 23:13:38 -0000       1.2
@@ -19,7 +19,7 @@
 //
 
 
-/* $Id: Range2d.h,v 1.1 2006/12/01 15:38:18 strk Exp $ */
+/* $Id: Range2d.h,v 1.2 2006/12/02 23:13:38 strk Exp $ */
 
 #ifndef GNASH_RANGE2D_H
 #define GNASH_RANGE2D_H
@@ -168,10 +168,14 @@
        }
 
        /// Set the Range2d to the NULL value
-       void setNull()
+       //
+       /// @return a reference to this instance
+       ///
+       Range2d<T>& setNull()
        {
                _xmin = std::numeric_limits<T>::max();
                _xmax = std::numeric_limits<T>::min();
+               return *this;
        }
 
        /// Returns true if this is the WORLD Range2d
@@ -197,10 +201,13 @@
        ///
        /// See RangeType::worldRange
        ///
-       void setWorld()
+       /// @return a reference to this instance
+       ///
+       Range2d<T>& setWorld()
        {
                _xmin = std::numeric_limits<T>::min();
                _xmax = std::numeric_limits<T>::max();
+               return *this;
        }
 
        /// \brief
@@ -241,10 +248,13 @@
        }
 
        /// Expand this Range2d to enclose the given point.
-       void expandTo(T x, T y)
+       //
+       /// @return a reference to this instance
+       ///
+       Range2d<T> expandTo(T x, T y)
        {
                // A WORLD range already enclose every point
-               if ( isWorld() ) return;
+               if ( isWorld() ) return *this;
 
                if ( isNull() ) 
                {
@@ -257,13 +267,19 @@
                        _xmax = std::max(_xmax, x);
                        _ymax = std::max(_ymax, y);
                }
+
+               return *this;
        }
 
        /// Set ourself to bound the given point
-       void setTo(T x, T y)
+       //
+       /// @return a reference to this instance
+       ///
+       Range2d<T> setTo(T x, T y)
        {
                _xmin = _xmax = x;
                _ymin = _ymax = y;
+               return *this;
        }
 
        /// Set coordinates to given values
@@ -274,7 +290,9 @@
        /// force caller to deal with this, as a similar
        /// case might as well expose a bug in the code.
        //
-       void setTo(T xmin, T ymin, T xmax, T ymax)
+       /// @return a reference to this instance
+       ///
+       Range2d<T> setTo(T xmin, T ymin, T xmax, T ymax)
        {
                _xmin = xmin;
                _xmax = xmax;
@@ -284,6 +302,8 @@
                // use the default ctor to make a NULL Range2d
                assert(_xmin <= _xmax);
                assert(_ymin <= _ymax);
+
+               return *this;
        }
 
        /// Return width this Range2d
@@ -315,11 +335,14 @@
        ///
        /// WORLD or NULL ranges will be unchanged
        ///
-       void shiftX(T offset)
+       /// @return a reference to this instance
+       ///
+       Range2d<T> shiftX(T offset)
        {
-               if ( isNull() || isWorld() ) return;
+               if ( isNull() || isWorld() ) return *this;
                _xmin += offset;
                _xmax += offset;
+               return *this;
        }
 
        /// Shift this Range2dangle vertically
@@ -329,11 +352,14 @@
        ///
        /// WORLD or NULL ranges will be unchanged
        ///
-       void shiftY(T offset)
+       /// @return a reference to this instance
+       ///
+       Range2d<T> shiftY(T offset)
        {
-               if ( isNull() || isWorld() ) return;
+               if ( isNull() || isWorld() ) return *this;
                _ymin += offset;
                _ymax += offset;
+               return *this;
        }
 
        /// Scale this Range2d horizontally
@@ -349,12 +375,15 @@
        /// of the range an assertion will fail
        /// (TODO: throw an exception instead!).
        ///
-       void scaleX(T factor)
+       /// @return a reference to this instance
+       ///
+       Range2d<T> scaleX(T factor)
        {
-               if ( isNull() || isWorld() ) return;
+               if ( isNull() || isWorld() ) return *this;
                _xmin *= factor;
                _xmax *= factor;
                assert(_xmin < _xmax); // in case of overflow...
+               return *this;
        }
 
        /// Scale this Range2dangle vertically
@@ -368,12 +397,128 @@
        /// of the range an assertion will fail
        /// (TODO: throw an exception instead!).
        ///
-       void scaleY(T factor)
+       /// @return a reference to this instance
+       ///
+       Range2d<T> scaleY(T factor)
        {
-               if ( isNull() ) return;
+               if ( isNull() ) return *this;
+
                _ymin *= factor;
                _ymax *= factor;
                assert(_ymin < _ymax); // in case of overflow...
+
+               return *this;
+       }
+
+       /// Grow this range by the given amout in all directions.
+       //
+       /// WORLD or NULL ranges will be unchanged.
+       ///
+       /// If a growing range hits the numerical limit for T
+       /// it will be set to the WORLD range.
+       ///
+       /// @param amount
+       ///     The amount of T to grow this range in all directions.
+       ///     If negative the range will shrink.
+       ///     If negative (where T allows that) the range will shrink:
+       ///     See shrinkBy().
+       ///
+       /// @return a reference to this instance
+       ///
+       Range2d<T>& growBy(T amount)
+       {
+               if ( isNull() || isWorld() || amount==0 ) return *this;
+
+               // NOTE: whith will likely trigger a compiler
+               //       warning when T is an unsigned type
+               if ( amount < 0 ) return shrinkBy(-amount);
+
+               if ( amount > 0 )
+               {
+                       T lowerbound = std::numeric_limits<T>::min();
+                       T upperbound = std::numeric_limits<T>::max();
+
+                       // Compute space remaining before hitting the 
+                       // numeric limits
+
+                       T spaceleft = _xmin - lowerbound;
+                       T spaceright = upperbound - _xmax;
+                       T spacebottom = _ymin - lowerbound;
+                       T spacetop = upperbound - _ymax;
+
+                       // Turn this range into the WORLD range
+                       // if any limit is reached.
+
+                       if ( spaceleft <= amount ) return setWorld();
+                       if ( spaceright <= amount ) return setWorld();
+                       if ( spacebottom <= amount ) return setWorld();
+                       if ( spacetop <= amount ) return setWorld();
+
+               }
+               else
+               {
+                       // Turn this range into the NULL range
+                       // if any dimension collapses.
+                       // Don't use width() and height() to 
+                       // avoid superflous checks.
+
+                       if ( _xmax - _xmin <= amount ) return setNull();
+                       if ( _ymax - _ymin <= amount ) return setNull();
+
+               }
+
+               _xmin -= amount;
+               _ymin -= amount;
+               _xmax += amount;
+               _ymax += amount;
+
+               return *this;
+
+       }
+
+       /// Shirnk this range by the given amout in all directions.
+       //
+       /// WORLD or NULL ranges will be unchanged.
+       ///
+       /// If a shrinking range will collapse in either the horizontal
+       /// or vertical dimension it will be set to the NULL range.
+       ///
+       /// @param amount
+       ///     The amount of T to shink this range in all directions.
+       ///     If negative (where T allows that) the range will grow:
+       ///     See growBy().
+       ///
+       /// @return a reference to this instance
+       ///
+       /// NOTE: This method assumes that the numerical type used
+       ///       as parameter does allow both positive and negative
+       ///       values. Using this method against an instance of
+       ///       an 'unsigned' Range2d will likely raise unexpected
+       ///       results.
+       ///
+       Range2d<T>& shrinkBy(T amount)
+       {
+               if ( isNull() || isWorld() || amount==0 ) return *this;
+
+               // NOTE: whith will likely trigger a compiler
+               //       warning when T is an unsigned type
+               if ( amount < 0 ) return growBy(-amount);
+
+               // Turn this range into the NULL range
+               // if any dimension collapses.
+               // Don't use width() and height() to 
+               // avoid superflous checks.
+
+               if ( _xmax - _xmin <= amount ) return setNull();
+               if ( _ymax - _ymin <= amount ) return setNull();
+
+               _xmin -= amount;
+               _ymin -= amount;
+               _xmax += amount;
+               _ymax += amount;
+
+               return *this;
+
        }
 
        /// Get min X ordinate.




reply via email to

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