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

Print this page

        

*** 37,46 **** --- 37,49 ---- import javax.swing.border.*; import javax.accessibility.*; import java.io.Serializable; + import sun.awt.image.OffScreenImage; + import sun.awt.image.SurfaceManager; + import sun.java2d.SunGraphics2D; /** * The "viewport" or "porthole" through which you see the underlying * information. When you scroll, what moves is the viewport. It is like
*** 752,771 **** // blit garbage into the exposed areas. Rectangle viewBounds = getView().getBounds(); if (!isOpaque()) { g.clipRect(0, 0, viewBounds.width, viewBounds.height); } ! if (backingStoreImage == null) { // Backing store is enabled but this is the first call to paint. // Create the backing store, paint it and then copy to g. // The backing store image will be created with the size of // the viewport. We must make sure the clip region is the // same size, otherwise when scrolling the backing image // the region outside of the clipped region will not be painted, // and result in empty areas. backingStoreImage = createImage(width, height); Rectangle clip = g.getClipBounds(); if (clip.width != width || clip.height != height) { if (!isOpaque()) { g.setClip(0, 0, Math.min(viewBounds.width, width), Math.min(viewBounds.height, height)); --- 755,784 ---- // blit garbage into the exposed areas. Rectangle viewBounds = getView().getBounds(); if (!isOpaque()) { g.clipRect(0, 0, viewBounds.width, viewBounds.height); } + int scale = g instanceof SunGraphics2D ? + ((SunGraphics2D)g).surfaceData.getDefaultScale() : 1; ! if (backingStoreImage == null || ! SurfaceManager.getImageScale(backingStoreImage) != scale) ! { // Backing store is enabled but this is the first call to paint. // Create the backing store, paint it and then copy to g. // The backing store image will be created with the size of // the viewport. We must make sure the clip region is the // same size, otherwise when scrolling the backing image // the region outside of the clipped region will not be painted, // and result in empty areas. + Window w = SwingUtilities.getWindowAncestor(this); + if (w instanceof JLightweightFrame) { + backingStoreImage = ((JLightweightFrame)w).createHiDPIImage(width, height); + ((OffScreenImage)backingStoreImage).setReturnLayoutSize(true); + } else { backingStoreImage = createImage(width, height); + } Rectangle clip = g.getClipBounds(); if (clip.width != width || clip.height != height) { if (!isOpaque()) { g.setClip(0, 0, Math.min(viewBounds.width, width), Math.min(viewBounds.height, height));