src/share/classes/javax/swing/RepaintManager.java

Print this page

        

*** 43,52 **** --- 43,56 ---- import sun.misc.JavaSecurityAccess; import sun.misc.SharedSecrets; import sun.security.action.GetPropertyAction; import com.sun.java.swing.SwingUtilities3; + 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 * of repaints to be minimized, for example by collapsing multiple * requests into a single repaint for members of a component tree.
*** 1071,1084 **** } width = Math.max(doubleBuffer.size.width, width); height = Math.max(doubleBuffer.size.height, height); } Image result = doubleBuffer.image; ! if (doubleBuffer.image == null) { ! result = c.createImage(width , height); doubleBuffer.size = new Dimension(width, height); if (c instanceof JComponent) { ((JComponent)c).setCreatedDoubleBuffer(true); doubleBuffer.image = result; } --- 1075,1098 ---- } width = Math.max(doubleBuffer.size.width, width); 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 || ! 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); doubleBuffer.image = result; }
*** 1510,1521 **** */ protected void paintDoubleBuffered(JComponent c, Image image, 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 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) { --- 1524,1541 ---- */ protected void paintDoubleBuffered(JComponent c, Image image, Graphics g, int clipX, int clipY, int clipW, int clipH) { Graphics osg = image.getGraphics(); ! 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) {
*** 1534,1547 **** if (volatileBufferType != Transparency.OPAQUE && g instanceof Graphics2D) { final Graphics2D g2d = (Graphics2D) g; final Composite oldComposite = g2d.getComposite(); g2d.setComposite(AlphaComposite.Src); ! g2d.drawImage(image, x, y, c); g2d.setComposite(oldComposite); } else { ! g.drawImage(image, x, y, c); } osg.translate(x, y); } } } finally { --- 1554,1567 ---- if (volatileBufferType != Transparency.OPAQUE && g instanceof Graphics2D) { final Graphics2D g2d = (Graphics2D) g; final Composite oldComposite = g2d.getComposite(); g2d.setComposite(AlphaComposite.Src); ! g2d.drawImage(image, x, y, lw, lh, c); g2d.setComposite(oldComposite); } else { ! g.drawImage(image, x, y, lw, lh, c); } osg.translate(x, y); } } } finally {