blob: f4f8676a748ec3621e6b4876d5fc1f0dbfe40b25 [file] [log] [blame]
commit-bot@chromium.org6169f2b2014-01-31 00:04:25 +00001/*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
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 SkEventTracer_DEFINED
9#define SkEventTracer_DEFINED
10
11// The class in this header defines the interface between Skia's internal
12// tracing macros and an external entity (e.g., Chrome) that will consume them.
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000013// Such an entity should subclass SkEventTracer and provide an instance of
commit-bot@chromium.org6169f2b2014-01-31 00:04:25 +000014// that event to SkEventTracer::SetInstance.
15
16// If you're looking for the tracing macros to instrument Skia itself, those
17// live in src/core/SkTraceEvent.h
18
19#include "SkTypes.h"
20
21// This will mark the trace event as disabled by default. The user will need
22// to explicitly enable the event.
23#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
24
25class SK_API SkEventTracer {
26public:
27
commit-bot@chromium.org2859f9f2014-02-03 19:47:13 +000028 typedef uint64_t Handle;
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000029
commit-bot@chromium.org6169f2b2014-01-31 00:04:25 +000030 static SkEventTracer* GetInstance();
31
mtklein59bcfae2015-04-21 09:38:03 -070032 static void SetInstance(SkEventTracer*);
commit-bot@chromium.org6169f2b2014-01-31 00:04:25 +000033
34 virtual ~SkEventTracer() { }
35
36 // The pointer returned from GetCategoryGroupEnabled() points to a
37 // value with zero or more of the following bits. Used in this class only.
38 // The TRACE_EVENT macros should only use the value as a bool.
39 // These values must be in sync with macro values in trace_event.h in chromium.
40 enum CategoryGroupEnabledFlags {
41 // Category group enabled for the recording mode.
42 kEnabledForRecording_CategoryGroupEnabledFlags = 1 << 0,
43 // Category group enabled for the monitoring mode.
44 kEnabledForMonitoring_CategoryGroupEnabledFlags = 1 << 1,
45 // Category group enabled by SetEventCallbackEnabled().
46 kEnabledForEventCallback_CategoryGroupEnabledFlags = 1 << 2,
47 };
48
commit-bot@chromium.org3458a172014-02-03 18:09:32 +000049 virtual const uint8_t* getCategoryGroupEnabled(const char* name) = 0;
commit-bot@chromium.org6169f2b2014-01-31 00:04:25 +000050 virtual const char* getCategoryGroupName(
commit-bot@chromium.org2859f9f2014-02-03 19:47:13 +000051 const uint8_t* categoryEnabledFlag) = 0;
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000052
53 virtual SkEventTracer::Handle
commit-bot@chromium.org6169f2b2014-01-31 00:04:25 +000054 addTraceEvent(char phase,
55 const uint8_t* categoryEnabledFlag,
56 const char* name,
57 uint64_t id,
58 int32_t numArgs,
59 const char** argNames,
60 const uint8_t* argTypes,
61 const uint64_t* argValues,
62 uint8_t flags) = 0;
skia.committer@gmail.com4c18e9f2014-01-31 03:01:59 +000063
64 virtual void
65 updateTraceEventDuration(const uint8_t* categoryEnabledFlag,
66 const char* name,
commit-bot@chromium.org3458a172014-02-03 18:09:32 +000067 SkEventTracer::Handle handle) = 0;
commit-bot@chromium.org6169f2b2014-01-31 00:04:25 +000068};
69
70#endif // SkEventTracer_DEFINED