[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/shape.cpp server/shape.h...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/shape.cpp server/shape.h... |
Date: |
Sun, 04 Nov 2007 23:12:56 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/11/04 23:12:56
Modified files:
. : ChangeLog
server : shape.cpp shape.h
server/parser : shape_character_def.cpp
Log message:
* server/shape.{cpp,h}: extract a ray_crossing out of
point_test.
* server/parser/shape_character_def.cpp (point_test): use
path::ray_crossing against any filled path, to detect fills
composed by multiple paths. Fixes bug #21498.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4763&r2=1.4764
http://cvs.savannah.gnu.org/viewcvs/gnash/server/shape.cpp?cvsroot=gnash&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/gnash/server/shape.h?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/shape_character_def.cpp?cvsroot=gnash&r1=1.41&r2=1.42
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4763
retrieving revision 1.4764
diff -u -b -r1.4763 -r1.4764
--- ChangeLog 2 Nov 2007 20:18:34 -0000 1.4763
+++ ChangeLog 4 Nov 2007 23:12:55 -0000 1.4764
@@ -1,3 +1,10 @@
+2007-11-05 Sandro Santilli <address@hidden>
+
+ * server/shape.{cpp,h}: extract a ray_crossing out of point_test.
+ * server/parser/shape_character_def.cpp (point_test): use
+ path::ray_crossing against any filled path, to detect fills
+ composed by multiple paths. Fixes bug #21498.
+
2007-11-02 Bastiaan Jacques <address@hidden>
* backend/render_handler_ogl.cpp: Add OSRenderMesa, a class
Index: server/shape.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/shape.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- server/shape.cpp 14 Sep 2007 16:02:50 -0000 1.39
+++ server/shape.cpp 4 Nov 2007 23:12:56 -0000 1.40
@@ -23,6 +23,7 @@
#include "tu_file.h"
#include "tesselate.h"
#include "rect.h"
+#include "log.h"
#include <cfloat>
#include <map>
@@ -189,13 +190,10 @@
}
}
-
-bool path::point_test(float x, float y) const
+void
+path::ray_crossing(int& ray_crossings, float x, float y) const
{
- if ( m_edges.empty() ) return false;
-
- // No fill, nothing more to check.
- if (m_fill0 == 0 && m_fill1 == 0) return false;
+ if ( m_edges.empty() ) return;
// Shoot a horizontal ray from (x,y) to the right, and
// count the number of edge crossings. An even number
@@ -205,7 +203,6 @@
float x0 = m_ax;
float y0 = m_ay;
- int ray_crossings = 0;
for (int i = 0, n = m_edges.size(); i < n; i++) {
const edge& e = m_edges[i];
@@ -320,6 +317,20 @@
y0 = y1;
}
+ return;
+}
+
+
+bool path::point_test(float x, float y) const
+{
+ if ( m_edges.empty() ) return false;
+
+ // No fill, nothing more to check.
+ if (m_fill0 == 0 && m_fill1 == 0) return false;
+
+ int ray_crossings = 0;
+ ray_crossing(ray_crossings, x, y);
+
if (ray_crossings & 1) {
// Odd number of ray crossings means the point
// is inside the poly.
Index: server/shape.h
===================================================================
RCS file: /sources/gnash/gnash/server/shape.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/shape.h 14 Sep 2007 16:02:51 -0000 1.24
+++ server/shape.h 4 Nov 2007 23:12:56 -0000 1.25
@@ -5,7 +5,7 @@
// Quadratic bezier outline shapes, the basis for most SWF rendering.
-/* $Id: shape.h,v 1.24 2007/09/14 16:02:51 strk Exp $ */
+/* $Id: shape.h,v 1.25 2007/11/04 23:12:56 strk Exp $ */
#ifndef GNASH_SHAPE_H
#define GNASH_SHAPE_H
@@ -119,10 +119,27 @@
///
/// WARNING: often a filled shape is composed by multiple
/// paths. we probably fail in those cases.
- ///
+ /// Use the ray_crossing() function to compute
+ /// Point-in-shape for multi-path shapes.
///
bool point_test(float x, float y) const;
+ /// Ray crossing count.
+ //
+ /// Update ray crossing for the given query point using
+ /// edges in this path.
+ ///
+ /// @param ray_crossings
+ /// Number of crossings, updated by this method.
+ ///
+ /// @param x
+ /// X ordinate of the query point, in local coordinate
space.
+ ///
+ /// @param y
+ /// Y ordinate of the query point, in local coordinate
space.
+ ///
+ void ray_crossing(int& ray_crossings, float x, float y) const;
+
/// Push the path into the tesselator.
void tesselate() const;
@@ -250,7 +267,9 @@
/// 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
+ /// \brief
+ /// Return true if the given point is withing the given squared
distance
+ /// from this path edges.
//
/// NOTE: if the path is empty, false is returned.
///
Index: server/parser/shape_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/shape_character_def.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- server/parser/shape_character_def.cpp 3 Oct 2007 06:52:42 -0000
1.41
+++ server/parser/shape_character_def.cpp 4 Nov 2007 23:12:56 -0000
1.42
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: shape_character_def.cpp,v 1.41 2007/10/03 06:52:42 strk Exp $ */
+/* $Id: shape_character_def.cpp,v 1.42 2007/11/04 23:12:56 strk Exp $ */
// Based on the public domain shape.cpp of Thatcher Ulrich <address@hidden>
2003
@@ -731,6 +731,8 @@
point pt(x, y);
+ int ray_crossings=0;
+
// Try each of the paths.
for (size_t i = 0; i < npaths; ++i)
{
@@ -755,14 +757,25 @@
float dist = thickness/2;
sqdist = dist*dist;
}
+
//cout << "Thickness of line is " << thickness << " squared is
" << sqdist << endl;
if ( pth.withinSquareDistance(pt, sqdist) ) return true;
}
// Check for point in polygon (if filled - but that test is in
point_test itself)
- if (pth.point_test(x, y)) return true;
+ if ( pth.m_fill0 || pth.m_fill1 )
+ {
+ pth.ray_crossing(ray_crossings, x, y);
}
+ //if (pth.point_test(x, y)) return true;
+ }
+
+ if (ray_crossings & 1) {
+ // Odd number of ray crossings means the point
+ // is inside the poly.
+ return true;
+ }
return false;
}
- [Gnash-commit] gnash ChangeLog server/shape.cpp server/shape.h...,
Sandro Santilli <=