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/trace_event/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 const uint8_t* getCategoryGroupEnabled(const char* name
) override
;
13 const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag
) override
;
14 SkEventTracer::Handle
addTraceEvent(char phase
,
15 const uint8_t* categoryEnabledFlag
,
19 const char** argNames
,
20 const uint8_t* argTypes
,
21 const uint64_t* argValues
,
22 uint8_t flags
) override
;
23 void updateTraceEventDuration(const uint8_t* categoryEnabledFlag
,
25 SkEventTracer::Handle handle
) override
;
29 SkChromiumEventTracer::getCategoryGroupEnabled(const char* name
) {
30 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(name
);
33 const char* SkChromiumEventTracer::getCategoryGroupName(
34 const uint8_t* categoryEnabledFlag
) {
35 return base::debug::TraceLog::GetCategoryGroupName(
40 SkChromiumEventTracer::addTraceEvent(char phase
,
41 const uint8_t* categoryEnabledFlag
,
45 const char** argNames
,
46 const uint8_t* argTypes
,
47 const uint64_t* argValues
,
49 base::debug::TraceEventHandle handle
= TRACE_EVENT_API_ADD_TRACE_EVENT(
50 phase
, categoryEnabledFlag
, name
, id
, numArgs
, argNames
,
51 argTypes
, (const long long unsigned int*) argValues
, NULL
, flags
);
52 SkEventTracer::Handle result
;
53 memcpy(&result
, &handle
, sizeof(result
));
58 SkChromiumEventTracer::updateTraceEventDuration(
59 const uint8_t* categoryEnabledFlag
,
61 SkEventTracer::Handle handle
) {
62 base::debug::TraceEventHandle traceEventHandle
;
63 memcpy(&traceEventHandle
, &handle
, sizeof(handle
));
64 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
65 categoryEnabledFlag
, name
, traceEventHandle
);
71 void InitSkiaEventTracer() {
72 // Initialize the binding to Skia's tracing events. Skia will
73 // take ownership of and clean up the memory allocated here.
74 SkEventTracer::SetInstance(new skia::SkChromiumEventTracer());