Merge
diff --git a/.hgtags b/.hgtags
index 8e633c7..f4d0b34 100644
--- a/.hgtags
+++ b/.hgtags
@@ -467,3 +467,8 @@
bd2ad7acb217391747dae8263c090483af454313 jdk8u65-b07
d215cd281678e4b89a4155755cd6e03e37b7e9b1 jdk8u65-b08
e9de15763a5a3cef64ef1d4bc40a018d4d572325 jdk8u65-b09
+e9f82302d5fdef8a0976640e09363895e9dcde3c jdk8u66-b00
+64d7bd4e98150447916f210e3bfd6875a4c2728a jdk8u66-b01
+d8210091911b14930192abd3138ee37c281fb632 jdk8u66-b02
+b3773a2b6bf64c1df4db2b94f822b5ffb17eacc9 jdk8u66-b07
+6751966e4e943dba0f5640505530789dc4d184bf jdk8u66-b08
diff --git a/make/lib/Awt2dLibraries.gmk b/make/lib/Awt2dLibraries.gmk
index ac7da1c..2c843f5 100644
--- a/make/lib/Awt2dLibraries.gmk
+++ b/make/lib/Awt2dLibraries.gmk
@@ -763,6 +763,102 @@
##########################################################################################
+ifeq ($(BUILD_HEADLESS), true)
+ # Mac and Windows only use the native AWT lib, do not build libawt_headless
+ ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),)
+
+ LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/share/native/sun/font \
+ $(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
+ $(JDK_TOPDIR)/src/solaris/native/sun/font \
+ $(JDK_TOPDIR)/src/solaris/native/sun/awt \
+ $(JDK_TOPDIR)/src/solaris/native/sun/java2d/opengl \
+ $(JDK_TOPDIR)/src/solaris/native/sun/java2d/x11
+
+ ifeq ($(OPENJDK_TARGET_OS), macosx)
+ LIBAWT_HEADLESS_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/font
+ endif
+
+ LIBAWT_HEADLESS_CFLAGS := -DHEADLESS=true \
+ -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
+ $(CUPS_CFLAGS) \
+ $(X_CFLAGS) \
+ -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
+ -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d \
+ -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
+ -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
+ -I$(JDK_TOPDIR)/src/share/native/sun/awt/image \
+ -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
+ -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
+ -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/jdga \
+ $(foreach dir, $(LIBAWT_HEADLESS_DIRS), -I$(dir))
+
+ LIBAWT_HEADLESS_FILES := \
+ awt_Font.c \
+ HeadlessToolkit.c \
+ fontpath.c \
+ VDrawingArea.c \
+ X11Color.c \
+ X11Renderer.c \
+ X11PMBlitLoops.c \
+ X11SurfaceData.c \
+ X11FontScaler_md.c \
+ X11TextRenderer_md.c \
+ OGLBlitLoops.c \
+ OGLBufImgOps.c \
+ OGLContext.c \
+ OGLFuncs.c \
+ OGLMaskBlit.c \
+ OGLMaskFill.c \
+ OGLPaints.c \
+ OGLRenderQueue.c \
+ OGLRenderer.c \
+ OGLSurfaceData.c \
+ OGLTextRenderer.c \
+ OGLVertexCache.c \
+ GLXGraphicsConfig.c \
+ GLXSurfaceData.c \
+ AccelGlyphCache.c \
+ CUPSfuncs.c
+
+ LIBAWT_HEADLESS_REORDER :=
+ ifeq ($(OPENJDK_TARGET_OS), solaris)
+ ifneq ($(OPENJDK_TARGET_CPU), x86_64)
+ LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU)
+ endif
+ endif
+
+ $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS, \
+ LIBRARY := awt_headless, \
+ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
+ SRC := $(LIBAWT_HEADLESS_DIRS), \
+ INCLUDE_FILES := $(LIBAWT_HEADLESS_FILES), \
+ LANG := C, \
+ OPTIMIZATION := LOW, \
+ CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_HEADLESS_CFLAGS), \
+ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/mapfile-vers, \
+ LDFLAGS := $(LDFLAGS_JDKLIB) \
+ $(call SET_SHARED_LIBRARY_ORIGIN), \
+ LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
+ LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..) \
+ -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \
+ -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \
+ LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN)., \
+ REORDER := $(LIBAWT_HEADLESS_REORDER), \
+ LDFLAGS_SUFFIX_linux := -ljvm -lawt -lm $(LIBDL) -ljava, \
+ LDFLAGS_SUFFIX_aix := -ljvm -lawt -ljava,\
+ LDFLAGS_SUFFIX_solaris := $(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc, \
+ OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libawt_headless, \
+ DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
+
+ $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
+
+ BUILD_LIBRARIES += $(BUILD_LIBAWT_HEADLESS)
+
+ endif
+endif
+
+##########################################################################################
+
ifndef OPENJDK
FONT_HEADERS := -I$(JDK_TOPDIR)/src/closed/share/native/sun/font/t2k
BUILD_LIBFONTMANAGER_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libfontmanager/mapfile-vers
@@ -843,7 +939,7 @@
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT)
ifneq (, $(findstring $(OPENJDK_TARGET_OS), solaris aix))
- $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT_XAWT)
+ $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT_HEADLESS)
endif
BUILD_LIBRARIES += $(BUILD_LIBFONTMANAGER)
@@ -888,7 +984,7 @@
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_windows := user32.lib $(JDK_OUTPUTDIR)/objs/libfontmanager/fontmanager.lib, \
LDFLAGS_SUFFIX_posix := $(LIBM) $(LIBCXX) -lfontmanager -ljava -ljvm -lc, \
- LDFLAGS_SUFFIX_solaris := -lawt -lawt_xawt, \
+ LDFLAGS_SUFFIX_solaris := -lawt -lawt_headless, \
VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
RC_FLAGS := $(RC_FLAGS) \
-D "JDK_FNAME=t2k.dll" \
@@ -1090,102 +1186,6 @@
##########################################################################################
-ifeq ($(BUILD_HEADLESS), true)
- # Mac and Windows only use the native AWT lib, do not build libawt_headless
- ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),)
-
- LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/share/native/sun/font \
- $(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
- $(JDK_TOPDIR)/src/solaris/native/sun/font \
- $(JDK_TOPDIR)/src/solaris/native/sun/awt \
- $(JDK_TOPDIR)/src/solaris/native/sun/java2d/opengl \
- $(JDK_TOPDIR)/src/solaris/native/sun/java2d/x11
-
- ifeq ($(OPENJDK_TARGET_OS), macosx)
- LIBAWT_HEADLESS_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/font
- endif
-
- LIBAWT_HEADLESS_CFLAGS := -DHEADLESS=true \
- -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
- $(CUPS_CFLAGS) \
- $(X_CFLAGS) \
- -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
- -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d \
- -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
- -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
- -I$(JDK_TOPDIR)/src/share/native/sun/awt/image \
- -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
- -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
- -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/jdga \
- $(foreach dir, $(LIBAWT_HEADLESS_DIRS), -I$(dir))
-
- LIBAWT_HEADLESS_FILES := \
- awt_Font.c \
- HeadlessToolkit.c \
- fontpath.c \
- VDrawingArea.c \
- X11Color.c \
- X11Renderer.c \
- X11PMBlitLoops.c \
- X11SurfaceData.c \
- X11FontScaler_md.c \
- X11TextRenderer_md.c \
- OGLBlitLoops.c \
- OGLBufImgOps.c \
- OGLContext.c \
- OGLFuncs.c \
- OGLMaskBlit.c \
- OGLMaskFill.c \
- OGLPaints.c \
- OGLRenderQueue.c \
- OGLRenderer.c \
- OGLSurfaceData.c \
- OGLTextRenderer.c \
- OGLVertexCache.c \
- GLXGraphicsConfig.c \
- GLXSurfaceData.c \
- AccelGlyphCache.c \
- CUPSfuncs.c
-
- LIBAWT_HEADLESS_REORDER :=
- ifeq ($(OPENJDK_TARGET_OS), solaris)
- ifneq ($(OPENJDK_TARGET_CPU), x86_64)
- LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU)
- endif
- endif
-
- $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS, \
- LIBRARY := awt_headless, \
- OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
- SRC := $(LIBAWT_HEADLESS_DIRS), \
- INCLUDE_FILES := $(LIBAWT_HEADLESS_FILES), \
- LANG := C, \
- OPTIMIZATION := LOW, \
- CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_HEADLESS_CFLAGS), \
- MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/mapfile-vers, \
- LDFLAGS := $(LDFLAGS_JDKLIB) \
- $(call SET_SHARED_LIBRARY_ORIGIN), \
- LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
- LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..) \
- -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \
- -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \
- LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN)., \
- REORDER := $(LIBAWT_HEADLESS_REORDER), \
- LDFLAGS_SUFFIX_linux := -ljvm -lawt -lm $(LIBDL) -ljava, \
- LDFLAGS_SUFFIX_aix := -ljvm -lawt -ljava,\
- LDFLAGS_SUFFIX_solaris := $(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc, \
- OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libawt_headless, \
- DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
-
- $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
-
- BUILD_LIBRARIES += $(BUILD_LIBAWT_HEADLESS)
-
- endif
-endif
-
-##########################################################################################
-
ifndef BUILD_HEADLESS_ONLY
LIBSPLASHSCREEN_DIRS := \
$(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg \
diff --git a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java
index 8b2eb3d..26d2347 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java
@@ -52,7 +52,9 @@
"RICH_TEXT",
"HTML",
"PDF",
- "URL"
+ "URL",
+ "PNG",
+ "JFIF"
};
static {
@@ -74,8 +76,8 @@
public static final int CF_HTML = 5;
public static final int CF_PDF = 6;
public static final int CF_URL = 7;
- public static final int CF_PNG = 10;
- public static final int CF_JPEG = 11;
+ public static final int CF_PNG = 8;
+ public static final int CF_JPEG = 9;
private CDataTransferer() {}
@@ -204,20 +206,9 @@
return handler;
}
- private native byte[] imageDataToPlatformImageBytes(int[] rData, int nW, int nH);
@Override
protected byte[] imageToPlatformBytes(Image image, long format) {
- int w = image.getWidth(null);
- int h = image.getHeight(null);
- BufferedImage bimage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
- Graphics g = bimage.getGraphics();
- g.drawImage(image, 0, 0, w, h, null);
- g.dispose();
- Raster raster = bimage.getRaster();
- DataBuffer buffer = raster.getDataBuffer();
- return imageDataToPlatformImageBytes(((DataBufferInt)buffer).getData(),
- raster.getWidth(),
- raster.getHeight());
+ return CImage.getCreator().getPlatformImageBytes(image);
}
private static native String[] nativeDragQueryFile(final byte[] bytes);
@@ -228,14 +219,9 @@
return nativeDragQueryFile(bytes);
}
- private native Image getImageForByteStream(byte[] bytes);
- /**
- * Translates a byte array which contains
- * platform-specific image data in the given format into an Image.
- */
@Override
protected Image platformImageBytesToImage(byte[] bytes, long format) throws IOException {
- return getImageForByteStream(bytes);
+ return CImage.getCreator().createImageFromPlatformImageBytes(bytes);
}
@Override
diff --git a/src/macosx/classes/sun/lwawt/macosx/CImage.java b/src/macosx/classes/sun/lwawt/macosx/CImage.java
index bef17be..5f468df 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CImage.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CImage.java
@@ -38,11 +38,13 @@
public class CImage extends CFRetainedResource {
private static native long nativeCreateNSImageFromArray(int[] buffer, int w, int h);
+ private static native long nativeCreateNSImageFromBytes(byte[] buffer);
private static native long nativeCreateNSImageFromArrays(int[][] buffers, int w[], int h[]);
private static native long nativeCreateNSImageFromFileContents(String file);
private static native long nativeCreateNSImageOfFileFromLaunchServices(String file);
private static native long nativeCreateNSImageFromImageName(String name);
private static native long nativeCreateNSImageFromIconSelector(int selector);
+ private static native byte[] nativeGetPlatformImageBytes(int[] buffer, int w, int h);
private static native void nativeCopyNSImageIntoArray(long image, int[] buffer, int sw, int sh, int dw, int dh);
private static native Dimension2D nativeGetNSImageSize(long image);
private static native void nativeSetNSImageSize(long image, double w, double h);
@@ -50,7 +52,7 @@
private static native Dimension2D[] nativeGetNSImageRepresentationSizes(long image, double w, double h);
static Creator creator = new Creator();
- static Creator getCreator() {
+ public static Creator getCreator() {
return creator;
}
@@ -136,6 +138,23 @@
return ((DataBufferInt)bimg.getRaster().getDataBuffer()).getData();
}
+ public byte[] getPlatformImageBytes(final Image image) {
+ int[] buffer = imageToArray(image, false);
+
+ if (buffer == null) {
+ return null;
+ }
+
+ return nativeGetPlatformImageBytes(buffer, image.getWidth(null), image.getHeight(null));
+ }
+
+ /**
+ * Translates a byte array which contains platform-specific image data in the given format into an Image.
+ */
+ public Image createImageFromPlatformImageBytes(final byte[] buffer) {
+ return createImageUsingNativeSize(nativeCreateNSImageFromBytes(buffer));
+ }
+
// This is used to create a CImage from a Image
public CImage createFromImage(final Image image) {
return createFromImage(image, true);
diff --git a/src/macosx/native/sun/awt/CDataTransferer.m b/src/macosx/native/sun/awt/CDataTransferer.m
index 09a7e5c..488068a 100644
--- a/src/macosx/native/sun/awt/CDataTransferer.m
+++ b/src/macosx/native/sun/awt/CDataTransferer.m
@@ -54,6 +54,10 @@
forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_PDF]];
[sStandardMappings setObject:NSURLPboardType
forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_URL]];
+ [sStandardMappings setObject:NSPasteboardTypePNG
+ forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_PNG]];
+ [sStandardMappings setObject:(NSString*)kUTTypeJPEG
+ forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_JPEG]];
}
return sStandardMappings;
}
@@ -126,108 +130,6 @@
return returnValue;
}
-/*
- * Class: sun_lwawt_macosx_CDataTransferer
- * Method: imageDataToPlatformImageBytes
- * Signature: ([III)[B
- */
-JNIEXPORT jbyteArray JNICALL Java_sun_lwawt_macosx_CDataTransferer_imageDataToPlatformImageBytes
-(JNIEnv *env, jobject obj, jintArray inPixelData, jint inWidth, jint inHeight)
-{
- jbyteArray returnValue = nil;
-JNF_COCOA_ENTER(env);
- UInt32 *rawImageData = (UInt32 *)(*env)->GetPrimitiveArrayCritical(env, inPixelData, 0);
-
- // The pixel data is in premultiplied ARGB format. That's exactly what
- // we need for the bitmap image rep.
- if (rawImageData != NULL) {
- NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
- pixelsWide:inWidth
- pixelsHigh:inHeight
- bitsPerSample:8
- samplesPerPixel:4
- hasAlpha:YES
- isPlanar:NO
- colorSpaceName:NSCalibratedRGBColorSpace
- bytesPerRow:(inWidth*4)
- bitsPerPixel:32];
-
- // Conver the ARGB data into RGBA data that the bitmap can draw.
- unsigned char *destData = [imageRep bitmapData];
- unsigned char *currentRowBase;
- jint x, y;
-
- for (y = 0; y < inHeight; y++) {
- currentRowBase = destData + y * (inWidth * 4);
- unsigned char *currElement = currentRowBase;
- for (x = 0; x < inWidth; x++) {
- UInt32 currPixel = rawImageData[y * inWidth + x];
- *currElement++ = ((currPixel & 0xFF0000) >> 16);
- *currElement++ = ((currPixel & 0xFF00) >> 8);
- *currElement++ = (currPixel & 0xFF);
- *currElement++ = ((currPixel & 0xFF000000) >> 24);
- }
- }
-
- (*env)->ReleasePrimitiveArrayCritical(env, inPixelData, rawImageData, JNI_ABORT);
- NSData *tiffImage = [imageRep TIFFRepresentation];
- jsize tiffSize = (jsize)[tiffImage length]; // #warning 64-bit: -length returns NSUInteger, but NewByteArray takes jsize
- returnValue = (*env)->NewByteArray(env, tiffSize);
- CHECK_NULL_RETURN(returnValue, nil);
- jbyte *tiffData = (jbyte *)(*env)->GetPrimitiveArrayCritical(env, returnValue, 0);
- CHECK_NULL_RETURN(tiffData, nil);
- [tiffImage getBytes:tiffData];
- (*env)->ReleasePrimitiveArrayCritical(env, returnValue, tiffData, 0); // Do not use JNI_COMMIT, as that will not free the buffer copy when +ProtectJavaHeap is on.
- [imageRep release];
- }
-JNF_COCOA_EXIT(env);
- return returnValue;
-
-}
-
-static jobject getImageForByteStream(JNIEnv *env, jbyteArray sourceData)
-{
- CHECK_NULL_RETURN(sourceData, NULL);
-
- jsize sourceSize = (*env)->GetArrayLength(env, sourceData);
- if (sourceSize == 0) return NULL;
-
- jbyte *sourceBytes = (*env)->GetPrimitiveArrayCritical(env, sourceData, NULL);
- CHECK_NULL_RETURN(sourceBytes, NULL);
- NSData *rawData = [NSData dataWithBytes:sourceBytes length:sourceSize];
-
- NSImage *newImage = [[NSImage alloc] initWithData:rawData];
- if (newImage) CFRetain(newImage); // GC
- [newImage release];
-
- (*env)->ReleasePrimitiveArrayCritical(env, sourceData, sourceBytes, JNI_ABORT);
- CHECK_NULL_RETURN(newImage, NULL);
-
- // The ownership of the NSImage is passed to the new CImage jobject. No need to release it.
- static JNF_CLASS_CACHE(jc_CImage, "sun/lwawt/macosx/CImage");
- static JNF_STATIC_MEMBER_CACHE(jm_CImage_getCreator, jc_CImage, "getCreator", "()Lsun/lwawt/macosx/CImage$Creator;");
- jobject creator = JNFCallStaticObjectMethod(env, jm_CImage_getCreator);
-
- static JNF_CLASS_CACHE(jc_CImage_Generator, "sun/lwawt/macosx/CImage$Creator");
- static JNF_MEMBER_CACHE(jm_CImage_Generator_createImageUsingNativeSize, jc_CImage_Generator, "createImageUsingNativeSize", "(J)Ljava/awt/image/BufferedImage;");
- return JNFCallObjectMethod(env, creator, jm_CImage_Generator_createImageUsingNativeSize, ptr_to_jlong(newImage)); // AWT_THREADING Safe (known object)
-}
-
-/*
- * Class: sun_lwawt_macosx_CDataTransferer
- * Method: getImageForByteStream
- * Signature: ([B)Ljava/awt/Image;
- */
-JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CDataTransferer_getImageForByteStream
- (JNIEnv *env, jobject obj, jbyteArray sourceData)
-{
- jobject img = NULL;
-JNF_COCOA_ENTER(env);
- img = getImageForByteStream(env, sourceData);
-JNF_COCOA_EXIT(env);
- return img;
-}
-
static jobjectArray CreateJavaFilenameArray(JNIEnv *env, NSArray *filenameArray)
{
NSUInteger filenameCount = [filenameArray count];
diff --git a/src/macosx/native/sun/awt/CDragSource.m b/src/macosx/native/sun/awt/CDragSource.m
index dc15077..da67762 100644
--- a/src/macosx/native/sun/awt/CDragSource.m
+++ b/src/macosx/native/sun/awt/CDragSource.m
@@ -318,8 +318,7 @@
// This is a good approximation if not perfect. A conclusive search would
// have to be done matching all defined strings in AppKit's commonStrings.h.
- if ([type hasPrefix:@"NS"] || [type hasPrefix:@"NeXT"])
- hasNSTypeData = true;
+ hasNSTypeData = [type hasPrefix:@"NS"] || [type hasPrefix:@"NeXT"] || [type hasPrefix:@"public."];
}
}
}
diff --git a/src/macosx/native/sun/awt/CDropTarget.m b/src/macosx/native/sun/awt/CDropTarget.m
index bff775f..7c2c0e1 100644
--- a/src/macosx/native/sun/awt/CDropTarget.m
+++ b/src/macosx/native/sun/awt/CDropTarget.m
@@ -106,6 +106,7 @@
NSFilenamesPboardType,
NSPostScriptPboardType,
NSTIFFPboardType,
+ NSPasteboardTypePNG,
NSRTFPboardType,
NSTabularTextPboardType,
NSFontPboardType,
@@ -119,6 +120,7 @@
NSVCardPboardType,
NSFilesPromisePboardType,
[DnDUtilities javaPboardType],
+ (NSString*)kUTTypeJPEG,
nil];
// Enable dragging events over this object:
diff --git a/src/macosx/native/sun/awt/CImage.m b/src/macosx/native/sun/awt/CImage.m
index da7cefc..ae93d56 100644
--- a/src/macosx/native/sun/awt/CImage.m
+++ b/src/macosx/native/sun/awt/CImage.m
@@ -112,7 +112,7 @@
jlong result = 0L;
JNF_COCOA_ENTER(env);
-
+
NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
if (imageRep) {
NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
@@ -435,4 +435,64 @@
JNF_COCOA_EXIT(env);
return jreturnArray;
-}
\ No newline at end of file
+}
+
+/*
+ * Class: sun_lwawt_macosx_CImage
+ * Method: nativeGetPlatformImageBytes
+ * Signature: ([III)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_sun_lwawt_macosx_CImage_nativeGetPlatformImageBytes
+(JNIEnv *env, jclass klass, jintArray buffer, jint width, jint height)
+{
+ jbyteArray result = 0L;
+
+ JNF_COCOA_ENTER(env);
+
+ NSBitmapImageRep* imageRep = [CImage_CreateImageRep(env, buffer, width, height) autorelease];
+ if (imageRep) {
+ NSData *tiffImage = [imageRep TIFFRepresentation];
+ jsize tiffSize = (jsize)[tiffImage length];
+ result = (*env)->NewByteArray(env, tiffSize);
+ CHECK_NULL_RETURN(result, nil);
+ jbyte *tiffData = (jbyte *)(*env)->GetPrimitiveArrayCritical(env, result, 0);
+ CHECK_NULL_RETURN(tiffData, nil);
+ [tiffImage getBytes:tiffData];
+ (*env)->ReleasePrimitiveArrayCritical(env, result, tiffData, 0);
+ }
+
+ JNF_COCOA_EXIT(env);
+
+ return result;
+}
+
+/*
+ * Class: sun_lwawt_macosx_CImage
+ * Method: nativeCreateNSImageFromBytes
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromBytes
+(JNIEnv *env, jclass klass, jbyteArray sourceData)
+{
+ jlong result = 0L;
+ CHECK_NULL_RETURN(sourceData, 0L);
+
+ JNF_COCOA_ENTER(env);
+
+ jsize sourceSize = (*env)->GetArrayLength(env, sourceData);
+ if (sourceSize == 0) return 0L;
+
+ jbyte *sourceBytes = (*env)->GetPrimitiveArrayCritical(env, sourceData, NULL);
+ CHECK_NULL_RETURN(sourceBytes, 0L);
+ NSData *rawData = [NSData dataWithBytes:sourceBytes length:sourceSize];
+ NSImage *newImage = [[NSImage alloc] initWithData:rawData];
+
+ (*env)->ReleasePrimitiveArrayCritical(env, sourceData, sourceBytes, JNI_ABORT);
+ CHECK_NULL_RETURN(newImage, 0L);
+
+ result = ptr_to_jlong(newImage);
+ JNF_COCOA_EXIT(env);
+
+ return result;
+}
+
diff --git a/src/share/classes/sun/java2d/opengl/OGLContext.java b/src/share/classes/sun/java2d/opengl/OGLContext.java
index e3ac65f..bda1cc7 100644
--- a/src/share/classes/sun/java2d/opengl/OGLContext.java
+++ b/src/share/classes/sun/java2d/opengl/OGLContext.java
@@ -194,6 +194,10 @@
/** Indicates the presence of the GL_ARB_texture_rectangle extension. */
@Native
static final int CAPS_EXT_TEXRECT = (FIRST_PRIVATE_CAP << 4);
+ /** Indicates the presence of the GL_NV_texture_barrier extension. */
+ @Native
+ static final int CAPS_EXT_TEXBARRIER = (FIRST_PRIVATE_CAP << 5);
+
OGLContextCaps(int caps, String adapterId) {
super(caps, adapterId);
@@ -223,6 +227,9 @@
if ((caps & CAPS_EXT_TEXRECT) != 0) {
buf.append("CAPS_EXT_TEXRECT|");
}
+ if ((caps & CAPS_EXT_TEXBARRIER) != 0) {
+ buf.append("CAPS_EXT_TEXBARRIER|");
+ }
return buf.toString();
}
}
diff --git a/src/share/native/sun/java2d/opengl/J2D_GL/glext.h b/src/share/native/sun/java2d/opengl/J2D_GL/glext.h
index 547f1c3..33185a0 100644
--- a/src/share/native/sun/java2d/opengl/J2D_GL/glext.h
+++ b/src/share/native/sun/java2d/opengl/J2D_GL/glext.h
@@ -6506,6 +6506,13 @@
typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string);
#endif
+#ifndef GL_NV_texture_barrier
+#define GL_NV_texture_barrier 1
+#ifdef GL_EXT_PROTOTYPES
+GLAPI void APIENTRY glTextureBarrierNV (void);
+#endif /* GL_EXT_PROTOTYPES */
+typedef void (APIENTRYP PNFGLTEXTUREBARRIERNVPROC) (void);
+#endif
#ifdef __cplusplus
}
diff --git a/src/share/native/sun/java2d/opengl/OGLContext.c b/src/share/native/sun/java2d/opengl/OGLContext.c
index dcd17a8..14820c6 100644
--- a/src/share/native/sun/java2d/opengl/OGLContext.c
+++ b/src/share/native/sun/java2d/opengl/OGLContext.c
@@ -911,6 +911,10 @@
}
}
}
+ if (OGLContext_IsExtensionAvailable(e, "GL_NV_texture_barrier")) {
+ *caps |= CAPS_EXT_TEXBARRIER;
+ }
+
// stuff vendor descriptor in the upper bits of the caps
if (vendor != NULL) {
if (strncmp(vendor, "ATI", 3) == 0) {
diff --git a/src/share/native/sun/java2d/opengl/OGLContext.h b/src/share/native/sun/java2d/opengl/OGLContext.h
index 27c5cec..864167b 100644
--- a/src/share/native/sun/java2d/opengl/OGLContext.h
+++ b/src/share/native/sun/java2d/opengl/OGLContext.h
@@ -134,6 +134,8 @@
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_GRAD_SHADER
#define CAPS_EXT_TEXRECT \
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_TEXRECT
+#define CAPS_EXT_TEXBARRIER \
+ sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_TEXBARRIER
/**
* Evaluates to true if the given capability bitmask is present for the
diff --git a/src/share/native/sun/java2d/opengl/OGLFuncs.h b/src/share/native/sun/java2d/opengl/OGLFuncs.h
index 0dc9b11..427c91d 100644
--- a/src/share/native/sun/java2d/opengl/OGLFuncs.h
+++ b/src/share/native/sun/java2d/opengl/OGLFuncs.h
@@ -173,6 +173,11 @@
typedef void (GLAPIENTRY *glDeleteObjectARBType)(GLhandleARB);
/**
+ * GL_NV_texture_barrier extension function typedef's
+ */
+typedef void (GLAPIENTRY *glTextureBarrierNVType) (void);
+
+/**
* REMIND: this caused an internal error in the MS compiler!?!?
*
*#define OGL_CHECK_FUNC_ERR(f) \
@@ -316,7 +321,8 @@
OGL_##action##_EXT_FUNC(glGetProgramivARB); \
OGL_##action##_EXT_FUNC(glGetInfoLogARB); \
OGL_##action##_EXT_FUNC(glGetObjectParameterivARB); \
- OGL_##action##_EXT_FUNC(glDeleteObjectARB);
+ OGL_##action##_EXT_FUNC(glDeleteObjectARB); \
+ OGL_##action##_EXT_FUNC(glTextureBarrierNV);
#define OGL_EXPRESS_ALL_FUNCS(action) \
OGL_EXPRESS_BASE_FUNCS(action) \
diff --git a/src/share/native/sun/java2d/opengl/OGLTextRenderer.c b/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
index 015dbae..53184c2 100644
--- a/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
+++ b/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
@@ -46,8 +46,8 @@
*/
#define OGLTR_CACHE_WIDTH 512
#define OGLTR_CACHE_HEIGHT 512
-#define OGLTR_CACHE_CELL_WIDTH 16
-#define OGLTR_CACHE_CELL_HEIGHT 16
+#define OGLTR_CACHE_CELL_WIDTH 32
+#define OGLTR_CACHE_CELL_HEIGHT 32
/**
* The current "glyph mode" state. This variable is used to track the
@@ -68,26 +68,17 @@
static GlyphMode glyphMode = MODE_NOT_INITED;
/**
- * This enum indicates the current state of the hardware glyph cache.
- * Initially the CacheStatus is set to CACHE_NOT_INITED, and then it is
- * set to either GRAY or LCD when the glyph cache is initialized.
- */
-typedef enum {
- CACHE_NOT_INITED,
- CACHE_GRAY,
- CACHE_LCD
-} CacheStatus;
-static CacheStatus cacheStatus = CACHE_NOT_INITED;
-
-/**
- * This is the one glyph cache. Once it is initialized as either GRAY or
- * LCD, it stays in that mode for the duration of the application. It should
+ * There are two separate glyph caches: for AA and for LCD.
+ * Once one of them is initialized as either GRAY or LCD, it
+ * stays in that mode for the duration of the application. It should
* be safe to use this one glyph cache for all screens in a multimon
* environment, since the glyph cache texture is shared between all contexts,
* and (in theory) OpenGL drivers should be smart enough to manage that
* texture across all screens.
*/
-static GlyphCacheInfo *glyphCache = NULL;
+
+static GlyphCacheInfo *glyphCacheLCD = NULL;
+static GlyphCacheInfo *glyphCacheAA = NULL;
/**
* The handle to the LCD text fragment program object.
@@ -138,7 +129,7 @@
* (OGLTR_CACHED_DEST_HEIGHT >= OGLTR_NOCACHE_TILE_SIZE)
*/
#define OGLTR_CACHED_DEST_WIDTH 512
-#define OGLTR_CACHED_DEST_HEIGHT 32
+#define OGLTR_CACHED_DEST_HEIGHT (OGLTR_CACHE_CELL_HEIGHT * 2)
/**
* The handle to the "cached destination" texture object.
@@ -212,8 +203,11 @@
OGLTR_CACHE_WIDTH, OGLTR_CACHE_HEIGHT, 0,
pixelFormat, GL_UNSIGNED_BYTE, NULL);
- cacheStatus = (lcdCache ? CACHE_LCD : CACHE_GRAY);
- glyphCache = gcinfo;
+ if (lcdCache) {
+ glyphCacheLCD = gcinfo;
+ } else {
+ glyphCacheAA = gcinfo;
+ }
return JNI_TRUE;
}
@@ -223,24 +217,24 @@
* associated with the given OGLContext.
*/
static void
-OGLTR_AddToGlyphCache(GlyphInfo *glyph, jboolean rgbOrder)
+OGLTR_AddToGlyphCache(GlyphInfo *glyph, GLenum pixelFormat)
{
- GLenum pixelFormat;
CacheCellInfo *ccinfo;
+ GlyphCacheInfo *gcinfo;
J2dTraceLn(J2D_TRACE_INFO, "OGLTR_AddToGlyphCache");
- if ((glyphCache == NULL) || (glyph->image == NULL)) {
+ if (pixelFormat == GL_LUMINANCE) {
+ gcinfo = glyphCacheAA;
+ } else {
+ gcinfo = glyphCacheLCD;
+ }
+
+ if ((gcinfo == NULL) || (glyph->image == NULL)) {
return;
}
- if (cacheStatus == CACHE_LCD) {
- pixelFormat = rgbOrder ? GL_RGB : GL_BGR;
- } else {
- pixelFormat = GL_LUMINANCE;
- }
-
- AccelGlyphCache_AddGlyph(glyphCache, glyph);
+ AccelGlyphCache_AddGlyph(gcinfo, glyph);
ccinfo = (CacheCellInfo *) glyph->cellInfo;
if (ccinfo != NULL) {
@@ -413,24 +407,31 @@
* gamma lookup table textures.
*/
static jboolean
-OGLTR_EnableLCDGlyphModeState(GLuint glyphTextureID, jint contrast)
+OGLTR_EnableLCDGlyphModeState(GLuint glyphTextureID,
+ GLuint dstTextureID,
+ jint contrast)
{
// bind the texture containing glyph data to texture unit 0
j2d_glActiveTextureARB(GL_TEXTURE0_ARB);
j2d_glBindTexture(GL_TEXTURE_2D, glyphTextureID);
+ j2d_glEnable(GL_TEXTURE_2D);
// bind the texture tile containing destination data to texture unit 1
j2d_glActiveTextureARB(GL_TEXTURE1_ARB);
- if (cachedDestTextureID == 0) {
- cachedDestTextureID =
- OGLContext_CreateBlitTexture(GL_RGB8, GL_RGB,
- OGLTR_CACHED_DEST_WIDTH,
- OGLTR_CACHED_DEST_HEIGHT);
+ if (dstTextureID != 0) {
+ j2d_glBindTexture(GL_TEXTURE_2D, dstTextureID);
+ } else {
if (cachedDestTextureID == 0) {
- return JNI_FALSE;
+ cachedDestTextureID =
+ OGLContext_CreateBlitTexture(GL_RGB8, GL_RGB,
+ OGLTR_CACHED_DEST_WIDTH,
+ OGLTR_CACHED_DEST_HEIGHT);
+ if (cachedDestTextureID == 0) {
+ return JNI_FALSE;
+ }
}
+ j2d_glBindTexture(GL_TEXTURE_2D, cachedDestTextureID);
}
- j2d_glBindTexture(GL_TEXTURE_2D, cachedDestTextureID);
// note that GL_TEXTURE_2D was already enabled for texture unit 0,
// but we need to explicitly enable it for texture unit 1
@@ -472,14 +473,14 @@
return;
}
- if (glyphCache == NULL) {
+ if (glyphCacheAA == NULL) {
if (!OGLTR_InitGlyphCache(JNI_FALSE)) {
return;
}
}
j2d_glEnable(GL_TEXTURE_2D);
- j2d_glBindTexture(GL_TEXTURE_2D, glyphCache->cacheID);
+ j2d_glBindTexture(GL_TEXTURE_2D, glyphCacheAA->cacheID);
j2d_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// for grayscale/monochrome text, the current OpenGL source color
@@ -522,6 +523,7 @@
j2d_glActiveTextureARB(GL_TEXTURE1_ARB);
j2d_glDisable(GL_TEXTURE_2D);
j2d_glActiveTextureARB(GL_TEXTURE0_ARB);
+ j2d_glDisable(GL_TEXTURE_2D);
break;
case MODE_NO_CACHE_GRAY:
@@ -547,7 +549,7 @@
if (ginfo->cellInfo == NULL) {
// attempt to add glyph to accelerated glyph cache
- OGLTR_AddToGlyphCache(ginfo, JNI_FALSE);
+ OGLTR_AddToGlyphCache(ginfo, GL_LUMINANCE);
if (ginfo->cellInfo == NULL) {
// we'll just no-op in the rare case that the cell is NULL
@@ -707,7 +709,8 @@
OGLTR_DrawLCDGlyphViaCache(OGLContext *oglc, OGLSDOps *dstOps,
GlyphInfo *ginfo, jint x, jint y,
jint glyphIndex, jint totalGlyphs,
- jboolean rgbOrder, jint contrast)
+ jboolean rgbOrder, jint contrast,
+ GLuint dstTextureID)
{
CacheCellInfo *cell;
jint dx1, dy1, dx2, dy2;
@@ -718,7 +721,7 @@
CHECK_PREVIOUS_OP(GL_TEXTURE_2D);
j2d_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- if (glyphCache == NULL) {
+ if (glyphCacheLCD == NULL) {
if (!OGLTR_InitGlyphCache(JNI_TRUE)) {
return JNI_FALSE;
}
@@ -727,11 +730,13 @@
if (rgbOrder != lastRGBOrder) {
// need to invalidate the cache in this case; see comments
// for lastRGBOrder above
- AccelGlyphCache_Invalidate(glyphCache);
+ AccelGlyphCache_Invalidate(glyphCacheLCD);
lastRGBOrder = rgbOrder;
}
- if (!OGLTR_EnableLCDGlyphModeState(glyphCache->cacheID, contrast)) {
+ if (!OGLTR_EnableLCDGlyphModeState(glyphCacheLCD->cacheID,
+ dstTextureID, contrast))
+ {
return JNI_FALSE;
}
@@ -750,7 +755,7 @@
j2d_glActiveTextureARB(GL_TEXTURE0_ARB);
// attempt to add glyph to accelerated glyph cache
- OGLTR_AddToGlyphCache(ginfo, rgbOrder);
+ OGLTR_AddToGlyphCache(ginfo, rgbOrder ? GL_RGB : GL_BGR);
if (ginfo->cellInfo == NULL) {
// we'll just no-op in the rare case that the cell is NULL
@@ -767,16 +772,34 @@
dx2 = dx1 + ginfo->width;
dy2 = dy1 + ginfo->height;
- // copy destination into second cached texture, if necessary
- OGLTR_UpdateCachedDestination(dstOps, ginfo,
- dx1, dy1, dx2, dy2,
- glyphIndex, totalGlyphs);
+ if (dstTextureID == 0) {
+ // copy destination into second cached texture, if necessary
+ OGLTR_UpdateCachedDestination(dstOps, ginfo,
+ dx1, dy1, dx2, dy2,
+ glyphIndex, totalGlyphs);
- // texture coordinates of the destination tile
- dtx1 = ((jfloat)(dx1 - cachedDestBounds.x1)) / OGLTR_CACHED_DEST_WIDTH;
- dty1 = ((jfloat)(cachedDestBounds.y2 - dy1)) / OGLTR_CACHED_DEST_HEIGHT;
- dtx2 = ((jfloat)(dx2 - cachedDestBounds.x1)) / OGLTR_CACHED_DEST_WIDTH;
- dty2 = ((jfloat)(cachedDestBounds.y2 - dy2)) / OGLTR_CACHED_DEST_HEIGHT;
+ // texture coordinates of the destination tile
+ dtx1 = ((jfloat)(dx1 - cachedDestBounds.x1)) / OGLTR_CACHED_DEST_WIDTH;
+ dty1 = ((jfloat)(cachedDestBounds.y2 - dy1)) / OGLTR_CACHED_DEST_HEIGHT;
+ dtx2 = ((jfloat)(dx2 - cachedDestBounds.x1)) / OGLTR_CACHED_DEST_WIDTH;
+ dty2 = ((jfloat)(cachedDestBounds.y2 - dy2)) / OGLTR_CACHED_DEST_HEIGHT;
+ } else {
+ jint gw = ginfo->width;
+ jint gh = ginfo->height;
+
+ // this accounts for lower-left origin of the destination region
+ jint dxadj = dstOps->xOffset + x;
+ jint dyadj = dstOps->yOffset + dstOps->height - (y + gh);
+
+ // update the remaining destination texture coordinates
+ dtx1 =((GLfloat)dxadj) / dstOps->textureWidth;
+ dtx2 = ((GLfloat)dxadj + gw) / dstOps->textureWidth;
+
+ dty1 = ((GLfloat)dyadj + gh) / dstOps->textureHeight;
+ dty2 = ((GLfloat)dyadj) / dstOps->textureHeight;
+
+ j2d_glTextureBarrierNV();
+ }
// render composed texture to the destination surface
j2d_glBegin(GL_QUADS);
@@ -837,7 +860,8 @@
OGLTR_DrawLCDGlyphNoCache(OGLContext *oglc, OGLSDOps *dstOps,
GlyphInfo *ginfo, jint x, jint y,
jint rowBytesOffset,
- jboolean rgbOrder, jint contrast)
+ jboolean rgbOrder, jint contrast,
+ GLuint dstTextureID)
{
GLfloat tx1, ty1, tx2, ty2;
GLfloat dtx1, dty1, dtx2, dty2;
@@ -859,7 +883,9 @@
}
}
- if (!OGLTR_EnableLCDGlyphModeState(oglc->blitTextureID, contrast)) {
+ if (!OGLTR_EnableLCDGlyphModeState(oglc->blitTextureID,
+ dstTextureID, contrast))
+ {
return JNI_FALSE;
}
@@ -907,18 +933,29 @@
dxadj = dstOps->xOffset + x;
dyadj = dstOps->yOffset + dstOps->height - (y + sh);
- // copy destination into cached texture tile (the lower-left
- // corner of the destination region will be positioned at the
- // lower-left corner (0,0) of the texture)
- j2d_glActiveTextureARB(GL_TEXTURE1_ARB);
- j2d_glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, 0,
- dxadj, dyadj,
- sw, sh);
+ if (dstTextureID == 0) {
+ // copy destination into cached texture tile (the lower-left
+ // corner of the destination region will be positioned at the
+ // lower-left corner (0,0) of the texture)
+ j2d_glActiveTextureARB(GL_TEXTURE1_ARB);
+ j2d_glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
+ 0, 0,
+ dxadj, dyadj,
+ sw, sh);
+ // update the remaining destination texture coordinates
+ dtx2 = ((GLfloat)sw) / OGLTR_CACHED_DEST_WIDTH;
+ dty1 = ((GLfloat)sh) / OGLTR_CACHED_DEST_HEIGHT;
+ } else {
+ // use the destination texture directly
+ // update the remaining destination texture coordinates
+ dtx1 =((GLfloat)dxadj) / dstOps->textureWidth;
+ dtx2 = ((GLfloat)dxadj + sw) / dstOps->textureWidth;
- // update the remaining destination texture coordinates
- dtx2 = ((GLfloat)sw) / OGLTR_CACHED_DEST_WIDTH;
- dty1 = ((GLfloat)sh) / OGLTR_CACHED_DEST_HEIGHT;
+ dty1 = ((GLfloat)dyadj + sh) / dstOps->textureHeight;
+ dty2 = ((GLfloat)dyadj) / dstOps->textureHeight;
+
+ j2d_glTextureBarrierNV();
+ }
// render composed texture to the destination surface
j2d_glBegin(GL_QUADS);
@@ -953,6 +990,7 @@
unsigned char *images, unsigned char *positions)
{
int glyphCounter;
+ GLuint dstTextureID = 0;
J2dTraceLn(J2D_TRACE_INFO, "OGLTR_DrawGlyphList");
@@ -966,6 +1004,29 @@
glyphMode = MODE_NOT_INITED;
isCachedDestValid = JNI_FALSE;
+ // We have to obtain an information about destination content
+ // in order to render lcd glyphs. It could be done by copying
+ // a part of desitination buffer into an intermediate texture
+ // using glCopyTexSubImage2D(). However, on macosx this path is
+ // slow, and it dramatically reduces the overall speed of lcd
+ // text rendering.
+ //
+ // In some cases, we can use a texture from the destination
+ // surface data in oredr to avoid this slow reading routine.
+ // It requires:
+ // * An appropriate textureTarget for the destination SD.
+ // In particular, we need GL_TEXTURE_2D
+ // * Means to prevent read-after-write problem.
+ // At the moment, a GL_NV_texture_barrier extension is used
+ // to achieve this.
+#ifdef MACOSX
+ if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_TEXBARRIER) &&
+ dstOps->textureTarget == GL_TEXTURE_2D)
+ {
+ dstTextureID = dstOps->textureID;
+ }
+#endif
+
for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) {
jint x, y;
jfloat glyphx, glyphy;
@@ -1003,8 +1064,7 @@
if (grayscale) {
// grayscale or monochrome glyph data
- if (cacheStatus != CACHE_LCD &&
- ginfo->width <= OGLTR_CACHE_CELL_WIDTH &&
+ if (ginfo->width <= OGLTR_CACHE_CELL_WIDTH &&
ginfo->height <= OGLTR_CACHE_CELL_HEIGHT)
{
ok = OGLTR_DrawGrayscaleGlyphViaCache(oglc, ginfo, x, y);
@@ -1024,19 +1084,20 @@
}
if (rowBytesOffset == 0 &&
- cacheStatus != CACHE_GRAY &&
ginfo->width <= OGLTR_CACHE_CELL_WIDTH &&
ginfo->height <= OGLTR_CACHE_CELL_HEIGHT)
{
ok = OGLTR_DrawLCDGlyphViaCache(oglc, dstOps,
ginfo, x, y,
glyphCounter, totalGlyphs,
- rgbOrder, lcdContrast);
+ rgbOrder, lcdContrast,
+ dstTextureID);
} else {
ok = OGLTR_DrawLCDGlyphNoCache(oglc, dstOps,
ginfo, x, y,
rowBytesOffset,
- rgbOrder, lcdContrast);
+ rgbOrder, lcdContrast,
+ dstTextureID);
}
}
diff --git a/src/solaris/classes/sun/awt/X11GraphicsDevice.java b/src/solaris/classes/sun/awt/X11GraphicsDevice.java
index 3749b82..d40a383 100644
--- a/src/solaris/classes/sun/awt/X11GraphicsDevice.java
+++ b/src/solaris/classes/sun/awt/X11GraphicsDevice.java
@@ -318,6 +318,7 @@
@Override
public boolean isDisplayChangeSupported() {
return (isFullScreenSupported()
+ && (getFullScreenWindow() != null)
&& !((X11GraphicsEnvironment) GraphicsEnvironment
.getLocalGraphicsEnvironment()).runningXinerama());
}
diff --git a/src/windows/native/sun/security/krb5/NativeCreds.c b/src/windows/native/sun/security/krb5/NativeCreds.c
index ab0ee03..554eb63 100644
--- a/src/windows/native/sun/security/krb5/NativeCreds.c
+++ b/src/windows/native/sun/security/krb5/NativeCreds.c
@@ -389,7 +389,7 @@
jobject authTime, renewTillTime, hostAddresses = NULL;
KERB_EXTERNAL_TICKET *msticket;
int found = 0;
- FILETIME Now, EndTime, LocalEndTime;
+ FILETIME Now, EndTime;
int i, netypes;
jint *etypes = NULL;
@@ -476,8 +476,7 @@
GetSystemTimeAsFileTime(&Now);
EndTime.dwLowDateTime = msticket->EndTime.LowPart;
EndTime.dwHighDateTime = msticket->EndTime.HighPart;
- FileTimeToLocalFileTime(&EndTime, &LocalEndTime);
- if (CompareFileTime(&Now, &LocalEndTime) < 0) {
+ if (CompareFileTime(&Now, &EndTime) < 0) {
for (i=0; i<netypes; i++) {
if (etypes[i] == msticket->SessionKey.KeyType) {
found = 1;
diff --git a/src/windows/native/sun/security/mscapi/security.cpp b/src/windows/native/sun/security/mscapi/security.cpp
index 83613e8..161c2ae 100644
--- a/src/windows/native/sun/security/mscapi/security.cpp
+++ b/src/windows/native/sun/security/mscapi/security.cpp
@@ -30,6 +30,7 @@
#include <jni.h>
#include <stdlib.h>
+#include <string.h>
#include <windows.h>
#include <BaseTsd.h>
#include <wincrypt.h>
@@ -58,11 +59,16 @@
char szMessage[1024];
szMessage[0] = '\0';
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, NULL, szMessage,
- 1024, NULL);
+ DWORD res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError,
+ NULL, szMessage, sizeof(szMessage), NULL);
+ if (res == 0) {
+ strcpy(szMessage, "Unknown error");
+ }
jclass exceptionClazz = env->FindClass(exceptionName);
- env->ThrowNew(exceptionClazz, szMessage);
+ if (exceptionClazz != NULL) {
+ env->ThrowNew(exceptionClazz, szMessage);
+ }
}
@@ -295,22 +301,42 @@
// Determine clazz and method ID to generate certificate
jclass clazzArrayList = env->FindClass("java/util/ArrayList");
+ if (clazzArrayList == NULL) {
+ __leave;
+ }
jmethodID mNewArrayList = env->GetMethodID(clazzArrayList, "<init>", "()V");
+ if (mNewArrayList == NULL) {
+ __leave;
+ }
- jmethodID mGenCert = env->GetMethodID(env->GetObjectClass(obj),
+ jclass clazzOfThis = env->GetObjectClass(obj);
+ if (clazzOfThis == NULL) {
+ __leave;
+ }
+
+ jmethodID mGenCert = env->GetMethodID(clazzOfThis,
"generateCertificate",
"([BLjava/util/Collection;)V");
+ if (mGenCert == NULL) {
+ __leave;
+ }
// Determine method ID to generate certificate chain
- jmethodID mGenCertChain = env->GetMethodID(env->GetObjectClass(obj),
+ jmethodID mGenCertChain = env->GetMethodID(clazzOfThis,
"generateCertificateChain",
"(Ljava/lang/String;Ljava/util/Collection;Ljava/util/Collection;)V");
+ if (mGenCertChain == NULL) {
+ __leave;
+ }
// Determine method ID to generate RSA certificate chain
- jmethodID mGenRSAKeyAndCertChain = env->GetMethodID(env->GetObjectClass(obj),
+ jmethodID mGenRSAKeyAndCertChain = env->GetMethodID(clazzOfThis,
"generateRSAKeyAndCertificateChain",
"(Ljava/lang/String;JJILjava/util/Collection;Ljava/util/Collection;)V");
+ if (mGenRSAKeyAndCertChain == NULL) {
+ __leave;
+ }
// Use CertEnumCertificatesInStore to get the certificates
// from the open store. pCertContext must be reset to
@@ -590,9 +616,6 @@
}
__finally
{
- if (hCryptProvAlt)
- ::CryptReleaseContext(hCryptProvAlt, 0);
-
if (pSignedHashBuffer)
delete [] pSignedHashBuffer;
@@ -601,6 +624,9 @@
if (hHash)
::CryptDestroyHash(hHash);
+
+ if (hCryptProvAlt)
+ ::CryptReleaseContext(hCryptProvAlt, 0);
}
return jSignedHash;
@@ -688,9 +714,6 @@
__finally
{
- if (hCryptProvAlt)
- ::CryptReleaseContext(hCryptProvAlt, 0);
-
if (pSignedHashBuffer)
delete [] pSignedHashBuffer;
@@ -699,6 +722,9 @@
if (hHash)
::CryptDestroyHash(hHash);
+
+ if (hCryptProvAlt)
+ ::CryptReleaseContext(hCryptProvAlt, 0);
}
return result;
@@ -763,9 +789,15 @@
// Get the method ID for the RSAKeyPair constructor
jclass clazzRSAKeyPair =
env->FindClass("sun/security/mscapi/RSAKeyPair");
+ if (clazzRSAKeyPair == NULL) {
+ __leave;
+ }
jmethodID mNewRSAKeyPair =
env->GetMethodID(clazzRSAKeyPair, "<init>", "(JJI)V");
+ if (mNewRSAKeyPair == NULL) {
+ __leave;
+ }
// Create a new RSA keypair
keypair = env->NewObject(clazzRSAKeyPair, mNewRSAKeyPair,
@@ -1948,9 +1980,15 @@
// Get the method ID for the RSAPrivateKey constructor
jclass clazzRSAPrivateKey =
env->FindClass("sun/security/mscapi/RSAPrivateKey");
+ if (clazzRSAPrivateKey == NULL) {
+ __leave;
+ }
jmethodID mNewRSAPrivateKey =
env->GetMethodID(clazzRSAPrivateKey, "<init>", "(JJI)V");
+ if (mNewRSAPrivateKey == NULL) {
+ __leave;
+ }
// Create a new RSA private key
privateKey = env->NewObject(clazzRSAPrivateKey, mNewRSAPrivateKey,
@@ -2035,9 +2073,15 @@
// Get the method ID for the RSAPublicKey constructor
jclass clazzRSAPublicKey =
env->FindClass("sun/security/mscapi/RSAPublicKey");
+ if (clazzRSAPublicKey == NULL) {
+ __leave;
+ }
jmethodID mNewRSAPublicKey =
env->GetMethodID(clazzRSAPublicKey, "<init>", "(JJI)V");
+ if (mNewRSAPublicKey == NULL) {
+ __leave;
+ }
// Create a new RSA public key
publicKey = env->NewObject(clazzRSAPublicKey, mNewRSAPublicKey,
diff --git a/test/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java b/test/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java
index 83b2c69..d7b3971 100644
--- a/test/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java
+++ b/test/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java
@@ -66,15 +66,17 @@
megaByte = new byte [MB];
data.add(megaByte);
} catch (OutOfMemoryError e) {
- System.out.println("OOME is thrown when allocating "
- + data.size() + "MB memory.");
- megaByte = null;
+ megaByte = null; // Free memory ASAP
+
+ int size = data.size();
for (int j = 0; j < RESERVATION && !data.isEmpty(); j++) {
data.removeLast();
}
System.gc();
hasException = true;
+ System.out.println("OOME is thrown when allocating "
+ + size + "MB memory.");
}
}
dumpMemoryStats("After memory allocation");
diff --git a/test/java/awt/dnd/ImageTransferTest/ImageTransferTest.java b/test/java/awt/dnd/ImageTransferTest/ImageTransferTest.java
new file mode 100644
index 0000000..491d35f
--- /dev/null
+++ b/test/java/awt/dnd/ImageTransferTest/ImageTransferTest.java
@@ -0,0 +1,412 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ @test
+ @bug 4397404 4720930
+ @summary tests that images of all supported native image formats are transfered properly
+ @library ../../regtesthelpers/process/
+ @build ProcessResults ProcessCommunicator
+ @author gas@sparc.spb.su area=Clipboard
+ @run main ImageTransferTest
+*/
+
+import sun.awt.OSInfo;
+import sun.awt.SunToolkit;
+import test.java.awt.regtesthelpers.process.ProcessCommunicator;
+import test.java.awt.regtesthelpers.process.ProcessResults;
+
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.SystemFlavorMap;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceAdapter;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetAdapter;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.event.InputEvent;
+import java.awt.image.BufferedImage;
+import java.awt.image.MemoryImageSource;
+import java.util.stream.Stream;
+
+public class ImageTransferTest {
+ public static void main(String[] arg) throws Exception {
+ ImageDragSource ids = new ImageDragSource();
+ ids.frame.setLocation(100, 100);
+ ids.frame.setVisible(true);
+ Util.sync();
+ String classpath = System.getProperty("java.class.path");
+ String[] args = new String[ids.formats.length + 4];
+ args[0] = "200";
+ args[1] = "100";
+ args[2] = args[3] = "150";
+
+ System.arraycopy(ids.formats, 0, args, 4, ids.formats.length);
+ ProcessResults pres = ProcessCommunicator.executeChildProcess(ImageDropTarget.class, classpath, args);
+
+ if (pres.getStdErr() != null && pres.getStdErr().length() > 0) {
+ System.err.println("========= Child VM System.err ========");
+ System.err.print(pres.getStdErr());
+ System.err.println("======================================");
+ }
+
+ if (pres.getStdOut() != null && pres.getStdOut().length() > 0) {
+ System.err.println("========= Child VM System.out ========");
+ System.err.print(pres.getStdOut());
+ System.err.println("======================================");
+ }
+
+ boolean failed = false;
+ String passedFormats = "";
+ String failedFormats = "";
+
+ for (int i = 0; i < ids.passedArray.length; i++) {
+ if (ids.passedArray[i]) passedFormats += ids.formats[i] + " ";
+ else {
+ failed = true;
+ failedFormats += ids.formats[i] + " ";
+ }
+ }
+
+ if (failed) {
+ throw new RuntimeException("test failed: images in following " +
+ "native formats are not transferred properly: " + failedFormats);
+ } else {
+ System.err.println("images in following " +
+ "native formats are transferred properly: " + passedFormats);
+ }
+ }
+}
+
+
+class Util {
+ public static void sync() {
+ ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
+
+abstract class ImageTransferer {
+ Image image;
+ String[] formats;
+ int fi; // current format index
+ Frame frame = new Frame();
+
+
+ ImageTransferer() {
+ image = createImage();
+ frame.setSize(100, 100);
+ }
+
+ private static Image createImage() {
+ int w = 100;
+ int h = 100;
+ int[] pix = new int[w * h];
+
+ int index = 0;
+ for (int y = 0; y < h; y++) {
+ for (int x = 0; x < w; x++) {
+ int red = 127;
+ int green = 127;
+ int blue = y > h / 2 ? 127 : 0;
+ int alpha = 255;
+ if (x < w / 4 && y < h / 4) {
+ alpha = 0;
+ red = 0;
+ }
+ pix[index++] = (alpha << 24) | (red << 16) | (green << 8) | blue;
+ }
+ }
+ return Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, pix, 0, w));
+ }
+
+
+ static String[] retrieveFormatsToTest() {
+ SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
+ java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
+ if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
+ // for test failing on JDK without this fix
+ ln.add("METAFILEPICT");
+ }
+ return ln.toArray(new String[ln.size()]);
+ }
+
+ static void leaveFormat(String format) {
+ SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
+ sfm.setFlavorsForNative(format, new DataFlavor[]{DataFlavor.imageFlavor});
+ sfm.setNativesForFlavor(DataFlavor.imageFlavor, new String[]{format});
+ }
+
+
+ boolean areImagesIdentical(Image im1, Image im2) {
+ if (formats[fi].equals("JFIF") || formats[fi].equals("image/jpeg") ||
+ formats[fi].equals("GIF") || formats[fi].equals("image/gif")) {
+ // JFIF and GIF are lossy formats
+ return true;
+ }
+ int[] ib1 = getImageData(im1);
+ int[] ib2 = getImageData(im2);
+
+ if (ib1.length != ib2.length) {
+ return false;
+ }
+
+ if (formats[fi].equals("PNG") ||
+ formats[fi].equals("image/png") ||
+ formats[fi].equals("image/x-png")) {
+ // check alpha as well
+ for (int i = 0; i < ib1.length; i++) {
+ if (ib1[i] != ib2[i]) {
+ System.err.println("different pixels: " +
+ Integer.toHexString(ib1[i]) + " " +
+ Integer.toHexString(ib2[i]));
+ return false;
+ }
+ }
+ } else {
+ for (int i = 0; i < ib1.length; i++) {
+ if ((ib1[i] & 0x00FFFFFF) != (ib2[i] & 0x00FFFFFF)) {
+ System.err.println("different pixels: " +
+ Integer.toHexString(ib1[i]) + " " +
+ Integer.toHexString(ib2[i]));
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private static int[] getImageData(Image image) {
+ int width = image.getWidth(null);
+ int height = image.getHeight(null);
+ BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2d = bimage.createGraphics();
+ try {
+ g2d.drawImage(image, 0, 0, width, height, null);
+ } finally {
+ g2d.dispose();
+ }
+ return bimage.getRGB(0, 0, width, height, null, 0, width);
+ }
+
+ public static int sign(int n) {
+ return n < 0 ? -1 : n == 0 ? 0 : 1;
+ }
+
+}
+
+
+class ImageDragSource extends ImageTransferer {
+ boolean[] passedArray;
+
+ ImageDragSource() {
+ formats = retrieveFormatsToTest();
+ passedArray = new boolean[formats.length];
+ final DragSourceListener dsl = new DragSourceAdapter() {
+ public void dragDropEnd(DragSourceDropEvent e) {
+ System.err.println("Drop was successful=" + e.getDropSuccess());
+ notifyTransferSuccess(e.getDropSuccess());
+ if (++fi < formats.length) {
+ leaveFormat(formats[fi]);
+ }
+ }
+ };
+
+ new DragSource().createDefaultDragGestureRecognizer(frame,
+ DnDConstants.ACTION_COPY,
+ dge -> dge.startDrag(null, new ImageSelection(image), dsl));
+ leaveFormat(formats[fi]);
+ }
+
+
+ void notifyTransferSuccess(boolean status) {
+ passedArray[fi] = status;
+ }
+}
+
+
+class ImageDropTarget extends ImageTransferer {
+ private final Robot robot;
+ private static Point startPoint, endPoint = new Point(250, 150);
+
+ ImageDropTarget() throws AWTException {
+ DropTargetAdapter dropTargetAdapter = new DropTargetAdapter() {
+ @Override
+ public void drop(DropTargetDropEvent dtde) {
+ checkImage(dtde);
+ startImageDrag();
+ }
+ };
+ new DropTarget(frame, dropTargetAdapter);
+ robot = new Robot();
+ }
+
+
+ void checkImage(DropTargetDropEvent dtde) {
+ final Transferable t = dtde.getTransferable();
+ if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
+ dtde.acceptDrop(DnDConstants.ACTION_COPY);
+ Image im;
+ try {
+ im = (Image) t.getTransferData(DataFlavor.imageFlavor);
+ System.err.println("getTransferData was successful");
+ } catch (Exception e) {
+ System.err.println("Can't getTransferData: " + e);
+ dtde.dropComplete(false);
+ notifyTransferSuccess(false);
+ return;
+ }
+
+ if (im == null) {
+ System.err.println("getTransferData returned null");
+ dtde.dropComplete(false);
+ notifyTransferSuccess(false);
+ } else if (areImagesIdentical(image, im)) {
+ dtde.dropComplete(true);
+ notifyTransferSuccess(true);
+ } else {
+ System.err.println("transferred image is different from initial image");
+ dtde.dropComplete(false);
+ notifyTransferSuccess(false);
+ }
+
+ } else {
+ System.err.println("imageFlavor is not supported by Transferable");
+ dtde.rejectDrop();
+ notifyTransferSuccess(false);
+ }
+ }
+
+ void startImageDrag() {
+ leaveFormat(formats[fi]);
+ new Thread(() -> {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ // Exit from the child process
+ System.exit(1);
+ }
+ robot.mouseMove(startPoint.x, startPoint.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ for (Point p = new Point(startPoint); !p.equals(endPoint);
+ p.translate(sign(endPoint.x - p.x), sign(endPoint.y - p.y))) {
+ robot.mouseMove(p.x, p.y);
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }).start();
+ }
+
+ void notifyTransferSuccess(boolean status) {
+ if (status) {
+ System.err.println("format passed: " + formats[fi]);
+ } else {
+ System.err.println("format failed: " + formats[fi]);
+ System.exit(1);
+ }
+ if (fi < formats.length - 1) {
+ leaveFormat(formats[++fi]);
+ } else {
+ new Thread(() -> {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.exit(0);
+ }).start();
+ }
+ }
+
+
+ public static void main(String[] args) {
+ try {
+ ImageDropTarget idt = new ImageDropTarget();
+
+ int x = Integer.parseInt(args[0]);
+ int y = Integer.parseInt(args[1]);
+ startPoint = new Point(Integer.parseInt(args[2]), Integer.parseInt(args[3]));
+
+ idt.formats = new String[args.length - 4];
+ System.arraycopy(args, 4, idt.formats, 0, args.length - 4);
+ leaveFormat(idt.formats[0]);
+
+ idt.frame.setLocation(x, y);
+ idt.frame.setVisible(true);
+ Util.sync();
+
+ idt.startImageDrag();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+}
+
+
+class ImageSelection implements Transferable {
+ private static final int IMAGE = 0;
+ private static final DataFlavor[] flavors = {DataFlavor.imageFlavor};
+ private Image data;
+
+ public ImageSelection(Image data) {
+ this.data = data;
+ }
+
+ @Override
+ public DataFlavor[] getTransferDataFlavors() {
+ // returning flavors itself would allow client code to modify
+ // our internal behavior
+ return flavors.clone();
+ }
+
+ @Override
+ public boolean isDataFlavorSupported(DataFlavor flavor) {
+ return Stream.of(flavor).anyMatch(flavor::equals);
+ }
+
+ @Override
+ public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
+ if (flavor.equals(flavors[IMAGE])) {
+ return data;
+ } else {
+ throw new UnsupportedFlavorException(flavor);
+ }
+ }
+}
diff --git a/test/javax/swing/JFileChooser/8002077/bug8002077.java b/test/javax/swing/JFileChooser/8002077/bug8002077.java
index ea1470d..c6d49a1 100644
--- a/test/javax/swing/JFileChooser/8002077/bug8002077.java
+++ b/test/javax/swing/JFileChooser/8002077/bug8002077.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,8 @@
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
+ UIManager.put("FileChooser.openButtonMnemonic", KeyEvent.VK_O);
+ UIManager.put("FileChooser.saveButtonMnemonic", KeyEvent.VK_S);
runTest();
break;
}
@@ -58,24 +60,24 @@
Robot robot = new Robot();
robot.setAutoDelay(50);
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- fileChooserState = new JFileChooser().showSaveDialog(null);
- }
- });
+ SwingUtilities.invokeLater(() ->
+ fileChooserState = new JFileChooser().showSaveDialog(null));
toolkit.realSync();
Util.hitMnemonics(robot, KeyEvent.VK_N);
toolkit.realSync();
- robot.keyPress(KeyEvent.VK_A);
- robot.keyRelease(KeyEvent.VK_A);
+ Util.hitKeys(robot, KeyEvent.VK_A);
toolkit.realSync();
Util.hitMnemonics(robot, KeyEvent.VK_S);
toolkit.realSync();
if (fileChooserState != JFileChooser.APPROVE_OPTION) {
+ // Close the dialog
+ Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
+ toolkit.realSync();
+
throw new RuntimeException("Save button is not pressed!");
}
}