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

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: fix comment 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') | src/gpu/GrResourceCache2.h » ('J')
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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 if (kApprox_ScratchTexMatch == match) { 464 if (kApprox_ScratchTexMatch == match) {
465 // bin by pow2 with a reasonable min 465 // bin by pow2 with a reasonable min
466 static const int MIN_SIZE = 16; 466 static const int MIN_SIZE = 16;
467 GrTextureDesc* wdesc = desc.writable(); 467 GrTextureDesc* wdesc = desc.writable();
468 wdesc->fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc->fWidth)); 468 wdesc->fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc->fWidth));
469 wdesc->fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc->fHeight)); 469 wdesc->fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc->fHeight));
470 } 470 }
471 471
472 do { 472 do {
473 GrResourceKey key = GrTexturePriv::ComputeScratchKey(*desc); 473 GrResourceKey key = GrTexturePriv::ComputeScratchKey(*desc);
474 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, 474 uint32_t scratchFlags = 0;
475 calledDuringFlush); 475 if (calledDuringFlush) {
476 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag ;
477 } else if (!(desc->fFlags & kRenderTarget_GrTextureFlagBit)) {
robertphillips 2014/10/15 20:06:13 Why not just always pass Prefer if !calledDuringFl
bsalomon 2014/10/16 01:51:14 I think it's better to keep reusing the same textu
478 // If it is not a render target then it will most likley be popu lated by
479 // writePixels() which will trigger a flush if the texture has p ending IO.
480 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag;
481 }
482 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, scratchFlags);
476 if (resource) { 483 if (resource) {
477 fResourceCache->makeResourceMRU(resource); 484 fResourceCache->makeResourceMRU(resource);
478 return static_cast<GrTexture*>(resource); 485 return static_cast<GrTexture*>(resource);
479 } 486 }
480 487
481 if (kExact_ScratchTexMatch == match) { 488 if (kExact_ScratchTexMatch == match) {
482 break; 489 break;
483 } 490 }
484 // We had a cache miss and we are in approx mode, relax the fit of t he flags. 491 // We had a cache miss and we are in approx mode, relax the fit of t he flags.
485 492
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 fResourceCache->printStats(); 1795 fResourceCache->printStats();
1789 } 1796 }
1790 #endif 1797 #endif
1791 1798
1792 #if GR_GPU_STATS 1799 #if GR_GPU_STATS
1793 const GrContext::GPUStats* GrContext::gpuStats() const { 1800 const GrContext::GPUStats* GrContext::gpuStats() const {
1794 return fGpu->gpuStats(); 1801 return fGpu->gpuStats();
1795 } 1802 }
1796 #endif 1803 #endif
1797 1804
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrResourceCache2.h » ('j') | src/gpu/GrResourceCache2.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698