| 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 "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
| 9 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
| 10 #include "SkWriteBuffer.h" | 10 #include "SkWriteBuffer.h" |
| 11 #include "SkPixelRef.h" | 11 #include "SkPixelRef.h" |
| 12 #include "SkErrorInternals.h" | 12 #include "SkErrorInternals.h" |
| 13 #include "SkBitmapProcShader.h" | 13 #include "SkBitmapProcShader.h" |
| 14 | 14 |
| 15 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
| 16 #include "effects/GrSimpleTextureEffect.h" | 16 #include "effects/GrSimpleTextureEffect.h" |
| 17 #include "effects/GrBicubicEffect.h" | 17 #include "effects/GrBicubicEffect.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) { | 20 bool SkBitmapProcShader::CanDo(const SkBitmap& bm, TileMode tx, TileMode ty) { |
| 21 switch (bm.colorType()) { | 21 switch (bm.colorType()) { |
| 22 case kAlpha_8_SkColorType: | 22 case kAlpha_8_SkColorType: |
| 23 case kRGB_565_SkColorType: | 23 case kRGB_565_SkColorType: |
| 24 case kIndex_8_SkColorType: | 24 case kIndex_8_SkColorType: |
| 25 case kPMColor_SkColorType: | 25 case kN32_SkColorType: |
| 26 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx)) | 26 // if (tx == ty && (kClamp_TileMode == tx || kRepeat_TileMode == tx)) |
| 27 return true; | 27 return true; |
| 28 default: | 28 default: |
| 29 break; | 29 break; |
| 30 } | 30 } |
| 31 return false; | 31 return false; |
| 32 } | 32 } |
| 33 | 33 |
| 34 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, | 34 SkBitmapProcShader::SkBitmapProcShader(const SkBitmap& src, |
| 35 TileMode tmx, TileMode tmy) { | 35 TileMode tmx, TileMode tmy) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 uint32_t flags = 0; | 123 uint32_t flags = 0; |
| 124 if (bitmapIsOpaque && (255 == this->getPaintAlpha())) { | 124 if (bitmapIsOpaque && (255 == this->getPaintAlpha())) { |
| 125 flags |= kOpaqueAlpha_Flag; | 125 flags |= kOpaqueAlpha_Flag; |
| 126 } | 126 } |
| 127 | 127 |
| 128 switch (bitmap.colorType()) { | 128 switch (bitmap.colorType()) { |
| 129 case kRGB_565_SkColorType: | 129 case kRGB_565_SkColorType: |
| 130 flags |= (kHasSpan16_Flag | kIntrinsicly16_Flag); | 130 flags |= (kHasSpan16_Flag | kIntrinsicly16_Flag); |
| 131 break; | 131 break; |
| 132 case kIndex_8_SkColorType: | 132 case kIndex_8_SkColorType: |
| 133 case kPMColor_SkColorType: | 133 case kN32_SkColorType: |
| 134 if (bitmapIsOpaque) { | 134 if (bitmapIsOpaque) { |
| 135 flags |= kHasSpan16_Flag; | 135 flags |= kHasSpan16_Flag; |
| 136 } | 136 } |
| 137 break; | 137 break; |
| 138 case kAlpha_8_SkColorType: | 138 case kAlpha_8_SkColorType: |
| 139 break; // never set kHasSpan16_Flag | 139 break; // never set kHasSpan16_Flag |
| 140 default: | 140 default: |
| 141 break; | 141 break; |
| 142 } | 142 } |
| 143 | 143 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 if (1 != bm.width() || 1 != bm.height()) { | 272 if (1 != bm.width() || 1 != bm.height()) { |
| 273 return false; | 273 return false; |
| 274 } | 274 } |
| 275 | 275 |
| 276 SkAutoLockPixels alp(bm); | 276 SkAutoLockPixels alp(bm); |
| 277 if (!bm.readyToDraw()) { | 277 if (!bm.readyToDraw()) { |
| 278 return false; | 278 return false; |
| 279 } | 279 } |
| 280 | 280 |
| 281 switch (bm.colorType()) { | 281 switch (bm.colorType()) { |
| 282 case kPMColor_SkColorType: | 282 case kN32_SkColorType: |
| 283 *color = SkUnPreMultiply::PMColorToColor(*bm.getAddr32(0, 0)); | 283 *color = SkUnPreMultiply::PMColorToColor(*bm.getAddr32(0, 0)); |
| 284 return true; | 284 return true; |
| 285 case kRGB_565_SkColorType: | 285 case kRGB_565_SkColorType: |
| 286 *color = SkPixel16ToColor(*bm.getAddr16(0, 0)); | 286 *color = SkPixel16ToColor(*bm.getAddr16(0, 0)); |
| 287 return true; | 287 return true; |
| 288 case kIndex_8_SkColorType: | 288 case kIndex_8_SkColorType: |
| 289 *color = SkUnPreMultiply::PMColorToColor(bm.getIndex8Color(0, 0)); | 289 *color = SkUnPreMultiply::PMColorToColor(bm.getIndex8Color(0, 0)); |
| 290 return true; | 290 return true; |
| 291 default: // just skip the other configs for now | 291 default: // just skip the other configs for now |
| 292 break; | 292 break; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 GrEffectRef* effect = NULL; | 444 GrEffectRef* effect = NULL; |
| 445 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { | 445 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { |
| 446 effect = GrBicubicEffect::Create(texture, matrix, tm); | 446 effect = GrBicubicEffect::Create(texture, matrix, tm); |
| 447 } else { | 447 } else { |
| 448 effect = GrSimpleTextureEffect::Create(texture, matrix, params); | 448 effect = GrSimpleTextureEffect::Create(texture, matrix, params); |
| 449 } | 449 } |
| 450 GrUnlockAndUnrefCachedBitmapTexture(texture); | 450 GrUnlockAndUnrefCachedBitmapTexture(texture); |
| 451 return effect; | 451 return effect; |
| 452 } | 452 } |
| 453 #endif | 453 #endif |
| OLD | NEW |