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

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

Issue 26734003: Proactive SkPixelRef invalidation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: drop the check Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkPixelRef.cpp ('k') | src/gpu/GrResourceCache.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 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 SkASSERT(NULL != texture); 386 SkASSERT(NULL != texture);
387 } 387 }
388 388
389 return texture; 389 return texture;
390 } 390 }
391 391
392 GrTexture* GrContext::createTexture(const GrTextureParams* params, 392 GrTexture* GrContext::createTexture(const GrTextureParams* params,
393 const GrTextureDesc& desc, 393 const GrTextureDesc& desc,
394 const GrCacheID& cacheID, 394 const GrCacheID& cacheID,
395 void* srcData, 395 void* srcData,
396 size_t rowBytes) { 396 size_t rowBytes,
397 GrResourceKey* cacheKey) {
397 SK_TRACE_EVENT0("GrContext::createTexture"); 398 SK_TRACE_EVENT0("GrContext::createTexture");
398 399
399 GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheI D); 400 GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheI D);
400 401
401 GrTexture* texture; 402 GrTexture* texture;
402 if (GrTexture::NeedsResizing(resourceKey)) { 403 if (GrTexture::NeedsResizing(resourceKey)) {
403 texture = this->createResizedTexture(desc, cacheID, 404 texture = this->createResizedTexture(desc, cacheID,
404 srcData, rowBytes, 405 srcData, rowBytes,
405 GrTexture::NeedsBilerp(resourceKey) ); 406 GrTexture::NeedsBilerp(resourceKey) );
406 } else { 407 } else {
407 texture= fGpu->createTexture(desc, srcData, rowBytes); 408 texture= fGpu->createTexture(desc, srcData, rowBytes);
408 } 409 }
409 410
410 if (NULL != texture) { 411 if (NULL != texture) {
411 // Adding a resource could put us overbudget. Try to free up the 412 // Adding a resource could put us overbudget. Try to free up the
412 // necessary space before adding it. 413 // necessary space before adding it.
413 fTextureCache->purgeAsNeeded(1, texture->sizeInBytes()); 414 fTextureCache->purgeAsNeeded(1, texture->sizeInBytes());
414 fTextureCache->addResource(resourceKey, texture); 415 fTextureCache->addResource(resourceKey, texture);
416
417 if (NULL != cacheKey) {
418 *cacheKey = resourceKey;
419 }
415 } 420 }
416 421
417 return texture; 422 return texture;
418 } 423 }
419 424
420 static GrTexture* create_scratch_texture(GrGpu* gpu, 425 static GrTexture* create_scratch_texture(GrGpu* gpu,
421 GrResourceCache* textureCache, 426 GrResourceCache* textureCache,
422 const GrTextureDesc& desc) { 427 const GrTextureDesc& desc) {
423 GrTexture* texture = gpu->createTexture(desc, NULL, 0); 428 GrTexture* texture = gpu->createTexture(desc, NULL, 0);
424 if (NULL != texture) { 429 if (NULL != texture) {
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 return NULL; 1786 return NULL;
1782 } 1787 }
1783 } 1788 }
1784 1789
1785 /////////////////////////////////////////////////////////////////////////////// 1790 ///////////////////////////////////////////////////////////////////////////////
1786 #if GR_CACHE_STATS 1791 #if GR_CACHE_STATS
1787 void GrContext::printCacheStats() const { 1792 void GrContext::printCacheStats() const {
1788 fTextureCache->printStats(); 1793 fTextureCache->printStats();
1789 } 1794 }
1790 #endif 1795 #endif
OLDNEW
« no previous file with comments | « src/core/SkPixelRef.cpp ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698