diff options
author | Brian Osman <brianosman@google.com> | 2017-08-10 15:45:30 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-10 20:05:36 +0000 |
commit | e4f846aae7f089703d4f73e7092e377a577c4ec9 (patch) | |
tree | f09f5b3316f550b932dfa8365a8efa5f083b254b /src | |
parent | 6da8f796183161481d3c0677e6c7217e0ad1852a (diff) |
Bypass libandroid dynamic linking for ATrace in framework builds
These symbols were resolving, but weren't really connected to systrace
on Android. Using the macros/functions allows this to work correctly.
This change doesn't actually cause anything to happen in framework
builds - that still requires installing an instance of SkATrace, but
now doing so will route all of Skia's TRACE_EVENT macros to systrace.
Bug: skia:
Change-Id: I6d2eafac7ef2531ba92094b92f68e59e0490ef62
Reviewed-on: https://skia-review.googlesource.com/33400
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkATrace.cpp | 7 | ||||
-rw-r--r-- | src/core/SkATrace.h | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/core/SkATrace.cpp b/src/core/SkATrace.cpp index ed158e2e52..f465286c4f 100644 --- a/src/core/SkATrace.cpp +++ b/src/core/SkATrace.cpp @@ -14,13 +14,18 @@ #endif SkATrace::SkATrace() : fBeginSection(nullptr), fEndSection(nullptr), fIsEnabled(nullptr) { -#ifdef SK_BUILD_FOR_ANDROID +#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) + fIsEnabled = []{ return static_cast<bool>(CC_UNLIKELY(ATRACE_ENABLED())); }; + fBeginSection = [](const char* name){ ATRACE_BEGIN(name); }; + fEndSection = []{ ATRACE_END(); }; +#elif defined(SK_BUILD_FOR_ANDROID) if (void* lib = dlopen("libandroid.so", RTLD_NOW | RTLD_LOCAL)) { fBeginSection = (decltype(fBeginSection))dlsym(lib, "ATrace_beginSection"); fEndSection = (decltype(fEndSection))dlsym(lib, "ATrace_endSection"); fIsEnabled = (decltype(fIsEnabled))dlsym(lib, "ATrace_isEnabled"); } #endif + if (!fIsEnabled) { fIsEnabled = []{ return false; }; } diff --git a/src/core/SkATrace.h b/src/core/SkATrace.h index f2282f78c1..ad2c8a52cf 100644 --- a/src/core/SkATrace.h +++ b/src/core/SkATrace.h @@ -12,7 +12,7 @@ /** * This class is used to support ATrace in android apps. It hooks into the SkEventTracer system. It - * currently supports the macros TRACE_EVENT*, TRACE_EVENT_INSTANT*, and TRANCE_EVENT_BEGIN/END*. + * currently supports the macros TRACE_EVENT*, TRACE_EVENT_INSTANT*, and TRACE_EVENT_BEGIN/END*. * For versions of these calls that take additoinal args and value pairs we currently just drop them * and report only the name. Since ATrace is a simple push and pop system (all traces are fully * nested), if using BEGIN and END you should also make sure your calls are properly nested (i.e. if |