gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog gui/gui.cpp server/shape.cpp se...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog gui/gui.cpp server/shape.cpp se...
Date: Mon, 23 Apr 2007 19:19:31 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/04/23 19:19:30

Modified files:
        .              : ChangeLog 
        gui            : gui.cpp 
        server         : shape.cpp shape.h types.cpp 
        server/parser  : shape_character_def.cpp 
        testsuite/misc-ming.all: DrawingApiTest.as 
                                 DrawingApiTestRunner.cpp 

Log message:
                * server/shape.{cpp,h}: add path::withinSquareDistance.
                * server/types.cpp (point::distance): return 0 for 0 
squaredDistance
                  (not 1).
                * server/parser/shape_character_def.cpp (point_test_local):
                  test for point falling in the shape stroke, taking thickness
                  in consideration.
                * testsuite/misc-ming.all/DrawingApiTestRunner.cpp: more
                  tests.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2973&r2=1.2974
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.73&r2=1.74
http://cvs.savannah.gnu.org/viewcvs/gnash/server/shape.cpp?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/server/shape.h?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/types.cpp?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/shape_character_def.cpp?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DrawingApiTest.as?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DrawingApiTestRunner.cpp?cvsroot=gnash&r1=1.5&r2=1.6

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2973
retrieving revision 1.2974
diff -u -b -r1.2973 -r1.2974
--- ChangeLog   23 Apr 2007 18:09:54 -0000      1.2973
+++ ChangeLog   23 Apr 2007 19:19:30 -0000      1.2974
@@ -1,5 +1,16 @@
 2007-04-23 Sandro Santilli <address@hidden>
 
+       * server/shape.{cpp,h}: add path::withinSquareDistance.
+       * server/types.cpp (point::distance): return 0 for 0 squaredDistance
+         (not 1).
+       * server/parser/shape_character_def.cpp (point_test_local):
+         test for point falling in the shape stroke, taking thickness
+         in consideration.
+       * testsuite/misc-ming.all/DrawingApiTestRunner.cpp: more
+         tests.
+
+2007-04-23 Sandro Santilli <address@hidden>
+
        * server/shape.{cpp,h}: add primitive distance functions
          for point-segment
        * testsuite/server/: Makefile.am, EdgeTest.cpp: add tests 

Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -b -r1.73 -r1.74
--- gui/gui.cpp 18 Apr 2007 09:35:41 -0000      1.73
+++ gui/gui.cpp 23 Apr 2007 19:19:30 -0000      1.74
@@ -245,7 +245,7 @@
 {
        movie_root* m = get_current_root();
 
-       //log_msg(_("mouse @ %d,%d"), x, y);
+       log_msg(_("mouse @ %d,%d"), x, y);
        if ( m->notify_mouse_moved(x, y) )
        {
                // any action triggered by the

Index: server/shape.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/shape.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- server/shape.cpp    23 Apr 2007 18:09:54 -0000      1.32
+++ server/shape.cpp    23 Apr 2007 19:19:30 -0000      1.33
@@ -5,7 +5,7 @@
 
 // Quadratic bezier outline shapes, the basis for most SWF rendering.
 
-/* $Id: shape.cpp,v 1.32 2007/04/23 18:09:54 strk Exp $ */
+/* $Id: shape.cpp,v 1.33 2007/04/23 19:19:30 strk Exp $ */
 
 #include "shape.h"
 
@@ -87,13 +87,13 @@
 
         if (u<0)
        {
-               cout << "R was < 0 " << endl;
+               //cout << "R was < 0 " << endl;
                return p.squareDistance(A); 
        }
 
         if (u>1)
        {
-               cout << "R was > 1 " << endl;
+               //cout << "R was > 1 " << endl;
                return p.squareDistance(B);
        }
 
@@ -101,7 +101,7 @@
        px.m_x = A.m_x + u * (B.m_x - A.m_x);
        px.m_y = A.m_y + u * (B.m_y - A.m_y);
 
-       cout << "R was between 0 and 1, u is " << u << " px : " << px.m_x << 
"," << px.m_y << endl;
+       //cout << "R was between 0 and 1, u is " << u << " px : " << px.m_x << 
"," << px.m_y << endl;
 
        return p.squareDistance(px);
 }
@@ -157,29 +157,10 @@
     // Point-in-shape test.  Return true if the query point is on the filled
     // interior of this shape.
 {
-    if (m_edges.size() <= 0) {
-       return false;
-    }
-#if 0
-    // This test makes no sense: m_fill0 is unsigned and "1-based" -martin
-    if (m_fill0 < 0) {
-       // No interior fill.
-       
-       // @@ This isn't quite right due to some paths
-       // doing double-duty with both fill0 and fill1
-       // styles.
-       
-       // TODO: get rid of this stupid fill0/fill1
-       // business -- a path should always be
-       // counterclockwise and have one fill.  For
-       // input paths with fill1, generate a separate
-       // reversed path with fill set to fill1.
-       // Group all paths with the same fill into a
-       // path group; do the point_test on the whole
-       // group.
-       return false;
-    }
-#endif
+    if ( m_edges.empty() ) return false;
+
+    // No fill, nothing more to check.
+    if (m_fill0 == 0 && m_fill1 == 0) return false;
     
     // Shoot a horizontal ray from (x,y) to the right, and
     // count the number of edge crossings.  An even number
@@ -354,6 +335,29 @@
        }
 }
 
+bool
+path::withinSquareDistance(const point& p, float dist)
+{
+       size_t nedges = m_edges.size();
+
+       if ( ! nedges ) return false;
+
+       // TODO: FIXME: we're not considering the control
+       //       point at all so the check will only work
+       //       for straight lines
+
+       point px(m_ax, m_ay);
+       for (size_t i=0; i<nedges; ++i)
+       {
+               const edge& e = m_edges[i];
+               point np(e.m_ax, e.m_ay);
+               float d = edge::squareDistancePtSeg(p, px, np);
+               if ( d < dist ) return true;
+       }
+
+       return false;
+}
+
 // Utility.
 
 

Index: server/shape.h
===================================================================
RCS file: /sources/gnash/gnash/server/shape.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/shape.h      23 Apr 2007 18:09:54 -0000      1.20
+++ server/shape.h      23 Apr 2007 19:19:30 -0000      1.21
@@ -5,7 +5,7 @@
 
 // Quadratic bezier outline shapes, the basis for most SWF rendering.
 
-/* $Id: shape.h,v 1.20 2007/04/23 18:09:54 strk Exp $ */
+/* $Id: shape.h,v 1.21 2007/04/23 19:19:30 strk Exp $ */
 
 #ifndef GNASH_SHAPE_H
 #define GNASH_SHAPE_H
@@ -235,6 +235,13 @@
                /// Close this path with a straight line, if not already closed
                void close();
 
+               /// return true if the given point is withing the given squared 
distance
+               //
+               /// NOTE: if the path is empty, false is returned.
+               ///
+               bool withinSquareDistance(const point& p, float dist);
+
+
        //private:
 
                /// Left fill style index (1-based)
@@ -254,6 +261,7 @@
 
                /// ?
                bool m_new_shape;
+
        };
 
        /// For holding a pre-tesselated shape.

Index: server/types.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/types.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/types.cpp    23 Apr 2007 16:40:08 -0000      1.23
+++ server/types.cpp    23 Apr 2007 19:19:30 -0000      1.24
@@ -46,7 +46,9 @@
 
        float point::distance(const point& other) const
        {
-               return sqrt(squareDistance(other));
+               float sd = squareDistance(other);
+               if ( ! sd ) return sd;
+               else return sqrt(squareDistance(other));
        }
 
 

Index: server/parser/shape_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/shape_character_def.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- server/parser/shape_character_def.cpp       18 Apr 2007 14:07:32 -0000      
1.16
+++ server/parser/shape_character_def.cpp       23 Apr 2007 19:19:30 -0000      
1.17
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: shape_character_def.cpp,v 1.16 2007/04/18 14:07:32 jgilmore Exp $ */
+/* $Id: shape_character_def.cpp,v 1.17 2007/04/23 19:19:30 strk Exp $ */
 
 // Based on the public domain shape.cpp of Thatcher Ulrich <address@hidden> 
2003
 
@@ -607,12 +607,27 @@
        return false;
     }
 
+    point pt(x, y);
+
     // Try each of the paths.
-    for (unsigned int i = 0; i < m_paths.size(); i++) {
-       if (m_paths[i].point_test(x, y))
+    for (unsigned int i = 0; i < m_paths.size(); i++)
            {
-               return true;
+       path& pth = m_paths[i];
+
+       if ( pth.m_edges.empty() ) continue;
+
+       // If it has 
+       if ( pth.m_line != 0 )
+       {
+               assert(m_line_styles.size() >= pth.m_line);
+               line_style& ls = m_line_styles[pth.m_line-1];
+               int thickness = ls.get_width();
+               //cout << "Thickness of line is " << thickness << endl;
+               float dist = thickness/2;
+               if ( pth.withinSquareDistance(pt, dist*dist) ) return true;
            }
+
+       if (pth.point_test(x, y)) return true;
     }
 
     return false;

Index: testsuite/misc-ming.all/DrawingApiTest.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/DrawingApiTest.as,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- testsuite/misc-ming.all/DrawingApiTest.as   23 Apr 2007 13:32:15 -0000      
1.2
+++ testsuite/misc-ming.all/DrawingApiTest.as   23 Apr 2007 19:19:30 -0000      
1.3
@@ -16,9 +16,12 @@
 with (a)
 {
        clear();
+
+       // The thick red line
        lineStyle(20, 0xFF0000, 100);
        moveTo(100, 100);
        lineTo(200, 200);
+
        moveTo(100, 200);
        lineStyle(5, 0xFF00FF, 50);
        lineTo(200, 250);

Index: testsuite/misc-ming.all/DrawingApiTestRunner.cpp
===================================================================
RCS file: 
/sources/gnash/gnash/testsuite/misc-ming.all/DrawingApiTestRunner.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- testsuite/misc-ming.all/DrawingApiTestRunner.cpp    23 Apr 2007 13:45:18 
-0000      1.5
+++ testsuite/misc-ming.all/DrawingApiTestRunner.cpp    23 Apr 2007 19:19:30 
-0000      1.6
@@ -99,5 +99,14 @@
        check(tester.isMouseOverMouseEntity());
        check_pixel(82, 127, 2, black, 2);
 
+       // In the middle of an imaginary line between
+       // first and last point of the green curve
+       tester.movePointerTo(355, 156);
+       xcheck(!tester.isMouseOverMouseEntity()); // fails due to 
edge::withinSquareDistance bug
+       check_pixel(355, 156, 2, white, 2);
+
+       tester.movePointerTo(376, 139);
+       xcheck(tester.isMouseOverMouseEntity()); // fails due to 
edge::withinSquareDistance bug
+       xcheck_pixel(376, 139, 2, green, 2); // fails due to bug in AGG
 }
 




reply via email to

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