From 03643bb61e581cc2f5fbe416951b2b70fc24836d Mon Sep 17 00:00:00 2001 From: prr Date: Mon, 25 Jul 2016 10:36:12 -0700 Subject: [PATCH] 8147542: ClassCastException when repainting after display resolution change Reviewed-by: prr, flar Contributed-by: alexey.ushakov@jetbrains.com --- src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java b/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java index 6a2f71405..a06a312bd 100644 --- a/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java +++ b/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java @@ -127,7 +127,11 @@ public class XRPMBlitLoops { 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 @@ public class XRPMBlitLoops { } 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); -- GitLab