Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: include/gpu/GrResourceKey.h

Issue 1260363007: Revert "Implement caching of filled paths in the tessellated path renderer." (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPathRef.h ('k') | src/core/SkPathPriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
14 #include "SkOnce.h" 13 #include "SkOnce.h"
15 #include "SkTemplates.h" 14 #include "SkTemplates.h"
16 15
17 uint32_t GrResourceKeyHash(const uint32_t* data, size_t size); 16 uint32_t GrResourceKeyHash(const uint32_t* data, size_t size);
18 17
19 /** 18 /**
20 * Base class for all GrGpuResource cache keys. There are two types of cache key s. Refer to the 19 * Base class for all GrGpuResource cache keys. There are two types of cache key s. Refer to the
21 * comments for each key type below. 20 * comments for each key type below.
22 */ 21 */
23 class GrResourceKey { 22 class GrResourceKey {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 230
232 GrUniqueKey(const GrUniqueKey& that) { *this = that; } 231 GrUniqueKey(const GrUniqueKey& that) { *this = that; }
233 232
234 /** reset() returns the key to the invalid state. */ 233 /** reset() returns the key to the invalid state. */
235 using INHERITED::reset; 234 using INHERITED::reset;
236 235
237 using INHERITED::isValid; 236 using INHERITED::isValid;
238 237
239 GrUniqueKey& operator=(const GrUniqueKey& that) { 238 GrUniqueKey& operator=(const GrUniqueKey& that) {
240 this->INHERITED::operator=(that); 239 this->INHERITED::operator=(that);
241 this->setCustomData(that.getCustomData());
242 return *this; 240 return *this;
243 } 241 }
244 242
245 bool operator==(const GrUniqueKey& that) const { 243 bool operator==(const GrUniqueKey& that) const {
246 return this->INHERITED::operator==(that); 244 return this->INHERITED::operator==(that);
247 } 245 }
248 bool operator!=(const GrUniqueKey& that) const { return !(*this == that); } 246 bool operator!=(const GrUniqueKey& that) const { return !(*this == that); }
249 247
250 void setCustomData(const SkData* data) {
251 SkSafeRef(data);
252 fData.reset(data);
253 }
254 const SkData* getCustomData() const {
255 return fData.get();
256 }
257
258 class Builder : public INHERITED::Builder { 248 class Builder : public INHERITED::Builder {
259 public: 249 public:
260 Builder(GrUniqueKey* key, Domain domain, int data32Count) 250 Builder(GrUniqueKey* key, Domain domain, int data32Count)
261 : INHERITED::Builder(key, domain, data32Count) {} 251 : INHERITED::Builder(key, domain, data32Count) {}
262 252
263 /** Used to build a key that wraps another key and adds additional data. */ 253 /** Used to build a key that wraps another key and adds additional data. */
264 Builder(GrUniqueKey* key, const GrUniqueKey& innerKey, Domain domain, 254 Builder(GrUniqueKey* key, const GrUniqueKey& innerKey, Domain domain,
265 int extraData32Cnt) 255 int extraData32Cnt)
266 : INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + e xtraData32Cnt) { 256 : INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + e xtraData32Cnt) {
267 SkASSERT(&innerKey != key); 257 SkASSERT(&innerKey != key);
268 // add the inner key to the end of the key so that op[] can be index ed normally. 258 // add the inner key to the end of the key so that op[] can be index ed normally.
269 uint32_t* innerKeyData = &this->operator[](extraData32Cnt); 259 uint32_t* innerKeyData = &this->operator[](extraData32Cnt);
270 const uint32_t* srcData = innerKey.data(); 260 const uint32_t* srcData = innerKey.data();
271 (*innerKeyData++) = innerKey.domain(); 261 (*innerKeyData++) = innerKey.domain();
272 memcpy(innerKeyData, srcData, innerKey.dataSize()); 262 memcpy(innerKeyData, srcData, innerKey.dataSize());
273 } 263 }
274 264
275 private: 265 private:
276 static int Data32CntForInnerKey(const GrUniqueKey& innerKey) { 266 static int Data32CntForInnerKey(const GrUniqueKey& innerKey) {
277 // key data + domain 267 // key data + domain
278 return SkToInt((innerKey.dataSize() >> 2) + 1); 268 return SkToInt((innerKey.dataSize() >> 2) + 1);
279 } 269 }
280 }; 270 };
281
282 private:
283 SkAutoTUnref<const SkData> fData;
284 }; 271 };
285 272
286 /** 273 /**
287 * It is common to need a frequently reused GrUniqueKey where the only requireme nt is that the key 274 * It is common to need a frequently reused GrUniqueKey where the only requireme nt is that the key
288 * is unique. These macros create such a key in a thread safe manner so the key can be truly global 275 * is unique. These macros create such a key in a thread safe manner so the key can be truly global
289 * and only constructed once. 276 * and only constructed once.
290 */ 277 */
291 278
292 /** Place outside of function/class definitions. */ 279 /** Place outside of function/class definitions. */
293 #define GR_DECLARE_STATIC_UNIQUE_KEY(name) SK_DECLARE_STATIC_ONCE(name##_once) 280 #define GR_DECLARE_STATIC_UNIQUE_KEY(name) SK_DECLARE_STATIC_ONCE(name##_once)
(...skipping 18 matching lines...) Expand all
312 fKey = that.fKey; 299 fKey = that.fKey;
313 return *this; 300 return *this;
314 } 301 }
315 302
316 const GrUniqueKey& key() const { return fKey; } 303 const GrUniqueKey& key() const { return fKey; }
317 304
318 private: 305 private:
319 GrUniqueKey fKey; 306 GrUniqueKey fKey;
320 }; 307 };
321 #endif 308 #endif
OLDNEW
« no previous file with comments | « include/core/SkPathRef.h ('k') | src/core/SkPathPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698