| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkAndroidCodec.h" | 8 #include "SkAndroidCodec.h" |
| 9 #include "SkCodec.h" | 9 #include "SkCodec.h" |
| 10 #include "SkCodecPriv.h" | 10 #include "SkCodecPriv.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 case kIndex_8_SkColorType: | 79 case kIndex_8_SkColorType: |
| 80 if (kIndex_8_SkColorType == suggestedColorType) { | 80 if (kIndex_8_SkColorType == suggestedColorType) { |
| 81 return kIndex_8_SkColorType; | 81 return kIndex_8_SkColorType; |
| 82 } | 82 } |
| 83 break; | 83 break; |
| 84 case kAlpha_8_SkColorType: | 84 case kAlpha_8_SkColorType: |
| 85 // Fall through to kGray_8. Before kGray_8_SkColorType existed, | 85 // Fall through to kGray_8. Before kGray_8_SkColorType existed, |
| 86 // we allowed clients to request kAlpha_8 when they wanted a | 86 // we allowed clients to request kAlpha_8 when they wanted a |
| 87 // grayscale decode. | 87 // grayscale decode. |
| 88 case kGray_8_SkColorType: | 88 case kGray_8_SkColorType: |
| 89 if (kGray_8_SkColorType == suggestedColorType) { | 89 if (kGray_8_SkColorType == suggestedColorType || |
| 90 kAlpha_8_SkColorType == suggestedColorType) |
| 91 { |
| 90 return kGray_8_SkColorType; | 92 return kGray_8_SkColorType; |
| 91 } | 93 } |
| 92 break; | 94 break; |
| 93 case kRGB_565_SkColorType: | 95 case kRGB_565_SkColorType: |
| 94 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) { | 96 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) { |
| 95 return kRGB_565_SkColorType; | 97 return kRGB_565_SkColorType; |
| 96 } | 98 } |
| 97 break; | 99 break; |
| 98 default: | 100 default: |
| 99 break; | 101 break; |
| 100 } | 102 } |
| 101 | 103 |
| 102 // Android has limited support for kGray_8 (using kAlpha_8). We will not | 104 // Android has limited support for kGray_8 and kAlpha_8. We will not use th
ese types for |
| 103 // use kGray_8 for Android unless they specifically ask for it. | 105 // Android unless they specifically ask for it. |
| 104 if (kGray_8_SkColorType == suggestedColorType) { | 106 if (kGray_8_SkColorType == suggestedColorType || kAlpha_8_SkColorType == sug
gestedColorType) { |
| 105 return kN32_SkColorType; | 107 return kN32_SkColorType; |
| 106 } | 108 } |
| 107 | 109 |
| 108 // This may be kN32_SkColorType or kIndex_8_SkColorType. | 110 // This may be kN32_SkColorType or kIndex_8_SkColorType. |
| 109 return suggestedColorType; | 111 return suggestedColorType; |
| 110 } | 112 } |
| 111 | 113 |
| 112 SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) { | 114 SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) { |
| 113 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) { | 115 if (kOpaque_SkAlphaType == this->getInfo().alphaType()) { |
| 114 return kOpaque_SkAlphaType; | 116 return kOpaque_SkAlphaType; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 190 } |
| 189 } | 191 } |
| 190 | 192 |
| 191 return this->onGetAndroidPixels(info, pixels, rowBytes, *options); | 193 return this->onGetAndroidPixels(info, pixels, rowBytes, *options); |
| 192 } | 194 } |
| 193 | 195 |
| 194 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void*
pixels, | 196 SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void*
pixels, |
| 195 size_t rowBytes) { | 197 size_t rowBytes) { |
| 196 return this->getAndroidPixels(info, pixels, rowBytes, nullptr); | 198 return this->getAndroidPixels(info, pixels, rowBytes, nullptr); |
| 197 } | 199 } |
| OLD | NEW |