[OpenJDK 2D-Dev] [9] Review Request: 8167310 The graphics clip is incorrectly rounded for some fractional scales

Jim Graham james.graham at oracle.com
Mon Oct 10 18:31:45 UTC 2016

Hi Sergey,

Comments inline...

On 10/8/16 2:15 PM, Sergey Bylokhov wrote:
> On 08.10.16 0:58, Jim Graham wrote:
>> That looks great.  A couple of questions.
> An updated version and a comments inline:
> http://cr.openjdk.java.net/~serb/8167310/webrev.01
>> Test case:
>> Where do you get white gaps?  Is it in the line test?  If so, then
>> consider setting the line width higher (or drawing 2 lines per iteration
>> as I mention in the last paragraph).  I can illustrate this with the
>> following:
> Yes, it was in the lines. In the new version I changed the line width to 6. This value will fill the whole clip in all
> tested scales[0.1 - 4].
> I did not use two lines because I use "srcover+transparentColor" and two lines can produce one more color after
> overlapping.

OK, but you only need a line width of 2.0 to cover the gap regardless of scale.  Line width scales in user space so 
larger scales scale up the line width along with the clip region being rendered.  With STROKE_CONTROL on, 2.0 is plenty 
because the line is normalized (though I'm not sure the test should assume that).  WITH STROKE_PURE, 2.0 is precisely 
exactly the right amount.  Round-off error might theoretically bite us, so maybe 2.01 just to be safe.

Other comments...

In the drawImage case in the test, is there a reason to stretch the image to MAX_INT size?  Isn't (img,0,0,null) enough? 
  The issue with the MAX_INT arguments is that this then becomes not only a test of clipping, but a test for how our 
image scaling handles huge scales that might overflow.  Those should be tested independently if we fear there is a 
problem with image scaling.

Also, This line in the test case:

  161                 if (rgb != goldRGB && rgb != GREEN.getRGB()
  162                         && rgb != RED.getRGB()) {

Will give us a pass on the test as long as we made the same mistake for both the rect clip and the shape clip.  I think 
you want "(rgb != goldRGB) || (rgb != GREEN && rgb != RED)"...?


More information about the 2d-dev mailing list