8197499: RepaintManager does not increase double buffer after attaching a device with higher resolution
authoravu
Thu, 15 Feb 2018 17:20:57 -0800
changeset 49086 96ea4dff640e
parent 49085 cf931670015b
child 49087 68b37374319c
8197499: RepaintManager does not increase double buffer after attaching a device with higher resolution Reviewed-by: serb, prr
src/java.desktop/share/classes/javax/swing/RepaintManager.java
--- a/src/java.desktop/share/classes/javax/swing/RepaintManager.java	Thu Feb 15 14:20:44 2018 +0530
+++ b/src/java.desktop/share/classes/javax/swing/RepaintManager.java	Thu Feb 15 17:20:57 2018 -0800
@@ -110,6 +110,8 @@
 
     private Dimension doubleBufferMaxSize;
 
+    private boolean isCustomMaxBufferSizeSet = false;
+
     // Support for both the standard and volatile offscreen buffers exists to
     // provide backwards compatibility for the [rare] programs which may be
     // calling getOffScreenBuffer() and not expecting to get a VolatileImage.
@@ -335,7 +337,13 @@
     }
 
     private void displayChanged() {
-        clearImages();
+        if (isCustomMaxBufferSizeSet) {
+            clearImages();
+        } else {
+            // Reset buffer maximum size to get valid size from updated graphics
+            // environment in getDoubleBufferMaximumSize()
+            setDoubleBufferMaximumSize(null);
+        }
     }
 
     /**
@@ -1156,8 +1164,10 @@
     public void setDoubleBufferMaximumSize(Dimension d) {
         doubleBufferMaxSize = d;
         if (doubleBufferMaxSize == null) {
+            isCustomMaxBufferSizeSet = false;
             clearImages();
         } else {
+            isCustomMaxBufferSizeSet = true;
             clearImages(d.width, d.height);
         }
     }