| 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" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 return SkRef(resource); | 88 return SkRef(resource); |
| 89 } else if (flags & kRequireNoPendingIO_ScratchFlag) { | 89 } else if (flags & kRequireNoPendingIO_ScratchFlag) { |
| 90 return NULL; | 90 return NULL; |
| 91 } | 91 } |
| 92 // TODO: fail here when kPrefer is specified, we didn't find a resource
without pending io, | 92 // TODO: fail here when kPrefer is specified, we didn't find a resource
without pending io, |
| 93 // but there is still space in our budget for the resource. | 93 // but there is still space in our budget for the resource. |
| 94 } | 94 } |
| 95 return SkSafeRef(fScratchMap.find(scratchKey, AvailableForScratchUse(false))
); | 95 return SkSafeRef(fScratchMap.find(scratchKey, AvailableForScratchUse(false))
); |
| 96 } | 96 } |
| 97 | 97 |
| 98 #if 0 |
| 98 void GrResourceCache2::willRemoveContentKey(const GrGpuResource* resource) { | 99 void GrResourceCache2::willRemoveContentKey(const GrGpuResource* resource) { |
| 99 SkASSERT(resource); | 100 SkASSERT(resource); |
| 100 SkASSERT(resource->getContentKey()); | 101 SkASSERT(resource->getContentKey()); |
| 101 SkDEBUGCODE(GrGpuResource* res = fContentHash.find(*resource->getContentKey(
))); | 102 SkDEBUGCODE(GrGpuResource* res = fContentHash.find(*resource->getContentKey(
))); |
| 102 SkASSERT(res == resource); | 103 SkASSERT(res == resource); |
| 103 | 104 |
| 104 fContentHash.remove(*resource->getContentKey()); | 105 fContentHash.remove(*resource->getContentKey()); |
| 105 } | 106 } |
| 107 #endif |
| 106 | 108 |
| 107 bool GrResourceCache2::didAddContentKey(GrGpuResource* resource) { | 109 bool GrResourceCache2::didSetContentKey(GrGpuResource* resource) { |
| 108 SkASSERT(resource); | 110 SkASSERT(resource); |
| 109 SkASSERT(resource->getContentKey()); | 111 SkASSERT(resource->getContentKey()); |
| 112 SkASSERT(!resource->getContentKey()->isScratch()); |
| 110 | 113 |
| 111 GrGpuResource* res = fContentHash.find(*resource->getContentKey()); | 114 GrGpuResource* res = fContentHash.find(*resource->getContentKey()); |
| 112 if (NULL != res) { | 115 if (NULL != res) { |
| 113 return false; | 116 return false; |
| 114 } | 117 } |
| 115 | 118 |
| 116 fContentHash.add(resource); | 119 fContentHash.add(resource); |
| 117 return true; | 120 return true; |
| 118 } | 121 } |
| OLD | NEW |