Chromium Code Reviews| 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.h" | 8 #include "SkCodec.h" |
| 9 #include "SkColorSpaceXform.h" | 9 #include "SkColorSpaceXform.h" |
| 10 #include "SkColorTable.h" | 10 #include "SkColorTable.h" |
| 11 #include "SkPngChunkReader.h" | 11 #include "SkPngChunkReader.h" |
| 12 #include "SkEncodedFormat.h" | 12 #include "SkEncodedFormat.h" |
| 13 #include "SkImageInfo.h" | 13 #include "SkImageInfo.h" |
| 14 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
| 15 #include "SkSwizzler.h" | 15 #include "SkSwizzler.h" |
| 16 | 16 |
| 17 #include "png.h" | 17 // Instead of including png.h here, forward declare the few types we refer to. |
|
msarett
2016/08/24 16:41:51
This should work. I believe we've had issues in t
| |
| 18 struct png_struct_def; | |
| 19 struct png_info_def; | |
| 20 typedef png_struct_def png_struct; | |
| 21 typedef png_info_def png_info; | |
| 18 | 22 |
| 19 class SkStream; | 23 class SkStream; |
| 20 | 24 |
| 21 class SkPngCodec : public SkCodec { | 25 class SkPngCodec : public SkCodec { |
| 22 public: | 26 public: |
| 23 static bool IsPng(const char*, size_t); | 27 static bool IsPng(const char*, size_t); |
| 24 | 28 |
| 25 // Assume IsPng was called and returned true. | 29 // Assume IsPng was called and returned true. |
| 26 static SkCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL); | 30 static SkCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL); |
| 27 | 31 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 40 SkSampler* getSampler(bool createIfNecessary) override { | 44 SkSampler* getSampler(bool createIfNecessary) override { |
| 41 SkASSERT(fSwizzler); | 45 SkASSERT(fSwizzler); |
| 42 return fSwizzler; | 46 return fSwizzler; |
| 43 } | 47 } |
| 44 void allocateStorage(); | 48 void allocateStorage(); |
| 45 | 49 |
| 46 virtual int readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int count, | 50 virtual int readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int count, |
| 47 int startRow) = 0; | 51 int startRow) = 0; |
| 48 | 52 |
| 49 SkPngCodec(const SkEncodedInfo&, const SkImageInfo&, SkStream*, SkPngChunkRe ader*, | 53 SkPngCodec(const SkEncodedInfo&, const SkImageInfo&, SkStream*, SkPngChunkRe ader*, |
| 50 png_structp, png_infop, int, int); | 54 png_struct*, png_info*, int, int); |
| 51 | 55 |
| 52 SkAutoTUnref<SkPngChunkReader> fPngChunkReader; | 56 SkAutoTUnref<SkPngChunkReader> fPngChunkReader; |
| 53 png_structp fPng_ptr; | 57 png_struct* fPng_ptr; |
| 54 png_infop fInfo_ptr; | 58 png_info* fInfo_ptr; |
| 55 | 59 |
| 56 // These are stored here so they can be used both by normal decoding and sca nline decoding. | 60 // These are stored here so they can be used both by normal decoding and sca nline decoding. |
| 57 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul. | 61 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul. |
| 58 SkAutoTDelete<SkSwizzler> fSwizzler; | 62 SkAutoTDelete<SkSwizzler> fSwizzler; |
| 59 std::unique_ptr<SkColorSpaceXform> fColorXform; | 63 std::unique_ptr<SkColorSpaceXform> fColorXform; |
| 60 SkAutoTMalloc<uint8_t> fStorage; | 64 SkAutoTMalloc<uint8_t> fStorage; |
| 61 uint8_t* fSwizzlerSrcRow; | 65 uint8_t* fSwizzlerSrcRow; |
| 62 uint32_t* fColorXformSrcRow; | 66 uint32_t* fColorXformSrcRow; |
| 63 size_t fSrcRowBytes; | 67 size_t fSrcRowBytes; |
| 64 | 68 |
| 65 const int fNumberPasses; | 69 const int fNumberPasses; |
| 66 int fBitDepth; | 70 int fBitDepth; |
| 67 | 71 |
| 68 private: | 72 private: |
| 69 bool createColorTable(const SkImageInfo& dstInfo, int* ctableCount); | 73 bool createColorTable(const SkImageInfo& dstInfo, int* ctableCount); |
| 70 void destroyReadStruct(); | 74 void destroyReadStruct(); |
| 71 | 75 |
| 72 typedef SkCodec INHERITED; | 76 typedef SkCodec INHERITED; |
| 73 }; | 77 }; |
| OLD | NEW |