Skip to content

Commit 15f97ed

Browse files
author
Jose Pereda
committed
8240264: iOS: Unnecessary logging on every pulse when GL context changes
Reviewed-by: kcr, jvos
1 parent 2ca509a commit 15f97ed

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

modules/javafx.graphics/src/main/native-prism-es2/ios/IOSGLContext.c

+24-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@
3434
#include "com_sun_prism_es2_IOSGLContext.h"
3535

3636
extern void printAndReleaseResources(jlong pf, jlong ctx, const char *message);
37+
jboolean pulseLoggingRequested;
38+
39+
jboolean isPulseLoggingRequested(JNIEnv *env) {
40+
jclass loggerCls = (*env)->FindClass(env, "com/sun/javafx/logging/PulseLogger");
41+
if ((*env)->ExceptionCheck(env) || loggerCls == NULL) {
42+
(*env)->ExceptionClear(env);
43+
return JNI_FALSE;
44+
}
45+
jmethodID loggerMID = (*env)->GetStaticMethodID(env, loggerCls, "isPulseLoggingRequested", "()Z");
46+
if ((*env)->ExceptionCheck(env) || loggerMID == NULL) {
47+
(*env)->ExceptionClear(env);
48+
return JNI_FALSE;
49+
}
50+
jboolean result = (*env)->CallStaticBooleanMethod(env, loggerCls, loggerMID);
51+
if ((*env)->ExceptionCheck(env)) {
52+
(*env)->ExceptionClear(env);
53+
return JNI_FALSE;
54+
}
55+
return result;
56+
}
3757

3858
/*
3959
* Class: com_sun_prism_es2_IOSGLContext
@@ -51,6 +71,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_prism_es2_IOSGLContext_nInitialize
5171
int versionNumbers[2];
5272
const char *glExtensions;
5373

74+
pulseLoggingRequested = isPulseLoggingRequested(env);
5475
jlong pixelFormat = 0;
5576
jlong win = 0;
5677
jlong context = 0;
@@ -289,5 +310,7 @@ JNIEXPORT void JNICALL Java_com_sun_prism_es2_IOSGLContext_nMakeCurrent
289310
interval = (vSyncNeeded) ? 1 : 0;
290311
ctxInfo->state.vSyncEnabled = vSyncNeeded;
291312
setSwapInterval(ctxInfo->context, interval);
292-
fprintf(stderr, "setSwapInterval(%d)\n", interval);
313+
if (pulseLoggingRequested) {
314+
fprintf(stderr, "setSwapInterval(%d)\n", interval);
315+
}
293316
}

modules/javafx.graphics/src/main/native-prism-es2/ios/IOSWindowSystemInterface.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ jboolean flushBuffer(void *context) {
9292
}
9393

9494
void setSwapInterval(void *context, int interval) {
95-
fprintf(stderr, "IOSWindowSystemInterface : setSwapInterval unimp\n");
95+
if (pulseLoggingRequested) {
96+
fprintf(stderr, "IOSWindowSystemInterface : setSwapInterval unimp\n");
97+
}
9698
}
9799

98100

modules/javafx.graphics/src/main/native-prism-es2/ios/ios-window-system.h

+1
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ void* getProcAddress(const char *procName);
5050

5151
void setSwapInterval(void* nsContext, int interval);
5252

53+
extern jboolean pulseLoggingRequested;

0 commit comments

Comments
 (0)