Chromium Code Reviews| Index: src/gpu/GrResourceCache2.cpp |
| diff --git a/src/gpu/GrResourceCache2.cpp b/src/gpu/GrResourceCache2.cpp |
| index 5144c59eef44f38ca5da81bb90caba0d7817caa1..702e5e21d5187d5a641584358c1502e249757141 100644 |
| --- a/src/gpu/GrResourceCache2.cpp |
| +++ b/src/gpu/GrResourceCache2.cpp |
| @@ -59,29 +59,32 @@ void GrResourceCache2::releaseAll() { |
| class GrResourceCache2::AvailableForScratchUse { |
| public: |
| - AvailableForScratchUse(bool calledDuringFlush) : fFlushing(calledDuringFlush) { } |
| + AvailableForScratchUse(bool rejectPendingIO) : fRejectPendingIO(rejectPendingIO) { } |
| bool operator()(const GrGpuResource* resource) const { |
| - if (fFlushing) { |
| - // If this request is coming during draw buffer flush then no refs are allowed |
| - // either by drawing code or for pending io operations. |
| - // This will be removed when flush no longer creates resources. |
| - return resource->reffedOnlyByCache() && !resource->internalHasPendingIO() && |
| - resource->isScratch(); |
| - } else { |
| - // Because duties are currently shared between GrResourceCache and GrResourceCache2, the |
| - // current interpretation of this rule is that only GrResourceCache has a ref but that |
| - // it has been marked as a scratch resource. |
| - return resource->reffedOnlyByCache() && resource->isScratch(); |
| + if (!resource->reffedOnlyByCache() || !resource->isScratch()) { |
| + return false; |
| } |
| + |
| + return !fRejectPendingIO || !resource->internalHasPendingIO(); |
| } |
| private: |
| - bool fFlushing; |
| + bool fRejectPendingIO; |
| }; |
|
robertphillips
2014/10/15 20:06:13
add line break ?
bsalomon
2014/10/16 01:51:14
Done.
|
| -GrGpuResource* GrResourceCache2::findAndRefScratchResource(const GrResourceKey& scratchKey, |
| - bool calledDuringFlush) { |
| +GrGpuResource* GrResourceCache2::findAndRefScratchResource(const GrResourceKey& scratchKey, uint32_t flags) { |
| SkASSERT(scratchKey.isScratch()); |
| - return SkSafeRef(fScratchMap.find(scratchKey, AvailableForScratchUse(calledDuringFlush))); |
| + |
| + if (flags & (kPreferNoPendingIO_ScratchFlag | kRequireNoPendingIO_ScratchFlag)) { |
| + GrGpuResource* resource = fScratchMap.find(scratchKey, AvailableForScratchUse(true)); |
| + if (resource) { |
| + return SkRef(resource); |
| + } else if (flags & kRequireNoPendingIO_ScratchFlag) { |
| + return NULL; |
| + } |
|
robertphillips
2014/10/15 20:06:13
wihout -> without ?
bsalomon
2014/10/16 01:51:14
Done.
|
| + // TODO: fail here when kPrefer is specified, we didn't find a resource wihout pending io, |
| + // but there is still space in our budget for the resource. |
| + } |
| + return SkSafeRef(fScratchMap.find(scratchKey, AvailableForScratchUse(false))); |
| } |