commit-bot@chromium.org | 6169f2b | 2014-01-31 00:04:25 +0000 | [diff] [blame] | 1 | /* |
| 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.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 13 | // Such an entity should subclass SkEventTracer and provide an instance of |
commit-bot@chromium.org | 6169f2b | 2014-01-31 00:04:25 +0000 | [diff] [blame] | 14 | // 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 | |
commit-bot@chromium.org | 6169f2b | 2014-01-31 00:04:25 +0000 | [diff] [blame] | 21 | class SK_API SkEventTracer { |
| 22 | public: |
| 23 | |
commit-bot@chromium.org | 2859f9f | 2014-02-03 19:47:13 +0000 | [diff] [blame] | 24 | typedef uint64_t Handle; |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 25 | |
Brian Salomon | 175f588 | 2017-05-12 12:02:50 -0400 | [diff] [blame] | 26 | /** |
| 27 | * If this is the first call to SetInstance or GetInstance then the passed instance is |
| 28 | * installed and true is returned. Otherwise, false is returned. In either case ownership of the |
| 29 | * tracer is transferred and it will be deleted when no longer needed. |
| 30 | */ |
| 31 | static bool SetInstance(SkEventTracer*); |
commit-bot@chromium.org | 6169f2b | 2014-01-31 00:04:25 +0000 | [diff] [blame] | 32 | |
Brian Salomon | 175f588 | 2017-05-12 12:02:50 -0400 | [diff] [blame] | 33 | /** |
| 34 | * Gets the event tracer. If this is the first call to SetInstance or GetIntance then a default |
| 35 | * event tracer is installed and returned. |
| 36 | */ |
| 37 | static SkEventTracer* GetInstance(); |
commit-bot@chromium.org | 6169f2b | 2014-01-31 00:04:25 +0000 | [diff] [blame] | 38 | |
| 39 | virtual ~SkEventTracer() { } |
| 40 | |
| 41 | // The pointer returned from GetCategoryGroupEnabled() points to a |
| 42 | // value with zero or more of the following bits. Used in this class only. |
| 43 | // The TRACE_EVENT macros should only use the value as a bool. |
| 44 | // These values must be in sync with macro values in trace_event.h in chromium. |
| 45 | enum CategoryGroupEnabledFlags { |
| 46 | // Category group enabled for the recording mode. |
| 47 | kEnabledForRecording_CategoryGroupEnabledFlags = 1 << 0, |
| 48 | // Category group enabled for the monitoring mode. |
| 49 | kEnabledForMonitoring_CategoryGroupEnabledFlags = 1 << 1, |
| 50 | // Category group enabled by SetEventCallbackEnabled(). |
| 51 | kEnabledForEventCallback_CategoryGroupEnabledFlags = 1 << 2, |
| 52 | }; |
| 53 | |
commit-bot@chromium.org | 3458a17 | 2014-02-03 18:09:32 +0000 | [diff] [blame] | 54 | virtual const uint8_t* getCategoryGroupEnabled(const char* name) = 0; |
Brian Osman | 65e4c61 | 2017-07-21 11:06:24 -0400 | [diff] [blame] | 55 | virtual const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag) = 0; |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 56 | |
| 57 | virtual SkEventTracer::Handle |
commit-bot@chromium.org | 6169f2b | 2014-01-31 00:04:25 +0000 | [diff] [blame] | 58 | addTraceEvent(char phase, |
| 59 | const uint8_t* categoryEnabledFlag, |
| 60 | const char* name, |
| 61 | uint64_t id, |
| 62 | int32_t numArgs, |
| 63 | const char** argNames, |
| 64 | const uint8_t* argTypes, |
| 65 | const uint64_t* argValues, |
| 66 | uint8_t flags) = 0; |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 67 | |
| 68 | virtual void |
| 69 | updateTraceEventDuration(const uint8_t* categoryEnabledFlag, |
| 70 | const char* name, |
commit-bot@chromium.org | 3458a17 | 2014-02-03 18:09:32 +0000 | [diff] [blame] | 71 | SkEventTracer::Handle handle) = 0; |
commit-bot@chromium.org | 6169f2b | 2014-01-31 00:04:25 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | #endif // SkEventTracer_DEFINED |