michael@0: /* michael@0: * Copyright (C) 2014 Google Inc. All rights reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkEventTracer_DEFINED michael@0: #define SkEventTracer_DEFINED michael@0: michael@0: // The class in this header defines the interface between Skia's internal michael@0: // tracing macros and an external entity (e.g., Chrome) that will consume them. michael@0: // Such an entity should subclass SkEventTracer and provide an instance of michael@0: // that event to SkEventTracer::SetInstance. michael@0: michael@0: // If you're looking for the tracing macros to instrument Skia itself, those michael@0: // live in src/core/SkTraceEvent.h michael@0: michael@0: #include "SkTypes.h" michael@0: michael@0: // This will mark the trace event as disabled by default. The user will need michael@0: // to explicitly enable the event. michael@0: #define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name michael@0: michael@0: class SK_API SkEventTracer { michael@0: public: michael@0: michael@0: typedef uint64_t Handle; michael@0: michael@0: static SkEventTracer* GetInstance(); michael@0: michael@0: static void SetInstance(SkEventTracer* tracer) { michael@0: SkDELETE(SkEventTracer::gInstance); michael@0: SkEventTracer::gInstance = tracer; michael@0: } michael@0: michael@0: virtual ~SkEventTracer() { } michael@0: michael@0: // The pointer returned from GetCategoryGroupEnabled() points to a michael@0: // value with zero or more of the following bits. Used in this class only. michael@0: // The TRACE_EVENT macros should only use the value as a bool. michael@0: // These values must be in sync with macro values in trace_event.h in chromium. michael@0: enum CategoryGroupEnabledFlags { michael@0: // Category group enabled for the recording mode. michael@0: kEnabledForRecording_CategoryGroupEnabledFlags = 1 << 0, michael@0: // Category group enabled for the monitoring mode. michael@0: kEnabledForMonitoring_CategoryGroupEnabledFlags = 1 << 1, michael@0: // Category group enabled by SetEventCallbackEnabled(). michael@0: kEnabledForEventCallback_CategoryGroupEnabledFlags = 1 << 2, michael@0: }; michael@0: michael@0: virtual const uint8_t* getCategoryGroupEnabled(const char* name) = 0; michael@0: virtual const char* getCategoryGroupName( michael@0: const uint8_t* categoryEnabledFlag) = 0; michael@0: michael@0: virtual SkEventTracer::Handle michael@0: addTraceEvent(char phase, michael@0: const uint8_t* categoryEnabledFlag, michael@0: const char* name, michael@0: uint64_t id, michael@0: int32_t numArgs, michael@0: const char** argNames, michael@0: const uint8_t* argTypes, michael@0: const uint64_t* argValues, michael@0: uint8_t flags) = 0; michael@0: michael@0: virtual void michael@0: updateTraceEventDuration(const uint8_t* categoryEnabledFlag, michael@0: const char* name, michael@0: SkEventTracer::Handle handle) = 0; michael@0: private: michael@0: static SkEventTracer *gInstance; michael@0: }; michael@0: michael@0: #endif // SkEventTracer_DEFINED