diff options
author | Brian Osman <brianosman@google.com> | 2017-07-26 09:36:09 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-26 14:22:19 +0000 |
commit | 39c08ac3be30f9956cea7c5e4fd9a1d86e993a65 (patch) | |
tree | 0a51e1be04f6f4bbbc30e2082019316a43d4fbbf /tools/trace | |
parent | 9ac801c12c48b67b48e5a8ef2876a093b7de73fc (diff) |
Automatically prepend "disabled-by-default-" to TRACE categories
Ensures that all Skia events are disabled by default in Chrome, and
eliminates redundant typing.
Bug: skia:
Change-Id: I289c5e5a01084fcf4cccf512da65a4727f4aeca2
Reviewed-on: https://skia-review.googlesource.com/26880
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tools/trace')
-rw-r--r-- | tools/trace/SkEventTracingPriv.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/trace/SkEventTracingPriv.cpp b/tools/trace/SkEventTracingPriv.cpp index 42d992cb13..7a9ca2ee80 100644 --- a/tools/trace/SkEventTracingPriv.cpp +++ b/tools/trace/SkEventTracingPriv.cpp @@ -12,7 +12,7 @@ #include "SkCommandLineFlags.h" #include "SkDebugfTracer.h" #include "SkEventTracer.h" -#include "SkTraceEventCommon.h" +#include "SkTraceEvent.h" DEFINE_string(trace, "", "Log trace events in one of several modes:\n" @@ -42,17 +42,17 @@ void initializeEventTracingForTools(const char* 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 (though we could honor it)
- if (SkStrStartsWith(name, TRACE_DISABLED_BY_DEFAULT_PREFIX)) {
- name += strlen(TRACE_DISABLED_BY_DEFAULT_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):
+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): SkAutoMutexAcquire lock(&fMutex); for (int i = 0; i < fNumCategories; ++i) { if (0 == strcmp(name, fCategories[i].fName)) { @@ -71,7 +71,7 @@ uint8_t* SkEventTracingCategories::getCategoryGroupEnabled(const char* name) { return reinterpret_cast<uint8_t*>(&fCategories[fNumCategories++]); } -const char* SkEventTracingCategories::getCategoryGroupName(const uint8_t* categoryEnabledFlag) {
+const char* SkEventTracingCategories::getCategoryGroupName(const uint8_t* categoryEnabledFlag) { if (categoryEnabledFlag) { return reinterpret_cast<const CategoryState*>(categoryEnabledFlag)->fName; } |