scroggo | f24f224 | 2015-03-03 08:59:20 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkCodec.h" |
scroggo | 1dd3ea9 | 2015-03-20 11:55:55 -0700 | [diff] [blame^] | 9 | #include "SkEncodedFormat.h" |
scroggo | f24f224 | 2015-03-03 08:59:20 -0800 | [diff] [blame] | 10 | #include "SkImageInfo.h" |
| 11 | |
| 12 | extern "C" { |
| 13 | // FIXME: I'd like to force all platforms to use the same decoder, but this |
| 14 | // means an extra dependency on Mac/Win. |
| 15 | #include "png.h" |
| 16 | } |
| 17 | |
| 18 | class SkStream; |
| 19 | |
| 20 | class SkPngCodec : public SkCodec { |
| 21 | public: |
| 22 | // Assumes IsPng was called and returned true. |
| 23 | static SkCodec* NewFromStream(SkStream*); |
| 24 | static bool IsPng(SkStream*); |
| 25 | protected: |
scroggo | 9552662 | 2015-03-17 05:02:17 -0700 | [diff] [blame] | 26 | Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMColor*, int*) |
| 27 | SK_OVERRIDE; |
scroggo | 1dd3ea9 | 2015-03-20 11:55:55 -0700 | [diff] [blame^] | 28 | SkEncodedFormat onGetEncodedFormat() const SK_OVERRIDE { return kPNG_SkEncodedFormat; } |
scroggo | f24f224 | 2015-03-03 08:59:20 -0800 | [diff] [blame] | 29 | private: |
| 30 | png_structp fPng_ptr; |
| 31 | png_infop fInfo_ptr; |
| 32 | |
| 33 | SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop); |
| 34 | ~SkPngCodec(); |
| 35 | |
| 36 | typedef SkCodec INHERITED; |
| 37 | }; |