Path: blob/master/test/jdk/sun/java2d/marlin/Renderer/Test7019861.java
41152 views
/*1* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 701986126*27* @summary Verifies that the last scanline isn't skipped when doing28* antialiased rendering.29*30* @run main Test701986131*/3233import java.awt.BasicStroke;34import java.awt.Color;35import java.awt.Graphics2D;36import java.awt.geom.Path2D;37import java.awt.image.BufferedImage;38import java.util.Arrays;3940import static java.awt.RenderingHints.*;4142public class Test7019861 {4344public static void main(String[] argv) throws Exception {45BufferedImage im = getWhiteImage(30, 30);46Graphics2D g2 = (Graphics2D)im.getGraphics();47g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);48g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);49g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));50g2.setBackground(Color.white);51g2.setColor(Color.black);5253Path2D p = getPath(0, 0, 20);54g2.draw(p);5556if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) {57throw new Exception("This pixel should be black");58}59}6061private static Path2D getPath(int x, int y, int len) {62Path2D p = new Path2D.Double();63p.moveTo(x, y);64p.quadTo(x + len, y, x + len, y + len);65return p;66}6768private static BufferedImage getWhiteImage(int w, int h) {69BufferedImage ret = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);70final int[] white = new int[w * h];71Arrays.fill(white, 0xffffff);72ret.setRGB(0, 0, w, h, white, 0, w);73return ret;74}75}767778