| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 "SkImageDecoder.h" | 8 #include "SkImageDecoder.h" |
| 9 #include "SkImageEncoder.h" | 9 #include "SkImageEncoder.h" |
| 10 #include "SkColor.h" | 10 #include "SkColor.h" |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 | 607 |
| 608 // sanity check for size | 608 // sanity check for size |
| 609 { | 609 { |
| 610 int64_t size = sk_64_mul(origWidth, origHeight); | 610 int64_t size = sk_64_mul(origWidth, origHeight); |
| 611 // now check that if we are 4-bytes per pixel, we also don't overflow | 611 // now check that if we are 4-bytes per pixel, we also don't overflow |
| 612 if (size < 0 || size > (0x7FFFFFFF >> 2)) { | 612 if (size < 0 || size > (0x7FFFFFFF >> 2)) { |
| 613 return false; | 613 return false; |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 | 616 |
| 617 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER | |
| 618 if (!this->chooseFromOneChoice(*colorTypep, origWidth, origHeight)) { | |
| 619 return false; | |
| 620 } | |
| 621 #endif | |
| 622 | |
| 623 // If the image has alpha and the decoder wants unpremultiplied | 617 // If the image has alpha and the decoder wants unpremultiplied |
| 624 // colors, the only supported colortype is 8888. | 618 // colors, the only supported colortype is 8888. |
| 625 if (this->getRequireUnpremultipliedColors() && *hasAlphap) { | 619 if (this->getRequireUnpremultipliedColors() && *hasAlphap) { |
| 626 *colorTypep = kN32_SkColorType; | 620 *colorTypep = kN32_SkColorType; |
| 627 } | 621 } |
| 628 | 622 |
| 629 if (fImageIndex != NULL) { | 623 if (fImageIndex != NULL) { |
| 630 if (kUnknown_SkColorType == fImageIndex->fColorType) { | 624 if (kUnknown_SkColorType == fImageIndex->fColorType) { |
| 631 // This is the first time for this subset decode. From now on, | 625 // This is the first time for this subset decode. From now on, |
| 632 // all decodes must be in the same colortype. | 626 // all decodes must be in the same colortype. |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 return SkImageDecoder::kUnknown_Format; | 1269 return SkImageDecoder::kUnknown_Format; |
| 1276 } | 1270 } |
| 1277 | 1271 |
| 1278 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1272 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
| 1279 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1273 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
| 1280 } | 1274 } |
| 1281 | 1275 |
| 1282 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1276 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
| 1283 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1277 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
| 1284 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1278 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
| OLD | NEW |