Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit 5263974

Browse files
committed
8247332: Checkbox reaches inconsistent state on tap to click
8251477: java/awt/Frame/MiscUndecorated/RepaintTest.java fails with metal pipeline 8247739: Lanai : SwingSet2Demo -More than one radio button can be selected the same time 8252501: Sometimes more than one menu items are shown as highlighted on hover 8242187: Lanai - JCheckBox and JRadioButton can get into inconsitent visual state -- but recover on window refresh 8252907: Motif L&F - SwingSet2 - Two Toolbar buttons are shown as selected
1 parent 5c53e62 commit 5263974

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLLayer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define MTLLayer_h_Included
2828
#import <Metal/Metal.h>
2929
#import <QuartzCore/CAMetalLayer.h>
30+
#include <CoreVideo/CVDisplayLink.h>
3031
#import "common.h"
3132

3233
#import <JavaNativeFoundation/JavaNativeFoundation.h>
@@ -44,6 +45,7 @@
4445
int nextDrawableCount;
4546
int topInset;
4647
int leftInset;
48+
CVDisplayLinkRef displayLink;
4749
}
4850

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

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

@@ -66,6 +69,7 @@
6669
DY2:(jfloat)dy2;
6770
- (void) blitCallback;
6871
- (void) display;
72+
- (void) redraw;
6973
@end
7074

7175
#endif /* CGLLayer_h_Included */

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLLayer.m

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ @implementation MTLLayer
4040
@synthesize topInset;
4141
@synthesize leftInset;
4242
@synthesize nextDrawableCount;
43+
@synthesize displayLink;
4344

4445
- (id) initWithJavaLayer:(JNFWeakJObjectWrapper *)layer
4546
{
@@ -70,6 +71,8 @@ - (id) initWithJavaLayer:(JNFWeakJObjectWrapper *)layer
7071
self.framebufferOnly = NO;
7172
self.nextDrawableCount = 0;
7273
self.opaque = FALSE;
74+
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink);
75+
CVDisplayLinkSetOutputCallback(displayLink, &displayLinkCallback, (__bridge void*)self);
7376
return self;
7477
}
7578

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

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

118122
- (void) dealloc {
119123
self.javaLayer = nil;
124+
if (CVDisplayLinkIsRunning(self.displayLink))
125+
CVDisplayLinkStop(self.displayLink);
126+
CVDisplayLinkRelease(self.displayLink);
127+
self.displayLink = nil;
120128
[super dealloc];
121129
}
122130

@@ -141,6 +149,21 @@ - (void) display {
141149
[self blitCallback];
142150
[super display];
143151
}
152+
153+
- (void) redraw {
154+
AWT_ASSERT_APPKIT_THREAD;
155+
[self setNeedsDisplay];
156+
}
157+
158+
CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext)
159+
{
160+
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer_displayLinkCallback() called");
161+
@autoreleasepool {
162+
MTLLayer *layer = (__bridge MTLLayer *)displayLinkContext;
163+
[layer performSelectorOnMainThread:@selector(redraw) withObject:nil waitUntilDone:NO];
164+
}
165+
return kCVReturnSuccess;
166+
}
144167
@end
145168

146169
/*
@@ -187,8 +210,12 @@ - (void) display {
187210
layer.drawableSize =
188211
CGSizeMake(layer.buffer.width,
189212
layer.buffer.height);
213+
if (!CVDisplayLinkIsRunning(layer.displayLink))
214+
CVDisplayLinkStart(layer.displayLink);
190215
} else {
191216
layer.ctx = NULL;
217+
if (CVDisplayLinkIsRunning(layer.displayLink))
218+
CVDisplayLinkStop(layer.displayLink);
192219
}
193220
}
194221

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLRenderQueue.m

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,17 +1159,6 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
11591159
[cbwrapper release];
11601160
}];
11611161
[commandbuf commit];
1162-
BMTLSDOps *dstOps = MTLRenderQueue_GetCurrentDestination();
1163-
if (dstOps != NULL) {
1164-
MTLSDOps *dstMTLOps = (MTLSDOps *)dstOps->privOps;
1165-
MTLLayer *layer = (MTLLayer*)dstMTLOps->layer;
1166-
if (layer != NULL) {
1167-
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
1168-
AWT_ASSERT_APPKIT_THREAD;
1169-
[layer setNeedsDisplay];
1170-
}];
1171-
}
1172-
}
11731162
}
11741163
RESET_PREVIOUS_OP();
11751164
}

0 commit comments

Comments
 (0)