aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkATrace.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkATrace.h')
-rw-r--r--src/core/SkATrace.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/core/SkATrace.h b/src/core/SkATrace.h
new file mode 100644
index 0000000000..f870c5a57b
--- /dev/null
+++ b/src/core/SkATrace.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkATrace_DEFINED
+#define SkATrace_DEFINED
+
+#include "SkEventTracer.h"
+
+/**
+ * This class is used to support ATrace in android apps. It hooks into the SkEventTracer system. It
+ * currently supports the macros TRACE_EVENT*, TRACE_EVENT_INSTANT*, and TRANCE_EVENT_BEGIN/END*.
+ * For versions of these calls that take additoinal args and value pairs we currently just drop them
+ * and report only the name. Since ATrace is a simple push and pop system (all traces are fully
+ * nested), if using BEGIN and END you should also make sure your calls are properly nested (i.e. if
+ * startA is before startB, then endB is before endA).
+ */
+class SkATrace : public SkEventTracer {
+public:
+ SkATrace();
+
+ SkEventTracer::Handle addTraceEvent(char phase,
+ const uint8_t* categoryEnabledFlag,
+ const char* name,
+ uint64_t id,
+ int numArgs,
+ const char** argNames,
+ const uint8_t* argTypes,
+ const uint64_t* argValues,
+ uint8_t flags) override;
+
+
+ void updateTraceEventDuration(const uint8_t* categoryEnabledFlag,
+ const char* name,
+ SkEventTracer::Handle handle) override;
+
+ const uint8_t* getCategoryGroupEnabled(const char* name) override;
+
+ const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag) override {
+ static const char* category = "skiaATrace";
+ return category;
+ }
+
+private:
+ void (*fBeginSection)(const char*);
+ void (*fEndSection)(void);
+ bool (*fIsEnabled)(void);
+};
+
+#endif
+