Chromium Code Reviews| Index: include/utils/SkEventTracer.h |
| diff --git a/include/utils/SkEventTracer.h b/include/utils/SkEventTracer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c518259380a4a96e4cb728027027774cac92980c |
| --- /dev/null |
| +++ b/include/utils/SkEventTracer.h |
| @@ -0,0 +1,75 @@ |
| +/* |
| + * 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. |
| +// Such an entity should subclass SkEventTracer and provide an instance of |
| +// that event to SkEventTracer::SetInstance. |
| + |
| +// If you're looking for the tracing macros to instrument Skia itself, those |
| +// live in src/core/SkTraceEvent.h |
| + |
| +#include "SkTypes.h" |
| + |
| +// This will mark the trace event as disabled by default. The user will need |
| +// to explicitly enable the event. |
| +#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name |
| + |
| +typedef uint32_t SkTraceEventHandle; |
|
mtklein
2014/01/30 14:18:26
Suggestion: make this SkEventTracer::Handle ?
humper
2014/01/30 16:03:38
I like that a lot better; done.
|
| + |
| +class SK_API SkEventTracer { |
| +public: |
| + |
| + static SkEventTracer* GetInstance(); |
| + |
| + static void SetInstance(SkEventTracer* tracer) { |
| + SkDELETE(SkEventTracer::gInstance); |
| + SkEventTracer::gInstance = tracer; |
| + } |
| + |
| + virtual ~SkEventTracer() { } |
|
mtklein
2014/01/30 14:18:26
Sorry, somehow I'd brainfarted and not realized it
|
| + |
| + // 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. |
|
mtklein
2014/01/30 14:18:26
Sorry, I hadn't realized these have to stay in syn
humper
2014/01/30 16:03:38
I believe the design of the Chrome tracing system
|
| + 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, |
| + }; |
| + |
| + virtual const unsigned char* getCategoryGroupEnabled(const char* name) = 0; |
| + virtual const char* getCategoryGroupName( |
| + const uint8_t* category_group_enabled) = 0; |
| + |
| + virtual SkTraceEventHandle |
| + 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; |
| + |
| + virtual void |
| + updateTraceEventDuration(const uint8_t* categoryEnabledFlag, |
| + const char* name, |
| + SkTraceEventHandle) = 0; |
| +private: |
| + static SkEventTracer *gInstance; |
| +}; |
| + |
| +#endif // SkEventTracer_DEFINED |