skia2/tools/trace/SkEventTracingPriv.h
Mike Klein 3bf0042caa ok, basic tracing support
This doesn't do anything in the default process-per-task mode, because
those child tasks exit using _exit(), which doesn't trigger the event
tracer destructor to flush.

I don't remember exactly why I exit with _exit(), so I'm going to have
to follow up on that.  But written this way as I think I'm at least
initializing the tracing in the right place for each process for the
future.

In threaded (-j -1) and serial (-j 0) modes, everything seems to work
great.

I'm also thinking I might add a tracer like the SkDebugf tracer but
using ok_log(), which handles interlaced logging from concurrent tasks
better than vanilla SkDebugf.

Example:
    ninja -C out ok; and out/ok gm 8888 filter:search=fontmgr_bounds trace -j -1

Change-Id: Ia3cdad930ce65e6fd12fa74f3fb00894e35138d3
Reviewed-on: https://skia-review.googlesource.com/26350
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2017-07-24 19:22:05 +00:00

43 lines
984 B
C++

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkEventTracingPriv_DEFINED
#define SkEventTracingPriv_DEFINED
#include "SkMutex.h"
/**
* Construct and install an SkEventTracer, based on the mode,
* defaulting to the --trace command line argument.
*/
void initializeEventTracingForTools(const char* mode = nullptr);
/**
* Helper class used by internal implementations of SkEventTracer to manage categories.
*/
class SkEventTracingCategories {
public:
SkEventTracingCategories() : fNumCategories(0) {}
uint8_t* getCategoryGroupEnabled(const char* name);
const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag);
private:
enum { kMaxCategories = 256 };
struct CategoryState {
uint8_t fEnabled;
const char* fName;
};
CategoryState fCategories[kMaxCategories];
int fNumCategories;
SkMutex fMutex;
};
#endif