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

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

Issue 1997703003: Make SkPngCodec decode progressively. (Closed) Base URL: https://skia.googlesource.com/skia.git@foil
Patch Set: Fixes for ICO, Incomplete, comments Created 4 years, 7 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
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 class SkStream; 18 class SkStream;
19 19
20 class SkPngCodec : public SkCodec { 20 class SkPngCodec : public SkCodec {
21 public: 21 public:
22 static bool IsPng(const char*, size_t); 22 static bool IsPng(const char*, size_t);
23 23
24 // Assume IsPng was called and returned true. 24 // Assume IsPng was called and returned true.
25 static SkCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL); 25 static SkCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL);
26 26
27 virtual ~SkPngCodec(); 27 virtual ~SkPngCodec();
28 28
29 protected: 29 protected:
30 SkPngCodec(int width, int height, const SkEncodedInfo&, SkStream*, SkPngChun kReader*,
31 png_structp, png_infop, int bitDepth, sk_sp<SkColorSpace>);
32
30 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*, int*) 33 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*, int*)
31 override; 34 override;
32 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF ormat; } 35 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF ormat; }
33 bool onRewind() override; 36 bool onRewind() override;
34 uint32_t onGetFillValue(SkColorType) const override; 37 uint32_t onGetFillValue(SkColorType) const override;
35 38
36 // Helper to set up swizzler and color table. Also calls png_read_update_inf o. 39 // Helper to set up swizzler and color table. Also calls png_read_update_inf o.
37 Result initializeSwizzler(const SkImageInfo& requestedInfo, const Options&, 40 bool initializeSwizzler(const SkImageInfo& requestedInfo, const Options&,
38 SkPMColor*, int* ctableCount); 41 SkPMColor*, int* ctableCount);
39 SkSampler* getSampler(bool createIfNecessary) override { 42 SkSampler* getSampler(bool createIfNecessary) override {
40 SkASSERT(fSwizzler); 43 SkASSERT(fSwizzler);
41 return fSwizzler; 44 return fSwizzler;
42 } 45 }
43 46
44 SkPngCodec(int width, int height, const SkEncodedInfo&, SkStream*, SkPngChun kReader*, 47 png_structp png_ptr() { return fPng_ptr; }
45 png_structp, png_infop, int, int, sk_sp<SkColorSpace>); 48 png_infop info_ptr() { return fInfo_ptr; }
49 SkSwizzler* swizzler() { return fSwizzler; }
50 void processData();
msarett 2016/05/20 15:04:41 nit: Comments to explain what this does?
scroggo_chromium 2016/05/20 16:51:59 Done.
46 51
47 png_structp png_ptr() { return fPng_ptr; } 52 Result onStartIncrementalDecode(const SkImageInfo& dstInfo, const SkCodec::O ptions&,
48 SkSwizzler* swizzler() { return fSwizzler; } 53 SkPMColor* ctable, int* ctableCount) override;
49 int numberPasses() const { return fNumberPasses; } 54 Result onIncrementalDecode(std::function<void*(int)> callback, int*) overrid e;
50 55
51 private: 56 private:
52 SkAutoTUnref<SkPngChunkReader> fPngChunkReader; 57 SkAutoTUnref<SkPngChunkReader> fPngChunkReader;
53 png_structp fPng_ptr; 58 png_structp fPng_ptr;
54 png_infop fInfo_ptr; 59 png_infop fInfo_ptr;
55 60
56 // 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 63
60 const int fNumberPasses; 64 const int fBitDepth;
61 int fBitDepth;
62 65
63 bool createColorTable(SkColorType dstColorType, bool premultiply, int* ctabl eCount); 66 bool createColorTable(SkColorType dstColorType, bool premultiply, int* ctabl eCount);
64 void destroyReadStruct(); 67 void destroyReadStruct();
65 68
69 virtual Result decodeAllRows(void* dst, size_t rowBytes, int* rowsDecoded) = 0;
70 virtual void setRange(int firstRow, int lastRow) = 0;
71 virtual Result decode(std::function<void*(int)> callback, int* rowsDecoded) = 0;
72
66 typedef SkCodec INHERITED; 73 typedef SkCodec INHERITED;
67 }; 74 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698