commit-bot@chromium.org | 6169f2b | 2014-01-31 00:04:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | #include "SkEventTracer.h" |
| 9 | #include "SkOnce.h" |
| 10 | |
| 11 | class SkDefaultEventTracer: public SkEventTracer { |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 12 | virtual SkEventTracer::Handle |
commit-bot@chromium.org | 6169f2b | 2014-01-31 00:04:25 +0000 | [diff] [blame] | 13 | addTraceEvent(char phase, |
| 14 | const uint8_t* categoryEnabledFlag, |
| 15 | const char* name, |
| 16 | uint64_t id, |
| 17 | int numArgs, |
| 18 | const char** argNames, |
| 19 | const uint8_t* argTypes, |
| 20 | const uint64_t* argValues, |
| 21 | uint8_t flags) SK_OVERRIDE { return 0; } |
skia.committer@gmail.com | 4c18e9f | 2014-01-31 03:01:59 +0000 | [diff] [blame] | 22 | |
| 23 | virtual void |
| 24 | updateTraceEventDuration(const uint8_t* categoryEnabledFlag, |
| 25 | const char* name, |
commit-bot@chromium.org | 3458a17 | 2014-02-03 18:09:32 +0000 | [diff] [blame^] | 26 | SkEventTracer::Handle handle) SK_OVERRIDE {}; |
commit-bot@chromium.org | 6169f2b | 2014-01-31 00:04:25 +0000 | [diff] [blame] | 27 | |
| 28 | virtual const uint8_t* getCategoryGroupEnabled(const char* name) SK_OVERRIDE { |
| 29 | static uint8_t no = 0; |
| 30 | return &no; |
| 31 | }; |
| 32 | virtual const char* getCategoryGroupName( |
| 33 | const uint8_t* category_group_enabled) SK_OVERRIDE { |
| 34 | static const char* dummy = "dummy"; |
| 35 | return dummy; |
| 36 | }; |
| 37 | }; |
| 38 | |
| 39 | SkEventTracer *SkEventTracer::gInstance; |
| 40 | |
| 41 | static void intiailize_default_tracer(int) { |
| 42 | SkEventTracer::SetInstance(SkNEW(SkDefaultEventTracer)); |
| 43 | } |
| 44 | |
| 45 | static void cleanup_tracer() { |
| 46 | // calling SetInstance will delete the existing instance. |
| 47 | SkEventTracer::SetInstance(NULL); |
| 48 | } |
| 49 | |
| 50 | SkEventTracer* SkEventTracer::GetInstance() { |
| 51 | SK_DECLARE_STATIC_ONCE(once); |
| 52 | SkOnce(&once, intiailize_default_tracer, 0, cleanup_tracer); |
| 53 | SkASSERT(NULL != SkEventTracer::gInstance); |
| 54 | return SkEventTracer::gInstance; |
| 55 | } |