1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrTracing_DEFINED
#define GrTracing_DEFINED
#include "GrDrawTarget.h"
#include "GrGpu.h"
#include "GrTraceMarker.h"
#include "SkTLazy.h"
#include "SkTraceEvent.h"
/**
* Marker generation class used for adding and removing markers around code blocks
*/
class GrGpuTraceMarkerGenerator : public ::SkNoncopyable {
public:
GrGpuTraceMarkerGenerator(GrDrawTarget* target) {}
~GrGpuTraceMarkerGenerator() {
if (fTraceMarker.isValid()) {
// TODO remove trace marker
}
}
void initialize(const char* marker_str, int* marker_counter) {
// GrGpuTraceMarker* traceMarker = fTraceMarker.init(marker_str, *marker_counter);
// TODO add trace marker
}
private:
SkTLazy<GrGpuTraceMarker> fTraceMarker;
};
class GrGpuTraceMarkerGeneratorContext : public ::SkNoncopyable {
public:
GrGpuTraceMarkerGeneratorContext(GrContext* context) {}
~GrGpuTraceMarkerGeneratorContext() {
if (fTraceMarker.isValid()) {
// TODO remove trace marker
}
}
void initialize(const char* marker_str, int* marker_counter) {
// GrGpuTraceMarker* traceMarker = fTraceMarker.init(marker_str, *marker_counter);
// TODO add trace marker
}
private:
SkTLazy<GrGpuTraceMarker> fTraceMarker;
};
/**
* GR_CREATE_TRACE_MARKER will place begin and end trace markers for both
* cpu and gpu (if gpu tracing enabled) for the current scope.
* marker is of type const char* and target is of type GrDrawTarget*
*/
#define GR_CREATE_TRACE_MARKER(name, target) \
INTERNAL_GR_CREATE_TRACE_MARKER_SCOPED(name, target)
#define GR_CREATE_TRACE_MARKER1(name, target, arg1_name, arg1_val) \
INTERNAL_GR_CREATE_TRACE_MARKER_SCOPED(name, target, arg1_name, arg1_val)
#define INTERNAL_GR_CREATE_TRACE_MARKER_SCOPED(name, target, ...) \
static const char* SK_MACRO_APPEND_LINE(static_name) = name; \
static int SK_MACRO_APPEND_LINE(name_counter) = 0; \
INTERNAL_GR_CREATE_TRACE_MARKER(SK_MACRO_APPEND_LINE(static_name), \
SK_MACRO_APPEND_LINE(name_counter), \
target, ##__VA_ARGS__) \
sk_atomic_inc(&SK_MACRO_APPEND_LINE(name_counter));
#define INTERNAL_GR_CREATE_TRACE_MARKER(name, name_counter, target, ...) \
GR_CREATE_GPU_TRACE_MARKER(name, name_counter, target) \
INTERNAL_TRACE_EVENT_ADD_SCOPED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"),name, \
"id", name_counter, ##__VA_ARGS__);
#if GR_FORCE_GPU_TRACE_DEBUGGING
#define GR_CREATE_GPU_TRACE_MARKER(name, name_counter, target) \
GrGpuTraceMarkerGenerator SK_MACRO_APPEND_LINE(TMG)(target); \
SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter);
#else
#define GR_CREATE_GPU_TRACE_MARKER(name, name_counter, target) \
GrGpuTraceMarkerGenerator SK_MACRO_APPEND_LINE(TMG)(target); \
bool SK_MACRO_APPEND_LINE(gpuTracingEnabled); \
TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), \
&SK_MACRO_APPEND_LINE(gpuTracingEnabled)); \
if (SK_MACRO_APPEND_LINE(gpuTracingEnabled)) { \
SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter); \
}
#endif
#define GR_CREATE_TRACE_MARKER_CONTEXT(name, context) \
INTERNAL_GR_CREATE_TRACE_MARKER_SCOPED_C(name, context)
#define GR_CREATE_TRACE_MARKER_CONTEXT1(name, context, arg1_name, arg1_val) \
INTERNAL_GR_CREATE_TRACE_MARKER_SCOPED_C(name, context, arg1_name, arg1_val)
#define INTERNAL_GR_CREATE_TRACE_MARKER_SCOPED_C(name, context, ...) \
static const char* SK_MACRO_APPEND_LINE(static_name) = name; \
static int SK_MACRO_APPEND_LINE(name_counter) = 0; \
INTERNAL_GR_CREATE_TRACE_MARKER_C(SK_MACRO_APPEND_LINE(static_name), \
SK_MACRO_APPEND_LINE(name_counter), \
context, ##__VA_ARGS__) \
sk_atomic_inc(&SK_MACRO_APPEND_LINE(name_counter));
#define INTERNAL_GR_CREATE_TRACE_MARKER_C(name, name_counter, context, ...) \
GR_CREATE_GPU_TRACE_MARKER_C(name, name_counter, context) \
INTERNAL_TRACE_EVENT_ADD_SCOPED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"),name, \
"id", name_counter, ##__VA_ARGS__);
#if GR_FORCE_GPU_TRACE_DEBUGGING
#define GR_CREATE_GPU_TRACE_MARKER_C(name, name_counter, context) \
GrGpuTraceMarkerGeneratorContext SK_MACRO_APPEND_LINE(TMG)(context); \
SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter);
#else
#define GR_CREATE_GPU_TRACE_MARKER_C(name, name_counter, context) \
GrGpuTraceMarkerGeneratorContext SK_MACRO_APPEND_LINE(TMG)(context); \
bool SK_MACRO_APPEND_LINE(gpuTracingEnabled); \
TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), \
&SK_MACRO_APPEND_LINE(gpuTracingEnabled)); \
if (SK_MACRO_APPEND_LINE(gpuTracingEnabled)) { \
SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter); \
}
#endif
#endif
|