[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/parser/shape_character_d...
From: |
Udo Giacomozzi |
Subject: |
[Gnash-commit] gnash ChangeLog server/parser/shape_character_d... |
Date: |
Mon, 12 Nov 2007 19:24:29 +0000 |
CVSROOT: /cvsroot/gnash
Module name: gnash
Changes by: Udo Giacomozzi <udog> 07/11/12 19:24:29
Modified files:
. : ChangeLog
server/parser : shape_character_def.cpp
Log message:
* server/parser/shape_character_def.cpp: point_test_local bugfix:
revert last commit and align test coordinate to a grid instead;
commit some debug so I don't have to rewrite it again... ;)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4837&r2=1.4838
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/shape_character_def.cpp?cvsroot=gnash&r1=1.49&r2=1.50
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnash/gnash/ChangeLog,v
retrieving revision 1.4837
retrieving revision 1.4838
diff -u -b -r1.4837 -r1.4838
--- ChangeLog 12 Nov 2007 18:27:45 -0000 1.4837
+++ ChangeLog 12 Nov 2007 19:24:28 -0000 1.4838
@@ -1,3 +1,9 @@
+2007-11-12 Udo Giacomozzi <address@hidden>
+
+ * server/parser/shape_character_def.cpp: point_test_local bugfix:
+ revert last commit and align test coordinate to a grid instead;
+ commit some debug so I don't have to rewrite it again... ;)
+
2007-11-12 Lucio Flavio Correa <address@hidden>
* gui/kdesup.h, gui/kde.cpp: implement setCuror (patch #6266).
Index: server/parser/shape_character_def.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/parser/shape_character_def.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- server/parser/shape_character_def.cpp 12 Nov 2007 10:56:15 -0000
1.49
+++ server/parser/shape_character_def.cpp 12 Nov 2007 19:24:28 -0000
1.50
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: shape_character_def.cpp,v 1.49 2007/11/12 10:56:15 udog Exp $ */
+/* $Id: shape_character_def.cpp,v 1.50 2007/11/12 19:24:28 udog Exp $ */
// Based on the public domain shape.cpp of Thatcher Ulrich <address@hidden>
2003
@@ -803,12 +803,20 @@
}
-
bool shape_character_def::point_test_local(float x, float y)
// Return true if the specified point is on the interior of our shape.
// Incoming coords are local coords.
{
+//#define DEBUG_POINT_TEST
+//#define DEBUG_POINT_TEST_EXT
+
+
+#ifdef DEBUG_POINT_TEST
+ printf("=== point_test_local ===\n");
+ char debug[1024];
+#endif
+
/*
Principle:
For the fill of the shape, we project a ray from the test point to the left
@@ -826,6 +834,16 @@
- intersecting paths
*/
+
+ // Align test coordinates to TWIP coordinate system and shift by a half
+ // TWIP to avoid line junction situations which are hard to handle.
Oversample
+ // everything by 100 to get some degree of accuracy (ie. this won't produce
+ // any visible inaccuracy before the shape is scaled more an 2000x). The
+ // resulting coordinate is *very* close to the original one and still in the
+ // same coordinate system.
+ x = (round(x * 2000.0f) + 0.5f) / 2000.0f;
+ y = (round(y * 2000.0f) + 0.5f) / 2000.0f;
+
point pt(x, y);
bool even_odd = true; // later we will need non-zero for glyphs... (TODO)
@@ -835,6 +853,7 @@
return false;
}
+
unsigned npaths = m_paths.size();
int counter = 0;
@@ -852,12 +871,24 @@
if ( (even_odd && (counter % 2) != 0) ||
(!even_odd && (counter != 0)) ) {
// the point is inside the previous subshape, so exit now
+
+#ifdef DEBUG_POINT_TEST
+ printf(" subshape early out. counter=%d\n", counter);
+#endif
+
return true;
}
counter=0;
}
+#ifdef DEBUG_POINT_TEST_EXT
+ printf(" new path, anchor = %.2f / %.2f\n", pth.ap.x, pth.ap.y);
+#endif
+
+ if (pth.empty())
+ continue;
+
// If the path has a line style, check for strokes there
if (pth.m_line != 0 ) {
@@ -893,6 +924,10 @@
next_pen_x = edg.ap.x;
next_pen_y = edg.ap.y;
+#ifdef DEBUG_POINT_TEST_EXT
+ printf(" to %.2f / %.2f |", edg.ap.x, edg.ap.y);
+#endif
+
/*
printf("EDGE #%d #%d [ %d %d ] : %.2f / %.2f -> %.2f / %.2f\n", pno, eno,
pth.m_fill0, pth.m_fill1,
@@ -900,7 +935,6 @@
edg.ap.x, edg.ap.y);
*/
-
float cross1, cross2;
int dir1, dir2; // +1 = downward, -1 = upward
int crosscount=0;
@@ -909,16 +943,21 @@
// ==> straight line case
+#ifdef DEBUG_POINT_TEST
+ sprintf(debug, "straight");
+#endif
+
// ignore horizontal lines
- if (edg.ap.y == pen_y) // TODO: better check for small difference?
+ if (edg.ap.y == pen_y) { // TODO: better check for small difference?
+#ifdef DEBUG_POINT_TEST_EXT
+ printf(" #%02d, #%02d [%s] horizontal line\n", pno, eno, debug);
+#endif
continue;
+ }
// does this line cross the Y coordinate?
- // NOTE: We don't want to detect a crossing at the end of the line,
- // (simply put, the last pixel) because the next line (connected to
this
- // one) will also cross the Y coordinate.
- if ( ((pen_y <= y) && (edg.ap.y > y))
- || ((pen_y >= y) && (edg.ap.y < y)) ) {
+ if ( ((pen_y <= y) && (edg.ap.y >= y))
+ || ((pen_y >= y) && (edg.ap.y <= y)) ) {
// calculate X crossing
cross1 = pen_x + (edg.ap.x - pen_x) *
@@ -933,8 +972,8 @@
} else {
- // no crossing, ignore edge..
- continue;
+ // no crossing found
+ crosscount = 0;
}
@@ -942,35 +981,16 @@
// ==> curve case
+#ifdef DEBUG_POINT_TEST
+ sprintf(debug, "curve ");
+#endif
+
crosscount = curve_x_crossings(pen_x, pen_y, edg.ap.x, edg.ap.y,
edg.cp.x, edg.cp.y, y, cross1, cross2);
- // Safety check: remove any crossing at the very end of the curve.
- // Any line or curve connected to this one would also detect a
crossing,
- // which is bad since we don't want double crossings for a single
point.
- // Assuming that cross2 is always near to the end, we won't find a
- // cross1 at the end of the curve when there is a cross2 (so no moving
- // is necessary).
-
- if ((crosscount==2) && (y==edg.ap.y) && (cross2==edg.ap.x))
- crosscount--;
- else
- if ((crosscount==1) && (y==edg.ap.y) && (cross1==edg.ap.x))
- crosscount--;
-
dir1 = pen_y > y ? -1 : +1;
dir2 = dir1 * (-1); // second crossing always in opposite dir.
- /*
- printf(" curve crosses at %d points\n", crosscount);
-
- if (scount>0)
- printf(" first crossing at %.2f / %.2f, dir %d\n", cross1, y,
dir1);
-
- if (scount>1)
- printf(" second crossing at %.2f / %.2f, dir %d\n", cross2, y,
dir2);
- */
-
} // curve
@@ -981,27 +1001,57 @@
// - crosscount tells the number of crossings
- if (crosscount==0)
- continue; // need at least one crossing
+ // need at least one crossing
+ if (crosscount==0) {
+#ifdef DEBUG_POINT_TEST_EXT
+ printf(" #%02d, #%02d [%s] no crossing\n", pno, eno, debug);
+#endif
+ continue;
+ }
+ bool touched=false;
// check first crossing
if (cross1 <= x) {
if (pth.m_fill0 > 0) counter += dir1;
if (pth.m_fill1 > 0) counter -= dir1;
+
+ touched = true;
+
+#ifdef DEBUG_POINT_TEST
+ printf(" #%02d, #%02d [%s] crossing at x=%.2f y=%.2f dir=%d
fills=[%d,%d] -> C=%d\n",
+ pno, eno, debug, cross1, y, dir1, pth.m_fill0, pth.m_fill1, counter);
+#endif
}
// check optional second crossing (only possible with curves)
if ((crosscount>1) && (cross2 <= x)) {
if (pth.m_fill0 > 0) counter += dir2;
if (pth.m_fill1 > 0) counter -= dir2;
+
+ touched = true;
+
+#ifdef DEBUG_POINT_TEST
+ printf(" #%02d, #%02d [%s] crossing at x=%.2f y=%.2f dir=%d
fills=[%d,%d] -> C=%d\n",
+ pno, eno, debug, cross2, y, dir2, pth.m_fill0, pth.m_fill1, counter);
+#endif
}
+#ifdef DEBUG_POINT_TEST_EXT
+ if (!touched)
+ printf(" #%02d, #%02d [%s] no crossing at left side\n", pno, eno,
debug);
+#endif
+
+
} // for edge
} // for path
+#ifdef DEBUG_POINT_TEST
+ printf(" all paths processed. counter=%d\n", counter);
+#endif
+
return ( (even_odd && (counter % 2) != 0) ||
(!even_odd && (counter != 0)) );
}
- Re: [Gnash-commit] gnash ChangeLog server/parser/shape_character_d..., (continued)
- Re: [Gnash-commit] gnash ChangeLog server/parser/shape_character_d..., strk, 2007/11/12
- Re[2]: [Gnash-commit] gnash ChangeLog server/parser/shape_character_d..., Udo Giacomozzi, 2007/11/12
- Re: [Gnash-commit] gnash ChangeLog server/parser/shape_character_d..., strk, 2007/11/12
- Re[2]: [Gnash-commit] gnash ChangeLog server/parser/shape_character_d..., Udo Giacomozzi, 2007/11/12
- Re: [Gnash-commit] gnash ChangeLog server/parser/shape_character_d..., strk, 2007/11/12
[Gnash-commit] gnash ChangeLog server/parser/shape_character_d..., Udo Giacomozzi, 2007/11/12
[Gnash-commit] gnash ChangeLog server/parser/shape_character_d...,
Udo Giacomozzi <=
Re: [Gnash-commit] gnash ChangeLog server/parser/shape_character_d..., strk, 2007/11/12