# HG changeset patch # User ssadetsky # Date 1493752255 25200 # Node ID 0b4642f22ee61b1011f07c14251cffd9b171ce6f # Parent aefe4c345bd2f60d7c429d0c53b6955c2d3dbd37 8159902: OGL surfaces are not HiDPI compatible on Linux/Solaris Reviewed-by: prr, serb diff -r aefe4c345bd2 -r 0b4642f22ee6 jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXSurfaceData.java --- a/jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXSurfaceData.java Tue May 02 11:24:21 2017 -0700 +++ b/jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXSurfaceData.java Tue May 02 12:10:55 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, 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 @@ -112,11 +112,13 @@ } public static class GLXWindowSurfaceData extends GLXSurfaceData { + protected final int scale; public GLXWindowSurfaceData(X11ComponentPeer peer, GLXGraphicsConfig gc) { super(peer, gc, peer.getColorModel(), WINDOW); + scale = gc.getScale(); } public SurfaceData getReplacement() { @@ -126,6 +128,8 @@ public Rectangle getBounds() { Rectangle r = peer.getBounds(); r.x = r.y = 0; + r.width = (int) Math.ceil(r.width * scale); + r.height = (int) Math.ceil(r.height * scale); return r; } @@ -135,6 +139,16 @@ public Object getDestination() { return peer.getTarget(); } + + @Override + public double getDefaultScaleX() { + return scale; + } + + @Override + public double getDefaultScaleY() { + return scale; + } } /** @@ -177,6 +191,7 @@ private Image offscreenImage; private int width, height; + private final int scale; public GLXOffScreenSurfaceData(X11ComponentPeer peer, GLXGraphicsConfig gc, @@ -186,11 +201,12 @@ { super(peer, gc, cm, type); - this.width = width; - this.height = height; + scale = gc.getDevice().getScaleFactor(); + this.width = width * scale; + this.height = height * scale; offscreenImage = image; - initSurface(width, height); + initSurface(this.width, this.height); } public SurfaceData getReplacement() { @@ -201,6 +217,8 @@ if (type == FLIP_BACKBUFFER) { Rectangle r = peer.getBounds(); r.x = r.y = 0; + r.width = (int) Math.ceil(r.width * scale); + r.height = (int) Math.ceil(r.height * scale); return r; } else { return new Rectangle(width, height); @@ -213,5 +231,15 @@ public Object getDestination() { return offscreenImage; } + + @Override + public double getDefaultScaleX() { + return scale; + } + + @Override + public double getDefaultScaleY() { + return scale; + } } } diff -r aefe4c345bd2 -r 0b4642f22ee6 jdk/test/javax/swing/JInternalFrame/8069348/bug8069348.java --- a/jdk/test/javax/swing/JInternalFrame/8069348/bug8069348.java Tue May 02 11:24:21 2017 -0700 +++ b/jdk/test/javax/swing/JInternalFrame/8069348/bug8069348.java Tue May 02 12:10:55 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -37,7 +37,7 @@ /** * @test * @key headful - * @bug 8069348 + * @bug 8069348 8159902 * @summary SunGraphics2D.copyArea() does not properly work for scaled graphics * @author Alexandr Scherbatiy * @modules java.desktop/sun.awt