Skip to content
This repository has been archived by the owner before Nov 9, 2022. It is now read-only.

8247332: Checkbox reaches inconsistent state on tap to click #146

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -27,6 +27,7 @@
#define MTLLayer_h_Included
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
#include <CoreVideo/CVDisplayLink.h>
#import "common.h"

#import <JavaNativeFoundation/JavaNativeFoundation.h>
@@ -44,6 +45,7 @@
int nextDrawableCount;
int topInset;
int leftInset;
CVDisplayLinkRef displayLink;
}

@property (nonatomic, retain) JNFWeakJObjectWrapper *javaLayer;
@@ -54,6 +56,7 @@
@property (readwrite, assign) int nextDrawableCount;
@property (readwrite, assign) int topInset;
@property (readwrite, assign) int leftInset;
@property (readwrite, assign) CVDisplayLinkRef displayLink;

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

@@ -66,6 +69,7 @@
DY2:(jfloat)dy2;
- (void) blitCallback;
- (void) display;
- (void) redraw;
@end

#endif /* CGLLayer_h_Included */
@@ -40,6 +40,7 @@ @implementation MTLLayer
@synthesize topInset;
@synthesize leftInset;
@synthesize nextDrawableCount;
@synthesize displayLink;

- (id) initWithJavaLayer:(JNFWeakJObjectWrapper *)layer
{
@@ -70,6 +71,8 @@ - (id) initWithJavaLayer:(JNFWeakJObjectWrapper *)layer
self.framebufferOnly = NO;
self.nextDrawableCount = 0;
self.opaque = FALSE;
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink);
CVDisplayLinkSetOutputCallback(displayLink, &displayLinkCallback, (__bridge void*)self);
return self;
}

@@ -79,8 +82,9 @@ - (void) blitTexture {
return;
}

if (self.nextDrawableCount != 0)
if (self.nextDrawableCount != 0) {
return;
}
@autoreleasepool {
if ((self.buffer.width == 0) || (self.buffer.height == 0)) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: cannot create drawable of size 0");
@@ -117,6 +121,10 @@ - (void) blitTexture {

- (void) dealloc {
self.javaLayer = nil;
if (CVDisplayLinkIsRunning(self.displayLink))
CVDisplayLinkStop(self.displayLink);
CVDisplayLinkRelease(self.displayLink);
self.displayLink = nil;
[super dealloc];
}

@@ -141,6 +149,21 @@ - (void) display {
[self blitCallback];
[super display];
}

- (void) redraw {
AWT_ASSERT_APPKIT_THREAD;
[self setNeedsDisplay];
}

CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext)
{
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer_displayLinkCallback() called");
@autoreleasepool {
MTLLayer *layer = (__bridge MTLLayer *)displayLinkContext;
[layer performSelectorOnMainThread:@selector(redraw) withObject:nil waitUntilDone:NO];
}
return kCVReturnSuccess;
}
@end

/*
@@ -187,8 +210,12 @@ - (void) display {
layer.drawableSize =
CGSizeMake(layer.buffer.width,
layer.buffer.height);
if (!CVDisplayLinkIsRunning(layer.displayLink))
CVDisplayLinkStart(layer.displayLink);
} else {
layer.ctx = NULL;
if (CVDisplayLinkIsRunning(layer.displayLink))
CVDisplayLinkStop(layer.displayLink);
}
}

@@ -1159,17 +1159,6 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
[cbwrapper release];
}];
[commandbuf commit];
BMTLSDOps *dstOps = MTLRenderQueue_GetCurrentDestination();
if (dstOps != NULL) {
MTLSDOps *dstMTLOps = (MTLSDOps *)dstOps->privOps;
MTLLayer *layer = (MTLLayer*)dstMTLOps->layer;
if (layer != NULL) {
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
AWT_ASSERT_APPKIT_THREAD;
[layer setNeedsDisplay];
}];
}
}
}
RESET_PREVIOUS_OP();
}