On 10/11/2016 10:13 PM, Sergey Bylokhov wrote:
On 11.10.16 21:54, Jim Graham wrote:
Additionally, for AA rendering, there is no such thing as
"setClip(someShape)" and "fill(sameShape)" being identical no matter how
much we predict which rules they may want because clips are inherently
non-AA and so the fuzzy pixels along the boundary of an AA shape will be
randomly clipped or included.

When all is said and done I feel (not very strongly) it would be best to
have clipping remain unaffected by the biasing of STROKE hints, but part
of that is driven by the fact that I think it can be fixed with a couple
of lines of code in SG2D/LoopPipe...

I guess a bottom line is that it is require an additional investigation. I am not exactly sure, but my expectation is that fillRect(x,y,w,h)/drawImage(x,y,w,h) + setClip(x,y,w,h) should work in a similar way(covers the same pixels). And the question should this behavior be exactly the same as fill(RectShape) + setClip(RectShape) is unclear (I am not sure is it a critical issue or not) Right now I tried to fix overlapping, which produce visible artifacts and were considered as a bugs. The next issue which I would like to fix is a overlapping of drawImage().
I just created a small sample [1] which fills a rectangle (x, y, w, y), creates an image with size (w, h) and draws the image into the area (x, y, w, h). With the floating point scale like 1.5 the image does not exactly fits the area filled by the rectangle (see image [2] generated by the code [1]).

This is because the Graphics.drawImage(...) calls DrawImage.renderImageXform() which uses floor and ceil methods for the region corner rounding:
        final int dx1 = Math.max((int) Math.floor(ddx1), clip.getLoX());
        final int dy1 = Math.max((int) Math.floor(ddy1), clip.getLoY());
        final int dx2 = Math.min((int) Math.ceil(ddx2), clip.getHiX());
        final int dy2 = Math.min((int) Math.ceil(ddy2), clip.getHiY());

But the Graphics.fillRect() falls down to the code which just cast the transformed coordinates to int.

Why the floor/ceil methods are used for the image region rounding?
Is it possible to change this to fit the rule for the filled rectangles rounding?

[1] http://cr.openjdk.java.net/~alexsch/fpapi/code/FillRectAndImageTest.java
[2] http://cr.openjdk.java.net/~alexsch/fpapi/screenshots/rect-and-image.png

Thanks,
Alexandr.



Reply via email to