| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 if (png_ptrp) { | 339 if (png_ptrp) { |
| 340 *png_ptrp = png_ptr; | 340 *png_ptrp = png_ptr; |
| 341 } | 341 } |
| 342 if (info_ptrp) { | 342 if (info_ptrp) { |
| 343 *info_ptrp = info_ptr; | 343 *info_ptrp = info_ptr; |
| 344 } | 344 } |
| 345 return true; | 345 return true; |
| 346 } | 346 } |
| 347 | 347 |
| 348 SkCodec* SkPngCodec::NewFromStream(SkStream* stream) { | 348 SkCodec* SkPngCodec::NewFromStream(SkStream* stream) { |
| 349 SkAutoTDelete<SkStream> streamDeleter(stream); |
| 349 png_structp png_ptr; | 350 png_structp png_ptr; |
| 350 png_infop info_ptr; | 351 png_infop info_ptr; |
| 351 SkImageInfo imageInfo; | 352 SkImageInfo imageInfo; |
| 352 if (read_header(stream, &png_ptr, &info_ptr, &imageInfo)) { | 353 if (read_header(stream, &png_ptr, &info_ptr, &imageInfo)) { |
| 353 return SkNEW_ARGS(SkPngCodec, (imageInfo, stream, png_ptr, info_ptr)); | 354 return SkNEW_ARGS(SkPngCodec, (imageInfo, streamDeleter.detach(), png_pt
r, info_ptr)); |
| 354 } | 355 } |
| 355 return NULL; | 356 return NULL; |
| 356 } | 357 } |
| 357 | 358 |
| 358 #define INVALID_NUMBER_PASSES -1 | 359 #define INVALID_NUMBER_PASSES -1 |
| 359 SkPngCodec::SkPngCodec(const SkImageInfo& info, SkStream* stream, | 360 SkPngCodec::SkPngCodec(const SkImageInfo& info, SkStream* stream, |
| 360 png_structp png_ptr, png_infop info_ptr) | 361 png_structp png_ptr, png_infop info_ptr) |
| 361 : INHERITED(info, stream) | 362 : INHERITED(info, stream) |
| 362 , fPng_ptr(png_ptr) | 363 , fPng_ptr(png_ptr) |
| 363 , fInfo_ptr(info_ptr) | 364 , fInfo_ptr(info_ptr) |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 | 638 |
| 638 SkASSERT(fNumberPasses != INVALID_NUMBER_PASSES); | 639 SkASSERT(fNumberPasses != INVALID_NUMBER_PASSES); |
| 639 if (fNumberPasses > 1) { | 640 if (fNumberPasses > 1) { |
| 640 // We cannot efficiently do scanline decoding. | 641 // We cannot efficiently do scanline decoding. |
| 641 return NULL; | 642 return NULL; |
| 642 } | 643 } |
| 643 | 644 |
| 644 return SkNEW_ARGS(SkPngScanlineDecoder, (dstInfo, this)); | 645 return SkNEW_ARGS(SkPngScanlineDecoder, (dstInfo, this)); |
| 645 } | 646 } |
| 646 | 647 |
| OLD | NEW |