| 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 | 600 |
| 601 // sanity check for size | 601 // sanity check for size |
| 602 { | 602 { |
| 603 int64_t size = sk_64_mul(origWidth, origHeight); | 603 int64_t size = sk_64_mul(origWidth, origHeight); |
| 604 // now check that if we are 4-bytes per pixel, we also don't overflow | 604 // now check that if we are 4-bytes per pixel, we also don't overflow |
| 605 if (size < 0 || size > (0x7FFFFFFF >> 2)) { | 605 if (size < 0 || size > (0x7FFFFFFF >> 2)) { |
| 606 return false; | 606 return false; |
| 607 } | 607 } |
| 608 } | 608 } |
| 609 | 609 |
| 610 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER |
| 610 if (!this->chooseFromOneChoice(*colorTypep, origWidth, origHeight)) { | 611 if (!this->chooseFromOneChoice(*colorTypep, origWidth, origHeight)) { |
| 611 return false; | 612 return false; |
| 612 } | 613 } |
| 614 #endif |
| 613 | 615 |
| 614 // If the image has alpha and the decoder wants unpremultiplied | 616 // If the image has alpha and the decoder wants unpremultiplied |
| 615 // colors, the only supported config is 8888. | 617 // colors, the only supported config is 8888. |
| 616 if (this->getRequireUnpremultipliedColors() && *hasAlphap) { | 618 if (this->getRequireUnpremultipliedColors() && *hasAlphap) { |
| 617 *colorTypep = kN32_SkColorType; | 619 *colorTypep = kN32_SkColorType; |
| 618 } | 620 } |
| 619 | 621 |
| 620 if (fImageIndex != NULL) { | 622 if (fImageIndex != NULL) { |
| 621 if (kUnknown_SkColorType == fImageIndex->fColorType) { | 623 if (kUnknown_SkColorType == fImageIndex->fColorType) { |
| 622 // This is the first time for this subset decode. From now on, | 624 // This is the first time for this subset decode. From now on, |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 return SkImageDecoder::kUnknown_Format; | 1283 return SkImageDecoder::kUnknown_Format; |
| 1282 } | 1284 } |
| 1283 | 1285 |
| 1284 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1286 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
| 1285 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1287 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
| 1286 } | 1288 } |
| 1287 | 1289 |
| 1288 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1290 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
| 1289 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1291 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
| 1290 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1292 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
| OLD | NEW |