Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef GrResourceKey_DEFINED | 9 #ifndef GrResourceKey_DEFINED |
| 10 #define GrResourceKey_DEFINED | 10 #define GrResourceKey_DEFINED |
| 11 | 11 |
| 12 #include "GrTypes.h" | 12 #include "GrTypes.h" |
| 13 #include "SkData.h" | |
| 13 #include "SkOnce.h" | 14 #include "SkOnce.h" |
| 14 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
| 15 | 16 |
| 16 uint32_t GrResourceKeyHash(const uint32_t* data, size_t size); | 17 uint32_t GrResourceKeyHash(const uint32_t* data, size_t size); |
| 17 | 18 |
| 18 /** | 19 /** |
| 19 * Base class for all GrGpuResource cache keys. There are two types of cache key s. Refer to the | 20 * Base class for all GrGpuResource cache keys. There are two types of cache key s. Refer to the |
| 20 * comments for each key type below. | 21 * comments for each key type below. |
| 21 */ | 22 */ |
| 22 class GrResourceKey { | 23 class GrResourceKey { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 | 231 |
| 231 GrUniqueKey(const GrUniqueKey& that) { *this = that; } | 232 GrUniqueKey(const GrUniqueKey& that) { *this = that; } |
| 232 | 233 |
| 233 /** reset() returns the key to the invalid state. */ | 234 /** reset() returns the key to the invalid state. */ |
| 234 using INHERITED::reset; | 235 using INHERITED::reset; |
| 235 | 236 |
| 236 using INHERITED::isValid; | 237 using INHERITED::isValid; |
| 237 | 238 |
| 238 GrUniqueKey& operator=(const GrUniqueKey& that) { | 239 GrUniqueKey& operator=(const GrUniqueKey& that) { |
| 239 this->INHERITED::operator=(that); | 240 this->INHERITED::operator=(that); |
| 241 this->setCustomData(that.getCustomData()); | |
| 240 return *this; | 242 return *this; |
| 241 } | 243 } |
| 242 | 244 |
| 243 bool operator==(const GrUniqueKey& that) const { | 245 bool operator==(const GrUniqueKey& that) const { |
| 244 return this->INHERITED::operator==(that); | 246 return this->INHERITED::operator==(that); |
| 245 } | 247 } |
| 246 bool operator!=(const GrUniqueKey& that) const { return !(*this == that); } | 248 bool operator!=(const GrUniqueKey& that) const { return !(*this == that); } |
| 247 | 249 |
| 250 void setCustomData(const SkData* data) { | |
|
bsalomon
2015/08/03 18:08:26
Can you modify one of the tests (or add a new test
Stephen White
2015/08/03 18:54:41
Done.
| |
| 251 SkSafeRef(data); | |
| 252 fData.reset(data); | |
| 253 } | |
| 254 const SkData* getCustomData() const { | |
| 255 return fData.get(); | |
| 256 } | |
| 257 | |
| 258 SkAutoTUnref<const SkData> fData; | |
|
bsalomon
2015/08/03 18:08:26
Does fData need to be public?
Stephen White
2015/08/03 18:54:41
Fixed.
| |
| 259 | |
| 248 class Builder : public INHERITED::Builder { | 260 class Builder : public INHERITED::Builder { |
| 249 public: | 261 public: |
| 250 Builder(GrUniqueKey* key, Domain domain, int data32Count) | 262 Builder(GrUniqueKey* key, Domain domain, int data32Count) |
| 251 : INHERITED::Builder(key, domain, data32Count) {} | 263 : INHERITED::Builder(key, domain, data32Count) {} |
| 252 | 264 |
| 253 /** Used to build a key that wraps another key and adds additional data. */ | 265 /** Used to build a key that wraps another key and adds additional data. */ |
| 254 Builder(GrUniqueKey* key, const GrUniqueKey& innerKey, Domain domain, | 266 Builder(GrUniqueKey* key, const GrUniqueKey& innerKey, Domain domain, |
| 255 int extraData32Cnt) | 267 int extraData32Cnt) |
| 256 : INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + e xtraData32Cnt) { | 268 : INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + e xtraData32Cnt) { |
| 257 SkASSERT(&innerKey != key); | 269 SkASSERT(&innerKey != key); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 fKey = that.fKey; | 311 fKey = that.fKey; |
| 300 return *this; | 312 return *this; |
| 301 } | 313 } |
| 302 | 314 |
| 303 const GrUniqueKey& key() const { return fKey; } | 315 const GrUniqueKey& key() const { return fKey; } |
| 304 | 316 |
| 305 private: | 317 private: |
| 306 GrUniqueKey fKey; | 318 GrUniqueKey fKey; |
| 307 }; | 319 }; |
| 308 #endif | 320 #endif |
| OLD | NEW |