< prev index next >

src/java.desktop/share/native/libawt/java2d/Trace.h

Print this page
rev 54883 : JDK-8220154 Improve java2d rendering performance on macOS by using Metal framework

@@ -25,15 +25,18 @@
 
 #ifndef _Included_Trace
 #define _Included_Trace
 
 #include <jni.h>
+#include "jni_util.h"
 #include "debug_trace.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
+extern JavaVM *jvm;
+extern jint graphicsPrimitive_traceflags;
 
 /**
  * J2dTrace
  * Trace utility used throughout Java 2D code.  Uses a "level"
  * parameter that allows user to specify how much detail

@@ -173,10 +176,63 @@
         }
 #define J2dRlsTraceLn5(level, string, arg1, arg2, arg3, arg4, arg5) { \
             J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5); \
         }
 
+#define J2dTracePrimitive(string) { \
+        if (graphicsPrimitive_traceflags && jvm) { \
+            JNIEnv *env; \
+            jstring jstr; \
+            (*jvm)->AttachCurrentThreadAsDaemon(jvm, &env, NULL); \
+            jstr = (*env)->NewStringUTF(env, string); \
+            JNU_CallStaticMethodByName(env, NULL, "sun/java2d/loops/GraphicsPrimitive", \
+                                       "tracePrimitive", "(Ljava/lang/Object;)V", jstr); \
+            (*env)->DeleteLocalRef(env, jstr); \
+        } \
+    }
+
+#define J2dTraceNotImplPrimitive(prim) { \
+        if (graphicsPrimitive_traceflags && jvm) { \
+            char cbuf[255]; \
+            JNIEnv *env; \
+            jstring jprim; \
+            jstring jmsg; \
+            snprintf(cbuf, 255, "[NOT IMPL] at %s:%d", __FILE__, __LINE__); \
+            (*jvm)->AttachCurrentThreadAsDaemon(jvm, &env, NULL); \
+            jprim = (*env)->NewStringUTF(env, prim); \
+            jmsg = (*env)->NewStringUTF(env, cbuf); \
+            JNU_CallStaticMethodByName(env, NULL, \
+                                       "sun/java2d/loops/GraphicsPrimitive", \
+                                       "traceImplPrimitive", \
+                                       "(Ljava/lang/Object;Ljava/lang/Object;)V", \
+                                       jprim, jmsg); \
+            (*env)->DeleteLocalRef(env, jprim); \
+            (*env)->DeleteLocalRef(env, jmsg); \
+        } \
+    }
+
+#define J2dTraceImplPrimitive(prim, msg) { \
+        if (graphicsPrimitive_traceflags && jvm) { \
+            char cbuf[255]; \
+            JNIEnv *env; \
+            jstring jprim; \
+            jstring jmsg; \
+            snprintf(cbuf, 255, "%s at %s:%d", msg, __FILE__, __LINE__); \
+            (*jvm)->AttachCurrentThreadAsDaemon(jvm, &env, NULL); \
+            jprim = (*env)->NewStringUTF(env, prim); \
+            jmsg = (*env)->NewStringUTF(env, cbuf); \
+            JNU_CallStaticMethodByName(env, NULL, \
+                                       "sun/java2d/loops/GraphicsPrimitive", \
+                                       "traceImplPrimitive", \
+                                       "(Ljava/lang/Object;Ljava/lang/Object;)V", \
+                                       jprim, jmsg); \
+            (*env)->DeleteLocalRef(env, jprim); \
+            (*env)->DeleteLocalRef(env, jmsg); \
+        } \
+    }
+
+
 #ifdef __cplusplus
 };
 #endif /* __cplusplus */
 
 #endif /* _Included_Trace */
< prev index next >