2014-01-31 00:04:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Google Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkEventTracer_DEFINED
|
|
|
|
#define SkEventTracer_DEFINED
|
|
|
|
|
|
|
|
// The class in this header defines the interface between Skia's internal
|
|
|
|
// tracing macros and an external entity (e.g., Chrome) that will consume them.
|
2014-01-31 03:01:59 +00:00
|
|
|
// Such an entity should subclass SkEventTracer and provide an instance of
|
2014-01-31 00:04:25 +00:00
|
|
|
// that event to SkEventTracer::SetInstance.
|
|
|
|
|
|
|
|
// If you're looking for the tracing macros to instrument Skia itself, those
|
|
|
|
// live in src/core/SkTraceEvent.h
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkTypes.h"
|
2014-01-31 00:04:25 +00:00
|
|
|
|
|
|
|
class SK_API SkEventTracer {
|
|
|
|
public:
|
|
|
|
|
2014-02-03 19:47:13 +00:00
|
|
|
typedef uint64_t Handle;
|
2014-01-31 03:01:59 +00:00
|
|
|
|
2017-05-12 16:02:50 +00:00
|
|
|
/**
|
|
|
|
* If this is the first call to SetInstance or GetInstance then the passed instance is
|
|
|
|
* installed and true is returned. Otherwise, false is returned. In either case ownership of the
|
|
|
|
* tracer is transferred and it will be deleted when no longer needed.
|
|
|
|
*/
|
|
|
|
static bool SetInstance(SkEventTracer*);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the event tracer. If this is the first call to SetInstance or GetIntance then a default
|
|
|
|
* event tracer is installed and returned.
|
|
|
|
*/
|
2014-01-31 00:04:25 +00:00
|
|
|
static SkEventTracer* GetInstance();
|
|
|
|
|
|
|
|
virtual ~SkEventTracer() { }
|
|
|
|
|
|
|
|
// The pointer returned from GetCategoryGroupEnabled() points to a
|
|
|
|
// value with zero or more of the following bits. Used in this class only.
|
|
|
|
// The TRACE_EVENT macros should only use the value as a bool.
|
|
|
|
// These values must be in sync with macro values in trace_event.h in chromium.
|
|
|
|
enum CategoryGroupEnabledFlags {
|
|
|
|
// Category group enabled for the recording mode.
|
|
|
|
kEnabledForRecording_CategoryGroupEnabledFlags = 1 << 0,
|
|
|
|
// Category group enabled for the monitoring mode.
|
|
|
|
kEnabledForMonitoring_CategoryGroupEnabledFlags = 1 << 1,
|
|
|
|
// Category group enabled by SetEventCallbackEnabled().
|
|
|
|
kEnabledForEventCallback_CategoryGroupEnabledFlags = 1 << 2,
|
|
|
|
};
|
|
|
|
|
2014-02-03 18:09:32 +00:00
|
|
|
virtual const uint8_t* getCategoryGroupEnabled(const char* name) = 0;
|
2017-07-21 15:06:24 +00:00
|
|
|
virtual const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag) = 0;
|
2014-01-31 03:01:59 +00:00
|
|
|
|
|
|
|
virtual SkEventTracer::Handle
|
2014-01-31 00:04:25 +00:00
|
|
|
addTraceEvent(char phase,
|
|
|
|
const uint8_t* categoryEnabledFlag,
|
|
|
|
const char* name,
|
|
|
|
uint64_t id,
|
|
|
|
int32_t numArgs,
|
|
|
|
const char** argNames,
|
|
|
|
const uint8_t* argTypes,
|
|
|
|
const uint64_t* argValues,
|
|
|
|
uint8_t flags) = 0;
|
2014-01-31 03:01:59 +00:00
|
|
|
|
|
|
|
virtual void
|
|
|
|
updateTraceEventDuration(const uint8_t* categoryEnabledFlag,
|
|
|
|
const char* name,
|
2014-02-03 18:09:32 +00:00
|
|
|
SkEventTracer::Handle handle) = 0;
|
2014-01-31 00:04:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SkEventTracer_DEFINED
|