From d4aed30b975a3c7ac9d13b286e674860ba2c2c25 Mon Sep 17 00:00:00 2001 From: ceisserer Date: Tue, 1 Mar 2011 14:49:53 -0800 Subject: [PATCH] 6974985: Jave2Demo threw exceptions when xrender enabled in OEL5.5 Reviewed-by: prr --- make/sun/awt/mapfile-mawt-vers | 1 + make/sun/xawt/mapfile-vers | 1 + .../classes/sun/java2d/xr/XRSurfaceData.java | 13 +++++++++++ .../native/sun/java2d/x11/X11SurfaceData.c | 6 +++++ .../native/sun/java2d/x11/XRSurfaceData.c | 23 +++++++++++++++++++ 5 files changed, 44 insertions(+) diff --git a/make/sun/awt/mapfile-mawt-vers b/make/sun/awt/mapfile-mawt-vers index f1b7143e9..05de1fdd5 100644 --- a/make/sun/awt/mapfile-mawt-vers +++ b/make/sun/awt/mapfile-mawt-vers @@ -424,6 +424,7 @@ SUNWprivate_1.1 { Java_sun_java2d_xr_XRSurfaceData_initXRPicture; Java_sun_java2d_xr_XRSurfaceData_initIDs; Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; + Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; Java_sun_java2d_xr_XRBackendNative_initIDs; Java_sun_java2d_xr_XIDGenerator_bufferXIDs; Java_sun_java2d_xr_XRBackendNative_freeGC; diff --git a/make/sun/xawt/mapfile-vers b/make/sun/xawt/mapfile-vers index 479a55a80..8f6ae42fe 100644 --- a/make/sun/xawt/mapfile-vers +++ b/make/sun/xawt/mapfile-vers @@ -374,6 +374,7 @@ SUNWprivate_1.1 { Java_sun_java2d_xr_XRSurfaceData_initXRPicture; Java_sun_java2d_xr_XRSurfaceData_initIDs; Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; + Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; Java_sun_java2d_xr_XRBackendNative_initIDs; Java_sun_java2d_xr_XRBackendNative_freeGC; Java_sun_java2d_xr_XRBackendNative_createGC; diff --git a/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java b/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java index f09d0f3de..d8790b2cb 100644 --- a/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java +++ b/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java @@ -55,6 +55,8 @@ public abstract class XRSurfaceData extends XSurfaceData { native void initXRPicture(long xsdo, int pictForm); + native void freeXSDOPicture(long xsdo); + public static final String DESC_BYTE_A8_X11 = "Byte A8 Pixmap"; public static final String DESC_INT_RGB_X11 = "Integer RGB Pixmap"; public static final String DESC_INT_ARGB_X11 = "Integer ARGB-Pre Pixmap"; @@ -531,6 +533,17 @@ public abstract class XRSurfaceData extends XSurfaceData { public Object getDestination() { return peer.getTarget(); } + + public void invalidate() { + try { + SunToolkit.awtLock(); + freeXSDOPicture(getNativeOps()); + }finally { + SunToolkit.awtUnlock(); + } + + super.invalidate(); + } } public static class XRInternalSurfaceData extends XRSurfaceData { diff --git a/src/solaris/native/sun/java2d/x11/X11SurfaceData.c b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c index 1a715ca13..db16fdc52 100644 --- a/src/solaris/native/sun/java2d/x11/X11SurfaceData.c +++ b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c @@ -375,6 +375,12 @@ X11SD_Dispose(JNIEnv *env, SurfaceDataOps *ops) AWT_LOCK(); xsdo->invalid = JNI_TRUE; + + if (xsdo->xrPic != None) { + XRenderFreePicture(awt_display, xsdo->xrPic); + xsdo->xrPic = None; + } + if (xsdo->isPixmap == JNI_TRUE && xsdo->drawable != 0) { #ifdef MITSHM if (xsdo->shmPMData.shmSegInfo != NULL) { diff --git a/src/solaris/native/sun/java2d/x11/XRSurfaceData.c b/src/solaris/native/sun/java2d/x11/XRSurfaceData.c index 83fbec0c3..620f90f76 100644 --- a/src/solaris/native/sun/java2d/x11/XRSurfaceData.c +++ b/src/solaris/native/sun/java2d/x11/XRSurfaceData.c @@ -114,3 +114,26 @@ Java_sun_java2d_xr_XRSurfaceData_XRInitSurface(JNIEnv *env, jclass xsd, XShared_initSurface(env, xsdo, depth, width, height, drawable); #endif /* !HEADLESS */ } + + + +JNIEXPORT void JNICALL +Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture(JNIEnv *env, jobject xsd, + jlong pXSData) +{ +#ifndef HEADLESS + X11SDOps *xsdo; + + J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_freeXSDOPicture"); + + xsdo = X11SurfaceData_GetOps(env, xsd); + if (xsdo == NULL) { + return; + } + + if(xsdo->xrPic != None) { + XRenderFreePicture(awt_display, xsdo->xrPic); + xsdo->xrPic = None; + } +#endif /* !HEADLESS */ +} -- GitLab