diff options
author | 2016-02-05 15:32:36 -0800 | |
---|---|---|
committer | 2016-02-05 15:32:36 -0800 | |
commit | 369e9375a3ab7bb56580fc6b22690a76ad759240 (patch) | |
tree | 2f5acce207039a5208d711de64380090ff43a9eb /src/core | |
parent | 60dcd3cb85797b555e47f3e66de81728a2eca40f (diff) |
Add Histogram Macros to Skia
Adds a set of histogram macros to Skia, modeled after Chrome's
UMA_HISTOGRAM_* macros. These allow logging of high frequency events,
and are useful to analyze real world usage of certain features.
By default, these macros are no-ops. Users can provide a custom
header file which defines these macros if they wish to collect
histogram data. Chrome will provide such a header.
I've currently only added two macros:
- SK_HISTOGRAM_BOOLEAN - logs a true/false type relationship (whether
we are tiling a texture or not on each draw).
- SK_HISTOGRAM_ENUMERATION - logs a set of potential values (which of
a number of choices were selected for the texture upload path).
We could add more unused macros at the moment, but it seems easier to
add these as needed, WDYT?
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1652053004
Review URL: https://codereview.chromium.org/1652053004
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkImageCacherator.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index 572778e19c..dc831d7cbf 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -240,9 +240,24 @@ static GrTexture* set_key_and_return(GrTexture* tex, const GrUniqueKey& key) { */ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key, const SkImage* client, SkImage::CachingHint chint) { + // Values representing the various texture lock paths we can take. Used for logging the path + // taken to a histogram. + enum LockTexturePath { + kFailure_LockTexturePath, + kPreExisting_LockTexturePath, + kNative_LockTexturePath, + kCompressed_LockTexturePath, + kYUV_LockTexturePath, + kRGBA_LockTexturePath, + }; + + enum { kLockTexturePathCount = kRGBA_LockTexturePath + 1 }; + // 1. Check the cache for a pre-existing one if (key.isValid()) { if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(key)) { + SK_HISTOGRAM_ENUMERATION("LockTexturePath", kPreExisting_LockTexturePath, + kLockTexturePathCount); return tex; } } @@ -252,6 +267,8 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key ScopedGenerator generator(this); SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width(), fInfo.height()); if (GrTexture* tex = generator->generateTexture(ctx, &subset)) { + SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath, + kLockTexturePathCount); return set_key_and_return(tex, key); } } @@ -263,6 +280,8 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key if (data) { GrTexture* tex = load_compressed_into_texture(ctx, data, desc); if (tex) { + SK_HISTOGRAM_ENUMERATION("LockTexturePath", kCompressed_LockTexturePath, + kLockTexturePathCount); return set_key_and_return(tex, key); } } @@ -273,6 +292,8 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key Generator_GrYUVProvider provider(generator); GrTexture* tex = provider.refAsTexture(ctx, desc, true); if (tex) { + SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath, + kLockTexturePathCount); return set_key_and_return(tex, key); } } @@ -282,9 +303,13 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key if (this->tryLockAsBitmap(&bitmap, client, chint)) { GrTexture* tex = GrUploadBitmapToTexture(ctx, bitmap); if (tex) { + SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath, + kLockTexturePathCount); return set_key_and_return(tex, key); } } + SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath, + kLockTexturePathCount); return nullptr; } |