aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkCodec_libpng.h
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2015-03-25 11:11:52 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-25 11:11:52 -0700
commit05245900bf6d49068b1668da1b38890a41e09bc5 (patch)
treeb43842b1286b8ec62482644d84a6a1377864d4aa /src/codec/SkCodec_libpng.h
parent038cb5e8d8b095f3e1f87b7a68aa8b7fa6906826 (diff)
Add scanline decoding to SkCodec.
Add an interface for decoding scanlines, and implement that interface in the PNG decoder. Use a separate method to determine whether an image that used a type with alpha was actually opaque. SkScanlineDecoder.h: New interface for decoding scanlines. SkCodec.h: Add getScanlineDecoder. Add a virtual function (with non-virtual caller) for determining whether the image truly had alpha. The client can call this to determine if the image was actually opaque if it reported having alpha. Remove code to sneakily change the passed in alpha type. SkCodec_libpng.*: Split up code onGetPixels into helper functions that can be shared with the scanline decoder. Implement scanline decoding. Implement onReallyHasAlpha. SkSwizzler.*: Add a new SrcConfig as a default, which is invalid. Add a function for setting fDstRow directly. Assert fDstRow is not NULL. BUG=skia:3257 Review URL: https://codereview.chromium.org/1010903003
Diffstat (limited to 'src/codec/SkCodec_libpng.h')
-rw-r--r--src/codec/SkCodec_libpng.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/codec/SkCodec_libpng.h b/src/codec/SkCodec_libpng.h
index debb14b882..fa7b39d82f 100644
--- a/src/codec/SkCodec_libpng.h
+++ b/src/codec/SkCodec_libpng.h
@@ -6,15 +6,17 @@
*/
#include "SkCodec.h"
+#include "SkColorTable.h"
#include "SkEncodedFormat.h"
#include "SkImageInfo.h"
+#include "SkRefCnt.h"
+#include "SkSwizzler.h"
extern "C" {
- // FIXME: I'd like to force all platforms to use the same decoder, but this
- // means an extra dependency on Mac/Win.
#include "png.h"
}
+class SkScanlineDecoder;
class SkStream;
class SkPngCodec : public SkCodec {
@@ -26,12 +28,30 @@ protected:
Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMColor*, int*)
SK_OVERRIDE;
SkEncodedFormat onGetEncodedFormat() const SK_OVERRIDE { return kPNG_SkEncodedFormat; }
+ SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo) SK_OVERRIDE;
+ bool onReallyHasAlpha() const SK_OVERRIDE { return fReallyHasAlpha; }
private:
- png_structp fPng_ptr;
- png_infop fInfo_ptr;
+ png_structp fPng_ptr;
+ png_infop fInfo_ptr;
+
+ // These are stored here so they can be used both by normal decoding and scanline decoding.
+ SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul.
+ SkAutoTDelete<SkSwizzler> fSwizzler;
+
+ SkSwizzler::SrcConfig fSrcConfig;
+ int fNumberPasses;
+ bool fReallyHasAlpha;
SkPngCodec(const SkImageInfo&, SkStream*, png_structp, png_infop);
~SkPngCodec();
+ // Helper to set up swizzler and color table. Also calls png_read_update_info.
+ Result initializeSwizzler(const SkImageInfo& requestedInfo, void* dst,
+ size_t rowBytes, const Options&);
+ bool decodePalette(bool premultiply);
+ void finish();
+
+ friend class SkPngScanlineDecoder;
+
typedef SkCodec INHERITED;
};