[OpenJDK 2D-Dev] Corner case drawing wide lines of zero length

Denis Lila dlila at redhat.com
Mon Jun 14 21:04:46 UTC 2010


I can see one slight problem with this.
moveTo will check whether "if (prev == LINE_TO) {" in line 488.
This should be changed to "if (prev == LINE_TO || atLeastOneLine) {".
If this is not done, and if there are many moveTo's, each followed by
a lineTo to a line of 0 length, no end caps will be drawn for any of
the lines except perhaps the last lineTo.

See bug 197: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=197
for reproducers, effects, and some more discussion on this.

Regards,
Denis Lila.

----- Original Message -----
From: "jon vanalten" <jon.vanalten at redhat.com>
To: 2d-dev at openjdk.java.net
Sent: Tuesday, June 8, 2010 10:10:21 AM GMT -05:00 US/Canada Eastern
Subject: Re: [OpenJDK 2D-Dev] Corner case drawing wide lines of zero length

<BUMP>

Hi, I sent this a while ago.  Wondering if anyone has any feedback?

thanks in advance,

jon



----- "jon vanalten" <jon.vanalten at redhat.com> wrote:

> Hi,
> 
> I am new to this list, hopefully it is okay that I post a potential
> fix to a very minor rendering bug.
> 
> I've been looking at a bug reported downstream at IcedTea:
> 
> http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=383
> 
> To summarize, if a line is drawn via Graphics2D.drawLine() of zero
> length but thickness greater than 1, the endcap decorations are not
> rendered.  This is because the sun.java2d.pisces.Stroker class ignores
> such line segments.  This is ideal in most situations drawing complex
> shapes, but when such a line segment is the entire shape the end
> result nothing at all is rendered.  The closed-source Sun JDK
> implementation does render endcap decorations in this case, and the
> documentation of the BasicStroke class related to this suggests that
> they should be rendered.
> 
> I've put together a (possibly straw-man) fix.  Please do pick it
> apart, I have never looked at the graphics implementation before
> trying to tackle this bug.  I basically add a boolean to indicate that
> the finish() step should be taken if *any* lineTo() call has occurred,
> and in the finish() step detect if there are any segments and if no
> manually draw in the caps (while allowing normal behaviour in other
> cases).
> 
> See webrev at:
> 
> http://icedtea.classpath.org/~vanaltj/webrevs/2d/zeroline/webrev/
> (or download)
> http://icedtea.classpath.org/~vanaltj/webrevs/2d/zeroline/webrev.zip
> 
> Your comments are appreciated.
> 
> cheers,
> 
> jon



More information about the 2d-dev mailing list