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

Unified Diff: src/codec/SkPngCodec.h

Issue 1997703003: Make SkPngCodec decode progressively. (Closed) Base URL: https://skia.googlesource.com/skia.git@foil
Patch Set: rebase Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: src/codec/SkPngCodec.h
diff --git a/src/codec/SkPngCodec.h b/src/codec/SkPngCodec.h
index a4c20c708f16e73684c1e013241b9f7fafd700b1..3b40da916f45333a927364c3d852e2996fab7b30 100644
--- a/src/codec/SkPngCodec.h
+++ b/src/codec/SkPngCodec.h
@@ -39,25 +39,38 @@ protected:
void* fPtr;
};
+ SkPngCodec(const SkEncodedInfo&, const SkImageInfo&, SkStream*, SkPngChunkReader*,
+ void* png_ptr, void* info_ptr, int bitDepth);
+
Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMColor*, int*, int*)
override;
SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedFormat; }
bool onRewind() override;
uint64_t onGetFillValue(const SkImageInfo&) const override;
- // Helper to set up swizzler, color xforms, and color table. Also calls png_read_update_info.
- bool initializeXforms(const SkImageInfo& dstInfo, const Options&, SkPMColor* colorPtr,
- int* colorCount);
- void initializeSwizzler(const SkImageInfo& dstInfo, const Options&);
SkSampler* getSampler(bool createIfNecessary) override;
- void allocateStorage(const SkImageInfo& dstInfo);
- void applyXformRow(void* dst, const void* src, SkColorType, SkAlphaType, int width);
+ void applyXformRow(void* dst, const void* src, SkColorType);
- virtual int readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int count,
- int startRow) = 0;
+ voidp png_ptr() { return fPng_ptr; }
+ voidp info_ptr() { return fInfo_ptr; }
- SkPngCodec(const SkEncodedInfo&, const SkImageInfo&, SkStream*, SkPngChunkReader*,
- void* png_ptr, void* info_ptr, int, int);
+ SkSwizzler* swizzler() { return fSwizzler; }
+
+ // Initialize variables used by applyXformRow.
+ void initializeXformAlphaAndWidth();
+
+ /**
+ * Pass available input to libpng to process it.
+ *
+ * libpng will call any relevant callbacks installed. This will continue decoding
+ * until it reaches the end of the file, or until a callback tells libpng to stop.
+ */
+ void processData();
+
+ Result onStartIncrementalDecode(const SkImageInfo& dstInfo, void* pixels, size_t rowBytes,
+ const SkCodec::Options&,
+ SkPMColor* ctable, int* ctableCount) override;
+ Result onIncrementalDecode(int*) override;
SkAutoTUnref<SkPngChunkReader> fPngChunkReader;
voidp fPng_ptr;
@@ -68,12 +81,8 @@ protected:
SkAutoTDelete<SkSwizzler> fSwizzler;
std::unique_ptr<SkColorSpaceXform> fColorXform;
SkAutoTMalloc<uint8_t> fStorage;
- uint8_t* fSwizzlerSrcRow;
uint32_t* fColorXformSrcRow;
- size_t fSrcRowBytes;
-
- const int fNumberPasses;
- int fBitDepth;
+ const int fBitDepth;
private:
@@ -89,9 +98,20 @@ private:
};
bool createColorTable(const SkImageInfo& dstInfo, int* ctableCount);
+ // Helper to set up swizzler, color xforms, and color table. Also calls png_read_update_info.
+ bool initializeXforms(const SkImageInfo& dstInfo, const Options&, SkPMColor* colorPtr,
+ int* colorCount);
+ void initializeSwizzler(const SkImageInfo& dstInfo, const Options&);
+ void allocateStorage(const SkImageInfo& dstInfo);
void destroyReadStruct();
- XformMode fXformMode;
+ virtual Result decodeAllRows(void* dst, size_t rowBytes, int* rowsDecoded) = 0;
+ virtual void setRange(int firstRow, int lastRow, void* dst, size_t rowBytes) = 0;
+ virtual Result decode(int* rowsDecoded) = 0;
+
+ XformMode fXformMode;
+ SkAlphaType fXformAlphaType;
+ int fXformWidth;
typedef SkCodec INHERITED;
};
« no previous file with comments | « src/codec/SkIcoCodec.cpp ('k') | src/codec/SkPngCodec.cpp » ('j') | src/codec/SkSampler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698