1 // Copyright 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.
5 #include "base/debug/trace_event.h"
6 #include "skia/ext/event_tracer_impl.h"
7 #include "third_party/skia/include/utils/SkEventTracer.h"
11 class SkChromiumEventTracer
: public SkEventTracer
{
12 virtual const uint8_t* getCategoryGroupEnabled(const char* name
) OVERRIDE
;
13 virtual const char* getCategoryGroupName(
14 const uint8_t* categoryEnabledFlag
) OVERRIDE
;
15 virtual SkEventTracer::Handle
16 addTraceEvent(char phase
,
17 const uint8_t* categoryEnabledFlag
,
21 const char** argNames
,
22 const uint8_t* argTypes
,
23 const uint64_t* argValues
,
24 uint8_t flags
) OVERRIDE
;
26 updateTraceEventDuration(const uint8_t* categoryEnabledFlag
,
28 SkEventTracer::Handle handle
) OVERRIDE
;
32 SkChromiumEventTracer::getCategoryGroupEnabled(const char* name
) {
33 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(name
);
36 const char* SkChromiumEventTracer::getCategoryGroupName(
37 const uint8_t* categoryEnabledFlag
) {
38 return base::debug::TraceLog::GetCategoryGroupName(
43 SkChromiumEventTracer::addTraceEvent(char phase
,
44 const uint8_t* categoryEnabledFlag
,
48 const char** argNames
,
49 const uint8_t* argTypes
,
50 const uint64_t* argValues
,
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
));
61 SkChromiumEventTracer::updateTraceEventDuration(
62 const uint8_t* categoryEnabledFlag
,
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
);
74 void InitSkiaEventTracer() {
75 // Initialize the binding to Skia's tracing events. Skia will
76 // take ownership of and clean up the memory allocated here.
77 SkEventTracer::SetInstance(new skia::SkChromiumEventTracer());