--- old/src/java.desktop/windows/native/libawt/java2d/d3d/D3DVertexCacher.cpp 2016-09-05 13:25:57.768289500 +0300 +++ new/src/java.desktop/windows/native/libawt/java2d/d3d/D3DVertexCacher.cpp 2016-09-05 13:25:57.111289500 +0300 @@ -109,12 +109,13 @@ // Horiz/vertical #define HV_FF1 ( 0.0f) -#define HV_FF2 ( 0.51f) +#define HV_FF2 ( 0.501f) // For the record: value below (or larger) is required for Intel 855, but // breaks Nvidia, ATI and Intel 965, and since the pipeline is disabled on // 855 anyway we'll use 0.51f. //#define HV_FF2 ( 0.5315f) #define HV_FF3 (-0.2f) +#define HV_FF4 ( 0.51f) // single pixel #define SP_FF4 ( 0.3f) @@ -251,10 +252,10 @@ fx2 = fx1; if (y1 > y2) { fy1 = (float)y2+HV_FF3; - fy2 = (float)y1+HV_FF2; + fy2 = (float)y1+HV_FF4; } else { fy1 = (float)y1+HV_FF3; - fy2 = (float)y2+HV_FF2; + fy2 = (float)y2+HV_FF4; } } else { // diagonal @@ -447,9 +448,9 @@ // horiz: bottom left - bottom right ADD_LINE_XYC(fx1+1.0f+HV_FF3, fy2+HV_FF1, fx2+HV_FF2, fy2+HV_FF1,color); // vert : top right - bottom right - ADD_LINE_XYC(fx2+HV_FF1, fy1+HV_FF3, fx2+HV_FF1, fy2-1.0f+HV_FF2,color); + ADD_LINE_XYC(fx2+HV_FF1, fy1+HV_FF3, fx2+HV_FF1, fy2-1.0f+HV_FF4,color); // vert : top left - bottom left - ADD_LINE_XYC(fx1+HV_FF1, fy1+1.0f+HV_FF3, fx1+HV_FF1, fy2+HV_FF2,color); + ADD_LINE_XYC(fx1+HV_FF1, fy1+1.0f+HV_FF3, fx1+HV_FF1, fy2+HV_FF4,color); } return res; } --- /dev/null 2016-09-05 13:26:01.000000000 +0300 +++ new/test/java/awt/Graphics2D/RenderRectTest/RenderRectTest.java 2016-09-05 13:26:00.771289500 +0300 @@ -0,0 +1,111 @@ +/* + * 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. + */ + + +/** + * @test + * @bug 8146042 + * @run main RenderRectTest + */ + +import java.awt.*; + +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.awt.image.VolatileImage; + + +public class RenderRectTest { + + public static void main(String[] args) throws Exception { + GraphicsConfiguration gc = + GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(); + + AffineTransform transform = gc.getDefaultTransform(); + if(transform.getScaleX() == 1 && transform.getScaleY() == 1) { + VolatileImage vi = gc.createCompatibleVolatileImage(12, 12); + Graphics2D g = vi.createGraphics(); + g.setColor(Color.black); + g.drawRect(1, 1, 9, 9); + g.dispose(); + BufferedImage capture = vi.getSnapshot(); + + int w = capture.getWidth(); + int h = capture.getHeight(); + for (int y = 0; y < h >> 1; y++) { + for (int x = 0; x < w >> 1; x++) { + if (x > 0 && y > 0 && (x == 1 || y == 1)) { + if ((capture.getRGB(x, y) + | capture.getRGB(x, h - 1 - y) + | capture.getRGB(w - 1 - x, y) + | capture.getRGB(w - 1 - x, h - 1 - y)) != + Color.black.getRGB()) { + throw new RuntimeException("Wrong rectangle"); + } + } else { + if ((capture.getRGB(x, y) + & capture.getRGB(x, h - 1 - y) + & capture.getRGB(w - 1 - x, y) + & capture.getRGB(w - 1 - x, h - 1 - y)) != + Color.white.getRGB()) { + throw new RuntimeException("Wrong rectangle"); + } + } + } + } + } else { + VolatileImage vi = gc.createCompatibleVolatileImage(12, 12); + Graphics2D g = vi.createGraphics(); + g.setColor(Color.black); + g.drawRect(1, 1, 9, 9); + g.dispose(); + + BufferedImage i1 = new BufferedImage((int)(12 * transform.getScaleX()), + (int)(12 * transform.getScaleY()), BufferedImage.TYPE_4BYTE_ABGR_PRE); + g = i1.createGraphics(); + g.drawImage(vi, 0, 0, i1.getWidth(), i1.getHeight(), null); + g.dispose(); + + + BufferedImage i2 = gc.createCompatibleImage(i1.getWidth(), i1.getHeight()); + g = i2.createGraphics(); + g.setBackground(Color.white); + g.clearRect(0, 0, i2.getWidth(), i2.getHeight()); + g.setTransform(transform); + g.setColor(Color.black); + g.drawRect(1, 1, 9, 9); + g.dispose(); + + int w = i1.getWidth(); + int h = i1.getHeight(); + for (int y = 0; y < h; y++) { + for (int x = 0; x < w ; x++) { + if (i1.getRGB(x, y) != i2.getRGB(x, y)) { + throw new RuntimeException("Rectangles are different"); + } + } + } + } + } +}