# HG changeset patch # User serb # Date 1425303284 -10800 # Node ID e3b07effb6e3dcb0b2b6ed24dc0a3f45e29fcb3a # Parent 5bfc7adc422aeebe22ab3a21565536cfa61f8961 8048782: OpenJDK: PiscesCache : xmax/ymax rounding up can cause RasterFormatException Reviewed-by: prr, flar Contributed-by: prasanta.sadhukhan@oracle.com diff -r 5bfc7adc422a -r e3b07effb6e3 jdk/src/java.desktop/share/classes/sun/java2d/pisces/PiscesCache.java --- a/jdk/src/java.desktop/share/classes/sun/java2d/pisces/PiscesCache.java Fri Feb 27 01:06:39 2015 +0300 +++ b/jdk/src/java.desktop/share/classes/sun/java2d/pisces/PiscesCache.java Mon Mar 02 16:34:44 2015 +0300 @@ -167,6 +167,15 @@ rowAARLE[row][1] = end; } + void getBBox(int bbox[]) { + // Since we add +1 to bboxX1,bboxY1 so when PTG asks for bbox, + // we will give after -1 + bbox[0] = bboxX0; + bbox[1] = bboxY0; + bbox[2] = bboxX1 - 1; + bbox[3] = bboxY1 - 1; + } + @Override public String toString() { String ret = "bbox = ["+ diff -r 5bfc7adc422a -r e3b07effb6e3 jdk/src/java.desktop/share/classes/sun/java2d/pisces/PiscesTileGenerator.java --- a/jdk/src/java.desktop/share/classes/sun/java2d/pisces/PiscesTileGenerator.java Fri Feb 27 01:06:39 2015 +0300 +++ b/jdk/src/java.desktop/share/classes/sun/java2d/pisces/PiscesTileGenerator.java Mon Mar 02 16:34:44 2015 +0300 @@ -76,10 +76,7 @@ } public void getBbox(int bbox[]) { - bbox[0] = cache.bboxX0; - bbox[1] = cache.bboxY0; - bbox[2] = cache.bboxX1; - bbox[3] = cache.bboxY1; + cache.getBBox(bbox); //System.out.println("bbox["+bbox[0]+", "+bbox[1]+" => "+bbox[2]+", "+bbox[3]+"]"); } diff -r 5bfc7adc422a -r e3b07effb6e3 jdk/test/sun/java2d/pisces/OpenJDKFillBug.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/java2d/pisces/OpenJDKFillBug.java Mon Mar 02 16:34:44 2015 +0300 @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.awt.Color; +import java.awt.Composite; +import java.awt.CompositeContext; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; +import java.awt.geom.GeneralPath; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; +import java.awt.image.RasterFormatException; + +/** + * @test + * @bug 8048782 + * @summary Test program that demonstrates PiscesRendering bug in + * OpenJDK 1.7.0.60 (and probably in all other OpenJDK versions, too). + */ + +public class OpenJDKFillBug +{ + /** + * Test program that demonstrates a bug in OpenJDK 1.7.0.60 (and + * probably in all other OpenJDK versions, too). To see the bug, simply run + * the 'main' program with OpenJDK. The bug makes the 'g2d.fill' + * method fail with the following exception: + * + * This bug is found in OpenJDK but also is present in OracleJDK + * if run with + * -Dsun.java2d.renderer=sun.java2d.pisces.PiscesRenderingEngine + * + * The bug is related to sun.java2d.pisces.PiscesCache constructor + * that accepts '(int minx,int miny,int maxx,int maxy)' arguments: + * the internal 'bboxX1' and 'bboxY1' are set to values one greater + * than given maximum X and Y values. Those maximum values are then + * later used in AAShapePipe' class 'renderTiles' method, where a + * Y/X loop eventually calls 'GeneralCompositePipe' class + * 'renderPathTile' method. In that method, the operation will + * eventually call 'IntegerInterleavedRaster' class + * 'createWritableChild' method with arguments: + * + *