16169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org/* 26169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org * Copyright (C) 2014 Google Inc. All rights reserved. 36169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org * 46169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be 56169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org * found in the LICENSE file. 66169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org */ 76169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 86169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org#ifndef SkEventTracer_DEFINED 96169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org#define SkEventTracer_DEFINED 106169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 116169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org// The class in this header defines the interface between Skia's internal 126169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org// tracing macros and an external entity (e.g., Chrome) that will consume them. 134c18e9fbb685cccf23342757e786027a032197daskia.committer@gmail.com// Such an entity should subclass SkEventTracer and provide an instance of 146169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org// that event to SkEventTracer::SetInstance. 156169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 166169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org// If you're looking for the tracing macros to instrument Skia itself, those 176169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org// live in src/core/SkTraceEvent.h 186169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 196169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org#include "SkTypes.h" 206169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 216169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org// This will mark the trace event as disabled by default. The user will need 226169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org// to explicitly enable the event. 236169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name 246169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 256169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.orgclass SK_API SkEventTracer { 266169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.orgpublic: 276169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 282859f9fbf3764d401b3b9b27f3d9e9bddeaf3a14commit-bot@chromium.org typedef uint64_t Handle; 294c18e9fbb685cccf23342757e786027a032197daskia.committer@gmail.com 306169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org static SkEventTracer* GetInstance(); 316169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 324c18e9fbb685cccf23342757e786027a032197daskia.committer@gmail.com static void SetInstance(SkEventTracer* tracer) { 336169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org SkDELETE(SkEventTracer::gInstance); 346169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org SkEventTracer::gInstance = tracer; 356169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org } 366169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 376169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org virtual ~SkEventTracer() { } 386169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 396169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org // The pointer returned from GetCategoryGroupEnabled() points to a 406169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org // value with zero or more of the following bits. Used in this class only. 416169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org // The TRACE_EVENT macros should only use the value as a bool. 426169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org // These values must be in sync with macro values in trace_event.h in chromium. 436169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org enum CategoryGroupEnabledFlags { 446169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org // Category group enabled for the recording mode. 456169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org kEnabledForRecording_CategoryGroupEnabledFlags = 1 << 0, 466169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org // Category group enabled for the monitoring mode. 476169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org kEnabledForMonitoring_CategoryGroupEnabledFlags = 1 << 1, 486169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org // Category group enabled by SetEventCallbackEnabled(). 496169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org kEnabledForEventCallback_CategoryGroupEnabledFlags = 1 << 2, 506169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org }; 516169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 523458a1736feae84eba985591a8ab8d26530d96c8commit-bot@chromium.org virtual const uint8_t* getCategoryGroupEnabled(const char* name) = 0; 536169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org virtual const char* getCategoryGroupName( 542859f9fbf3764d401b3b9b27f3d9e9bddeaf3a14commit-bot@chromium.org const uint8_t* categoryEnabledFlag) = 0; 554c18e9fbb685cccf23342757e786027a032197daskia.committer@gmail.com 564c18e9fbb685cccf23342757e786027a032197daskia.committer@gmail.com virtual SkEventTracer::Handle 576169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org addTraceEvent(char phase, 586169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org const uint8_t* categoryEnabledFlag, 596169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org const char* name, 606169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org uint64_t id, 616169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org int32_t numArgs, 626169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org const char** argNames, 636169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org const uint8_t* argTypes, 646169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org const uint64_t* argValues, 656169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org uint8_t flags) = 0; 664c18e9fbb685cccf23342757e786027a032197daskia.committer@gmail.com 674c18e9fbb685cccf23342757e786027a032197daskia.committer@gmail.com virtual void 684c18e9fbb685cccf23342757e786027a032197daskia.committer@gmail.com updateTraceEventDuration(const uint8_t* categoryEnabledFlag, 694c18e9fbb685cccf23342757e786027a032197daskia.committer@gmail.com const char* name, 703458a1736feae84eba985591a8ab8d26530d96c8commit-bot@chromium.org SkEventTracer::Handle handle) = 0; 716169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.orgprivate: 726169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org static SkEventTracer *gInstance; 736169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org}; 746169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org 756169f2b4da39099b4e593f5ff85538dfe2f0249ecommit-bot@chromium.org#endif // SkEventTracer_DEFINED 76