Debian Codegraph @

src/core/SkATrace.h

raw
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkATrace_DEFINED
9 #define SkATrace_DEFINED
10
11 #include "include/utils/SkEventTracer.h"
12
13 #include <cstdint>
14
15 /**
16 * This class is used to support ATrace in android apps. It hooks into the SkEventTracer system. It
17 * currently supports the macros TRACE_EVENT*, TRACE_EVENT_INSTANT*, and TRACE_EVENT_BEGIN/END*.
18 * For versions of these calls that take additoinal args and value pairs we currently just drop them
19 * and report only the name. Since ATrace is a simple push and pop system (all traces are fully
20 * nested), if using BEGIN and END you should also make sure your calls are properly nested (i.e. if
21 * startA is before startB, then endB is before endA).
22 */
23 class SkATrace : public SkEventTracer {
24 public:
25 SkATrace();
26
27 SkEventTracer::Handle addTraceEvent(char phase,
28 const uint8_t* categoryEnabledFlag,
29 const char* name,
30 uint64_t id,
31 int numArgs,
32 const char** argNames,
33 const uint8_t* argTypes,
34 const uint64_t* argValues,
35 uint8_t flags) override;
36
37
38 void updateTraceEventDuration(const uint8_t* categoryEnabledFlag,
39 const char* name,
40 SkEventTracer::Handle handle) override;
41
42 const uint8_t* getCategoryGroupEnabled(const char* name) override;
43
44 const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag) override {
45 static const char* const category = "skiaATrace";
46 return category;
47 }
48
49 // Atrace does not yet support splitting up trace output into sections.
50 void newTracingSection(const char* name) override {}
51
52 private:
53 SkATrace(const SkATrace&) = delete;
54 SkATrace& operator=(const SkATrace&) = delete;
55
56 void (*fBeginSection)(const char*);
57 void (*fEndSection)(void);
58 bool (*fIsEnabled)(void);
59 };
60
61 #endif