Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: src/gpu/GrContext.cpp

Issue 650283002: Prefer to recycle non-RT scratch textures that don't have pending IO (Closed) Base URL: https://skia.googlesource.com/skia.git@ast
Patch Set: Address comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrResourceCache2.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 if (kApprox_ScratchTexMatch == match) { 463 if (kApprox_ScratchTexMatch == match) {
464 // bin by pow2 with a reasonable min 464 // bin by pow2 with a reasonable min
465 static const int MIN_SIZE = 16; 465 static const int MIN_SIZE = 16;
466 GrTextureDesc* wdesc = desc.writable(); 466 GrTextureDesc* wdesc = desc.writable();
467 wdesc->fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc->fWidth)); 467 wdesc->fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc->fWidth));
468 wdesc->fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc->fHeight)); 468 wdesc->fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc->fHeight));
469 } 469 }
470 470
471 do { 471 do {
472 GrResourceKey key = GrTexturePriv::ComputeScratchKey(*desc); 472 GrResourceKey key = GrTexturePriv::ComputeScratchKey(*desc);
473 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, 473 uint32_t scratchFlags = 0;
474 calledDuringFlush); 474 if (calledDuringFlush) {
475 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag ;
476 } else if (!(desc->fFlags & kRenderTarget_GrTextureFlagBit)) {
477 // If it is not a render target then it will most likely be popu lated by
478 // writePixels() which will trigger a flush if the texture has p ending IO.
479 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag;
480 }
481 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, scratchFlags);
475 if (resource) { 482 if (resource) {
476 fResourceCache->makeResourceMRU(resource); 483 fResourceCache->makeResourceMRU(resource);
477 return static_cast<GrTexture*>(resource); 484 return static_cast<GrTexture*>(resource);
478 } 485 }
479 486
480 if (kExact_ScratchTexMatch == match) { 487 if (kExact_ScratchTexMatch == match) {
481 break; 488 break;
482 } 489 }
483 // We had a cache miss and we are in approx mode, relax the fit of t he flags. 490 // We had a cache miss and we are in approx mode, relax the fit of t he flags.
484 491
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 fResourceCache->printStats(); 1794 fResourceCache->printStats();
1788 } 1795 }
1789 #endif 1796 #endif
1790 1797
1791 #if GR_GPU_STATS 1798 #if GR_GPU_STATS
1792 const GrContext::GPUStats* GrContext::gpuStats() const { 1799 const GrContext::GPUStats* GrContext::gpuStats() const {
1793 return fGpu->gpuStats(); 1800 return fGpu->gpuStats();
1794 } 1801 }
1795 #endif 1802 #endif
1796 1803
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrResourceCache2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698