| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkImagePriv.h" | 8 #include "SkImagePriv.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkPicture.h" | 10 #include "SkPicture.h" |
| 11 | 11 |
| 12 SkBitmap::Config SkImageInfoToBitmapConfig(const SkImage::Info& info, | 12 SkBitmap::Config SkImageInfoToBitmapConfig(const SkImage::Info& info) { |
| 13 bool* isOpaque) { | |
| 14 switch (info.fColorType) { | 13 switch (info.fColorType) { |
| 15 case SkImage::kAlpha_8_ColorType: | 14 case SkImage::kAlpha_8_ColorType: |
| 16 switch (info.fAlphaType) { | 15 return SkBitmap::kA8_Config; |
| 17 case kIgnore_SkAlphaType: | |
| 18 // makes no sense | |
| 19 return SkBitmap::kNo_Config; | |
| 20 | |
| 21 case kOpaque_SkAlphaType: | |
| 22 *isOpaque = true; | |
| 23 return SkBitmap::kA8_Config; | |
| 24 | |
| 25 case kPremul_SkAlphaType: | |
| 26 case kUnpremul_SkAlphaType: | |
| 27 *isOpaque = false; | |
| 28 return SkBitmap::kA8_Config; | |
| 29 } | |
| 30 break; | |
| 31 | 16 |
| 32 case SkImage::kRGB_565_ColorType: | 17 case SkImage::kRGB_565_ColorType: |
| 33 // we ignore fAlpahType, though some would not make sense | |
| 34 *isOpaque = true; | |
| 35 return SkBitmap::kRGB_565_Config; | 18 return SkBitmap::kRGB_565_Config; |
| 36 | 19 |
| 37 case SkImage::kPMColor_ColorType: | 20 case SkImage::kPMColor_ColorType: |
| 38 switch (info.fAlphaType) { | 21 return SkBitmap::kARGB_8888_Config; |
| 39 case kIgnore_SkAlphaType: | |
| 40 case kUnpremul_SkAlphaType: | |
| 41 // not supported yet | |
| 42 return SkBitmap::kNo_Config; | |
| 43 case kOpaque_SkAlphaType: | |
| 44 *isOpaque = true; | |
| 45 return SkBitmap::kARGB_8888_Config; | |
| 46 case kPremul_SkAlphaType: | |
| 47 *isOpaque = false; | |
| 48 return SkBitmap::kARGB_8888_Config; | |
| 49 } | |
| 50 break; | |
| 51 | 22 |
| 52 default: | 23 default: |
| 53 // break for unsupported colortypes | 24 // break for unsupported colortypes |
| 54 break; | 25 break; |
| 55 } | 26 } |
| 56 return SkBitmap::kNo_Config; | 27 return SkBitmap::kNo_Config; |
| 57 } | 28 } |
| 58 | 29 |
| 59 int SkImageBytesPerPixel(SkImage::ColorType ct) { | 30 int SkImageBytesPerPixel(SkImage::ColorType ct) { |
| 60 static const uint8_t gColorTypeBytesPerPixel[] = { | 31 static const uint8_t gColorTypeBytesPerPixel[] = { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 canvas->save(); | 133 canvas->save(); |
| 163 } | 134 } |
| 164 canvas->concat(matrix); | 135 canvas->concat(matrix); |
| 165 if (!paint || !needs_layer(*paint)) { | 136 if (!paint || !needs_layer(*paint)) { |
| 166 canvas->clipRect(tmpSrc); | 137 canvas->clipRect(tmpSrc); |
| 167 } | 138 } |
| 168 | 139 |
| 169 canvas->drawPicture(*picture); | 140 canvas->drawPicture(*picture); |
| 170 canvas->restoreToCount(saveCount); | 141 canvas->restoreToCount(saveCount); |
| 171 } | 142 } |
| OLD | NEW |