aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrResourceKey.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-01-06 12:04:19 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-06 17:54:03 +0000
commit1090da6433db575d59b93aec99f6bda49b808b84 (patch)
tree1aaba527e5cc1603fe16ccd153119e46870e4ad1 /include/gpu/GrResourceKey.h
parent7f71d8845c3c57c6e4b33c3666cca46b55e91d02 (diff)
Add support for tagging GrUniqueKeys with a debug string
Change-Id: Ie7d56214fdee7a19a1e8ca3869e5e4d5e72cedf8 Reviewed-on: https://skia-review.googlesource.com/6632 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include/gpu/GrResourceKey.h')
-rw-r--r--include/gpu/GrResourceKey.h22
1 files changed, 16 insertions, 6 deletions
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<SkData> fData;
+ SkDEBUGCODE(SkString fTag;)
};
/**