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

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

Issue 864833003: Revert of Make GrScratchKey memory buffer correct size on copy (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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 | « no previous file | tests/ResourceCacheTest.cpp » ('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
(...skipping 28 matching lines...) Expand all
39 39
40 ResourceType resourceType() const { return fKey[kTypeAndSize_MetaDataIdx] & 0xffff; } 40 ResourceType resourceType() const { return fKey[kTypeAndSize_MetaDataIdx] & 0xffff; }
41 41
42 uint32_t hash() const { return fKey[kHash_MetaDataIdx]; } 42 uint32_t hash() const { return fKey[kHash_MetaDataIdx]; }
43 43
44 size_t size() const { return SkToInt(fKey[kTypeAndSize_MetaDataIdx] >> 16); } 44 size_t size() const { return SkToInt(fKey[kTypeAndSize_MetaDataIdx] >> 16); }
45 45
46 const uint32_t* data() const { return &fKey[kMetaDataCnt]; } 46 const uint32_t* data() const { return &fKey[kMetaDataCnt]; }
47 47
48 GrScratchKey& operator=(const GrScratchKey& that) { 48 GrScratchKey& operator=(const GrScratchKey& that) {
49 size_t bytes = that.size(); 49 size_t size = that.size();
50 fKey.reset(SkToInt(bytes / sizeof(uint32_t))); 50 fKey.reset(SkToInt(size));
51 memcpy(fKey.get(), that.fKey.get(), bytes); 51 memcpy(fKey.get(), that.fKey.get(), size);
52 return *this; 52 return *this;
53 } 53 }
54 54
55 bool operator==(const GrScratchKey& that) const { 55 bool operator==(const GrScratchKey& that) const {
56 return 0 == memcmp(fKey.get(), that.fKey.get(), this->size()); 56 return 0 == memcmp(fKey.get(), that.fKey.get(), this->size());
57 } 57 }
58 bool operator!=(const GrScratchKey& that) const { return !(*this == that); } 58 bool operator!=(const GrScratchKey& that) const { return !(*this == that); }
59 59
60 /** Used to initialize scratch key. */ 60 /** Used to initialize scratch key. */
61 class Builder { 61 class Builder {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 memcpy(k + kCacheIDKeyOffset, key.fData8, sizeof(GrCacheID::Key)); 150 memcpy(k + kCacheIDKeyOffset, key.fData8, sizeof(GrCacheID::Key));
151 memcpy(k + kCacheIDDomainOffset, &domain, sizeof(GrCacheID::Domain)); 151 memcpy(k + kCacheIDDomainOffset, &domain, sizeof(GrCacheID::Domain));
152 memcpy(k + kResourceFlagsOffset, &flags, sizeof(ResourceFlags)); 152 memcpy(k + kResourceFlagsOffset, &flags, sizeof(ResourceFlags));
153 memset(k + kPadOffset, 0, kPadSize); 153 memset(k + kPadOffset, 0, kPadSize);
154 fKey.setKeyData(keyData.fKey32); 154 fKey.setKeyData(keyData.fKey32);
155 } 155 }
156 GrBinHashKey<kKeySize> fKey; 156 GrBinHashKey<kKeySize> fKey;
157 }; 157 };
158 158
159 #endif 159 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698