Chromium Code Reviews| 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 "SkWebpCodec.h" | 8 #include "SkWebpCodec.h" |
| 9 #include "SkImageGenerator.h" | 9 #include "SkImageGenerator.h" |
| 10 #include "SkTemplates.h" | 10 #include "SkTemplates.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 } | 96 } |
| 97 if (dst.alphaType() == src.alphaType()) { | 97 if (dst.alphaType() == src.alphaType()) { |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 return kPremul_SkAlphaType == dst.alphaType() && | 100 return kPremul_SkAlphaType == dst.alphaType() && |
| 101 kUnpremul_SkAlphaType == src.alphaType(); | 101 kUnpremul_SkAlphaType == src.alphaType(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const { | 104 SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const { |
| 105 SkISize dim = this->getInfo().dimensions(); | 105 SkISize dim = this->getInfo().dimensions(); |
| 106 dim.fWidth = SkScalarRoundToInt(desiredScale * dim.fWidth); | 106 dim.fWidth = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fWidth)); |
|
scroggo
2015/06/19 14:19:51
Maybe add a comment explaining our decision (on th
msarett
2015/06/19 14:28:45
Done.
| |
| 107 dim.fHeight = SkScalarRoundToInt(desiredScale * dim.fHeight); | 107 dim.fHeight = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fHeight)); |
| 108 return dim; | 108 return dim; |
| 109 } | 109 } |
| 110 | 110 |
| 111 static WEBP_CSP_MODE webp_decode_mode(SkColorType ct, bool premultiply) { | 111 static WEBP_CSP_MODE webp_decode_mode(SkColorType ct, bool premultiply) { |
| 112 switch (ct) { | 112 switch (ct) { |
| 113 case kBGRA_8888_SkColorType: | 113 case kBGRA_8888_SkColorType: |
| 114 return premultiply ? MODE_bgrA : MODE_BGRA; | 114 return premultiply ? MODE_bgrA : MODE_BGRA; |
| 115 case kRGBA_8888_SkColorType: | 115 case kRGBA_8888_SkColorType: |
| 116 return premultiply ? MODE_rgbA : MODE_RGBA; | 116 return premultiply ? MODE_rgbA : MODE_RGBA; |
| 117 default: | 117 default: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 // Break out of the switch statement. Continue the loop. | 191 // Break out of the switch statement. Continue the loop. |
| 192 break; | 192 break; |
| 193 default: | 193 default: |
| 194 return kInvalidInput; | 194 return kInvalidInput; |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 SkWebpCodec::SkWebpCodec(const SkImageInfo& info, SkStream* stream) | 199 SkWebpCodec::SkWebpCodec(const SkImageInfo& info, SkStream* stream) |
| 200 : INHERITED(info, stream) {} | 200 : INHERITED(info, stream) {} |
| OLD | NEW |