Merge
diff --git a/make/sun/awt/mapfile-mawt-vers b/make/sun/awt/mapfile-mawt-vers
index f1b7143..05de1fd 100644
--- a/make/sun/awt/mapfile-mawt-vers
+++ b/make/sun/awt/mapfile-mawt-vers
@@ -424,6 +424,7 @@
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 479a55a..8f6ae42 100644
--- a/make/sun/xawt/mapfile-vers
+++ b/make/sun/xawt/mapfile-vers
@@ -374,6 +374,7 @@
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/share/classes/sun/font/StrikeCache.java b/src/share/classes/sun/font/StrikeCache.java
index a7aa1f5..46c7b7a 100644
--- a/src/share/classes/sun/font/StrikeCache.java
+++ b/src/share/classes/sun/font/StrikeCache.java
@@ -319,8 +319,7 @@
ArrayList<Long> gids = null;
for (int i = 0; i < glyphPtrs.length; i++) {
- if (glyphPtrs[i] != 0 && unsafe.getByte(glyphPtrs[i] + managedOffset) == 0
- && unsafe.getInt(glyphPtrs[i] + cacheCellOffset) != 0) {
+ if (glyphPtrs[i] != 0 && unsafe.getByte(glyphPtrs[i] + managedOffset) == 0) {
if (gids == null) {
gids = new ArrayList<Long>();
@@ -330,6 +329,8 @@
}
if (gids != null) {
+ // Any reference by the disposers to the native glyph ptrs
+ // must be done before this returns.
notifyDisposeListeners(gids);
}
}
@@ -345,8 +346,7 @@
for (int i=0; i < glyphPtrs.length; i++) {
if (glyphPtrs[i] != 0
- && unsafe.getByte(glyphPtrs[i] + managedOffset) == 0
- && unsafe.getInt(glyphPtrs[i] + cacheCellOffset) != 0) {
+ && unsafe.getByte(glyphPtrs[i] + managedOffset) == 0) {
if (gids == null) {
gids = new ArrayList<Long>();
@@ -356,6 +356,8 @@
}
if (gids != null) {
+ // Any reference by the disposers to the native glyph ptrs
+ // must be done before this returns.
notifyDisposeListeners(gids);
}
}
diff --git a/src/share/classes/sun/java2d/pipe/AAShapePipe.java b/src/share/classes/sun/java2d/pipe/AAShapePipe.java
index 8654bed..4cba5a0 100644
--- a/src/share/classes/sun/java2d/pipe/AAShapePipe.java
+++ b/src/share/classes/sun/java2d/pipe/AAShapePipe.java
@@ -109,7 +109,7 @@
Region clip = sg.getCompClip();
int abox[] = new int[4];
AATileGenerator aatg =
- renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, 0, 0,
+ renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, lw1, lw2,
clip, abox);
if (aatg == null) {
// Nothing to render
diff --git a/src/solaris/classes/sun/font/XRGlyphCache.java b/src/solaris/classes/sun/font/XRGlyphCache.java
index 9e76724..7dbb23a 100644
--- a/src/solaris/classes/sun/font/XRGlyphCache.java
+++ b/src/solaris/classes/sun/font/XRGlyphCache.java
@@ -70,9 +70,14 @@
try {
SunToolkit.awtLock();
- ArrayList<Integer> glyphIDList = new ArrayList<Integer>(glyphPtrList.size());
+ GrowableIntArray glyphIDList = new GrowableIntArray(1, glyphPtrList.size());
for (long glyphPtr : glyphPtrList) {
- glyphIDList.add(XRGlyphCacheEntry.getGlyphID(glyphPtr));
+ int glyphID = XRGlyphCacheEntry.getGlyphID(glyphPtr);
+
+ //Check if glyph hasn't been freed already
+ if (glyphID != 0) {
+ glyphIDList.addInt(glyphID);
+ }
}
freeGlyphs(glyphIDList);
} finally {
@@ -83,7 +88,6 @@
protected int getFreeGlyphID() {
if (freeGlyphIDs.size() > 0) {
int newID = freeGlyphIDs.remove(freeGlyphIDs.size() - 1);
- ;
return newID;
}
return nextID++;
@@ -246,7 +250,7 @@
glyph.setPinned();
}
- ArrayList<Integer> deleteGlyphList = new ArrayList<Integer>();
+ GrowableIntArray deleteGlyphList = new GrowableIntArray(1, 10);
int pixelsToRelease = cachedPixels - MAX_CACHED_PIXELS;
for (int i = cacheList.size() - 1; i >= 0 && pixelsToRelease > 0; i--) {
@@ -254,7 +258,7 @@
if (!entry.isPinned()) {
pixelsToRelease -= entry.getPixelCnt();
- deleteGlyphList.add(new Integer(entry.getGlyphID()));
+ deleteGlyphList.addInt(entry.getGlyphID());
}
}
@@ -265,26 +269,23 @@
freeGlyphs(deleteGlyphList);
}
- private void freeGlyphs(List<Integer> glyphIdList) {
+ private void freeGlyphs(GrowableIntArray glyphIdList) {
+ GrowableIntArray removedLCDGlyphs = new GrowableIntArray(1, 10);
+ GrowableIntArray removedGrayscaleGlyphs = new GrowableIntArray(1, 10);
- freeGlyphIDs.addAll(glyphIdList);
+ for (int i=0; i < glyphIdList.getSize(); i++) {
+ int glyphId = glyphIdList.getInt(i);
+ freeGlyphIDs.add(glyphId);
- GrowableIntArray removedLCDGlyphs = new GrowableIntArray(1, 1);
- GrowableIntArray removedGrayscaleGlyphs = new GrowableIntArray(1, 1);
-
- for (Integer glyphId : glyphIdList) {
- tmp.setValue(glyphId.intValue());
+ tmp.setValue(glyphId);
XRGlyphCacheEntry entry = cacheMap.get(tmp);
cachedPixels -= entry.getPixelCnt();
-
- int removedGlyphID = entry.getGlyphID();
- tmp.setValue(removedGlyphID);
cacheMap.remove(tmp);
if (entry.getGlyphSet() == grayGlyphSet) {
- removedGrayscaleGlyphs.addInt(removedGlyphID);
+ removedGrayscaleGlyphs.addInt(glyphId);
} else {
- removedLCDGlyphs.addInt(removedGlyphID);
+ removedLCDGlyphs.addInt(glyphId);
}
entry.setGlyphID(0);
diff --git a/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java b/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java
index f09d0f3..d8790b2 100644
--- a/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java
+++ b/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java
@@ -55,6 +55,8 @@
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 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 1a715ca..db16fdc 100644
--- a/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
+++ b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
@@ -375,6 +375,12 @@
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/XRBackendNative.c b/src/solaris/native/sun/java2d/x11/XRBackendNative.c
index 1ce26c6..f56e904 100644
--- a/src/solaris/native/sun/java2d/x11/XRBackendNative.c
+++ b/src/solaris/native/sun/java2d/x11/XRBackendNative.c
@@ -304,23 +304,27 @@
color.blue = blue;
if (rectCnt <= 256) {
- xRects = &sRects[0];
+ xRects = &sRects[0];
} else {
- xRects = (XRectangle *) malloc(sizeof(XRectangle) * rectCnt);
- if (xRects == NULL) {
- return;
- }
+ xRects = (XRectangle *) malloc(sizeof(XRectangle) * rectCnt);
+ if (xRects == NULL) {
+ return;
+ }
}
- if ((rects = (jint *) (*env)->GetPrimitiveArrayCritical(env, rectArray, NULL)) == NULL) {
- return;
+ if ((rects = (jint *)
+ (*env)->GetPrimitiveArrayCritical(env, rectArray, NULL)) == NULL) {
+ if (xRects != &sRects[0]) {
+ free(xRects);
+ }
+ return;
}
for (i=0; i < rectCnt; i++) {
- xRects[i].x = rects[i*4 + 0];
- xRects[i].y = rects[i*4 + 1];
- xRects[i].width = rects[i*4 + 2];
- xRects[i].height = rects[i*4 + 3];
+ xRects[i].x = rects[i*4 + 0];
+ xRects[i].y = rects[i*4 + 1];
+ xRects[i].width = rects[i*4 + 2];
+ xRects[i].height = rects[i*4 + 3];
}
XRenderFillRectangles(awt_display, op,
@@ -328,7 +332,7 @@
(*env)->ReleasePrimitiveArrayCritical(env, rectArray, rects, JNI_ABORT);
if (xRects != &sRects[0]) {
- free(xRects);
+ free(xRects);
}
}
@@ -610,17 +614,30 @@
Glyph *gid = (Glyph *) malloc(sizeof(Glyph) * glyphCnt);
if (xginfo == NULL || gid == NULL) {
- return;
+ if (xginfo != NULL) {
+ free(xginfo);
+ }
+ if (gid != NULL) {
+ free(gid);
+ }
+ return;
}
- if ((glyphInfoPtrs = (jlong *) (*env)->GetPrimitiveArrayCritical(env, glyphInfoPtrsArray, NULL)) == NULL) {
+ if ((glyphInfoPtrs = (jlong *)(*env)->
+ GetPrimitiveArrayCritical(env, glyphInfoPtrsArray, NULL)) == NULL)
+ {
+ free(xginfo);
+ free(gid);
return;
}
if ((pixelData = (unsigned char *)
- (*env)->GetPrimitiveArrayCritical(env, pixelDataArray, NULL)) == NULL) {
+ (*env)->GetPrimitiveArrayCritical(env, pixelDataArray, NULL)) == NULL)
+ {
(*env)->ReleasePrimitiveArrayCritical(env,
- glyphInfoPtrsArray, glyphInfoPtrs, JNI_ABORT);
+ glyphInfoPtrsArray, glyphInfoPtrs, JNI_ABORT);
+ free(xginfo);
+ free(gid);
return;
}
@@ -637,7 +654,7 @@
}
XRenderAddGlyphs(awt_display, glyphSet, &gid[0], &xginfo[0], glyphCnt,
- pixelData, pixelDataLength);
+ (const char*)pixelData, pixelDataLength);
(*env)->ReleasePrimitiveArrayCritical(env, glyphInfoPtrsArray, glyphInfoPtrs, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, pixelDataArray, pixelData, JNI_ABORT);
@@ -684,22 +701,44 @@
xelts = &selts[0];
}else {
xelts = (XGlyphElt32 *) malloc(sizeof(XGlyphElt32) * eltCnt);
+ if (xelts == NULL) {
+ return;
+ }
}
if (glyphCnt <= 256) {
xids = &sids[0];
- }else {
+ } else {
xids = (Glyph *) malloc(sizeof(Glyph) * glyphCnt);
+ if (xids == NULL) {
+ if (xelts != &selts[0]) {
+ free(xelts);
+ }
+ return;
+ }
}
- if ((ids = (jint *) (*env)->GetPrimitiveArrayCritical(env, glyphIDArray, NULL)) == NULL) {
- return;
+ if ((ids = (jint *)
+ (*env)->GetPrimitiveArrayCritical(env, glyphIDArray, NULL)) == NULL) {
+ if (xelts != &selts[0]) {
+ free(xelts);
+ }
+ if (xids != &sids[0]) {
+ free(xids);
+ }
+ return;
}
if ((elts = (jint *)
(*env)->GetPrimitiveArrayCritical(env, eltArray, NULL)) == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env,
glyphIDArray, ids, JNI_ABORT);
- return;
+ if (xelts != &selts[0]) {
+ free(xelts);
+ }
+ if (xids != &sids[0]) {
+ free(xids);
+ }
+ return;
}
for (i=0; i < glyphCnt; i++) {
@@ -724,11 +763,11 @@
(*env)->ReleasePrimitiveArrayCritical(env, eltArray, elts, JNI_ABORT);
if (xelts != &selts[0]) {
- free(xelts);
+ free(xelts);
}
if (xids != &sids[0]) {
- free(xids);
+ free(xids);
}
}
@@ -762,8 +801,12 @@
}
}
- if ((rects = (jint *) (*env)->GetPrimitiveArrayCritical(env, rectArray, NULL)) == NULL) {
- return;
+ if ((rects = (jint*)
+ (*env)->GetPrimitiveArrayCritical(env, rectArray, NULL)) == NULL) {
+ if (xRects != &sRects[0]) {
+ free(xRects);
+ }
+ return;
}
for (i=0; i < rectCnt; i++) {
diff --git a/src/solaris/native/sun/java2d/x11/XRSurfaceData.c b/src/solaris/native/sun/java2d/x11/XRSurfaceData.c
index 83fbec0..620f90f 100644
--- a/src/solaris/native/sun/java2d/x11/XRSurfaceData.c
+++ b/src/solaris/native/sun/java2d/x11/XRSurfaceData.c
@@ -114,3 +114,26 @@
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 */
+}