changeset 12548:c0e157ac32e2

8147542: ClassCastException when repainting after display resolution change Reviewed-by: prr, flar Contributed-by: alexey.ushakov@jetbrains.com
author prr
date Mon, 25 Jul 2016 10:36:12 -0700
parents c7d0980af81a
children b4b06b5bc14f
files src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java	Wed Nov 29 16:29:54 2017 +0000
+++ b/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java	Mon Jul 25 10:36:12 2016 -0700
@@ -127,7 +127,11 @@
             vImgSurfaceType = SurfaceType.IntArgbPre;
         }
 
-        if (vImg == null || vImg.getWidth() < w || vImg.getHeight() < h) {
+        if (vImg == null || vImg.getWidth() < w || vImg.getHeight() < h ||
+            // Sometimes we get volatile image of wrong dest surface type,
+            // so recreating it
+            !(vImg.getDestSurface() instanceof XRSurfaceData))
+        {
             if (vImg != null) {
                 vImg.flush();
             }
@@ -145,6 +149,11 @@
         }
 
         Blit swToSurfaceBlit = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, vImgSurfaceType);
+
+        if (!(vImg.getDestSurface() instanceof XRSurfaceData)) {
+            throw new InvalidPipeException("wrong surface data type: " + vImg.getDestSurface());
+        }
+
         XRSurfaceData vImgSurface = (XRSurfaceData) vImg.getDestSurface();
         swToSurfaceBlit.Blit(src, vImgSurface, AlphaComposite.Src, null,
                              sx, sy, 0, 0, w, h);