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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 450 |
451 GrResource* resource = NULL; | 451 GrResource* resource = NULL; |
452 int origWidth = desc.fWidth; | 452 int origWidth = desc.fWidth; |
453 int origHeight = desc.fHeight; | 453 int origHeight = desc.fHeight; |
454 | 454 |
455 do { | 455 do { |
456 GrResourceKey key = GrTexture::ComputeScratchKey(desc); | 456 GrResourceKey key = GrTexture::ComputeScratchKey(desc); |
457 // Ensure we have exclusive access to the texture so future 'find' calls
don't return it | 457 // Ensure we have exclusive access to the texture so future 'find' calls
don't return it |
458 resource = fTextureCache->find(key, GrResourceCache::kHide_OwnershipFlag
); | 458 resource = fTextureCache->find(key, GrResourceCache::kHide_OwnershipFlag
); |
459 if (NULL != resource) { | 459 if (NULL != resource) { |
| 460 // If the scratch texture is a render target, discard its contents. |
| 461 GrRenderTarget* rt = static_cast<GrTexture*>(resource)->asRenderTarg
et(); |
| 462 if (NULL != rt) { |
| 463 rt->discard(); |
| 464 } |
460 resource->ref(); | 465 resource->ref(); |
461 break; | 466 break; |
462 } | 467 } |
463 if (kExact_ScratchTexMatch == match) { | 468 if (kExact_ScratchTexMatch == match) { |
464 break; | 469 break; |
465 } | 470 } |
466 // We had a cache miss and we are in approx mode, relax the fit of the f
lags. | 471 // We had a cache miss and we are in approx mode, relax the fit of the f
lags. |
467 | 472 |
468 // We no longer try to reuse textures that were previously used as rende
r targets in | 473 // We no longer try to reuse textures that were previously used as rende
r targets in |
469 // situations where no RT is needed; doing otherwise can confuse the vid
eo driver and | 474 // situations where no RT is needed; doing otherwise can confuse the vid
eo driver and |
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 } | 1803 } |
1799 return path; | 1804 return path; |
1800 } | 1805 } |
1801 | 1806 |
1802 /////////////////////////////////////////////////////////////////////////////// | 1807 /////////////////////////////////////////////////////////////////////////////// |
1803 #if GR_CACHE_STATS | 1808 #if GR_CACHE_STATS |
1804 void GrContext::printCacheStats() const { | 1809 void GrContext::printCacheStats() const { |
1805 fTextureCache->printStats(); | 1810 fTextureCache->printStats(); |
1806 } | 1811 } |
1807 #endif | 1812 #endif |
OLD | NEW |