| 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 "SkCodecPriv.h" | 8 #include "SkCodecPriv.h" |
| 9 #include "SkWebpCodec.h" | 9 #include "SkWebpCodec.h" |
| 10 #include "SkTemplates.h" | 10 #include "SkTemplates.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const { | 108 SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const { |
| 109 SkISize dim = this->getInfo().dimensions(); | 109 SkISize dim = this->getInfo().dimensions(); |
| 110 // SkCodec treats zero dimensional images as errors, so the minimum size | 110 // SkCodec treats zero dimensional images as errors, so the minimum size |
| 111 // that we will recommend is 1x1. | 111 // that we will recommend is 1x1. |
| 112 dim.fWidth = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fWidth)); | 112 dim.fWidth = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fWidth)); |
| 113 dim.fHeight = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fHeight)); | 113 dim.fHeight = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fHeight)); |
| 114 return dim; | 114 return dim; |
| 115 } | 115 } |
| 116 | 116 |
| 117 bool SkWebpCodec::onDimensionsSupported(const SkISize& dim) { |
| 118 const SkImageInfo& info = this->getInfo(); |
| 119 return dim.width() >= 1 && dim.width() <= info.width() |
| 120 && dim.height() >= 1 && dim.height() <= info.height(); |
| 121 } |
| 122 |
| 123 |
| 117 static WEBP_CSP_MODE webp_decode_mode(SkColorType ct, bool premultiply) { | 124 static WEBP_CSP_MODE webp_decode_mode(SkColorType ct, bool premultiply) { |
| 118 switch (ct) { | 125 switch (ct) { |
| 119 case kBGRA_8888_SkColorType: | 126 case kBGRA_8888_SkColorType: |
| 120 return premultiply ? MODE_bgrA : MODE_BGRA; | 127 return premultiply ? MODE_bgrA : MODE_BGRA; |
| 121 case kRGBA_8888_SkColorType: | 128 case kRGBA_8888_SkColorType: |
| 122 return premultiply ? MODE_rgbA : MODE_RGBA; | 129 return premultiply ? MODE_rgbA : MODE_RGBA; |
| 123 case kRGB_565_SkColorType: | 130 case kRGB_565_SkColorType: |
| 124 return MODE_RGB_565; | 131 return MODE_RGB_565; |
| 125 default: | 132 default: |
| 126 return MODE_LAST; | 133 return MODE_LAST; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // Break out of the switch statement. Continue the loop. | 247 // Break out of the switch statement. Continue the loop. |
| 241 break; | 248 break; |
| 242 default: | 249 default: |
| 243 return kInvalidInput; | 250 return kInvalidInput; |
| 244 } | 251 } |
| 245 } | 252 } |
| 246 } | 253 } |
| 247 | 254 |
| 248 SkWebpCodec::SkWebpCodec(const SkImageInfo& info, SkStream* stream) | 255 SkWebpCodec::SkWebpCodec(const SkImageInfo& info, SkStream* stream) |
| 249 : INHERITED(info, stream) {} | 256 : INHERITED(info, stream) {} |
| OLD | NEW |