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

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

Issue 1267583002: Create a scanline decoder without creating a codec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix interlaced Created 5 years, 4 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/SkCodec.cpp ('k') | src/codec/SkCodec_libpng.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 "SkEncodedFormat.h" 10 #include "SkEncodedFormat.h"
11 #include "SkImageInfo.h" 11 #include "SkImageInfo.h"
12 #include "SkRefCnt.h" 12 #include "SkRefCnt.h"
13 #include "SkSwizzler.h" 13 #include "SkSwizzler.h"
14 14
15 #ifdef SKIA_PNG_PREFIXED 15 #ifdef SKIA_PNG_PREFIXED
16 // this must proceed png.h 16 // this must proceed png.h
17 #include "pngprefix.h" 17 #include "pngprefix.h"
18 #endif 18 #endif
19 #include "png.h" 19 #include "png.h"
20 20
21 class SkScanlineDecoder; 21 class SkScanlineDecoder;
22 class SkStream; 22 class SkStream;
23 23
24 class SkPngCodec : public SkCodec { 24 class SkPngCodec : public SkCodec {
25 public: 25 public:
26 // Assumes IsPng was called and returned true. 26 static bool IsPng(SkStream*);
27
28 // Assume IsPng was called and returned true.
27 static SkCodec* NewFromStream(SkStream*); 29 static SkCodec* NewFromStream(SkStream*);
28 static bool IsPng(SkStream*); 30 static SkScanlineDecoder* NewSDFromStream(SkStream*);
29 31
30 virtual ~SkPngCodec(); 32 virtual ~SkPngCodec();
31 33
32 protected: 34 protected:
33 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*) 35 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*)
34 override; 36 override;
35 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF ormat; } 37 SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedF ormat; }
36 SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo, const Op tions& options,
37 SkPMColor ctable[], int* ctableCount ) override;
38 bool onReallyHasAlpha() const override { return fReallyHasAlpha; } 38 bool onReallyHasAlpha() const override { return fReallyHasAlpha; }
39 private: 39 private:
40 png_structp fPng_ptr; 40 png_structp fPng_ptr;
41 png_infop fInfo_ptr; 41 png_infop fInfo_ptr;
42 42
43 // These are stored here so they can be used both by normal decoding and sca nline decoding. 43 // These are stored here so they can be used both by normal decoding and sca nline decoding.
44 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul. 44 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul.
45 SkAutoTDelete<SkSwizzler> fSwizzler; 45 SkAutoTDelete<SkSwizzler> fSwizzler;
46 46
47 SkSwizzler::SrcConfig fSrcConfig; 47 SkSwizzler::SrcConfig fSrcConfig;
(...skipping 11 matching lines...) Expand all
59 // Calls rewindIfNeeded and returns true if the decoder can continue. 59 // Calls rewindIfNeeded and returns true if the decoder can continue.
60 bool handleRewind(); 60 bool handleRewind();
61 bool decodePalette(bool premultiply, int* ctableCount); 61 bool decodePalette(bool premultiply, int* ctableCount);
62 void destroyReadStruct(); 62 void destroyReadStruct();
63 63
64 friend class SkPngScanlineDecoder; 64 friend class SkPngScanlineDecoder;
65 friend class SkPngInterlacedScanlineDecoder; 65 friend class SkPngInterlacedScanlineDecoder;
66 66
67 typedef SkCodec INHERITED; 67 typedef SkCodec INHERITED;
68 }; 68 };
OLDNEW
« no previous file with comments | « src/codec/SkCodec.cpp ('k') | src/codec/SkCodec_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698