10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #ifndef _Included_Trace
27 #define _Included_Trace
28
29 #include <jni.h>
30 #include "debug_trace.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35
36 /**
37 * J2dTrace
38 * Trace utility used throughout Java 2D code. Uses a "level"
39 * parameter that allows user to specify how much detail
40 * they want traced at runtime. Tracing is only enabled
41 * in debug mode, to avoid overhead running release build.
42 */
43
44 #define J2D_TRACE_INVALID -1
45 #define J2D_TRACE_OFF 0
46 #define J2D_TRACE_ERROR 1
47 #define J2D_TRACE_WARNING 2
48 #define J2D_TRACE_INFO 3
49 #define J2D_TRACE_VERBOSE 4
50 #define J2D_TRACE_VERBOSE2 5
51 #define J2D_TRACE_MAX (J2D_TRACE_VERBOSE2+1)
52
53 JNIEXPORT void JNICALL
54 J2dTraceImpl(int level, jboolean cr, const char *string, ...);
158 }
159 #define J2dRlsTraceLn(level, string) { \
160 J2dTraceImpl(level, JNI_TRUE, string); \
161 }
162 #define J2dRlsTraceLn1(level, string, arg1) { \
163 J2dTraceImpl(level, JNI_TRUE, string, arg1); \
164 }
165 #define J2dRlsTraceLn2(level, string, arg1, arg2) { \
166 J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2); \
167 }
168 #define J2dRlsTraceLn3(level, string, arg1, arg2, arg3) { \
169 J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3); \
170 }
171 #define J2dRlsTraceLn4(level, string, arg1, arg2, arg3, arg4) { \
172 J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4); \
173 }
174 #define J2dRlsTraceLn5(level, string, arg1, arg2, arg3, arg4, arg5) { \
175 J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5); \
176 }
177
178 #ifdef __cplusplus
179 };
180 #endif /* __cplusplus */
181
182 #endif /* _Included_Trace */
|
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #ifndef _Included_Trace
27 #define _Included_Trace
28
29 #include <jni.h>
30 #include "jni_util.h"
31 #include "debug_trace.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
36 extern JavaVM *jvm;
37 extern jint graphicsPrimitive_traceflags;
38
39 /**
40 * J2dTrace
41 * Trace utility used throughout Java 2D code. Uses a "level"
42 * parameter that allows user to specify how much detail
43 * they want traced at runtime. Tracing is only enabled
44 * in debug mode, to avoid overhead running release build.
45 */
46
47 #define J2D_TRACE_INVALID -1
48 #define J2D_TRACE_OFF 0
49 #define J2D_TRACE_ERROR 1
50 #define J2D_TRACE_WARNING 2
51 #define J2D_TRACE_INFO 3
52 #define J2D_TRACE_VERBOSE 4
53 #define J2D_TRACE_VERBOSE2 5
54 #define J2D_TRACE_MAX (J2D_TRACE_VERBOSE2+1)
55
56 JNIEXPORT void JNICALL
57 J2dTraceImpl(int level, jboolean cr, const char *string, ...);
161 }
162 #define J2dRlsTraceLn(level, string) { \
163 J2dTraceImpl(level, JNI_TRUE, string); \
164 }
165 #define J2dRlsTraceLn1(level, string, arg1) { \
166 J2dTraceImpl(level, JNI_TRUE, string, arg1); \
167 }
168 #define J2dRlsTraceLn2(level, string, arg1, arg2) { \
169 J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2); \
170 }
171 #define J2dRlsTraceLn3(level, string, arg1, arg2, arg3) { \
172 J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3); \
173 }
174 #define J2dRlsTraceLn4(level, string, arg1, arg2, arg3, arg4) { \
175 J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4); \
176 }
177 #define J2dRlsTraceLn5(level, string, arg1, arg2, arg3, arg4, arg5) { \
178 J2dTraceImpl(level, JNI_TRUE, string, arg1, arg2, arg3, arg4, arg5); \
179 }
180
181 #define J2dTracePrimitive(string) { \
182 if (graphicsPrimitive_traceflags && jvm) { \
183 JNIEnv *env; \
184 jstring jstr; \
185 (*jvm)->AttachCurrentThreadAsDaemon(jvm, &env, NULL); \
186 jstr = (*env)->NewStringUTF(env, string); \
187 JNU_CallStaticMethodByName(env, NULL, "sun/java2d/loops/GraphicsPrimitive", \
188 "tracePrimitive", "(Ljava/lang/Object;)V", jstr); \
189 (*env)->DeleteLocalRef(env, jstr); \
190 } \
191 }
192
193 #define J2dTraceNotImplPrimitive(prim) { \
194 if (graphicsPrimitive_traceflags && jvm) { \
195 char cbuf[255]; \
196 JNIEnv *env; \
197 jstring jprim; \
198 jstring jmsg; \
199 snprintf(cbuf, 255, "[NOT IMPL] at %s:%d", __FILE__, __LINE__); \
200 (*jvm)->AttachCurrentThreadAsDaemon(jvm, &env, NULL); \
201 jprim = (*env)->NewStringUTF(env, prim); \
202 jmsg = (*env)->NewStringUTF(env, cbuf); \
203 JNU_CallStaticMethodByName(env, NULL, \
204 "sun/java2d/loops/GraphicsPrimitive", \
205 "traceImplPrimitive", \
206 "(Ljava/lang/Object;Ljava/lang/Object;)V", \
207 jprim, jmsg); \
208 (*env)->DeleteLocalRef(env, jprim); \
209 (*env)->DeleteLocalRef(env, jmsg); \
210 } \
211 }
212
213 #define J2dTraceImplPrimitive(prim, msg) { \
214 if (graphicsPrimitive_traceflags && jvm) { \
215 char cbuf[255]; \
216 JNIEnv *env; \
217 jstring jprim; \
218 jstring jmsg; \
219 snprintf(cbuf, 255, "%s at %s:%d", msg, __FILE__, __LINE__); \
220 (*jvm)->AttachCurrentThreadAsDaemon(jvm, &env, NULL); \
221 jprim = (*env)->NewStringUTF(env, prim); \
222 jmsg = (*env)->NewStringUTF(env, cbuf); \
223 JNU_CallStaticMethodByName(env, NULL, \
224 "sun/java2d/loops/GraphicsPrimitive", \
225 "traceImplPrimitive", \
226 "(Ljava/lang/Object;Ljava/lang/Object;)V", \
227 jprim, jmsg); \
228 (*env)->DeleteLocalRef(env, jprim); \
229 (*env)->DeleteLocalRef(env, jmsg); \
230 } \
231 }
232
233
234 #ifdef __cplusplus
235 };
236 #endif /* __cplusplus */
237
238 #endif /* _Included_Trace */
|