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

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

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. Created 4 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
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
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 GrUniqueKey(const GrUniqueKey& that) { *this = that; } 232 GrUniqueKey(const GrUniqueKey& that) { *this = that; }
233 233
234 /** reset() returns the key to the invalid state. */ 234 /** reset() returns the key to the invalid state. */
235 using INHERITED::reset; 235 using INHERITED::reset;
236 236
237 using INHERITED::isValid; 237 using INHERITED::isValid;
238 238
239 GrUniqueKey& operator=(const GrUniqueKey& that) { 239 GrUniqueKey& operator=(const GrUniqueKey& that) {
240 this->INHERITED::operator=(that); 240 this->INHERITED::operator=(that);
241 this->setCustomData(that.getCustomData()); 241 this->setCustomData(sk_ref_sp(that.getCustomData()));
242 return *this; 242 return *this;
243 } 243 }
244 244
245 bool operator==(const GrUniqueKey& that) const { 245 bool operator==(const GrUniqueKey& that) const {
246 return this->INHERITED::operator==(that); 246 return this->INHERITED::operator==(that);
247 } 247 }
248 bool operator!=(const GrUniqueKey& that) const { return !(*this == that); } 248 bool operator!=(const GrUniqueKey& that) const { return !(*this == that); }
249 249
250 void setCustomData(const SkData* data) { 250 void setCustomData(sk_sp<SkData> data) {
251 SkSafeRef(data); 251 fData = std::move(data);
252 fData.reset(data);
253 } 252 }
254 const SkData* getCustomData() const { 253 SkData* getCustomData() const {
255 return fData.get(); 254 return fData.get();
256 } 255 }
257 256
258 class Builder : public INHERITED::Builder { 257 class Builder : public INHERITED::Builder {
259 public: 258 public:
260 Builder(GrUniqueKey* key, Domain domain, int data32Count) 259 Builder(GrUniqueKey* key, Domain domain, int data32Count)
261 : INHERITED::Builder(key, domain, data32Count) {} 260 : INHERITED::Builder(key, domain, data32Count) {}
262 261
263 /** Used to build a key that wraps another key and adds additional data. */ 262 /** Used to build a key that wraps another key and adds additional data. */
264 Builder(GrUniqueKey* key, const GrUniqueKey& innerKey, Domain domain, 263 Builder(GrUniqueKey* key, const GrUniqueKey& innerKey, Domain domain,
265 int extraData32Cnt) 264 int extraData32Cnt)
266 : INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + e xtraData32Cnt) { 265 : INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + e xtraData32Cnt) {
267 SkASSERT(&innerKey != key); 266 SkASSERT(&innerKey != key);
268 // add the inner key to the end of the key so that op[] can be index ed normally. 267 // 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); 268 uint32_t* innerKeyData = &this->operator[](extraData32Cnt);
270 const uint32_t* srcData = innerKey.data(); 269 const uint32_t* srcData = innerKey.data();
271 (*innerKeyData++) = innerKey.domain(); 270 (*innerKeyData++) = innerKey.domain();
272 memcpy(innerKeyData, srcData, innerKey.dataSize()); 271 memcpy(innerKeyData, srcData, innerKey.dataSize());
273 } 272 }
274 273
275 private: 274 private:
276 static int Data32CntForInnerKey(const GrUniqueKey& innerKey) { 275 static int Data32CntForInnerKey(const GrUniqueKey& innerKey) {
277 // key data + domain 276 // key data + domain
278 return SkToInt((innerKey.dataSize() >> 2) + 1); 277 return SkToInt((innerKey.dataSize() >> 2) + 1);
279 } 278 }
280 }; 279 };
281 280
282 private: 281 private:
283 SkAutoTUnref<const SkData> fData; 282 sk_sp<SkData> fData;
284 }; 283 };
285 284
286 /** 285 /**
287 * It is common to need a frequently reused GrUniqueKey where the only requireme nt is that the key 286 * 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 287 * 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. 288 * and only constructed once.
290 */ 289 */
291 290
292 /** Place outside of function/class definitions. */ 291 /** Place outside of function/class definitions. */
293 #define GR_DECLARE_STATIC_UNIQUE_KEY(name) static SkOnce name##_once 292 #define GR_DECLARE_STATIC_UNIQUE_KEY(name) static SkOnce name##_once
(...skipping 20 matching lines...) Expand all
314 fKey = that.fKey; 313 fKey = that.fKey;
315 return *this; 314 return *this;
316 } 315 }
317 316
318 const GrUniqueKey& key() const { return fKey; } 317 const GrUniqueKey& key() const { return fKey; }
319 318
320 private: 319 private:
321 GrUniqueKey fKey; 320 GrUniqueKey fKey;
322 }; 321 };
323 #endif 322 #endif
OLDNEW
« include/core/SkData.h ('K') | « include/core/SkData.h ('k') | public.bzl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698