OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 "GrGpuResource.h" | 10 #include "GrGpuResource.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) { | 87 void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) { |
88 SkASSERT(fScratchKey.isNullScratch()); | 88 SkASSERT(fScratchKey.isNullScratch()); |
89 SkASSERT(scratchKey.isScratch()); | 89 SkASSERT(scratchKey.isScratch()); |
90 SkASSERT(!scratchKey.isNullScratch()); | 90 SkASSERT(!scratchKey.isNullScratch()); |
91 fScratchKey = scratchKey; | 91 fScratchKey = scratchKey; |
92 } | 92 } |
93 | 93 |
| 94 const GrResourceKey* GrGpuResource::getContentKey() const { |
| 95 if (fCacheEntry && !fCacheEntry->key().isScratch()) { |
| 96 return &fCacheEntry->key(); |
| 97 } |
| 98 return NULL; |
| 99 } |
| 100 |
| 101 bool GrGpuResource::isScratch() const { |
| 102 // Currently scratch resources have a cache entry in GrResourceCache with a
scratch key. |
| 103 return NULL != fCacheEntry && fCacheEntry->key().isScratch(); |
| 104 } |
| 105 |
94 uint32_t GrGpuResource::CreateUniqueID() { | 106 uint32_t GrGpuResource::CreateUniqueID() { |
95 static int32_t gUniqueID = SK_InvalidUniqueID; | 107 static int32_t gUniqueID = SK_InvalidUniqueID; |
96 uint32_t id; | 108 uint32_t id; |
97 do { | 109 do { |
98 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 110 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
99 } while (id == SK_InvalidUniqueID); | 111 } while (id == SK_InvalidUniqueID); |
100 return id; | 112 return id; |
101 } | 113 } |
OLD | NEW |