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

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

Issue 611383003: Revert of GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: 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 | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/SkGrPixelRef.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 * Copyright 2010 Google Inc. 2 * Copyright 2010 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkGr.h" 8 #include "SkGr.h"
9 #include "SkColorFilter.h" 9 #include "SkColorFilter.h"
10 #include "SkConfig8888.h" 10 #include "SkConfig8888.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 const SkBitmap& bitmap, 362 const SkBitmap& bitmap,
363 const GrTextureParams* params) { 363 const GrTextureParams* params) {
364 GrCacheID cacheID; 364 GrCacheID cacheID;
365 generate_bitmap_cache_id(bitmap, &cacheID); 365 generate_bitmap_cache_id(bitmap, &cacheID);
366 366
367 GrTextureDesc desc; 367 GrTextureDesc desc;
368 generate_bitmap_texture_desc(bitmap, &desc); 368 generate_bitmap_texture_desc(bitmap, &desc);
369 return ctx->isTextureInCache(desc, cacheID, params); 369 return ctx->isTextureInCache(desc, cacheID, params);
370 } 370 }
371 371
372 GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, 372 GrTexture* GrLockAndRefCachedBitmapTexture(GrContext* ctx,
373 const SkBitmap& bitmap, 373 const SkBitmap& bitmap,
374 const GrTextureParams* params) { 374 const GrTextureParams* params) {
375 GrTexture* result = NULL; 375 GrTexture* result = NULL;
376 376
377 bool cache = !bitmap.isVolatile(); 377 bool cache = !bitmap.isVolatile();
378 378
379 if (cache) { 379 if (cache) {
380 // If the bitmap isn't changing try to find a cached copy first. 380 // If the bitmap isn't changing try to find a cached copy first.
381 381
382 GrCacheID cacheID; 382 GrCacheID cacheID;
383 generate_bitmap_cache_id(bitmap, &cacheID); 383 generate_bitmap_cache_id(bitmap, &cacheID);
384 384
385 GrTextureDesc desc; 385 GrTextureDesc desc;
386 generate_bitmap_texture_desc(bitmap, &desc); 386 generate_bitmap_texture_desc(bitmap, &desc);
387 387
388 result = ctx->findAndRefTexture(desc, cacheID, params); 388 result = ctx->findAndRefTexture(desc, cacheID, params);
389 } 389 }
390 if (NULL == result) { 390 if (NULL == result) {
391 result = sk_gr_create_bitmap_texture(ctx, cache, params, bitmap); 391 result = sk_gr_create_bitmap_texture(ctx, cache, params, bitmap);
392 } 392 }
393 if (NULL == result) { 393 if (NULL == result) {
394 GrPrintf("---- failed to create texture for cache [%d %d]\n", 394 GrPrintf("---- failed to create texture for cache [%d %d]\n",
395 bitmap.width(), bitmap.height()); 395 bitmap.width(), bitmap.height());
396 } 396 }
397 return result; 397 return result;
398 } 398 }
399 399
400 void GrUnlockAndUnrefCachedBitmapTexture(GrTexture* texture) {
401 SkASSERT(texture->getContext());
402
403 texture->getContext()->unlockScratchTexture(texture);
404 texture->unref();
405 }
406
400 /////////////////////////////////////////////////////////////////////////////// 407 ///////////////////////////////////////////////////////////////////////////////
401 408
402 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass 409 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
403 // alpha info, that will be considered. 410 // alpha info, that will be considered.
404 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType) { 411 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType) {
405 switch (ct) { 412 switch (ct) {
406 case kUnknown_SkColorType: 413 case kUnknown_SkColorType:
407 return kUnknown_GrPixelConfig; 414 return kUnknown_GrPixelConfig;
408 case kAlpha_8_SkColorType: 415 case kAlpha_8_SkColorType:
409 return kAlpha_8_GrPixelConfig; 416 return kAlpha_8_GrPixelConfig;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) { 577 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) {
571 grPaint->addColorProcessor(fp)->unref(); 578 grPaint->addColorProcessor(fp)->unref();
572 constantColor = false; 579 constantColor = false;
573 } 580 }
574 } 581 }
575 582
576 // The grcolor is automatically set when calling asFragmentProcessor. 583 // The grcolor is automatically set when calling asFragmentProcessor.
577 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. 584 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint.
578 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); 585 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint );
579 } 586 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698