--- old/src/share/classes/javax/swing/RepaintManager.java 2014-05-13 21:17:45.000000000 +0400 +++ new/src/share/classes/javax/swing/RepaintManager.java 2014-05-13 21:17:45.000000000 +0400 @@ -47,6 +47,10 @@ import com.sun.java.swing.SwingUtilities3; import sun.swing.SwingAccessor; import sun.swing.SwingUtilities2.RepaintListener; +import sun.awt.image.OffScreenImage; +import sun.awt.image.SurfaceManager; +import sun.java2d.SunGraphics2D; +import sun.swing.JLightweightFrame; /** * This class manages repaint requests, allowing the number @@ -1063,7 +1067,7 @@ return null; } } - + if (standardDoubleBuffer == null) { standardDoubleBuffer = new DoubleBufferInfo(); } @@ -1086,10 +1090,20 @@ height = Math.max(doubleBuffer.size.height, height); } + Graphics g = c.getGraphics(); + int scale = g instanceof SunGraphics2D ? + ((SunGraphics2D)g).surfaceData.getDefaultScale() : 1; + Image result = doubleBuffer.image; - if (doubleBuffer.image == null) { - result = c.createImage(width , height); + if (doubleBuffer.image == null || + SurfaceManager.getImageScale(doubleBuffer.image) != scale) + { + if (w instanceof JLightweightFrame) { + result = ((JLightweightFrame)w).createHiDPIImage(width, height); + } else { + result = c.createImage(width, height); + } doubleBuffer.size = new Dimension(width, height); if (c instanceof JComponent) { ((JComponent)c).setCreatedDoubleBuffer(true); @@ -1552,10 +1566,16 @@ Graphics g, int clipX, int clipY, int clipW, int clipH) { Graphics osg = image.getGraphics(); - int bw = Math.min(clipW, image.getWidth(null)); - int bh = Math.min(clipH, image.getHeight(null)); + int lw = image.getWidth(null); + int lh = image.getHeight(null); + if (image instanceof OffScreenImage) { + lw = ((OffScreenImage)image).getLayoutWidth(); + lh = ((OffScreenImage)image).getLayoutHeight(); + } + int bw = Math.min(clipW, lw); + int bh = Math.min(clipH, lh); int x,y,maxx,maxy; - + try { for(x = clipX, maxx = clipX+clipW; x < maxx ; x += bw ) { for(y=clipY, maxy = clipY + clipH; y < maxy ; y += bh) { @@ -1576,10 +1596,10 @@ final Graphics2D g2d = (Graphics2D) g; final Composite oldComposite = g2d.getComposite(); g2d.setComposite(AlphaComposite.Src); - g2d.drawImage(image, x, y, c); + g2d.drawImage(image, x, y, lw, lh, c); g2d.setComposite(oldComposite); } else { - g.drawImage(image, x, y, c); + g.drawImage(image, x, y, lw, lh, c); } osg.translate(x, y); }