Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/debug/trace_event.h" | |
| 6 #include "skia/ext/event_tracer_impl.h" | |
| 7 #include "third_party/skia/include/utils/SkEventTracer.h" | |
| 8 | |
| 9 namespace skia { | |
| 10 | |
| 11 class SkChromiumEventTracer: public SkEventTracer { | |
| 12 virtual const uint8_t* getCategoryGroupEnabled(const char* name); | |
| 13 virtual const char* getCategoryGroupName( | |
| 14 const uint8_t* categoryEnabledFlag); | |
| 15 virtual SkEventTracer::Handle | |
| 16 addTraceEvent(char phase, | |
| 17 const uint8_t* categoryEnabledFlag, | |
| 18 const char* name, | |
| 19 uint64_t id, | |
| 20 int32_t numArgs, | |
| 21 const char** argNames, | |
| 22 const uint8_t* argTypes, | |
| 23 const uint64_t* argValues, | |
| 24 uint8_t flags); | |
| 25 virtual void | |
| 26 updateTraceEventDuration(const uint8_t* categoryEnabledFlag, | |
| 27 const char *name, | |
| 28 SkEventTracer::Handle handle); | |
| 29 }; | |
| 30 | |
| 31 const uint8_t* | |
| 32 SkChromiumEventTracer::getCategoryGroupEnabled(const char* name) { | |
| 33 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(name); | |
| 34 } | |
| 35 | |
| 36 const char* SkChromiumEventTracer::getCategoryGroupName( | |
| 37 const uint8_t* categoryEnabledFlag) { | |
| 38 return base::debug::TraceLog::GetCategoryGroupName( | |
| 39 categoryEnabledFlag); | |
| 40 } | |
| 41 | |
| 42 SkEventTracer::Handle | |
| 43 SkChromiumEventTracer::addTraceEvent(char phase, | |
| 44 const uint8_t* categoryEnabledFlag, | |
| 45 const char* name, | |
| 46 uint64_t id, | |
| 47 int32_t numArgs, | |
| 48 const char** argNames, | |
| 49 const uint8_t* argTypes, | |
| 50 const uint64_t* argValues, | |
| 51 uint8_t flags) { | |
| 52 base::debug::TraceEventHandle handle = TRACE_EVENT_API_ADD_TRACE_EVENT( | |
| 53 phase, categoryEnabledFlag, name, id, numArgs, argNames, | |
| 54 argTypes, (const long long unsigned int*) argValues, NULL, flags); | |
| 55 SkEventTracer::Handle result; | |
| 56 memcpy(&result, &handle, sizeof(result)); | |
| 57 return result; | |
| 58 } | |
| 59 | |
| 60 void | |
| 61 SkChromiumEventTracer::updateTraceEventDuration( | |
| 62 const uint8_t* categoryEnabledFlag, | |
| 63 const char *name, | |
| 64 SkEventTracer::Handle handle) { | |
| 65 base::debug::TraceEventHandle traceEventHandle; | |
| 66 memcpy(&traceEventHandle, &handle, sizeof(handle)); | |
| 67 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( | |
| 68 categoryEnabledFlag, name, traceEventHandle); | |
| 69 } | |
| 70 | |
| 71 } // namespace skia | |
| 72 | |
| 73 | |
| 74 void InitSkiaEventTracer() { | |
| 75 // Initialize the binding to Skia's tracing events. Skia will | |
|
nduca
2014/02/04 20:01:38
lgtm
should you dcheck against multiple initializ
| |
| 76 // take ownership of and clean up the memory allocated here. | |
| 77 SkEventTracer::SetInstance(new skia::SkChromiumEventTracer()); | |
| 78 } | |
| OLD | NEW |