Unverified Commit cbf3345b authored by Ivan Matkov's avatar Ivan Matkov Committed by GitHub
parent 79f1d43e
...@@ -88,7 +88,25 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt ...@@ -88,7 +88,25 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
[weakSelf onScreenDidChange]; [weakSelf onScreenDidChange];
}]; }];
if (NSThread.currentThread.isMainThread) {
[self onScreenDidChange]; [self onScreenDidChange];
} else {
// In case of OpenJDK, EDT thread != NSThread main thread
// There is one thing we should keep in mind. Postponing creation of vsync throttler will cause that for sometime there won't be any waiting:
//
// ```
// create window
// (10x) schedule render -> render
// onScreenDidChange
// schedule render -> wait vsync -> render
// ```
//
// It is probably okay, but possible alternative would be to wait for throttler creation. It is difficult, so we can just keep the current code.
__weak DisplayLinkThrottler *weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf onScreenDidChange];
});
}
} }
return self; return self;
......
...@@ -115,6 +115,26 @@ static jmethodID getOnOcclusionStateChangedMethodID(JNIEnv *env, jobject redrawe ...@@ -115,6 +115,26 @@ static jmethodID getOnOcclusionStateChangedMethodID(JNIEnv *env, jobject redrawe
return onOcclusionStateChanged; return onOcclusionStateChanged;
} }
static void setWindowPropertiesUnsafe(NSWindow* window, jboolean transparency) {
if (window == NULL) return;
if (transparency) {
window.hasShadow = NO;
}
}
static void setWindowProperties(NSWindow* window, jboolean transparency) {
if (NSThread.currentThread.isMainThread) {
setWindowPropertiesUnsafe(window, transparency);
} else {
// In case of OpenJDK, EDT thread != NSThread main thread
__weak NSWindow *weakWindow = window;
dispatch_async(dispatch_get_main_queue(), ^{
setWindowPropertiesUnsafe(weakWindow, transparency);
});
}
}
extern "C" extern "C"
{ {
...@@ -161,10 +181,7 @@ JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_createMe ...@@ -161,10 +181,7 @@ JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_createMe
device.inflightSemaphore = dispatch_semaphore_create(device.layer.maximumDrawableCount); device.inflightSemaphore = dispatch_semaphore_create(device.layer.maximumDrawableCount);
NSWindow* window = (__bridge NSWindow*) (void *) windowPtr; NSWindow* window = (__bridge NSWindow*) (void *) windowPtr;
setWindowProperties(window, transparency);
if (transparency) {
window.hasShadow = NO;
}
jmethodID onOcclusionStateChanged = getOnOcclusionStateChangedMethodID(env, redrawer); jmethodID onOcclusionStateChanged = getOnOcclusionStateChangedMethodID(env, redrawer);
device.occlusionObserver = device.occlusionObserver =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment