Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8259939: Remove JNF_COCOA_ENTER/EXIT usage from Lanai project
  • Loading branch information
prrace committed Jan 18, 2021
1 parent b68d1e4 commit ba667323a3b4bec8f808f498607079850fc07fc8
@@ -26,7 +26,7 @@
#ifndef MTLGraphicsConfig_h_Included
#define MTLGraphicsConfig_h_Included

#import "jni.h"
#import "JNIUtilities.h"
#import "MTLSurfaceDataBase.h"
#import "MTLContext.h"
#import <Cocoa/Cocoa.h>
@@ -135,7 +135,7 @@
(JNIEnv *env, jclass cglgc, jint displayID, jstring mtlShadersLib)
{
jlong ret = 0L;
JNF_COCOA_ENTER(env);
JNI_COCOA_ENTER(env);
NSMutableArray * retArray = [NSMutableArray arrayWithCapacity:3];
[retArray addObject: [NSNumber numberWithInt: (int)displayID]];
[retArray addObject: [NSString stringWithUTF8String: JNU_GetStringPlatformChars(env, mtlShadersLib, 0)]];
@@ -146,7 +146,7 @@
}
NSNumber * num = (NSNumber *)[retArray objectAtIndex: 0];
ret = (jlong)[num longValue];
JNF_COCOA_EXIT(env);
JNI_COCOA_EXIT(env);
return ret;
}

@@ -189,7 +189,7 @@ CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* no
{
__block MTLLayer *layer = nil;

JNF_COCOA_ENTER(env);
JNI_COCOA_ENTER(env);

JNFWeakJObjectWrapper *javaLayer = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env];

@@ -199,7 +199,7 @@ CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* no
layer = [[MTLLayer alloc] initWithJavaLayer: javaLayer];
}];

JNF_COCOA_EXIT(env);
JNI_COCOA_EXIT(env);

return ptr_to_jlong(layer);
}
@@ -233,7 +233,7 @@ CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* no
Java_sun_java2d_metal_MTLLayer_nativeSetScale
(JNIEnv *env, jclass cls, jlong layerPtr, jdouble scale)
{
JNF_COCOA_ENTER(env);
JNI_COCOA_ENTER(env);
MTLLayer *layer = jlong_to_ptr(layerPtr);
// We always call all setXX methods asynchronously, exception is only in
// this method where we need to change native texture size and layer's scale
@@ -242,7 +242,7 @@ CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* no
[ThreadUtilities performOnMainThreadWaiting:[NSThread isMainThread] block:^(){
layer.contentsScale = scale;
}];
JNF_COCOA_EXIT(env);
JNI_COCOA_EXIT(env);
}

JNIEXPORT void JNICALL
@@ -288,13 +288,13 @@ static jboolean MTLSurfaceData_initTexture(BMTLSDOps *bmtlsdo, jboolean isOpaque
MTLSD_DestroyMTLSurface(JNIEnv *env, BMTLSDOps * bmtlsdo)
{
J2dTraceLn(J2D_TRACE_ERROR, "MTLSD_DestroyMTLSurface not implemented!");
JNF_COCOA_ENTER(env);
JNI_COCOA_ENTER(env);
if (bmtlsdo->drawableType == MTLSD_WINDOW) {
// TODO: detach the NSView from the metal context
}

bmtlsdo->drawableType = MTLSD_UNDEFINED;
JNF_COCOA_EXIT(env);
JNI_COCOA_EXIT(env);
}

/**
@@ -322,13 +322,13 @@ static jboolean MTLSurfaceData_initTexture(BMTLSDOps *bmtlsdo, jboolean isOpaque
return JNI_FALSE;
}

JNF_COCOA_ENTER(env);
JNI_COCOA_ENTER(env);
NSRect surfaceBounds = [v bounds];
bmtlsdo->drawableType = MTLSD_WINDOW;
bmtlsdo->isOpaque = JNI_TRUE;
bmtlsdo->width = surfaceBounds.size.width;
bmtlsdo->height = surfaceBounds.size.height;
JNF_COCOA_EXIT(env);
JNI_COCOA_EXIT(env);

J2dTraceLn2(J2D_TRACE_VERBOSE, " created window: w=%d h=%d", bmtlsdo->width, bmtlsdo->height);
return JNI_TRUE;

0 comments on commit ba66732

Please sign in to comment.