Mercurial > hg > release > icedtea7-forest-2.6 > jdk
changeset 8983:bcd7f2459237
8159495: Fix index offsets
8140530: Creating a VolatileImage with size 0,0 results in no longer working g2d.drawString
Reviewed-by: prr, psadhukhan
author | aivanov |
---|---|
date | Tue, 12 Jul 2016 16:31:40 +0300 |
parents | 70bc73318756 |
children | 171036221ed7 |
files | src/share/classes/sun/awt/image/SunVolatileImage.java src/solaris/classes/sun/java2d/x11/X11SurfaceDataProxy.java src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java src/solaris/native/sun/java2d/x11/X11SurfaceData.c |
diffstat | 5 files changed, 29 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/sun/awt/image/SunVolatileImage.java Fri Oct 14 18:05:46 2016 +0100 +++ b/src/share/classes/sun/awt/image/SunVolatileImage.java Tue Jul 12 16:31:40 2016 +0300 @@ -70,6 +70,10 @@ { this.comp = comp; this.graphicsConfig = graphicsConfig; + if (width <= 0 || height <= 0) { + throw new IllegalArgumentException("Width (" + width + ")" + + " and height (" + height + ") cannot be <= 0"); + } this.width = width; this.height = height; this.forcedAccelSurfaceType = accType;
--- a/src/solaris/classes/sun/java2d/x11/X11SurfaceDataProxy.java Fri Oct 14 18:05:46 2016 +0100 +++ b/src/solaris/classes/sun/java2d/x11/X11SurfaceDataProxy.java Tue Jul 12 16:31:40 2016 +0300 @@ -102,10 +102,13 @@ int w, int h) { if (cachedData == null) { - // Bitmask will be created lazily during the blit phase - cachedData = X11SurfaceData.createData(x11gc, w, h, - x11gc.getColorModel(), - null, 0, getTransparency()); + try { + // Bitmask will be created lazily during the blit phase + cachedData = X11SurfaceData.createData(x11gc, w, h, + x11gc.getColorModel(), + null, 0, getTransparency()); + } catch (OutOfMemoryError oome) { + } } return cachedData; }
--- a/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java Fri Oct 14 18:05:46 2016 +0100 +++ b/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java Tue Jul 12 16:31:40 2016 +0300 @@ -134,6 +134,9 @@ vImg = (SunVolatileImage) dst.getGraphicsConfig().createCompatibleVolatileImage(w, h, src.getTransparency()); vImg.setAccelerationPriority(1.0f); + if (!(vImg.getDestSurface() instanceof XRSurfaceData)) { + throw new InvalidPipeException("Could not create XRSurfaceData"); + } if (src.getTransparency() == SurfaceData.OPAQUE) { rgbTmpPM = new WeakReference<SunVolatileImage>(vImg); } else {
--- a/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java Fri Oct 14 18:05:46 2016 +0100 +++ b/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java Tue Jul 12 16:31:40 2016 +0300 @@ -59,8 +59,12 @@ public SurfaceData validateSurfaceData(SurfaceData srcData, SurfaceData cachedData, int w, int h) { if (cachedData == null) { - cachedData = XRSurfaceData.createData(xrgc, w, h, xrgc - .getColorModel(), null, 0, getTransparency()); + try { + cachedData = XRSurfaceData.createData(xrgc, w, h, + xrgc.getColorModel(), null, 0, + getTransparency()); + } catch (OutOfMemoryError oome) { + } } return cachedData; }
--- a/src/solaris/native/sun/java2d/x11/X11SurfaceData.c Fri Oct 14 18:05:46 2016 +0100 +++ b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c Tue Jul 12 16:31:40 2016 +0300 @@ -456,6 +456,15 @@ xsdo->drawable = drawable; xsdo->isPixmap = JNI_FALSE; } else { + /* + * width , height must be nonzero otherwise XCreatePixmap + * generates BadValue in error_handler + */ + if (width <= 0 || height <= 0 || width > 32767 || height > 32767) { + JNU_ThrowOutOfMemoryError(env, + "Can't create offscreen surface"); + return JNI_FALSE; + } xsdo->isPixmap = JNI_TRUE; /* REMIND: workaround for bug 4420220 on pgx32 boards: don't use DGA with pixmaps unless USE_DGA_PIXMAPS is set.