Brian Salomon | dcbb9d9 | 2017-07-19 10:53:20 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 SkDebugfTracer_DEFINED |
| 9 | #define SkDebugfTracer_DEFINED |
| 10 | |
| 11 | #include "SkEventTracer.h" |
Brian Osman | 65e4c61 | 2017-07-21 11:06:24 -0400 | [diff] [blame] | 12 | #include "SkEventTracingPriv.h" |
Brian Salomon | dcbb9d9 | 2017-07-19 10:53:20 -0400 | [diff] [blame] | 13 | #include "SkString.h" |
| 14 | |
| 15 | /** |
| 16 | * A SkEventTracer implementation that logs events using SkDebugf. |
| 17 | */ |
| 18 | class SkDebugfTracer : public SkEventTracer { |
| 19 | public: |
| 20 | SkDebugfTracer() {} |
| 21 | |
| 22 | SkEventTracer::Handle addTraceEvent(char phase, |
| 23 | const uint8_t* categoryEnabledFlag, |
| 24 | const char* name, |
| 25 | uint64_t id, |
| 26 | int numArgs, |
| 27 | const char** argNames, |
| 28 | const uint8_t* argTypes, |
| 29 | const uint64_t* argValues, |
| 30 | uint8_t flags) override; |
| 31 | |
| 32 | void updateTraceEventDuration(const uint8_t* categoryEnabledFlag, |
| 33 | const char* name, |
| 34 | SkEventTracer::Handle handle) override; |
| 35 | |
Brian Osman | 65e4c61 | 2017-07-21 11:06:24 -0400 | [diff] [blame] | 36 | const uint8_t* getCategoryGroupEnabled(const char* name) override { |
| 37 | return fCategories.getCategoryGroupEnabled(name); |
| 38 | } |
Brian Salomon | dcbb9d9 | 2017-07-19 10:53:20 -0400 | [diff] [blame] | 39 | |
| 40 | const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag) override { |
Brian Osman | 65e4c61 | 2017-07-21 11:06:24 -0400 | [diff] [blame] | 41 | return fCategories.getCategoryGroupName(categoryEnabledFlag); |
Brian Salomon | dcbb9d9 | 2017-07-19 10:53:20 -0400 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | private: |
| 45 | SkString fIndent; |
| 46 | int fCnt = 0; |
Brian Osman | 65e4c61 | 2017-07-21 11:06:24 -0400 | [diff] [blame] | 47 | SkEventTracingCategories fCategories; |
Brian Salomon | dcbb9d9 | 2017-07-19 10:53:20 -0400 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | #endif |