1/* 2 * Copyright 2016 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 SkATrace_DEFINED 9#define SkATrace_DEFINED 10 11#include "SkEventTracer.h" 12 13/** 14 * This class is used to support ATrace in android apps. It hooks into the SkEventTracer system. It 15 * currently supports the macros TRACE_EVENT*, TRACE_EVENT_INSTANT*, and TRACE_EVENT_BEGIN/END*. 16 * For versions of these calls that take additoinal args and value pairs we currently just drop them 17 * and report only the name. Since ATrace is a simple push and pop system (all traces are fully 18 * nested), if using BEGIN and END you should also make sure your calls are properly nested (i.e. if 19 * startA is before startB, then endB is before endA). 20 */ 21class SkATrace : public SkEventTracer { 22public: 23 SkATrace(); 24 25 SkEventTracer::Handle addTraceEvent(char phase, 26 const uint8_t* categoryEnabledFlag, 27 const char* name, 28 uint64_t id, 29 int numArgs, 30 const char** argNames, 31 const uint8_t* argTypes, 32 const uint64_t* argValues, 33 uint8_t flags) override; 34 35 36 void updateTraceEventDuration(const uint8_t* categoryEnabledFlag, 37 const char* name, 38 SkEventTracer::Handle handle) override; 39 40 const uint8_t* getCategoryGroupEnabled(const char* name) override; 41 42 const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag) override { 43 static const char* category = "skiaATrace"; 44 return category; 45 } 46 47private: 48 void (*fBeginSection)(const char*); 49 void (*fEndSection)(void); 50 bool (*fIsEnabled)(void); 51}; 52 53#endif 54