gfx/skia/trunk/include/utils/SkEventTracer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/utils/SkEventTracer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +/*
     1.5 + * Copyright (C) 2014 Google Inc. All rights reserved.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkEventTracer_DEFINED
    1.12 +#define SkEventTracer_DEFINED
    1.13 +
    1.14 +// The class in this header defines the interface between Skia's internal
    1.15 +// tracing macros and an external entity (e.g., Chrome) that will consume them.
    1.16 +// Such an entity should subclass SkEventTracer and provide an instance of
    1.17 +// that event to SkEventTracer::SetInstance.
    1.18 +
    1.19 +// If you're looking for the tracing macros to instrument Skia itself, those
    1.20 +// live in src/core/SkTraceEvent.h
    1.21 +
    1.22 +#include "SkTypes.h"
    1.23 +
    1.24 +// This will mark the trace event as disabled by default. The user will need
    1.25 +// to explicitly enable the event.
    1.26 +#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
    1.27 +
    1.28 +class SK_API SkEventTracer {
    1.29 +public:
    1.30 +
    1.31 +    typedef uint64_t Handle;
    1.32 +
    1.33 +    static SkEventTracer* GetInstance();
    1.34 +
    1.35 +    static void SetInstance(SkEventTracer* tracer) {
    1.36 +        SkDELETE(SkEventTracer::gInstance);
    1.37 +        SkEventTracer::gInstance = tracer;
    1.38 +    }
    1.39 +
    1.40 +    virtual ~SkEventTracer() { }
    1.41 +
    1.42 +    // The pointer returned from GetCategoryGroupEnabled() points to a
    1.43 +    // value with zero or more of the following bits. Used in this class only.
    1.44 +    // The TRACE_EVENT macros should only use the value as a bool.
    1.45 +    // These values must be in sync with macro values in trace_event.h in chromium.
    1.46 +    enum CategoryGroupEnabledFlags {
    1.47 +        // Category group enabled for the recording mode.
    1.48 +        kEnabledForRecording_CategoryGroupEnabledFlags = 1 << 0,
    1.49 +        // Category group enabled for the monitoring mode.
    1.50 +        kEnabledForMonitoring_CategoryGroupEnabledFlags = 1 << 1,
    1.51 +        // Category group enabled by SetEventCallbackEnabled().
    1.52 +        kEnabledForEventCallback_CategoryGroupEnabledFlags = 1 << 2,
    1.53 +    };
    1.54 +
    1.55 +    virtual const uint8_t* getCategoryGroupEnabled(const char* name) = 0;
    1.56 +    virtual const char* getCategoryGroupName(
    1.57 +      const uint8_t* categoryEnabledFlag) = 0;
    1.58 +
    1.59 +    virtual SkEventTracer::Handle
    1.60 +        addTraceEvent(char phase,
    1.61 +                      const uint8_t* categoryEnabledFlag,
    1.62 +                      const char* name,
    1.63 +                      uint64_t id,
    1.64 +                      int32_t numArgs,
    1.65 +                      const char** argNames,
    1.66 +                      const uint8_t* argTypes,
    1.67 +                      const uint64_t* argValues,
    1.68 +                      uint8_t flags) = 0;
    1.69 +
    1.70 +    virtual void
    1.71 +        updateTraceEventDuration(const uint8_t* categoryEnabledFlag,
    1.72 +                                 const char* name,
    1.73 +                                 SkEventTracer::Handle handle) = 0;
    1.74 +private:
    1.75 +    static SkEventTracer *gInstance;
    1.76 +};
    1.77 +
    1.78 +#endif // SkEventTracer_DEFINED

mercurial