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

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

Issue 703303003: Add GrGpuResource::CacheAccess (Closed) Base URL: https://skia.googlesource.com/skia.git@nohash
Patch Set: update Created 6 years, 1 month 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
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
11 #include "effects/GrConfigConversionEffect.h" 11 #include "effects/GrConfigConversionEffect.h"
12 #include "effects/GrDashingEffect.h" 12 #include "effects/GrDashingEffect.h"
13 #include "effects/GrSingleTextureEffect.h" 13 #include "effects/GrSingleTextureEffect.h"
14 14
15 #include "GrAARectRenderer.h" 15 #include "GrAARectRenderer.h"
16 #include "GrBufferAllocPool.h" 16 #include "GrBufferAllocPool.h"
17 #include "GrGpu.h" 17 #include "GrGpu.h"
18 #include "GrGpuResource.h"
19 #include "GrGpuResourceCacheAccess.h"
18 #include "GrDistanceFieldTextContext.h" 20 #include "GrDistanceFieldTextContext.h"
19 #include "GrDrawTargetCaps.h" 21 #include "GrDrawTargetCaps.h"
20 #include "GrIndexBuffer.h" 22 #include "GrIndexBuffer.h"
21 #include "GrInOrderDrawBuffer.h" 23 #include "GrInOrderDrawBuffer.h"
22 #include "GrLayerCache.h" 24 #include "GrLayerCache.h"
23 #include "GrOvalRenderer.h" 25 #include "GrOvalRenderer.h"
24 #include "GrPathRenderer.h" 26 #include "GrPathRenderer.h"
25 #include "GrPathUtils.h" 27 #include "GrPathUtils.h"
26 #include "GrResourceCache.h" 28 #include "GrResourceCache.h"
27 #include "GrResourceCache2.h" 29 #include "GrResourceCache2.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 429 }
428 430
429 return texture; 431 return texture;
430 } 432 }
431 433
432 GrTexture* GrContext::createNewScratchTexture(const GrSurfaceDesc& desc) { 434 GrTexture* GrContext::createNewScratchTexture(const GrSurfaceDesc& desc) {
433 GrTexture* texture = fGpu->createTexture(desc, NULL, 0); 435 GrTexture* texture = fGpu->createTexture(desc, NULL, 0);
434 if (!texture) { 436 if (!texture) {
435 return NULL; 437 return NULL;
436 } 438 }
437 fResourceCache->addResource(texture->getScratchKey(), texture); 439 fResourceCache->addResource(texture->cacheAccess().getScratchKey(), texture) ;
438 return texture; 440 return texture;
439 } 441 }
440 442
441 GrTexture* GrContext::refScratchTexture(const GrSurfaceDesc& inDesc, ScratchTexM atch match, 443 GrTexture* GrContext::refScratchTexture(const GrSurfaceDesc& inDesc, ScratchTexM atch match,
442 bool calledDuringFlush) { 444 bool calledDuringFlush) {
443 // kNoStencil has no meaning if kRT isn't set. 445 // kNoStencil has no meaning if kRT isn't set.
444 SkASSERT((inDesc.fFlags & kRenderTarget_GrSurfaceFlag) || 446 SkASSERT((inDesc.fFlags & kRenderTarget_GrSurfaceFlag) ||
445 !(inDesc.fFlags & kNoStencil_GrSurfaceFlag)); 447 !(inDesc.fFlags & kNoStencil_GrSurfaceFlag));
446 448
447 // Make sure caller has checked for renderability if kRT is set. 449 // Make sure caller has checked for renderability if kRT is set.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 break; 492 break;
491 } 493 }
492 494
493 } while (true); 495 } while (true);
494 496
495 desc.writable()->fFlags = origFlags; 497 desc.writable()->fFlags = origFlags;
496 } 498 }
497 499
498 GrTexture* texture = this->createNewScratchTexture(*desc); 500 GrTexture* texture = this->createNewScratchTexture(*desc);
499 SkASSERT(NULL == texture || 501 SkASSERT(NULL == texture ||
500 texture->getScratchKey() == GrTexturePriv::ComputeScratchKey(*desc) ); 502 texture->cacheAccess().getScratchKey() == GrTexturePriv::ComputeScr atchKey(*desc));
501 return texture; 503 return texture;
502 } 504 }
503 505
504 bool GrContext::OverbudgetCB(void* data) { 506 bool GrContext::OverbudgetCB(void* data) {
505 SkASSERT(data); 507 SkASSERT(data);
506 508
507 GrContext* context = reinterpret_cast<GrContext*>(data); 509 GrContext* context = reinterpret_cast<GrContext*>(data);
508 510
509 // Flush the InOrderDrawBuffer to possibly free up some textures 511 // Flush the InOrderDrawBuffer to possibly free up some textures
510 context->fFlushToReduceCacheSize = true; 512 context->fFlushToReduceCacheSize = true;
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 fResourceCache->printStats(); 1781 fResourceCache->printStats();
1780 } 1782 }
1781 #endif 1783 #endif
1782 1784
1783 #if GR_GPU_STATS 1785 #if GR_GPU_STATS
1784 const GrContext::GPUStats* GrContext::gpuStats() const { 1786 const GrContext::GPUStats* GrContext::gpuStats() const {
1785 return fGpu->gpuStats(); 1787 return fGpu->gpuStats();
1786 } 1788 }
1787 #endif 1789 #endif
1788 1790
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698