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