29dffe9ba4
This reverts commitd78d52a86f
. That reason this CL was reverted in the first place is that it broke the Android roller - perfetto.h could not be located. We now disable the use of perfetto for Android in the gn_to_bp.py script, so the roller should be good to go. Reason for revert: Relanding Original change's description: > Revert "Add Perfetto library (gn & bazel) and bare-bones SkPerfTrace class" > > This reverts commitbfc9b94840
. > > Reason for revert: new dependency causing Android build error > > Original change's description: > > Add Perfetto library (gn & bazel) and bare-bones SkPerfTrace class > > > > First incremental step to incorporating Perfetto tracing into Skia, more CLs to follow > > > > NOTE: The presubmit check is failing. This appears to be due to the known issue where the presubmit check bugs out if the DEPS file is edited, which it was on this CL (modified to include Perfetto). > > > > Bug: skia:13303 > > Change-Id: I908be0392b520e8da14b34588b842bf6d955bd93 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543081 > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Nicolette Prevost <nicolettep@google.com> > > Bug: skia:13303 > Change-Id: Ia2b883bbab1f8fb4f3914b63104a39240cc60e86 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/544239 > Reviewed-by: Tyler Denniston <tdenniston@google.com> > Auto-Submit: Tyler Denniston <tdenniston@google.com> > Reviewed-by: Nicolette Prevost <nicolettep@google.com> > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > Commit-Queue: Tyler Denniston <tdenniston@google.com> Bug: skia:13303 Change-Id: Ibd369b9c8c0e69fc9615fc05cf588ee4440c8ed5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/544244 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Nicolette Prevost <nicolettep@google.com>
104 lines
3.7 KiB
C++
104 lines
3.7 KiB
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.
|
|
*/
|
|
|
|
#include "tools/trace/EventTracingPriv.h"
|
|
|
|
#include "include/utils/SkEventTracer.h"
|
|
#include "src/core/SkATrace.h"
|
|
#include "src/core/SkTraceEvent.h"
|
|
#include "tools/flags/CommandLineFlags.h"
|
|
#include "tools/trace/ChromeTracingTracer.h"
|
|
#include "tools/trace/SkDebugfTracer.h"
|
|
#if defined(SK_USE_PERFETTO)
|
|
#include "tools/trace/SkPerfettoTrace.h"
|
|
#endif
|
|
|
|
static DEFINE_string(trace,
|
|
"",
|
|
"Log trace events in one of several modes:\n"
|
|
" debugf : Show events using SkDebugf\n"
|
|
" atrace : Send events to Android ATrace\n"
|
|
" perfetto : Send events to Perfetto (Linux, Android, and Mac only)\n"
|
|
" <filename> : Any other string is interpreted as a filename. Writes\n"
|
|
" trace events to specified file as JSON, for viewing\n"
|
|
" with chrome://tracing");
|
|
|
|
static DEFINE_string(traceMatch,
|
|
"",
|
|
"Filter which categories are traced.\n"
|
|
"Uses same format as --match\n");
|
|
|
|
void initializeEventTracingForTools(const char* traceFlag) {
|
|
if (!traceFlag) {
|
|
if (FLAGS_trace.isEmpty()) {
|
|
return;
|
|
}
|
|
traceFlag = FLAGS_trace[0];
|
|
}
|
|
|
|
SkEventTracer* eventTracer = nullptr;
|
|
if (0 == strcmp(traceFlag, "atrace")) {
|
|
eventTracer = new SkATrace();
|
|
} else if (0 == strcmp(traceFlag, "debugf")) {
|
|
eventTracer = new SkDebugfTracer();
|
|
}
|
|
else if (0 == strcmp(traceFlag, "perfetto")) {
|
|
#if defined(SK_USE_PERFETTO)
|
|
eventTracer = new SkPerfettoTrace();
|
|
#else
|
|
SkDebugf("Perfetto is not enabled (SK_USE_PERFETTO is false). "
|
|
"Perfetto tracing will not be performed.\n"
|
|
"Tracing with Perfetto is only enabled for Linux, Android, and Mac.");
|
|
return;
|
|
#endif
|
|
}
|
|
else {
|
|
eventTracer = new ChromeTracingTracer(traceFlag);
|
|
}
|
|
|
|
SkAssertResult(SkEventTracer::SetInstance(eventTracer));
|
|
}
|
|
|
|
uint8_t* SkEventTracingCategories::getCategoryGroupEnabled(const char* name) {
|
|
static_assert(0 == offsetof(CategoryState, fEnabled), "CategoryState");
|
|
|
|
// We ignore the "disabled-by-default-" prefix in our internal tools
|
|
if (SkStrStartsWith(name, TRACE_CATEGORY_PREFIX)) {
|
|
name += strlen(TRACE_CATEGORY_PREFIX);
|
|
}
|
|
|
|
// Chrome's implementation of this API does a two-phase lookup (once without a lock, then again
|
|
// with a lock. But the tracing macros avoid calling these functions more than once per site,
|
|
// so just do something simple (and easier to reason about):
|
|
SkAutoMutexExclusive lock(fMutex);
|
|
for (int i = 0; i < fNumCategories; ++i) {
|
|
if (0 == strcmp(name, fCategories[i].fName)) {
|
|
return reinterpret_cast<uint8_t*>(&fCategories[i]);
|
|
}
|
|
}
|
|
|
|
if (fNumCategories >= kMaxCategories) {
|
|
SkDEBUGFAIL("Exhausted event tracing categories. Increase kMaxCategories.");
|
|
return reinterpret_cast<uint8_t*>(&fCategories[0]);
|
|
}
|
|
|
|
fCategories[fNumCategories].fEnabled =
|
|
CommandLineFlags::ShouldSkip(FLAGS_traceMatch, name)
|
|
? 0
|
|
: SkEventTracer::kEnabledForRecording_CategoryGroupEnabledFlags;
|
|
|
|
fCategories[fNumCategories].fName = name;
|
|
return reinterpret_cast<uint8_t*>(&fCategories[fNumCategories++]);
|
|
}
|
|
|
|
const char* SkEventTracingCategories::getCategoryGroupName(const uint8_t* categoryEnabledFlag) {
|
|
if (categoryEnabledFlag) {
|
|
return reinterpret_cast<const CategoryState*>(categoryEnabledFlag)->fName;
|
|
}
|
|
return nullptr;
|
|
}
|