Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8260857: Remove JNFWeakJObjectWrapper from Lanai Project
  • Loading branch information
Phil Race committed Feb 1, 2021
1 parent 5aca2ac commit 7bf226fcbc6a8b85e5b2743c574e0855a4c69096
@@ -35,7 +35,7 @@
@interface MTLLayer : CAMetalLayer
{
@private
JNFWeakJObjectWrapper *javaLayer;
jobject javaLayer;

// intermediate buffer, used the RQ lock to synchronize
MTLContext* ctx;
@@ -48,7 +48,7 @@
CVDisplayLinkRef displayLink;
}

@property (nonatomic, retain) JNFWeakJObjectWrapper *javaLayer;
@property (nonatomic) jobject javaLayer;
@property (readwrite, assign) MTLContext* ctx;
@property (readwrite, assign) float bufferWidth;
@property (readwrite, assign) float bufferHeight;
@@ -58,7 +58,7 @@
@property (readwrite, assign) int leftInset;
@property (readwrite, assign) CVDisplayLinkRef displayLink;

- (id) initWithJavaLayer:(JNFWeakJObjectWrapper *)layer;
- (id) initWithJavaLayer:(jobject)layer;

- (void) blitTexture;
- (void) fillParallelogramCtxX:(jfloat)x
@@ -43,7 +43,7 @@ @implementation MTLLayer
@synthesize nextDrawableCount;
@synthesize displayLink;

- (id) initWithJavaLayer:(JNFWeakJObjectWrapper *)layer
- (id) initWithJavaLayer:(jobject)layer
{
AWT_ASSERT_APPKIT_THREAD;
// Initialize ourselves
@@ -122,6 +122,8 @@ - (void) blitTexture {
}

- (void) dealloc {
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
(*env)->DeleteWeakGlobalRef(env, self.javaLayer);
self.javaLayer = nil;
[self stopDisplayLink];
CVDisplayLinkRelease(self.displayLink);
@@ -135,7 +137,7 @@ - (void) blitCallback {
DECLARE_CLASS(jc_JavaLayer, "sun/java2d/metal/MTLLayer");
DECLARE_METHOD(jm_drawInMTLContext, jc_JavaLayer, "drawInMTLContext", "()V");

jobject javaLayerLocalRef = [self.javaLayer jObjectWithEnv:env];
jobject javaLayerLocalRef = (*env)->NewLocalRef(env, self.javaLayer);
if ((*env)->IsSameObject(env, javaLayerLocalRef, NULL)) {
return;
}
@@ -191,7 +193,7 @@ CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* no

JNI_COCOA_ENTER(env);

JNFWeakJObjectWrapper *javaLayer = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env];
jobject javaLayer = (*env)->NewWeakGlobalRef(env, obj);

[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
AWT_ASSERT_APPKIT_THREAD;

0 comments on commit 7bf226f

Please sign in to comment.