[OpenJDK 2D-Dev] More incompatibilities

Roman Kennke roman.kennke at aicas.com
Tue Mar 3 20:27:02 UTC 2009


Hi Jim,

> I think the shape iterators used in the other pipelines (which should be 
> visible as it was code that we wrote, even if it isn't used for Pisces) 
> took a more flexible approach, testing each segment for NaN and overflow 
> and ignoring individual segments until the shape became finite again. 
> This happens somewhere in the src/share/classes/sun/java2d/pipe classes...

Ah cool. In this case we can implement it quite easily as in the
attached patch. Seems the output is 1:1 the same as with the non-free
JDK6.

/Roman

> 
> 			...jim
> 
> Roman Kennke wrote:
> > Hi again,
> > 
> >> 3. NotANumberTest: Double.NaN isn't handled gracefully.
> > 
> > The problem here is that the renderer in OpenJDK is originally written
> > for ME and uses fixed point arithmetic. I can't think of a quick fix,
> > because shapes are processed by iterating over them, this means, by the
> > time we hit the NaN, we might already have processed (==rendered) some
> > of the shape, but your test seems to suggest that you expect nothing to
> > be rendered in this case. The specification doesn't say anything about
> > this particular problem (at least I can't find anything). One solution
> > would be to pre-check all the incoming shapes for NaN or other invalid
> > values (infinity, etc) and not go into the iteration at all. But this
> > seems like quite a big overhead to me. We could also make the
> > floating->fixed conversion to throw an exception, that we would have to
> > catch higher up in the call tree and rollback what has already been
> > rendered (which doesn't seem easy either, because in the case of
> > strokeTo() this lies outside of the pisces renderer).
> > 
> > /Roman
-- 
Dipl.-Inform. (FH) Roman Kennke, Software Engineer, http://kennke.org
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-48
USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt

-------------- next part --------------
diff --git a/src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java b/src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java
--- a/src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java
+++ b/src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java
@@ -236,13 +236,17 @@
         while (!pi.isDone()) {
             switch (pi.currentSegment(coords)) {
             case PathIterator.SEG_MOVETO:
-                lsink.moveTo(FloatToS15_16(coords[0]),
-                             FloatToS15_16(coords[1]));
+                if (coordOk(coords[0]) && coordOk(coords[1])) {
+                    lsink.moveTo(FloatToS15_16(coords[0]),
+                            FloatToS15_16(coords[1]));
+                }
                 break;
             case PathIterator.SEG_LINETO:
-                lsink.lineJoin();
-                lsink.lineTo(FloatToS15_16(coords[0]),
-                             FloatToS15_16(coords[1]));
+                if (coordOk(coords[0]) && coordOk(coords[1])) {
+                    lsink.lineJoin();
+                    lsink.lineTo(FloatToS15_16(coords[0]),
+                            FloatToS15_16(coords[1]));
+                }
                 break;
             case PathIterator.SEG_CLOSE:
                 lsink.close();
@@ -253,6 +257,10 @@
             pi.next();
         }
         lsink.end();
+    }
+
+    private boolean coordOk(float coord) {
+        return (! Float.isNaN(coord)) && (! Float.isInfinite(coord));
     }
 
     /**


More information about the 2d-dev mailing list