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 #include "SkErrorInternals.h" |
13 | 13 |
14 #include "../effects/SkBicubicImageFilter.h" | |
reed1
2013/09/03 20:57:37
do we need the path to scope where these headers a
humper
2013/09/03 21:45:53
Probably not -- this one picks out a file from src
bsalomon
2013/09/04 13:06:15
I think we actually shouldn't have core depend on
| |
15 #include "effects/GrSimpleTextureEffect.h" | |
16 #include "effects/GrBicubicEffect.h" | |
17 | |
14 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) { | 18 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) { |
15 switch (bm.config()) { | 19 switch (bm.config()) { |
16 case SkBitmap::kA8_Config: | 20 case SkBitmap::kA8_Config: |
17 case SkBitmap::kRGB_565_Config: | 21 case SkBitmap::kRGB_565_Config: |
18 case SkBitmap::kIndex8_Config: | 22 case SkBitmap::kIndex8_Config: |
19 case SkBitmap::kARGB_8888_Config: | 23 case SkBitmap::kARGB_8888_Config: |
20 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx)) | 24 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx)) |
21 return true; | 25 return true; |
22 default: | 26 default: |
23 break; | 27 break; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 case SkPaint::kNone_FilterLevel: | 364 case SkPaint::kNone_FilterLevel: |
361 textureFilterMode = GrTextureParams::kNone_FilterMode; | 365 textureFilterMode = GrTextureParams::kNone_FilterMode; |
362 break; | 366 break; |
363 case SkPaint::kLow_FilterLevel: | 367 case SkPaint::kLow_FilterLevel: |
364 textureFilterMode = GrTextureParams::kBilerp_FilterMode; | 368 textureFilterMode = GrTextureParams::kBilerp_FilterMode; |
365 break; | 369 break; |
366 case SkPaint::kMedium_FilterLevel: | 370 case SkPaint::kMedium_FilterLevel: |
367 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 371 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
368 break; | 372 break; |
369 case SkPaint::kHigh_FilterLevel: | 373 case SkPaint::kHigh_FilterLevel: |
370 SkErrorInternals::SetError( kInvalidPaint_SkError, | 374 // fall back to no filtering here; we will install another |
371 "Sorry, I don't yet support high quality " | 375 // shader that will do the HQ filtering. |
372 "filtering on the GPU; falling back to " | 376 textureFilterMode = GrTextureParams::kNone_FilterMode; |
373 "MIPMaps."); | |
374 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | |
375 break; | 377 break; |
376 default: | 378 default: |
377 SkErrorInternals::SetError( kInvalidPaint_SkError, | 379 SkErrorInternals::SetError( kInvalidPaint_SkError, |
378 "Sorry, I don't understand the filtering " | 380 "Sorry, I don't understand the filtering " |
379 "mode you asked for. Falling back to " | 381 "mode you asked for. Falling back to " |
380 "MIPMaps."); | 382 "MIPMaps."); |
381 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 383 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
382 break; | 384 break; |
383 | 385 |
384 } | 386 } |
385 GrTextureParams params(tm, textureFilterMode); | 387 GrTextureParams params(tm, textureFilterMode); |
386 GrTexture* texture = GrLockAndRefCachedBitmapTexture(context, fRawBitmap, &p arams); | 388 GrTexture* texture = GrLockAndRefCachedBitmapTexture(context, fRawBitmap, &p arams); |
387 | 389 |
388 if (NULL == texture) { | 390 if (NULL == texture) { |
389 SkDebugf("Couldn't convert bitmap to texture.\n"); | 391 SkErrorInternals::SetError( kInternalError_SkError, |
392 "Couldn't convert bitmap to texture."); | |
390 return NULL; | 393 return NULL; |
391 } | 394 } |
392 | 395 |
393 GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params) ; | 396 GrEffectRef* effect = NULL; |
397 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { | |
398 effect = GrBicubicEffect::Create(texture, SkBicubicImageFilter::fMitchel lCoefficients, matrix, params); | |
399 } else { | |
400 effect = GrSimpleTextureEffect::Create(texture, matrix, params); | |
401 } | |
394 GrUnlockAndUnrefCachedBitmapTexture(texture); | 402 GrUnlockAndUnrefCachedBitmapTexture(texture); |
395 return effect; | 403 return effect; |
396 } | 404 } |
397 #endif | 405 #endif |
OLD | NEW |