| 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 "SkCodec_libpng.h" | 8 #include "SkCodec_libpng.h" |
| 9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 SkPMColor lastColor = index > 0 ? colorPtr[-1] : SkPackARGB32(0xFF, 0, 0, 0)
; | 182 SkPMColor lastColor = index > 0 ? colorPtr[-1] : SkPackARGB32(0xFF, 0, 0, 0)
; |
| 183 for (; index < colorCount; index++) { | 183 for (; index < colorCount; index++) { |
| 184 *colorPtr++ = lastColor; | 184 *colorPtr++ = lastColor; |
| 185 } | 185 } |
| 186 | 186 |
| 187 // Set the new color count | 187 // Set the new color count |
| 188 if (ctableCount != NULL) { | 188 if (ctableCount != NULL) { |
| 189 *ctableCount = colorCount; | 189 *ctableCount = colorCount; |
| 190 } | 190 } |
| 191 | 191 |
| 192 fColorTable.reset(SkNEW_ARGS(SkColorTable, (colorStorage, colorCount))); | 192 fColorTable.reset(new SkColorTable(colorStorage, colorCount)); |
| 193 return true; | 193 return true; |
| 194 } | 194 } |
| 195 | 195 |
| 196 /////////////////////////////////////////////////////////////////////////////// | 196 /////////////////////////////////////////////////////////////////////////////// |
| 197 // Creation | 197 // Creation |
| 198 /////////////////////////////////////////////////////////////////////////////// | 198 /////////////////////////////////////////////////////////////////////////////// |
| 199 | 199 |
| 200 #define PNG_BYTES_TO_CHECK 4 | 200 #define PNG_BYTES_TO_CHECK 4 |
| 201 | 201 |
| 202 bool SkPngCodec::IsPng(SkStream* stream) { | 202 bool SkPngCodec::IsPng(SkStream* stream) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 return true; | 349 return true; |
| 350 } | 350 } |
| 351 | 351 |
| 352 SkCodec* SkPngCodec::NewFromStream(SkStream* stream) { | 352 SkCodec* SkPngCodec::NewFromStream(SkStream* stream) { |
| 353 SkAutoTDelete<SkStream> streamDeleter(stream); | 353 SkAutoTDelete<SkStream> streamDeleter(stream); |
| 354 png_structp png_ptr; | 354 png_structp png_ptr; |
| 355 png_infop info_ptr; | 355 png_infop info_ptr; |
| 356 SkImageInfo imageInfo; | 356 SkImageInfo imageInfo; |
| 357 int bitDepth; | 357 int bitDepth; |
| 358 if (read_header(stream, &png_ptr, &info_ptr, &imageInfo, &bitDepth)) { | 358 if (read_header(stream, &png_ptr, &info_ptr, &imageInfo, &bitDepth)) { |
| 359 return SkNEW_ARGS(SkPngCodec, (imageInfo, streamDeleter.detach(), | 359 return new SkPngCodec(imageInfo, streamDeleter.detach(), png_ptr, info_p
tr, bitDepth); |
| 360 png_ptr, info_ptr, bitDepth)); | |
| 361 } | 360 } |
| 362 return NULL; | 361 return NULL; |
| 363 } | 362 } |
| 364 | 363 |
| 365 #define INVALID_NUMBER_PASSES -1 | 364 #define INVALID_NUMBER_PASSES -1 |
| 366 SkPngCodec::SkPngCodec(const SkImageInfo& info, SkStream* stream, | 365 SkPngCodec::SkPngCodec(const SkImageInfo& info, SkStream* stream, |
| 367 png_structp png_ptr, png_infop info_ptr, int bitDepth) | 366 png_structp png_ptr, png_infop info_ptr, int bitDepth) |
| 368 : INHERITED(info, stream) | 367 : INHERITED(info, stream) |
| 369 , fPng_ptr(png_ptr) | 368 , fPng_ptr(png_ptr) |
| 370 , fInfo_ptr(info_ptr) | 369 , fInfo_ptr(info_ptr) |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 if (!codec) { | 773 if (!codec) { |
| 775 return NULL; | 774 return NULL; |
| 776 } | 775 } |
| 777 | 776 |
| 778 codec->fNumberPasses = png_set_interlace_handling(codec->fPng_ptr); | 777 codec->fNumberPasses = png_set_interlace_handling(codec->fPng_ptr); |
| 779 SkASSERT(codec->fNumberPasses != INVALID_NUMBER_PASSES); | 778 SkASSERT(codec->fNumberPasses != INVALID_NUMBER_PASSES); |
| 780 | 779 |
| 781 const SkImageInfo& srcInfo = codec->getInfo(); | 780 const SkImageInfo& srcInfo = codec->getInfo(); |
| 782 if (codec->fNumberPasses > 1) { | 781 if (codec->fNumberPasses > 1) { |
| 783 // interlaced image | 782 // interlaced image |
| 784 return SkNEW_ARGS(SkPngInterlacedScanlineDecoder, (srcInfo, codec.detach
())); | 783 return new SkPngInterlacedScanlineDecoder(srcInfo, codec.detach()); |
| 785 } | 784 } |
| 786 | 785 |
| 787 return SkNEW_ARGS(SkPngScanlineDecoder, (srcInfo, codec.detach())); | 786 return new SkPngScanlineDecoder(srcInfo, codec.detach()); |
| 788 } | 787 } |
| 789 | 788 |
| OLD | NEW |