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

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

Issue 26734003: Proactive SkPixelRef invalidation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: tweaks Created 7 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 | Annotate | Revision Log
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 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 return NULL; 1766 return NULL;
1762 } 1767 }
1763 } 1768 }
1764 1769
1765 /////////////////////////////////////////////////////////////////////////////// 1770 ///////////////////////////////////////////////////////////////////////////////
1766 #if GR_CACHE_STATS 1771 #if GR_CACHE_STATS
1767 void GrContext::printCacheStats() const { 1772 void GrContext::printCacheStats() const {
1768 fTextureCache->printStats(); 1773 fTextureCache->printStats();
1769 } 1774 }
1770 #endif 1775 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698