From 1090da6433db575d59b93aec99f6bda49b808b84 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Fri, 6 Jan 2017 12:04:19 -0500 Subject: Add support for tagging GrUniqueKeys with a debug string Change-Id: Ie7d56214fdee7a19a1e8ca3869e5e4d5e72cedf8 Reviewed-on: https://skia-review.googlesource.com/6632 Commit-Queue: Brian Salomon Reviewed-by: Robert Phillips --- include/gpu/GrResourceKey.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'include/gpu') diff --git a/include/gpu/GrResourceKey.h b/include/gpu/GrResourceKey.h index 0ead35ea3f..8ba1140765 100644 --- a/include/gpu/GrResourceKey.h +++ b/include/gpu/GrResourceKey.h @@ -9,10 +9,11 @@ #ifndef GrResourceKey_DEFINED #define GrResourceKey_DEFINED +#include "../private/SkOnce.h" #include "../private/SkTemplates.h" #include "GrTypes.h" #include "SkData.h" -#include "../private/SkOnce.h" +#include "SkString.h" uint32_t GrResourceKeyHash(const uint32_t* data, size_t size); @@ -239,6 +240,7 @@ public: GrUniqueKey& operator=(const GrUniqueKey& that) { this->INHERITED::operator=(that); this->setCustomData(sk_ref_sp(that.getCustomData())); + SkDEBUGCODE(fTag = that.fTag;) return *this; } @@ -254,21 +256,28 @@ public: return fData.get(); } + SkDEBUGCODE(const char* tag() const { return fTag.c_str(); }) + class Builder : public INHERITED::Builder { public: - Builder(GrUniqueKey* key, Domain domain, int data32Count) - : INHERITED::Builder(key, domain, data32Count) {} + Builder(GrUniqueKey* key, Domain type, int data32Count, const char* tag = nullptr) + : INHERITED::Builder(key, type, data32Count) { + SkDEBUGCODE(key->fTag = tag;) + (void) tag; // suppress unused named param warning. + } /** Used to build a key that wraps another key and adds additional data. */ - Builder(GrUniqueKey* key, const GrUniqueKey& innerKey, Domain domain, - int extraData32Cnt) - : INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + extraData32Cnt) { + Builder(GrUniqueKey* key, const GrUniqueKey& innerKey, Domain domain, int extraData32Cnt, + const char* tag = nullptr) + : INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + extraData32Cnt) { SkASSERT(&innerKey != key); // add the inner key to the end of the key so that op[] can be indexed normally. uint32_t* innerKeyData = &this->operator[](extraData32Cnt); const uint32_t* srcData = innerKey.data(); (*innerKeyData++) = innerKey.domain(); memcpy(innerKeyData, srcData, innerKey.dataSize()); + SkDEBUGCODE(key->fTag = tag;) + (void) tag; // suppress unused named param warning. } private: @@ -280,6 +289,7 @@ public: private: sk_sp fData; + SkDEBUGCODE(SkString fTag;) }; /** -- cgit v1.2.3