diff options
-rw-r--r-- | src/core/SkATrace.h | 31 | ||||
-rw-r--r-- | src/core/SkTraceEventCommon.h | 36 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 3 |
3 files changed, 30 insertions, 40 deletions
diff --git a/src/core/SkATrace.h b/src/core/SkATrace.h index ad2c8a52cf..12e4bfaad2 100644 --- a/src/core/SkATrace.h +++ b/src/core/SkATrace.h @@ -50,35 +50,4 @@ 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/core/SkTraceEventCommon.h b/src/core/SkTraceEventCommon.h index 92777264eb..35368f5eb2 100644 --- a/src/core/SkTraceEventCommon.h +++ b/src/core/SkTraceEventCommon.h @@ -54,26 +54,42 @@ #error "Another copy of this file has already been included." #endif -#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK - -// If profiling Skia within the Android framework, setting this to 1 will route all Skia -// tracing events to ATrace. -#ifndef SK_TRACE_EVENTS_IN_FRAMEWORK -#define SK_TRACE_EVENTS_IN_FRAMEWORK 0 -#endif - #define TRACE_EMPTY do {} while (0) -#if SK_TRACE_EVENTS_IN_FRAMEWORK +#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK #include <utils/Trace.h> struct SkAndroidFrameworkTraceUtil { + SkAndroidFrameworkTraceUtil(const char* name) { ATRACE_BEGIN(name); } + SkAndroidFrameworkTraceUtil(bool, 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); + } ~SkAndroidFrameworkTraceUtil() { ATRACE_END(); } }; +#define ATRACE_ANDROID_FRAMEWORK(fmt, ...) SkAndroidFrameworkTraceUtil __trace(true, fmt, ##__VA_ARGS__) + +// If profiling Skia within the Android framework, setting this to 1 will route all Skia +// tracing events to ATrace. +#ifndef SK_TRACE_EVENTS_IN_FRAMEWORK +#define SK_TRACE_EVENTS_IN_FRAMEWORK 0 +#endif + +#if SK_TRACE_EVENTS_IN_FRAMEWORK + // Records a pair of begin and end events called "name" for the current scope, with 0, 1 or 2 // associated arguments. In the framework, the arguments are ignored. #define TRACE_EVENT0(category_group, name) \ @@ -135,6 +151,8 @@ struct SkAndroidFrameworkTraceUtil { #else // !SK_BUILD_FOR_ANDROID_FRAMEWORK +#define ATRACE_ANDROID_FRAMEWORK(fmt, ...) TRACE_EMPTY + // Records a pair of begin and end events called "name" for the current scope, with 0, 1 or 2 // associated arguments. If the category is not enabled, then this does nothing. #define TRACE_EVENT0(category_group, name) \ diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index c1fb2623b6..737d299d67 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -33,6 +33,7 @@ #include "SkResourceCache.h" #include "SkShaderBase.h" #include "SkTemplates.h" +#include "SkTraceEvent.h" #include "effects/GrBicubicEffect.h" #include "effects/GrConstColorProcessor.h" #include "effects/GrDitherEffect.h" @@ -135,6 +136,7 @@ sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrResourceProvider* resourceP SkPixmap tmpPixmap; GrSurfaceDesc desc; + ATRACE_ANDROID_FRAMEWORK("Upload Texture [%ux%u]", pixmap.width(), pixmap.height()); if (const SkPixmap* pmap = compute_desc(*resourceProvider->caps(), pixmap, &desc, &tmpBitmap, &tmpPixmap)) { return GrSurfaceProxy::MakeDeferred(resourceProvider, desc, @@ -177,6 +179,7 @@ sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext* ctx, return nullptr; } + ATRACE_ANDROID_FRAMEWORK("Upload MipMap Texture [%ux%u]", pixmap.width(), pixmap.height()); std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, colorMode, nullptr)); if (!mipmaps) { return nullptr; |