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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 autoClean.release(); | 601 autoClean.release(); |
602 if (png_ptrp) { | 602 if (png_ptrp) { |
603 *png_ptrp = png_ptr; | 603 *png_ptrp = png_ptr; |
604 } | 604 } |
605 if (info_ptrp) { | 605 if (info_ptrp) { |
606 *info_ptrp = info_ptr; | 606 *info_ptrp = info_ptr; |
607 } | 607 } |
608 | 608 |
609 if (outCodec) { | 609 if (outCodec) { |
610 sk_sp<SkColorSpace> colorSpace = read_color_space(png_ptr, info_ptr); | 610 sk_sp<SkColorSpace> colorSpace = read_color_space(png_ptr, info_ptr); |
| 611 if (!colorSpace) { |
| 612 // Treat unmarked pngs as sRGB. |
| 613 colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); |
| 614 } |
| 615 |
611 SkEncodedInfo info = SkEncodedInfo::Make(color, alpha, 8); | 616 SkEncodedInfo info = SkEncodedInfo::Make(color, alpha, 8); |
612 | 617 |
613 if (1 == numberPasses) { | 618 if (1 == numberPasses) { |
614 *outCodec = new SkPngScanlineDecoder(origWidth, origHeight, info, st
ream, | 619 *outCodec = new SkPngScanlineDecoder(origWidth, origHeight, info, st
ream, |
615 chunkReader, png_ptr, info_ptr, bitDepth, colorSpace); | 620 chunkReader, png_ptr, info_ptr, bitDepth, colorSpace); |
616 } else { | 621 } else { |
617 *outCodec = new SkPngInterlacedScanlineDecoder(origWidth, origHeight
, info, stream, | 622 *outCodec = new SkPngInterlacedScanlineDecoder(origWidth, origHeight
, info, stream, |
618 chunkReader, png_ptr, info_ptr, bitDepth, numberPasses, colo
rSpace); | 623 chunkReader, png_ptr, info_ptr, bitDepth, numberPasses, colo
rSpace); |
619 } | 624 } |
620 } | 625 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 SkCodec* outCodec; | 807 SkCodec* outCodec; |
803 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { | 808 if (read_header(stream, chunkReader, &outCodec, nullptr, nullptr)) { |
804 // Codec has taken ownership of the stream. | 809 // Codec has taken ownership of the stream. |
805 SkASSERT(outCodec); | 810 SkASSERT(outCodec); |
806 streamDeleter.release(); | 811 streamDeleter.release(); |
807 return outCodec; | 812 return outCodec; |
808 } | 813 } |
809 | 814 |
810 return nullptr; | 815 return nullptr; |
811 } | 816 } |
OLD | NEW |