| 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 "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 if (NULL == texture) { | 509 if (NULL == texture) { |
| 510 return; | 510 return; |
| 511 } | 511 } |
| 512 | 512 |
| 513 // This texture should already have a cache entry since it was once | 513 // This texture should already have a cache entry since it was once |
| 514 // attached | 514 // attached |
| 515 SkASSERT(NULL != texture->getCacheEntry()); | 515 SkASSERT(NULL != texture->getCacheEntry()); |
| 516 | 516 |
| 517 // Conceptually, the cache entry is going to assume responsibility | 517 // Conceptually, the cache entry is going to assume responsibility |
| 518 // for the creation ref. Assert refcnt == 1. | 518 // for the creation ref. Assert refcnt == 1. |
| 519 SkASSERT(texture->unique()); | 519 // Except that this also gets called when the texture is prematurely |
| 520 // abandoned. In that case the ref count may be > 1. |
| 521 // SkASSERT(texture->unique()); |
| 520 | 522 |
| 521 if (fGpu->caps()->reuseScratchTextures() || NULL != texture->asRenderTarget(
)) { | 523 if (fGpu->caps()->reuseScratchTextures() || NULL != texture->asRenderTarget(
)) { |
| 522 // Since this texture came from an AutoScratchTexture it should | 524 // Since this texture came from an AutoScratchTexture it should |
| 523 // still be in the exclusive pile. Recycle it. | 525 // still be in the exclusive pile. Recycle it. |
| 524 fResourceCache->makeNonExclusive(texture->getCacheEntry()); | 526 fResourceCache->makeNonExclusive(texture->getCacheEntry()); |
| 525 this->purgeCache(); | 527 this->purgeCache(); |
| 526 } else { | 528 } else { |
| 527 // When we aren't reusing textures we know this scratch texture | 529 // When we aren't reusing textures we know this scratch texture |
| 528 // will never be reused and would be just wasting time in the cache | 530 // will never be reused and would be just wasting time in the cache |
| 529 fResourceCache->makeNonExclusive(texture->getCacheEntry()); | 531 fResourceCache->makeNonExclusive(texture->getCacheEntry()); |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 fDrawBuffer->removeGpuTraceMarker(marker); | 1924 fDrawBuffer->removeGpuTraceMarker(marker); |
| 1923 } | 1925 } |
| 1924 } | 1926 } |
| 1925 | 1927 |
| 1926 /////////////////////////////////////////////////////////////////////////////// | 1928 /////////////////////////////////////////////////////////////////////////////// |
| 1927 #if GR_CACHE_STATS | 1929 #if GR_CACHE_STATS |
| 1928 void GrContext::printCacheStats() const { | 1930 void GrContext::printCacheStats() const { |
| 1929 fResourceCache->printStats(); | 1931 fResourceCache->printStats(); |
| 1930 } | 1932 } |
| 1931 #endif | 1933 #endif |
| OLD | NEW |