OLD | NEW |
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 #include "SkBitmapProcShader.h" | 8 #include "SkBitmapProcShader.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
11 #include "SkPixelRef.h" | 11 #include "SkPixelRef.h" |
| 12 #include "SkErrorInternals.h" |
12 | 13 |
13 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) { | 14 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) { |
14 switch (bm.config()) { | 15 switch (bm.config()) { |
15 case SkBitmap::kA8_Config: | 16 case SkBitmap::kA8_Config: |
16 case SkBitmap::kRGB_565_Config: | 17 case SkBitmap::kRGB_565_Config: |
17 case SkBitmap::kIndex8_Config: | 18 case SkBitmap::kIndex8_Config: |
18 case SkBitmap::kARGB_8888_Config: | 19 case SkBitmap::kARGB_8888_Config: |
19 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx)) | 20 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx)) |
20 return true; | 21 return true; |
21 default: | 22 default: |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 return NULL; | 347 return NULL; |
347 } | 348 } |
348 matrix.preConcat(inverse); | 349 matrix.preConcat(inverse); |
349 } | 350 } |
350 SkShader::TileMode tm[] = { | 351 SkShader::TileMode tm[] = { |
351 (TileMode)fState.fTileModeX, | 352 (TileMode)fState.fTileModeX, |
352 (TileMode)fState.fTileModeY, | 353 (TileMode)fState.fTileModeY, |
353 }; | 354 }; |
354 | 355 |
355 // Must set wrap and filter on the sampler before requesting a texture. | 356 // Must set wrap and filter on the sampler before requesting a texture. |
356 GrTextureParams params(tm, paint.isFilterBitmap()); | 357 SkPaint::FilterLevel paintFilterLevel = paint.getFilterLevel(); |
| 358 GrTextureParams::FilterMode textureFilterMode; |
| 359 switch(paintFilterLevel) { |
| 360 case SkPaint::kNone_FilterLevel: |
| 361 textureFilterMode = GrTextureParams::kNone_FilterMode; |
| 362 break; |
| 363 case SkPaint::kLow_FilterLevel: |
| 364 textureFilterMode = GrTextureParams::kBilerp_FilterMode; |
| 365 break; |
| 366 case SkPaint::kMedium_FilterLevel: |
| 367 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
| 368 break; |
| 369 case SkPaint::kHigh_FilterLevel: |
| 370 SkErrorInternals::SetError( kInvalidPaint_SkError, |
| 371 "Sorry, I don't yet support high quality
" |
| 372 "filtering on the GPU; falling back to " |
| 373 "MIPMaps."); |
| 374 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
| 375 break; |
| 376 } |
| 377 GrTextureParams params(tm, textureFilterMode); |
357 GrTexture* texture = GrLockAndRefCachedBitmapTexture(context, fRawBitmap, &p
arams); | 378 GrTexture* texture = GrLockAndRefCachedBitmapTexture(context, fRawBitmap, &p
arams); |
358 | 379 |
359 if (NULL == texture) { | 380 if (NULL == texture) { |
360 SkDebugf("Couldn't convert bitmap to texture.\n"); | 381 SkDebugf("Couldn't convert bitmap to texture.\n"); |
361 return NULL; | 382 return NULL; |
362 } | 383 } |
363 | 384 |
364 GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params)
; | 385 GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params)
; |
365 GrUnlockAndUnrefCachedBitmapTexture(texture); | 386 GrUnlockAndUnrefCachedBitmapTexture(texture); |
366 return effect; | 387 return effect; |
367 } | 388 } |
368 #endif | 389 #endif |
OLD | NEW |