1// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4#ifndef SkTraceEventCommon_DEFINED
5#define SkTraceEventCommon_DEFINED
6
7#include "include/core/SkTypes.h"
8#include "include/utils/SkTraceEventPhase.h"
9
10// Trace events are for tracking application performance and resource usage.
11// Macros are provided to track:
12//    Duration of scoped regions
13//    Instantaneous events
14//    Counters
15//
16// The first two arguments to all TRACE macros are the category and name. Both are strings, and
17// must have application lifetime (statics or literals). The same applies to arg_names, and string
18// argument values. However, you can force a copy of a string argument value with TRACE_STR_COPY:
19//     TRACE_EVENT1("category", "name", "arg1", "literal string is only referenced");
20//     TRACE_EVENT1("category", "name", "arg1", TRACE_STR_COPY("string will be copied"));
21//
22//
23// Categories are used to group events, and
24// can be enabled or disabled by the tracing framework. The trace system will automatically add the
25// process id, thread id, and microsecond timestamp to all events.
26//
27//
28// The TRACE_EVENT[0-2] macros trace the duration of entire scopes:
29//   void doSomethingCostly() {
30//     TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
31//     ...
32//   }
33//
34// Additional parameters can be associated with an event:
35//   void doSomethingCostly2(int howMuch) {
36//     TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly", "howMuch", howMuch);
37//     ...
38//   }
39//
40//
41// Trace event also supports counters, which is a way to track a quantity as it varies over time.
42// Counters are created with the following macro:
43//   TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
44//
45// Counters are process-specific. The macro itself can be issued from any thread, however.
46//
47// Sometimes, you want to track two counters at once. You can do this with two counter macros:
48//   TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
49//   TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
50// Or you can do it with a combined macro:
51//   TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
52//                  "bytesPinned", g_myCounterValue[0],
53//                  "bytesAllocated", g_myCounterValue[1]);
54// The tracing UI will show these counters in a single graph, as a summed area chart.
55
56#if defined(TRACE_EVENT0)
57#error "Another copy of this file has already been included."
58#endif
59
60#define TRACE_EMPTY do {} while (0)
61
62#ifdef SK_DISABLE_TRACING
63
64#define ATRACE_ANDROID_FRAMEWORK(fmt, ...) TRACE_EMPTY
65#define ATRACE_ANDROID_FRAMEWORK_ALWAYS(fmt, ...) TRACE_EMPTY
66#define HITRACE_OHOS_NAME_ALWAYS(name) TRACE_EMPTY
67#define HITRACE_OHOS_NAME_FMT_ALWAYS(fmt, ...) TRACE_EMPTY
68#define SKIA_OHOS_TRACE_PRIV(category_group, name) TRACE_EMPTY
69#define TRACE_EVENT0(cg, n) TRACE_EMPTY
70#define TRACE_EVENT0_ALWAYS(cg, n) TRACE_EMPTY
71#define TRACE_EVENT1(cg, n, a1n, a1v) TRACE_EMPTY
72#define TRACE_EVENT2(cg, n, a1n, a1v, a2n, a2v) TRACE_EMPTY
73#define TRACE_EVENT_INSTANT0(cg, n, scope) TRACE_EMPTY
74#define TRACE_EVENT_INSTANT1(cg, n, scope, a1n, a1v) TRACE_EMPTY
75#define TRACE_EVENT_INSTANT2(cg, n, scope, a1n, a1v, a2n, a2v) TRACE_EMPTY
76#define TRACE_COUNTER1(cg, n, value) TRACE_EMPTY
77#define TRACE_COUNTER2(cg, n, v1n, v1v, v2n, v2v) TRACE_EMPTY
78
79#elif defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
80
81#include <cutils/trace.h>
82#include <stdarg.h>
83
84class SkAndroidFrameworkTraceUtil {
85public:
86    SkAndroidFrameworkTraceUtil(const char* name) {
87        if (CC_UNLIKELY(gEnableAndroidTracing)) {
88            ATRACE_BEGIN(name);
89        }
90    }
91    SkAndroidFrameworkTraceUtil(bool, const char* fmt, ...) {
92        if (CC_LIKELY((!gEnableAndroidTracing) || (!ATRACE_ENABLED()))) return;
93
94        const int BUFFER_SIZE = 256;
95        va_list ap;
96        char buf[BUFFER_SIZE];
97
98        va_start(ap, fmt);
99        vsnprintf(buf, BUFFER_SIZE, fmt, ap);
100        va_end(ap);
101
102        ATRACE_BEGIN(buf);
103    }
104    ~SkAndroidFrameworkTraceUtil() {
105        if (CC_UNLIKELY(gEnableAndroidTracing)) {
106            ATRACE_END();
107        }
108    }
109
110    static void setEnableTracing(bool enableAndroidTracing) {
111        gEnableAndroidTracing = enableAndroidTracing;
112    }
113
114    static bool getEnableTracing() {
115        return gEnableAndroidTracing;
116    }
117
118private:
119    static bool gEnableAndroidTracing;
120};
121
122class SkAndroidFrameworkTraceUtilAlways {
123public:
124    SkAndroidFrameworkTraceUtilAlways(const char* fmt, ...) {
125        if (!ATRACE_ENABLED()) return;
126
127        const int BUFFER_SIZE = 256;
128        va_list ap;
129        char buf[BUFFER_SIZE];
130
131        va_start(ap, fmt);
132        vsnprintf(buf, BUFFER_SIZE, fmt, ap);
133        va_end(ap);
134
135        ATRACE_BEGIN(buf);
136    }
137    ~SkAndroidFrameworkTraceUtilAlways() {
138        ATRACE_END();
139    }
140};
141
142#define ATRACE_ANDROID_FRAMEWORK(fmt, ...) SkAndroidFrameworkTraceUtil __trace(true, fmt, ##__VA_ARGS__)
143#define ATRACE_ANDROID_FRAMEWORK_ALWAYS(fmt, ...) SkAndroidFrameworkTraceUtilAlways __trace_always(fmt, ##__VA_ARGS__)
144#define HITRACE_OHOS_NAME_ALWAYS(name) TRACE_EMPTY
145#define HITRACE_OHOS_NAME_FMT_ALWAYS(fmt, ...) TRACE_EMPTY
146#define SKIA_OHOS_TRACE_PRIV(category_group, name) TRACE_EMPTY
147
148// Records a pair of begin and end events called "name" for the current scope, with 0, 1 or 2
149// associated arguments. In the framework, the arguments are ignored.
150#define TRACE_EVENT0(category_group, name) \
151    SkAndroidFrameworkTraceUtil __trace(name)
152#define TRACE_EVENT0_ALWAYS(category_group, name) \
153    SkAndroidFrameworkTraceUtilAlways __trace_always(name)
154#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
155    SkAndroidFrameworkTraceUtil __trace(name)
156#define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) \
157    SkAndroidFrameworkTraceUtil __trace(name)
158
159// Records a single event called "name" immediately, with 0, 1 or 2 associated arguments. If the
160// category is not enabled, then this does nothing.
161#define TRACE_EVENT_INSTANT0(category_group, name, scope) \
162    do { SkAndroidFrameworkTraceUtil __trace(name); } while(0)
163
164#define TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val) \
165    do { SkAndroidFrameworkTraceUtil __trace(name); } while(0)
166
167#define TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, arg1_val, \
168                             arg2_name, arg2_val)                              \
169    do { SkAndroidFrameworkTraceUtil __trace(name); } while(0)
170
171// Records the value of a counter called "name" immediately. Value
172// must be representable as a 32 bit integer.
173#define TRACE_COUNTER1(category_group, name, value) \
174    if (CC_UNLIKELY(SkAndroidFrameworkTraceUtil::getEnableTracing())) { \
175        ATRACE_INT(name, value); \
176    }
177
178// Records the values of a multi-parted counter called "name" immediately.
179// In Chrome, this macro produces a stacked bar chart. ATrace doesn't support
180// that, so this just produces two separate counters.
181#define TRACE_COUNTER2(category_group, name, value1_name, value1_val, value2_name, value2_val) \
182    do { \
183        if (CC_UNLIKELY(SkAndroidFrameworkTraceUtil::getEnableTracing())) { \
184            ATRACE_INT(name "-" value1_name, value1_val); \
185            ATRACE_INT(name "-" value2_name, value2_val); \
186        } \
187    } while (0)
188
189// ATrace has no object tracking
190#define TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group, name, id) TRACE_EMPTY
191#define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group, name, id, snapshot) TRACE_EMPTY
192#define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) TRACE_EMPTY
193
194// Macro to efficiently determine if a given category group is enabled.
195// This is only used for some shader text logging that isn't supported in ATrace anyway.
196#define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret)             \
197  do { *ret = false; } while (0)
198
199#elif defined(SKIA_OHOS_FOR_OHOS_TRACE)
200
201#include "hitrace_meter.h"
202
203#define UNLIKELY(exp) (__builtin_expect((exp) != 0, false))
204#define ATRACE_ANDROID_FRAMEWORK(fmt, ...) TRACE_EMPTY
205#define ATRACE_ANDROID_FRAMEWORK_ALWAYS(fmt, ...) TRACE_EMPTY
206#define HITRACE_OHOS_NAME_ALWAYS(name) HITRACE_METER_NAME(HITRACE_TAG_GRAPHIC_AGP | HITRACE_TAG_COMMERCIAL, name)
207#define HITRACE_OHOS_NAME_FMT_ALWAYS(fmt, ...) \
208    HITRACE_METER_FMT(HITRACE_TAG_GRAPHIC_AGP | HITRACE_TAG_COMMERCIAL, fmt, ##__VA_ARGS__)
209
210// print ohos trace without SKIA_OHOS_DEBUG macro
211#define SKIA_OHOS_TRACE_PRIV(category_group, name) \
212    HitraceScoped _trace(HITRACE_TAG_GRAPHIC_AGP, name)
213
214// Records a pair of begin and end events called "name" for the current scope, with 0, 1 or 2
215// associated arguments. If the category is not enabled, then this does nothing.
216#ifdef SKIA_OHOS_DEBUG
217#define TRACE_EVENT0(category_group, name) \
218    HitraceScoped _trace(HITRACE_TAG_GRAPHIC_AGP, name)
219
220#define TRACE_EVENT0_ALWAYS(category_group, name) \
221    HitraceScoped _trace(HITRACE_TAG_GRAPHIC_AGP, name)
222
223#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
224    HitraceScoped _trace(HITRACE_TAG_GRAPHIC_AGP, name)
225
226#define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) \
227    HitraceScoped _trace(HITRACE_TAG_GRAPHIC_AGP, name)
228#else
229#define TRACE_EVENT0(category_group, name) TRACE_EMPTY
230#define TRACE_EVENT0_ALWAYS(category_group, name) TRACE_EMPTY
231#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) TRACE_EMPTY
232#define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) TRACE_EMPTY
233#endif
234
235// Records a single event called "name" immediately, with 0, 1 or 2 associated arguments. If the
236// category is not enabled, then this does nothing.
237#define TRACE_EVENT_INSTANT0(category_group, name, scope) TRACE_EMPTY
238#define TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val) TRACE_EMPTY
239#define TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, arg1_val, arg2_name, arg2_val) TRACE_EMPTY
240
241// Records the value of a counter called "name" immediately. Value
242// must be representable as a 32 bit integer.
243#define TRACE_COUNTER1(category_group, name, value) TRACE_EMPTY
244
245// Records the values of a multi-parted counter called "name" immediately.
246#ifdef SKIA_OHOS_DEBUG
247#define TRACE_COUNTER2(category_group, name, value1_name, value1_val, value2_name, value2_val) \
248    do { \
249        if (UNLIKELY(IsTagEnabled(HITRACE_TAG_GRAPHIC_AGP))) { \
250            std::string tid = std::to_string(gettid()); \
251            std::string threadValue1Name = tid + "-" + name + "-" + value1_name; \
252            std::string threadValue2Name = tid + "-" + name + "-" + value2_name; \
253            CountTrace(HITRACE_TAG_GRAPHIC_AGP, threadValue1Name, value1_val); \
254            CountTrace(HITRACE_TAG_GRAPHIC_AGP, threadValue2Name, value2_val); \
255        } \
256    } while (0)
257#else
258#define TRACE_COUNTER2(category_group, name, value1_name, value1_val, value2_name, value2_val) TRACE_EMPTY
259#endif
260
261#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) TRACE_EMPTY
262#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) TRACE_EMPTY
263#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, arg2_name, arg2_val) TRACE_EMPTY
264#define TRACE_EVENT_ASYNC_END0(category, name, id) TRACE_EMPTY
265#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) TRACE_EMPTY
266#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, arg2_name, arg2_val) TRACE_EMPTY
267
268// Macros to track the life time and value of arbitrary client objects.
269#define TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group, name, id) TRACE_EMPTY
270#define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group, name, id, snapshot) TRACE_EMPTY
271#define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) TRACE_EMPTY
272
273// Macro to efficiently determine if a given category group is enabled.
274#define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret)             \
275    do { *ret = false; } while (0)
276
277#else // !SK_BUILD_FOR_ANDROID_FRAMEWORK && !SK_DISABLE_TRACING
278
279#define ATRACE_ANDROID_FRAMEWORK(fmt, ...) TRACE_EMPTY
280#define ATRACE_ANDROID_FRAMEWORK_ALWAYS(fmt, ...) TRACE_EMPTY
281#define HITRACE_OHOS_NAME_ALWAYS(name) TRACE_EMPTY
282#define HITRACE_OHOS_NAME_FMT_ALWAYS(fmt, ...) TRACE_EMPTY
283#define SKIA_OHOS_TRACE_PRIV(category_group, name) TRACE_EMPTY
284
285// Records a pair of begin and end events called "name" for the current scope, with 0, 1 or 2
286// associated arguments. If the category is not enabled, then this does nothing.
287#define TRACE_EVENT0(category_group, name) \
288  INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name)
289
290#define TRACE_EVENT0_ALWAYS(category_group, name) \
291  INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name)
292
293#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
294  INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val)
295
296#define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) \
297  INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val)
298
299// Records a single event called "name" immediately, with 0, 1 or 2 associated arguments. If the
300// category is not enabled, then this does nothing.
301#define TRACE_EVENT_INSTANT0(category_group, name, scope)                   \
302  INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \
303                           TRACE_EVENT_FLAG_NONE | scope)
304
305#define TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val) \
306  INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name,    \
307                           TRACE_EVENT_FLAG_NONE | scope, arg1_name, arg1_val)
308
309#define TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, arg1_val, \
310                             arg2_name, arg2_val)                              \
311  INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name,    \
312                           TRACE_EVENT_FLAG_NONE | scope, arg1_name, arg1_val, \
313                           arg2_name, arg2_val)
314
315// Records the value of a counter called "name" immediately. Value
316// must be representable as a 32 bit integer.
317#define TRACE_COUNTER1(category_group, name, value)                         \
318  INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \
319                           TRACE_EVENT_FLAG_NONE, "value",                  \
320                           static_cast<int>(value))
321
322// Records the values of a multi-parted counter called "name" immediately.
323// The UI will treat value1 and value2 as parts of a whole, displaying their
324// values as a stacked-bar chart.
325#define TRACE_COUNTER2(category_group, name, value1_name, value1_val,       \
326                       value2_name, value2_val)                             \
327  INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \
328                           TRACE_EVENT_FLAG_NONE, value1_name,              \
329                           static_cast<int>(value1_val), value2_name,       \
330                           static_cast<int>(value2_val))
331
332#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id)                                           \
333    INTERNAL_TRACE_EVENT_ADD_WITH_ID(                                                          \
334        TRACE_EVENT_PHASE_ASYNC_BEGIN, category, name, id, TRACE_EVENT_FLAG_NONE)
335#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val)                      \
336    INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN,                            \
337        category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
338#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \
339    INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN,                            \
340        category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
341
342#define TRACE_EVENT_ASYNC_END0(category, name, id)                                           \
343    INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END,                            \
344        category, name, id, TRACE_EVENT_FLAG_NONE)
345#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val)                      \
346    INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END,                            \
347        category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
348#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \
349    INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END,                            \
350        category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
351
352// Macros to track the life time and value of arbitrary client objects.
353#define TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group, name, id) \
354  INTERNAL_TRACE_EVENT_ADD_WITH_ID(                                  \
355      TRACE_EVENT_PHASE_CREATE_OBJECT, category_group, name, id,     \
356      TRACE_EVENT_FLAG_NONE)
357
358#define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group, name, id, \
359                                            snapshot)                 \
360  INTERNAL_TRACE_EVENT_ADD_WITH_ID(                                   \
361      TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, category_group, name,        \
362      id, TRACE_EVENT_FLAG_NONE, "snapshot", snapshot)
363
364#define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \
365  INTERNAL_TRACE_EVENT_ADD_WITH_ID(                                  \
366      TRACE_EVENT_PHASE_DELETE_OBJECT, category_group, name, id,     \
367      TRACE_EVENT_FLAG_NONE)
368
369// Macro to efficiently determine if a given category group is enabled.
370#define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret)             \
371  do {                                                                      \
372    INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group);                 \
373    if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
374      *ret = true;                                                          \
375    } else {                                                                \
376      *ret = false;                                                         \
377    }                                                                       \
378  } while (0)
379
380#endif
381
382// Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
383#define TRACE_EVENT_FLAG_NONE (static_cast<unsigned int>(0))
384#define TRACE_EVENT_FLAG_COPY (static_cast<unsigned int>(1 << 0))
385#define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned int>(1 << 1))
386#define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned int>(1 << 2))
387#define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned int>(1 << 3))
388#define TRACE_EVENT_FLAG_SCOPE_EXTRA (static_cast<unsigned int>(1 << 4))
389#define TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP (static_cast<unsigned int>(1 << 5))
390#define TRACE_EVENT_FLAG_ASYNC_TTS (static_cast<unsigned int>(1 << 6))
391#define TRACE_EVENT_FLAG_BIND_TO_ENCLOSING (static_cast<unsigned int>(1 << 7))
392#define TRACE_EVENT_FLAG_FLOW_IN (static_cast<unsigned int>(1 << 8))
393#define TRACE_EVENT_FLAG_FLOW_OUT (static_cast<unsigned int>(1 << 9))
394#define TRACE_EVENT_FLAG_HAS_CONTEXT_ID (static_cast<unsigned int>(1 << 10))
395
396#define TRACE_EVENT_FLAG_SCOPE_MASK                          \
397  (static_cast<unsigned int>(TRACE_EVENT_FLAG_SCOPE_OFFSET | \
398                             TRACE_EVENT_FLAG_SCOPE_EXTRA))
399
400// Type values for identifying types in the TraceValue union.
401#define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1))
402#define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2))
403#define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3))
404#define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4))
405#define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5))
406#define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6))
407#define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7))
408#define TRACE_VALUE_TYPE_CONVERTABLE (static_cast<unsigned char>(8))
409
410// Enum reflecting the scope of an INSTANT event. Must fit within TRACE_EVENT_FLAG_SCOPE_MASK.
411#define TRACE_EVENT_SCOPE_GLOBAL (static_cast<unsigned char>(0 << 3))
412#define TRACE_EVENT_SCOPE_PROCESS (static_cast<unsigned char>(1 << 3))
413#define TRACE_EVENT_SCOPE_THREAD (static_cast<unsigned char>(2 << 3))
414
415#define TRACE_EVENT_SCOPE_NAME_GLOBAL ('g')
416#define TRACE_EVENT_SCOPE_NAME_PROCESS ('p')
417#define TRACE_EVENT_SCOPE_NAME_THREAD ('t')
418
419#endif  // SkTraceEventCommon_DEFINED
420