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

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

Issue 815833004: Add a simpler key type for scratch resource keys. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: final fix Created 5 years, 11 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 | « include/gpu/GrResourceKey.h ('k') | src/gpu/GrGpu.cpp » ('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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 GrSurfaceFlags origFlags = desc->fFlags; 404 GrSurfaceFlags origFlags = desc->fFlags;
405 if (kApprox_ScratchTexMatch == match) { 405 if (kApprox_ScratchTexMatch == match) {
406 // bin by pow2 with a reasonable min 406 // bin by pow2 with a reasonable min
407 static const int MIN_SIZE = 16; 407 static const int MIN_SIZE = 16;
408 GrSurfaceDesc* wdesc = desc.writable(); 408 GrSurfaceDesc* wdesc = desc.writable();
409 wdesc->fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc->fWidth)); 409 wdesc->fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc->fWidth));
410 wdesc->fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc->fHeight)); 410 wdesc->fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc->fHeight));
411 } 411 }
412 412
413 do { 413 do {
414 GrResourceKey key = GrTexturePriv::ComputeScratchKey(*desc); 414 GrScratchKey key;
415 GrTexturePriv::ComputeScratchKey(*desc, &key);
415 uint32_t scratchFlags = 0; 416 uint32_t scratchFlags = 0;
416 if (calledDuringFlush) { 417 if (calledDuringFlush) {
417 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag ; 418 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag ;
418 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { 419 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) {
419 // If it is not a render target then it will most likely be popu lated by 420 // If it is not a render target then it will most likely be popu lated by
420 // writePixels() which will trigger a flush if the texture has p ending IO. 421 // writePixels() which will trigger a flush if the texture has p ending IO.
421 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag; 422 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag;
422 } 423 }
423 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, scratchFlags); 424 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, scratchFlags);
424 if (resource) { 425 if (resource) {
(...skipping 13 matching lines...) Expand all
438 } else { 439 } else {
439 break; 440 break;
440 } 441 }
441 442
442 } while (true); 443 } while (true);
443 444
444 desc.writable()->fFlags = origFlags; 445 desc.writable()->fFlags = origFlags;
445 } 446 }
446 447
447 GrTexture* texture = fGpu->createTexture(*desc, NULL, 0); 448 GrTexture* texture = fGpu->createTexture(*desc, NULL, 0);
448 SkASSERT(NULL == texture || 449 #ifdef SK_DEBUG
449 texture->cacheAccess().getScratchKey() == GrTexturePriv::ComputeScr atchKey(*desc)); 450 GrScratchKey key;
451 GrTexturePriv::ComputeScratchKey(*desc, &key);
452 SkASSERT(NULL == texture || texture->cacheAccess().getScratchKey() == key);
453 #endif
450 return texture; 454 return texture;
451 } 455 }
452 456
453 void GrContext::OverBudgetCB(void* data) { 457 void GrContext::OverBudgetCB(void* data) {
454 SkASSERT(data); 458 SkASSERT(data);
455 459
456 GrContext* context = reinterpret_cast<GrContext*>(data); 460 GrContext* context = reinterpret_cast<GrContext*>(data);
457 461
458 // Flush the InOrderDrawBuffer to possibly free up some textures 462 // Flush the InOrderDrawBuffer to possibly free up some textures
459 context->fFlushToReduceCacheSize = true; 463 context->fFlushToReduceCacheSize = true;
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 fResourceCache2->printStats(); 1753 fResourceCache2->printStats();
1750 } 1754 }
1751 #endif 1755 #endif
1752 1756
1753 #if GR_GPU_STATS 1757 #if GR_GPU_STATS
1754 const GrContext::GPUStats* GrContext::gpuStats() const { 1758 const GrContext::GPUStats* GrContext::gpuStats() const {
1755 return fGpu->gpuStats(); 1759 return fGpu->gpuStats();
1756 } 1760 }
1757 #endif 1761 #endif
1758 1762
OLDNEW
« no previous file with comments | « include/gpu/GrResourceKey.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698