--- old/src/java.desktop/windows/native/libawt/java2d/d3d/D3DVertexCacher.cpp 2016-09-09 02:02:18.327888600 +0300 +++ new/src/java.desktop/windows/native/libawt/java2d/d3d/D3DVertexCacher.cpp 2016-09-09 02:02:17.735313400 +0300 @@ -211,6 +211,16 @@ RETURN_STATUS_IF_FAILED(res); lpD3DDevice->SetFVF(D3DFVF_J2DLVERTEX); + + fudge2 = HV_FF2; + if (fudge2 > 0) { + D3DADAPTER_IDENTIFIER9 aid; + if (SUCCEEDED(pCtx->Get3DObject()->GetAdapterIdentifier(pCtx-> + getAdapterOrdinal(), 0, &aid)) && aid.VendorId == 0x8086) { + // Intel + fudge2 -= 0.09f; + } + } return res; } @@ -233,10 +243,10 @@ if (x1 > x2) { fx1 = (float)x2+HV_FF3; - fx2 = (float)x1+HV_FF2; + fx2 = (float)x1+fudge2; } else if (x1 < x2) { fx1 = (float)x1+HV_FF3; - fx2 = (float)x2+HV_FF2; + fx2 = (float)x2+fudge2; } else { // single point, offset a little so that a single // pixel is rendered @@ -251,10 +261,10 @@ fx2 = fx1; if (y1 > y2) { fy1 = (float)y2+HV_FF3; - fy2 = (float)y1+HV_FF2; + fy2 = (float)y1+fudge2; } else { fy1 = (float)y1+HV_FF3; - fy2 = (float)y2+HV_FF2; + fy2 = (float)y2+fudge2; } } else { // diagonal @@ -387,7 +397,7 @@ reqVerts -= vertsInBatch; do { x1 = ((float)*(scanlines++)) +HV_FF3; - x2 = ((float)*(scanlines++)) +HV_FF2; + x2 = ((float)*(scanlines++)) +fudge2; y = ((float)*(scanlines++)) +HV_FF1; ADD_LINE_XYC(x1, y, x2, y, color); vertsInBatch -= 2; @@ -443,13 +453,13 @@ float fy2 = (float)y2; // horiz: top left - top right - ADD_LINE_XYC(fx1+HV_FF3, fy1+HV_FF1, fx2-1.0f+HV_FF2, fy1+HV_FF1,color); + ADD_LINE_XYC(fx1+HV_FF3, fy1+HV_FF1, fx2-1.0f+fudge2, fy1+HV_FF1,color); // horiz: bottom left - bottom right - ADD_LINE_XYC(fx1+1.0f+HV_FF3, fy2+HV_FF1, fx2+HV_FF2, fy2+HV_FF1,color); + ADD_LINE_XYC(fx1+1.0f+HV_FF3, fy2+HV_FF1, fx2+fudge2, 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+fudge2,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+fudge2,color); } return res; } --- old/src/java.desktop/windows/native/libawt/java2d/d3d/D3DVertexCacher.h 2016-09-09 02:02:21.661311900 +0300 +++ new/src/java.desktop/windows/native/libawt/java2d/d3d/D3DVertexCacher.h 2016-09-09 02:02:21.063236000 +0300 @@ -103,6 +103,7 @@ IDirect3DDevice9 *lpD3DDevice; D3DContext *pCtx; jint color; + float fudge2; }; #endif // D3DVERTEXCACHER_H --- old/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.h 2016-09-09 02:02:24.772206900 +0300 +++ new/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.h 2016-09-09 02:02:24.169630400 +0300 @@ -263,6 +263,7 @@ * a BeginScene is pending */ HRESULT EndScene(); + UINT getAdapterOrdinal() { return adapterOrdinal; } /** * Fields that track native-specific state. --- old/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h 2016-09-09 02:02:27.924107200 +0300 +++ new/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h 2016-09-09 02:02:27.333532200 +0300 @@ -51,9 +51,6 @@ static const ADAPTER_INFO badHardware[] = { - // All Intel Chips. - { 0x8086, ALL_DEVICEIDS, NO_VERSION, OS_ALL }, - // ATI Mobility Radeon X1600, X1400, X1450, X1300, X1350 // Reason: workaround for 6613066, 6687166 // X1300 (four sub ids) --- /dev/null 2016-09-09 02:02:31.000000000 +0300 +++ new/test/java/awt/Graphics2D/RenderRectTest/RenderRectTest.java 2016-09-09 02:02:30.324412000 +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"); + } + } + } + } + } +}