DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (d8847129d134)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
/*
 * Copyright 2014 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkEventTracer.h"
#include "SkOnce.h"

class SkDefaultEventTracer: public SkEventTracer {
    virtual SkEventTracer::Handle
        addTraceEvent(char phase,
                      const uint8_t* categoryEnabledFlag,
                      const char* name,
                      uint64_t id,
                      int numArgs,
                      const char** argNames,
                      const uint8_t* argTypes,
                      const uint64_t* argValues,
                      uint8_t flags) SK_OVERRIDE { return 0; }

    virtual void
        updateTraceEventDuration(const uint8_t* categoryEnabledFlag,
                                 const char* name,
                                 SkEventTracer::Handle handle) SK_OVERRIDE {};

    virtual const uint8_t* getCategoryGroupEnabled(const char* name) SK_OVERRIDE {
        static uint8_t no = 0;
        return &no;
    };
    virtual const char* getCategoryGroupName(
      const uint8_t* categoryEnabledFlag) SK_OVERRIDE {
        static const char* dummy = "dummy";
        return dummy;
    };
};

SkEventTracer* SkEventTracer::gInstance;

static void cleanup_tracer() {
    // calling SetInstance will delete the existing instance.
    SkEventTracer::SetInstance(NULL);
}

static void intialize_default_tracer(SkEventTracer* current_instance) {
    if (NULL == current_instance) {
        SkEventTracer::SetInstance(SkNEW(SkDefaultEventTracer));
    }
    atexit(cleanup_tracer);
}


SkEventTracer* SkEventTracer::GetInstance() {
    SK_DECLARE_STATIC_ONCE(once);
    SkOnce(&once, intialize_default_tracer, SkEventTracer::gInstance);
    SkASSERT(NULL != SkEventTracer::gInstance);
    return SkEventTracer::gInstance;
}