| OLD | NEW | 
|---|
| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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* GrLockAndRefCachedBitmapTexture(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 = bitmap.getTexture(); | 
|  | 376     if (result) { | 
|  | 377         return SkRef(result); | 
|  | 378     } | 
| 376 | 379 | 
| 377     bool cache = !bitmap.isVolatile(); | 380     bool cache = !bitmap.isVolatile(); | 
| 378 | 381 | 
| 379     if (cache) { | 382     if (cache) { | 
| 380         // If the bitmap isn't changing try to find a cached copy first. | 383         // If the bitmap isn't changing try to find a cached copy first. | 
| 381 | 384 | 
| 382         GrCacheID cacheID; | 385         GrCacheID cacheID; | 
| 383         generate_bitmap_cache_id(bitmap, &cacheID); | 386         generate_bitmap_cache_id(bitmap, &cacheID); | 
| 384 | 387 | 
| 385         GrTextureDesc desc; | 388         GrTextureDesc desc; | 
| 386         generate_bitmap_texture_desc(bitmap, &desc); | 389         generate_bitmap_texture_desc(bitmap, &desc); | 
| 387 | 390 | 
| 388         result = ctx->findAndRefTexture(desc, cacheID, params); | 391         result = ctx->findAndRefTexture(desc, cacheID, params); | 
| 389     } | 392     } | 
| 390     if (NULL == result) { | 393     if (NULL == result) { | 
| 391         result = sk_gr_create_bitmap_texture(ctx, cache, params, bitmap); | 394         result = sk_gr_create_bitmap_texture(ctx, cache, params, bitmap); | 
| 392     } | 395     } | 
| 393     if (NULL == result) { | 396     if (NULL == result) { | 
| 394         GrPrintf("---- failed to create texture for cache [%d %d]\n", | 397         GrPrintf("---- failed to create texture for cache [%d %d]\n", | 
| 395                     bitmap.width(), bitmap.height()); | 398                     bitmap.width(), bitmap.height()); | 
| 396     } | 399     } | 
| 397     return result; | 400     return result; | 
| 398 } | 401 } | 
| 399 | 402 | 
| 400 void GrUnlockAndUnrefCachedBitmapTexture(GrTexture* texture) { | 403 void GrUnlockAndUnrefCachedBitmapTexture(GrTexture* texture) { | 
| 401     SkASSERT(texture->getContext()); | 404     SkASSERT(texture->getContext()); | 
| 402 | 405 | 
| 403     texture->getContext()->unlockScratchTexture(texture); | 406     if (texture->getCacheEntry()) { | 
|  | 407         texture->getContext()->unlockScratchTexture(texture); | 
|  | 408     } | 
| 404     texture->unref(); | 409     texture->unref(); | 
| 405 } | 410 } | 
| 406 | 411 | 
| 407 /////////////////////////////////////////////////////////////////////////////// | 412 /////////////////////////////////////////////////////////////////////////////// | 
| 408 | 413 | 
| 409 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass | 414 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass | 
| 410 // alpha info, that will be considered. | 415 // alpha info, that will be considered. | 
| 411 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType) { | 416 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType) { | 
| 412     switch (ct) { | 417     switch (ct) { | 
| 413         case kUnknown_SkColorType: | 418         case kUnknown_SkColorType: | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 577         if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp
     ) && fp) { | 582         if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp
     ) && fp) { | 
| 578             grPaint->addColorProcessor(fp)->unref(); | 583             grPaint->addColorProcessor(fp)->unref(); | 
| 579             constantColor = false; | 584             constantColor = false; | 
| 580         } | 585         } | 
| 581     } | 586     } | 
| 582 | 587 | 
| 583     // The grcolor is automatically set when calling asFragmentProcessor. | 588     // The grcolor is automatically set when calling asFragmentProcessor. | 
| 584     // If the shader can be seen as an effect it returns true and adds its effec
     t to the grpaint. | 589     // If the shader can be seen as an effect it returns true and adds its effec
     t to the grpaint. | 
| 585     SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint
     ); | 590     SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint
     ); | 
| 586 } | 591 } | 
| OLD | NEW | 
|---|