Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: src/codec/SkPngCodec.h

Issue 2023103002: Revert of Make SkPngCodec decode progressively. (Closed) Base URL: https://skia.googlesource.com/skia.git@foil
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/codec/SkIcoCodec.cpp ('k') | src/codec/SkPngCodec.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkColorTable.h" 9 #include "SkColorTable.h"
10 #include "SkPngChunkReader.h" 10 #include "SkPngChunkReader.h"
11 #include "SkEncodedFormat.h" 11 #include "SkEncodedFormat.h"
12 #include "SkImageInfo.h" 12 #include "SkImageInfo.h"
13 #include "SkRefCnt.h" 13 #include "SkRefCnt.h"
14 #include "SkSwizzler.h" 14 #include "SkSwizzler.h"
15 15
16 #include "png.h" 16 #include "png.h"
17 17
18 #if PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MIN OR >= 5)
19 class SkStream; 18 class SkStream;
20 19
21 class SkPngCodec : public SkCodec { 20 class SkPngCodec : public SkCodec {
22 public: 21 public:
23 static bool IsPng(const char*, size_t); 22 static bool IsPng(const char*, size_t);
24 23
25 // Assume IsPng was called and returned true. 24 // Assume IsPng was called and returned true.
26 static SkCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL); 25 static SkCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL);
27 26
28 virtual ~SkPngCodec(); 27 virtual ~SkPngCodec();
29 28
30 protected: 29 protected:
31 SkPngCodec(int width, int height, const SkEncodedInfo&, SkStream*, SkPngChun kReader*,
32 png_structp, png_infop, int bitDepth, sk_sp<SkColorSpace>);
33
34 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*, int*) 30 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*, int*)
35 override; 31 override;
36 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF ormat; } 32 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF ormat; }
37 bool onRewind() override; 33 bool onRewind() override;
38 uint32_t onGetFillValue(SkColorType) const override; 34 uint32_t onGetFillValue(SkColorType) const override;
39 35
40 // Helper to set up swizzler and color table. Also calls png_read_update_inf o. 36 // Helper to set up swizzler and color table. Also calls png_read_update_inf o.
41 bool initializeSwizzler(const SkImageInfo& requestedInfo, const Options&, 37 Result initializeSwizzler(const SkImageInfo& requestedInfo, const Options&,
42 SkPMColor*, int* ctableCount); 38 SkPMColor*, int* ctableCount);
43 SkSampler* getSampler(bool createIfNecessary) override { 39 SkSampler* getSampler(bool createIfNecessary) override {
44 SkASSERT(fSwizzler); 40 SkASSERT(fSwizzler);
45 return fSwizzler; 41 return fSwizzler;
46 } 42 }
47 43
44 SkPngCodec(int width, int height, const SkEncodedInfo&, SkStream*, SkPngChun kReader*,
45 png_structp, png_infop, int, int, sk_sp<SkColorSpace>);
46
48 png_structp png_ptr() { return fPng_ptr; } 47 png_structp png_ptr() { return fPng_ptr; }
49 png_infop info_ptr() { return fInfo_ptr; }
50 SkSwizzler* swizzler() { return fSwizzler; } 48 SkSwizzler* swizzler() { return fSwizzler; }
51 49 int numberPasses() const { return fNumberPasses; }
52 /**
53 * Pass available input to libpng to process it.
54 *
55 * libpng will call any relevant callbacks installed. This will continue de coding
56 * until it reaches the end of the file, or until a callback tells libpng t o stop.
57 */
58 void processData();
59
60 Result onStartIncrementalDecode(const SkImageInfo& dstInfo, void* pixels, si ze_t rowBytes,
61 const SkCodec::Options&,
62 SkPMColor* ctable, int* ctableCount) override;
63 Result onIncrementalDecode(int*) override;
64 50
65 private: 51 private:
66 SkAutoTUnref<SkPngChunkReader> fPngChunkReader; 52 SkAutoTUnref<SkPngChunkReader> fPngChunkReader;
67 png_structp fPng_ptr; 53 png_structp fPng_ptr;
68 png_infop fInfo_ptr; 54 png_infop fInfo_ptr;
69 55
56 // These are stored here so they can be used both by normal decoding and sca nline decoding.
70 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul. 57 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul.
71 SkAutoTDelete<SkSwizzler> fSwizzler; 58 SkAutoTDelete<SkSwizzler> fSwizzler;
72 59
73 const int fBitDepth; 60 const int fNumberPasses;
61 int fBitDepth;
74 62
75 bool createColorTable(SkColorType dstColorType, bool premultiply, int* ctabl eCount); 63 bool createColorTable(SkColorType dstColorType, bool premultiply, int* ctabl eCount);
76 void destroyReadStruct(); 64 void destroyReadStruct();
77 65
78 virtual Result decodeAllRows(void* dst, size_t rowBytes, int* rowsDecoded) = 0;
79 virtual void setRange(int firstRow, int lastRow, void* dst, size_t rowBytes) = 0;
80 virtual Result decode(int* rowsDecoded) = 0;
81
82 typedef SkCodec INHERITED; 66 typedef SkCodec INHERITED;
83 }; 67 };
84 #else
85 #undef SK_HAS_PNG_LIBRARY
86 #endif
OLDNEW
« no previous file with comments | « src/codec/SkIcoCodec.cpp ('k') | src/codec/SkPngCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698