diff options
author | Derek Sollenberger <djsollen@google.com> | 2017-03-03 15:48:33 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-06 17:34:06 +0000 |
commit | 488f0d674811ae038d34ece9d59c2824ebd4df8f (patch) | |
tree | 1bee20d81fda3d0ae98a510245648a9d7a07b9b4 | |
parent | d83545e4904ba78c6bc7b82169e9be5070f64e32 (diff) |
Add ability to insert systrace markers for the android framework
Change-Id: I34cee8382b73f1d95fde279377f976ebad6983a7
Reviewed-on: https://skia-review.googlesource.com/9232
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Stan Iliev <stani@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
-rw-r--r-- | gn/gn_to_bp.py | 3 | ||||
-rw-r--r-- | src/core/SkATrace.h | 30 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLProgramBuilder.cpp | 2 |
3 files changed, 35 insertions, 0 deletions
diff --git a/gn/gn_to_bp.py b/gn/gn_to_bp.py index 58a8dd563c..487bdffd1e 100644 --- a/gn/gn_to_bp.py +++ b/gn/gn_to_bp.py @@ -33,6 +33,7 @@ tool_shared_libs = [ 'libft2', 'libdng_sdk', 'libpiex', + 'libcutils', ] # The ordering here is important: libsfntly needs to come after libskia. @@ -57,6 +58,7 @@ cc_library { "-U_FORTIFY_SOURCE", "-D_FORTIFY_SOURCE=1", "-DSKIA_IMPLEMENTATION=1", + "-DATRACE_TAG=ATRACE_TAG_VIEW", ], export_include_dirs: [ @@ -129,6 +131,7 @@ cc_library { "libpng", "libvulkan", "libz", + "libcutils", ], static_libs: [ "libarect", diff --git a/src/core/SkATrace.h b/src/core/SkATrace.h index f870c5a57b..f2282f78c1 100644 --- a/src/core/SkATrace.h +++ b/src/core/SkATrace.h @@ -50,5 +50,35 @@ private: bool (*fIsEnabled)(void); }; + +#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK + + #include <utils/Trace.h> + #define ATRACE_ANDROID_FRAMEWORK(fmt, ...) SkAndroidTraceUtil __trace = \ + (SkAndroidTraceUtil::atraceFormatBegin(fmt, ##__VA_ARGS__), SkAndroidTraceUtil()) + + class SkAndroidTraceUtil { + public: + ~SkAndroidTraceUtil() { ATRACE_END(); } + + static void atraceFormatBegin(const char* fmt, ...) { + if (CC_LIKELY(!ATRACE_ENABLED())) return; + + const int BUFFER_SIZE = 256; + va_list ap; + char buf[BUFFER_SIZE]; + + va_start(ap, fmt); + vsnprintf(buf, BUFFER_SIZE, fmt, ap); + va_end(ap); + + ATRACE_BEGIN(buf); + } + }; + +#else + #define ATRACE_ANDROID_FRAMEWORK(fmt, ...) +#endif // SK_BUILD_FOR_ANDROID_FRAMEWORK + #endif diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index 4f1909eecf..9ddfa80baf 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -15,6 +15,7 @@ #include "GrSwizzle.h" #include "GrTexture.h" #include "SkAutoMalloc.h" +#include "SkATrace.h" #include "SkTraceEvent.h" #include "gl/GrGLGpu.h" #include "gl/GrGLProgram.h" @@ -32,6 +33,7 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrPipeline& pipeline, const GrPrimitiveProcessor& primProc, GrProgramDesc* desc, GrGLGpu* gpu) { + ATRACE_ANDROID_FRAMEWORK("Shader Compile"); GrAutoLocaleSetter als("C"); // create a builder. This will be handed off to effects so they can use it to add |