| 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 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 | 10 |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 uint32_t scratchFlags = 0; | 466 uint32_t scratchFlags = 0; |
| 467 if (calledDuringFlush) { | 467 if (calledDuringFlush) { |
| 468 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag
; | 468 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag
; |
| 469 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { | 469 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { |
| 470 // If it is not a render target then it will most likely be popu
lated by | 470 // If it is not a render target then it will most likely be popu
lated by |
| 471 // writePixels() which will trigger a flush if the texture has p
ending IO. | 471 // writePixels() which will trigger a flush if the texture has p
ending IO. |
| 472 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag; | 472 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag; |
| 473 } | 473 } |
| 474 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource
(key, scratchFlags); | 474 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource
(key, scratchFlags); |
| 475 if (resource) { | 475 if (resource) { |
| 476 return static_cast<GrSurface*>(resource)->asTexture(); | 476 GrSurface* surface = static_cast<GrSurface*>(resource); |
| 477 GrRenderTarget* rt = surface->asRenderTarget(); |
| 478 if (rt && fGpu->caps()->discardRenderTargetSupport()) { |
| 479 rt->discard(); |
| 480 } |
| 481 return surface->asTexture(); |
| 477 } | 482 } |
| 478 | 483 |
| 479 if (kExact_ScratchTexMatch == match) { | 484 if (kExact_ScratchTexMatch == match) { |
| 480 break; | 485 break; |
| 481 } | 486 } |
| 482 // We had a cache miss and we are in approx mode, relax the fit of t
he flags. | 487 // We had a cache miss and we are in approx mode, relax the fit of t
he flags. |
| 483 | 488 |
| 484 // We no longer try to reuse textures that were previously used as r
ender targets in | 489 // We no longer try to reuse textures that were previously used as r
ender targets in |
| 485 // situations where no RT is needed; doing otherwise can confuse the
video driver and | 490 // situations where no RT is needed; doing otherwise can confuse the
video driver and |
| 486 // cause significant performance problems in some cases. | 491 // cause significant performance problems in some cases. |
| (...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1788 fResourceCache2->printStats(); | 1793 fResourceCache2->printStats(); |
| 1789 } | 1794 } |
| 1790 #endif | 1795 #endif |
| 1791 | 1796 |
| 1792 #if GR_GPU_STATS | 1797 #if GR_GPU_STATS |
| 1793 const GrContext::GPUStats* GrContext::gpuStats() const { | 1798 const GrContext::GPUStats* GrContext::gpuStats() const { |
| 1794 return fGpu->gpuStats(); | 1799 return fGpu->gpuStats(); |
| 1795 } | 1800 } |
| 1796 #endif | 1801 #endif |
| 1797 | 1802 |
| OLD | NEW |