jdk/src/macosx/native/sun/awt/CImage.m
author lana
Thu, 26 Dec 2013 12:04:16 -0800
changeset 23010 6dadb192ad81
parent 15322 3638f33225ec
child 23328 4c53a6ebc779
permissions -rw-r--r--
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013 Summary: updated files with 2011, 2012 and 2013 years according to the file's last updated date Reviewed-by: tbell, lancea, chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 15322
diff changeset
     2
 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     4
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    10
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    15
 * accompanied this code).
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    16
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    20
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    23
 * questions.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    24
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    25
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    26
#import <Cocoa/Cocoa.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    27
#import <JavaNativeFoundation/JavaNativeFoundation.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    28
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    29
#import "GeomUtilities.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    30
#import "ThreadUtilities.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    31
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    32
#import "sun_lwawt_macosx_CImage.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    33
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    34
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    35
static void CImage_CopyArrayIntoNSImageRep
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    36
(jint *srcPixels, jint *dstPixels, int width, int height)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    37
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    38
    int x, y;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    39
    // TODO: test this on big endian systems (not sure if its correct)...
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    40
    for (y = 0; y < height; y++) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    41
        for (x = 0; x < width; x++) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    42
            jint pix = srcPixels[x];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    43
            jint a = (pix >> 24) & 0xff;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    44
            jint r = (pix >> 16) & 0xff;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    45
            jint g = (pix >>  8) & 0xff;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    46
            jint b = (pix      ) & 0xff;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    47
            dstPixels[x] = (b << 24) | (g << 16) | (r << 8) | a;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    48
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    49
        srcPixels += width; // TODO: use explicit scanStride
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    50
        dstPixels += width;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    51
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    52
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    53
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    54
static void CImage_CopyNSImageIntoArray
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    55
(NSImage *srcImage, jint *dstPixels, int width, int height)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    56
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    57
    CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    58
    CGContextRef cgRef = CGBitmapContextCreate(dstPixels, width, height, 8, width * 4, colorspace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    59
    CGColorSpaceRelease(colorspace);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    60
    NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithGraphicsPort:cgRef flipped:NO];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    61
    CGContextRelease(cgRef);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    62
    NSGraphicsContext *oldContext = [[NSGraphicsContext currentContext] retain];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    63
    [NSGraphicsContext setCurrentContext:context];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    64
    NSRect rect = NSMakeRect(0, 0, width, height);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    65
    [srcImage drawInRect:rect
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    66
                fromRect:rect
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    67
               operation:NSCompositeSourceOver
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    68
                fraction:1.0];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    69
    [NSGraphicsContext setCurrentContext:oldContext];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    70
    [oldContext release];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    71
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    72
12403
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
    73
static NSBitmapImageRep* CImage_CreateImageRep(JNIEnv *env, jintArray buffer, jint width, jint height)
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    74
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    75
    NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    76
                                                                         pixelsWide:width
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    77
                                                                         pixelsHigh:height
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    78
                                                                      bitsPerSample:8
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    79
                                                                    samplesPerPixel:4
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    80
                                                                           hasAlpha:YES
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    81
                                                                           isPlanar:NO
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    82
                                                                     colorSpaceName:NSDeviceRGBColorSpace
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    83
                                                                       bitmapFormat:NSAlphaFirstBitmapFormat
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    84
                                                                        bytesPerRow:width*4 // TODO: use explicit scanStride
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    85
                                                                       bitsPerPixel:32];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    86
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    87
    jint *imgData = (jint *)[imageRep bitmapData];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    88
    if (imgData == NULL) return 0L;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    89
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    90
    jint *src = (*env)->GetPrimitiveArrayCritical(env, buffer, NULL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    91
    if (src == NULL) return 0L;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    92
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    93
    CImage_CopyArrayIntoNSImageRep(src, imgData, width, height);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    94
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    95
    (*env)->ReleasePrimitiveArrayCritical(env, buffer, src, JNI_ABORT);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    96
12403
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
    97
    return imageRep;
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
    98
}
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
    99
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   100
/*
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   101
 * Class:     sun_lwawt_macosx_CImage
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   102
 * Method:    nativeCreateNSImageFromArray
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   103
 * Signature: ([III)J
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   104
 */
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   105
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArray
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   106
(JNIEnv *env, jclass klass, jintArray buffer, jint width, jint height)
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   107
{
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   108
    jlong result = 0L;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   109
12403
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   110
JNF_COCOA_ENTER(env);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   111
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   112
    NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   113
    if (imageRep) {
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   114
        NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   115
        [nsImage addRepresentation:imageRep];
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   116
        [imageRep release];
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   117
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   118
        if (nsImage != nil) {
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   119
            CFRetain(nsImage); // GC
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   120
        }
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   121
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   122
        result = ptr_to_jlong(nsImage);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   123
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   124
12403
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   125
JNF_COCOA_EXIT(env);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   126
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   127
    return result;
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   128
}
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   129
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   130
/*
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   131
 * Class:     sun_lwawt_macosx_CImage
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   132
 * Method:    nativeCreateNSImageFromArrays
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   133
 * Signature: ([[I[I[I)J
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   134
 */
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   135
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArrays
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   136
(JNIEnv *env, jclass klass, jobjectArray buffers, jintArray widths, jintArray heights)
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   137
{
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   138
    jlong result = 0L;
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   139
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   140
JNF_COCOA_ENTER(env);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   141
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   142
    jsize num = (*env)->GetArrayLength(env, buffers);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   143
    NSMutableArray * reps = [NSMutableArray arrayWithCapacity: num];
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   144
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   145
    jint * ws = (*env)->GetIntArrayElements(env, widths, NULL);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   146
    jint * hs = (*env)->GetIntArrayElements(env, heights, NULL);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   147
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   148
    jsize i;
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   149
    for (i = 0; i < num; i++) {
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   150
        jintArray buffer = (*env)->GetObjectArrayElement(env, buffers, i);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   151
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   152
        NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, ws[i], hs[i]);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   153
        if (imageRep) {
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   154
            [reps addObject: imageRep];
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   155
        }
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   156
    }
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   157
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   158
    (*env)->ReleaseIntArrayElements(env, heights, hs, JNI_ABORT);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   159
    (*env)->ReleaseIntArrayElements(env, widths, ws, JNI_ABORT);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   160
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   161
    if ([reps count]) {
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   162
        NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0, 0)];
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   163
        [nsImage addRepresentations: reps];
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   164
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   165
        if (nsImage != nil) {
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   166
            CFRetain(nsImage); // GC
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   167
        }
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   168
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   169
        result = ptr_to_jlong(nsImage);
50b3f2982b59 7148275: [macosx] setIconImages() not working correctly (distorted icon when minimized)
anthony
parents: 12047
diff changeset
   170
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   171
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   172
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   173
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   174
    return result;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   175
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   176
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   177
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   178
 * Class:     sun_lwawt_macosx_CImage
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   179
 * Method:    nativeCreateNSImageFromIconSelector
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   180
 * Signature: (I)J
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   181
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   182
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromIconSelector
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   183
(JNIEnv *env, jclass klass, jint selector)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   184
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   185
    NSImage *image = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   186
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   187
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   188
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   189
    IconRef iconRef;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   190
    if (noErr == GetIconRef(kOnSystemDisk, kSystemIconsCreator, selector, &iconRef)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   191
        image = [[NSImage alloc] initWithIconRef:iconRef];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   192
        if (image) CFRetain(image); // GC
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   193
        ReleaseIconRef(iconRef);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   194
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   195
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   196
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   197
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   198
    return ptr_to_jlong(image);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   199
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   200
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   201
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   202
 * Class:     sun_lwawt_macosx_CImage
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   203
 * Method:    nativeCreateNSImageFromFileContents
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   204
 * Signature: (Ljava/lang/String;)J
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   205
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   206
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromFileContents
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   207
(JNIEnv *env, jclass klass, jstring file)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   208
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   209
    NSImage *image = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   210
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   211
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   212
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   213
    NSString *path = JNFNormalizedNSStringForPath(env, file);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   214
    image = [[NSImage alloc] initByReferencingFile:path];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   215
    if (image) CFRetain(image); // GC
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   216
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   217
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   218
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   219
    return ptr_to_jlong(image);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   220
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   221
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   222
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   223
 * Class:     sun_lwawt_macosx_CImage
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   224
 * Method:    nativeCreateNSImageOfFileFromLaunchServices
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   225
 * Signature: (Ljava/lang/String;)J
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   226
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   227
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageOfFileFromLaunchServices
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   228
(JNIEnv *env, jclass klass, jstring file)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   229
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   230
    __block NSImage *image = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   231
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   232
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   233
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   234
    NSString *path = JNFNormalizedNSStringForPath(env, file);
15322
3638f33225ec 7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents: 12654
diff changeset
   235
    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   236
        image = [[NSWorkspace sharedWorkspace] iconForFile:path];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   237
        [image setScalesWhenResized:TRUE];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   238
        if (image) CFRetain(image); // GC
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   239
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   240
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   241
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   242
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   243
    return ptr_to_jlong(image);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   244
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   245
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   246
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   247
 * Class:     sun_lwawt_macosx_CImage
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   248
 * Method:    nativeCreateNSImageFromImageName
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   249
 * Signature: (Ljava/lang/String;)J
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   250
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   251
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromImageName
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   252
(JNIEnv *env, jclass klass, jstring name)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   253
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   254
    NSImage *image = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   255
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   256
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   257
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   258
    image = [NSImage imageNamed:JNFJavaToNSString(env, name)];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   259
    if (image) CFRetain(image); // GC
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   260
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   261
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   262
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   263
    return ptr_to_jlong(image);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   264
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   265
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   266
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   267
 * Class:     sun_lwawt_macosx_CImage
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   268
 * Method:    nativeCopyNSImageIntoArray
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   269
 * Signature: (J[III)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   270
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   271
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CImage_nativeCopyNSImageIntoArray
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   272
(JNIEnv *env, jclass klass, jlong nsImgPtr, jintArray buffer, jint w, jint h)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   273
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   274
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   275
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   276
    NSImage *img = (NSImage *)jlong_to_ptr(nsImgPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   277
    jint *dst = (*env)->GetPrimitiveArrayCritical(env, buffer, NULL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   278
    if (dst) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   279
        CImage_CopyNSImageIntoArray(img, dst, w, h);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   280
        (*env)->ReleasePrimitiveArrayCritical(env, buffer, dst, JNI_ABORT);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   281
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   282
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   283
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   284
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   285
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   286
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   287
 * Class:     sun_lwawt_macosx_CImage
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   288
 * Method:    nativeGetNSImageSize
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   289
 * Signature: (J)Ljava/awt/geom/Dimension2D;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   290
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   291
JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CImage_nativeGetNSImageSize
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   292
(JNIEnv *env, jclass klass, jlong nsImgPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   293
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   294
    jobject size = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   295
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   296
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   297
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   298
    size = NSToJavaSize(env, [(NSImage *)jlong_to_ptr(nsImgPtr) size]);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   299
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   300
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   301
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   302
    return size;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   303
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   304
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   305
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   306
 * Class:     sun_lwawt_macosx_CImage
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   307
 * Method:    nativeSetNSImageSize
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   308
 * Signature: (JDD)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   309
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   310
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CImage_nativeSetNSImageSize
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   311
(JNIEnv *env, jclass clazz, jlong image, jdouble w, jdouble h)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   312
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   313
    if (!image) return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   314
    NSImage *i = (NSImage *)jlong_to_ptr(image);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   315
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   316
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   317
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   318
    [i setScalesWhenResized:TRUE];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   319
    [i setSize:NSMakeSize(w, h)];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   320
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   321
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   322
}