| 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 | 9 |
| 10 #include "GrResourceCache2.h" | 10 #include "GrResourceCache2.h" |
| 11 #include "GrGpuResource.h" | 11 #include "GrGpuResource.h" |
| 12 | 12 |
| 13 GrResourceKey& GrResourceKey::NullScratchKey() { |
| 14 static const GrCacheID::Key kBogusKey = { { {0} } }; |
| 15 static GrCacheID kBogusID(ScratchDomain(), kBogusKey); |
| 16 static GrResourceKey kNullScratchKey(kBogusID, NoneResourceType(), 0); |
| 17 return kNullScratchKey; |
| 18 } |
| 19 |
| 20 GrResourceKey::ResourceType GrResourceKey::NoneResourceType() { |
| 21 static const ResourceType gNoneResourceType = GenerateResourceType(); |
| 22 return gNoneResourceType; |
| 23 } |
| 24 |
| 25 GrCacheID::Domain GrResourceKey::ScratchDomain() { |
| 26 static const GrCacheID::Domain gDomain = GrCacheID::GenerateDomain(); |
| 27 return gDomain; |
| 28 } |
| 29 |
| 30 ////////////////////////////////////////////////////////////////////////////// |
| 31 |
| 13 GrResourceCache2::~GrResourceCache2() { | 32 GrResourceCache2::~GrResourceCache2() { |
| 14 this->releaseAll(); | 33 this->releaseAll(); |
| 15 } | 34 } |
| 16 | 35 |
| 17 void GrResourceCache2::insertResource(GrGpuResource* resource) { | 36 void GrResourceCache2::insertResource(GrGpuResource* resource) { |
| 18 SkASSERT(resource); | 37 SkASSERT(resource); |
| 19 SkASSERT(!resource->wasDestroyed()); | 38 SkASSERT(!resource->wasDestroyed()); |
| 20 SkASSERT(!this->isInCache(resource)); | 39 SkASSERT(!this->isInCache(resource)); |
| 21 fResources.addToHead(resource); | 40 fResources.addToHead(resource); |
| 22 ++fCount; | 41 ++fCount; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 SkASSERT(resource->getContentKey()); | 128 SkASSERT(resource->getContentKey()); |
| 110 | 129 |
| 111 GrGpuResource* res = fContentHash.find(*resource->getContentKey()); | 130 GrGpuResource* res = fContentHash.find(*resource->getContentKey()); |
| 112 if (NULL != res) { | 131 if (NULL != res) { |
| 113 return false; | 132 return false; |
| 114 } | 133 } |
| 115 | 134 |
| 116 fContentHash.add(resource); | 135 fContentHash.add(resource); |
| 117 return true; | 136 return true; |
| 118 } | 137 } |
| OLD | NEW |