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

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

Issue 1010903003: Add scanline decoding to SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Cleanups Created 5 years, 9 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 "SkImageInfo.h" 10 #include "SkImageInfo.h"
11 #include "SkRefCnt.h"
12 #include "SkSwizzler.h"
10 13
11 extern "C" { 14 extern "C" {
12 // FIXME: I'd like to force all platforms to use the same decoder, but this
13 // means an extra dependency on Mac/Win.
14 #include "png.h" 15 #include "png.h"
15 } 16 }
16 17
18 class SkScanlineDecoder;
17 class SkStream; 19 class SkStream;
18 20
19 class SkPngCodec : public SkCodec { 21 class SkPngCodec : public SkCodec {
20 public: 22 public:
21 // Assumes IsPng was called and returned true. 23 // Assumes IsPng was called and returned true.
22 static SkCodec* NewFromStream(SkStream*); 24 static SkCodec* NewFromStream(SkStream*);
23 static bool IsPng(SkStream*); 25 static bool IsPng(SkStream*);
24 protected: 26 protected:
25 Result onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*, int*) SK_O VERRIDE; 27 Result onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor*, int*) SK_O VERRIDE;
28 SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo,
29 const SkIRect& origSubset) SK_OVERRI DE;
30 bool onReallyHasAlpha() const SK_OVERRIDE { return fReallyHasAlpha; }
26 private: 31 private:
27 png_structp fPng_ptr; 32 png_structp fPng_ptr;
28 png_infop fInfo_ptr; 33 png_infop fInfo_ptr;
34
35 // These are stored here so they can be used both by normal decoding and sca nline decoding.
36 SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul.
37 SkAutoTDelete<SkSwizzler> fSwizzler;
38
39 SkSwizzler::SrcConfig fSc;
40 int fNumberPasses;
41 bool fReallyHasAlpha;
29 42
30 SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop); 43 SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop);
31 ~SkPngCodec(); 44 ~SkPngCodec();
32 45
46 // Helper to set up swizzler and color table. Also calls png_read_update_inf o.
47 Result initializeSwizzler(const SkImageInfo& requestedInfo, void* dst, size_ t rowBytes);
48 bool decodePalette(bool premultiply);
49 Result finish();
50
51 friend class SkPngScanlineDecoder;
52
33 typedef SkCodec INHERITED; 53 typedef SkCodec INHERITED;
34 }; 54 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698