[OpenJDK 2D-Dev] [100303] Graphics: custom Composite + anti-aliasing = RasterFormatException

Matthias Wienand matthias.wienand at itemis.de
Tue Mar 5 13:29:04 UTC 2013


when drawing outside of the client area while using a custom Composite when
anti-aliasing is enabled, then a RasterFormatException is thrown. When
anti-aliasing is disabled, the behavior is as expected, i.e. the drawing is
correctly clipped and the custom Composite is correctly applied. I opened a
bug ticket [1] where you can find a small program demonstrating the issue.

The exception is thrown when the Raster objects for the custom Composite are
constructed. (sun.java2d.pipe.GeneralCompositePipe#renderPathTile(...))

I opened a question at stackoverflow.com [2] to resolve the problem, but could
not find a way to get it working without changing AWT source code. I do not
have much knowledge of the AWT source code, nonetheless I have a guess where
to change it.

Fortunately, it seems to be an "off by one" error, considering that the
RasterFormatException is thrown because a Raster's bounds are exceeded by
exactly one. When you follow the execution flow to find out where the bounds
of the drawing are computed, then you end up at the
sun.java2d.pisces.PiscesCache#PiscesCache(...) constructor:

    PiscesCache(int minx, int miny, int maxx, int maxy) {
        assert maxy >= miny && maxx >= minx;
        bboxX0 = minx;
        bboxY0 = miny;
        bboxX1 = maxx + 1;
        bboxY1 = maxy + 1;

My guess is, that the bboxX1 and bboxY1 values are off by one. The passed-in
maxx and maxy values are inclusive, and my observation is, that the bboxX1 and
bboxY1 values shall be inclusive, too. At least, removing the addition solves
the problem for me.

best regards,

[1] https://bugs.openjdk.java.net/show_bug.cgi?id=100303
[2] http://stackoverflow.com/questions/1462588/java-awt-custom-

Matthias Wienand

Telefon: +49 231 98 60 210
Telefax: +49 231 98 60 211

matthias.wienand at itemis.de

itemis AG
Am Brambusch 15-24
44536 Lünen

Rechtlicher Hinweis:

Amtsgericht Dortmund, HRB 20621

Vorstand: Jens Wagener (Vors.), Wolfgang Neuhaus, Dr. Georg Pietrek, Jens Trompeter, Sebastian Neus
Aufsichtsrat: Dr. Burkhard Igel (Vors.), Stephan Grollmann, Michael Neuhaus

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20130305/356c48fa/signature.asc>

More information about the 2d-dev mailing list