| 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 #ifndef GrResourceCache2_DEFINED | 9 #ifndef GrResourceCache2_DEFINED |
| 10 #define GrResourceCache2_DEFINED | 10 #define GrResourceCache2_DEFINED |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 enum { | 35 enum { |
| 36 /** Preferentially returns scratch resources with no pending IO. */ | 36 /** Preferentially returns scratch resources with no pending IO. */ |
| 37 kPreferNoPendingIO_ScratchFlag = 0x1, | 37 kPreferNoPendingIO_ScratchFlag = 0x1, |
| 38 /** Will not return any resources that match but have pending IO. */ | 38 /** Will not return any resources that match but have pending IO. */ |
| 39 kRequireNoPendingIO_ScratchFlag = 0x2, | 39 kRequireNoPendingIO_ScratchFlag = 0x2, |
| 40 }; | 40 }; |
| 41 GrGpuResource* findAndRefScratchResource(const GrResourceKey& scratchKey, ui
nt32_t flags = 0); | 41 GrGpuResource* findAndRefScratchResource(const GrResourceKey& scratchKey, ui
nt32_t flags = 0); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 #ifdef SK_DEBUG | 44 #ifdef SK_DEBUG |
| 45 bool isInCache(const GrGpuResource* r) const { | 45 bool isInCache(const GrGpuResource* r) const { return fResources.isInList(r)
; } |
| 46 return fResources.isInList(r); | |
| 47 } | |
| 48 #endif | 46 #endif |
| 49 | 47 |
| 50 class AvailableForScratchUse; | 48 class AvailableForScratchUse; |
| 51 | 49 |
| 52 struct ScratchMapTraits { | 50 struct ScratchMapTraits { |
| 53 static const GrResourceKey& GetKey(const GrGpuResource& r) { | 51 static const GrResourceKey& GetKey(const GrGpuResource& r) { |
| 54 return r.getScratchKey(); | 52 return r.getScratchKey(); |
| 55 } | 53 } |
| 56 | 54 |
| 57 static uint32_t Hash(const GrResourceKey& key) { return key.getHash(); } | 55 static uint32_t Hash(const GrResourceKey& key) { return key.getHash(); } |
| 58 }; | 56 }; |
| 59 typedef SkTMultiMap<GrGpuResource, GrResourceKey, ScratchMapTraits> ScratchM
ap; | 57 typedef SkTMultiMap<GrGpuResource, GrResourceKey, ScratchMapTraits> ScratchM
ap; |
| 60 | 58 |
| 61 int fCount; | 59 int fCount; |
| 62 SkTInternalLList<GrGpuResource> fResources; | 60 SkTInternalLList<GrGpuResource> fResources; |
| 63 // This map holds all resources that can be used as scratch resources. | 61 // This map holds all resources that can be used as scratch resources. |
| 64 ScratchMap fScratchMap; | 62 ScratchMap fScratchMap; |
| 65 }; | 63 }; |
| 66 | 64 |
| 67 #endif | 65 #endif |
| OLD | NEW |