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

Unified Diff: include/codec/SkCodec.h

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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: include/codec/SkCodec.h
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index bdfa2326fba5acc4c89bdc346e2b972a0ddb25d4..341a02af76c88d4441a9a9d2bf57047a6ea018f2 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -225,6 +225,29 @@ public:
return this->onReallyHasAlpha();
}
+ /**
+ * @return the value with which to fill uninitialized pixels.
+ *
+ * This is used when onGetScanlines() returns kIncompleteInput.
+ *
+ * Note that we can interpret the return value as an SkPMColor, a 16-bit 565 color,
+ * an 8-bit gray color, or an 8-bit index into a color table, depending on the color
+ * type specified in dstInfo.
+ */
+ uint32_t getFillValue(const SkImageInfo& dstInfo) const {
scroggo 2015/09/22 18:02:48 I assume the implementation only needs color type
msarett 2015/09/23 13:22:39 Yes, I will add a comment explaining this. As an
scroggo 2015/09/25 15:55:05 I think only passing the information needed by the
msarett 2015/10/01 12:44:51 Done.
+ return this->onGetFillValue(dstInfo);
+ }
+
+ /**
+ * @param dstStart Pointer to the start of destination memory
+ * @param dstRowBytes Stride length in destination memory
+ * @param decodedScanlines Number of scanlines decoded successfully
+ * @return Pointer to the destination memory that we need to fill
+ */
+ void* getFillDst(void* dstStart, size_t rowBytes, uint32_t decodedScanlines) const {
scroggo 2015/09/22 18:02:48 Could you add a comment with an overview of what t
msarett 2015/09/23 13:22:39 Yes this needs clarification.
+ return this->onGetFillDst(dstStart, rowBytes, decodedScanlines);
+ }
+
protected:
SkCodec(const SkImageInfo&, SkStream*);
@@ -269,6 +292,37 @@ protected:
}
/**
+ * Some subclasses will override this function, but this is a useful default for the color
+ * types that we support. Note that for color types that do not use the full 32-bits,
+ * we will simply take the low bits of the fill value.
+ *
+ * kN32_SkColorType: Transparent or Black
+ * kRGB_565_SkColorType: Black
+ * kGray_8_SkColorType: Black
+ * kIndex_8_SkColorType: First color in color table
+ */
+ virtual uint32_t onGetFillValue(const SkImageInfo& dstInfo) const {
+ return kOpaque_SkAlphaType == dstInfo.alphaType() ? SK_ColorBLACK : SK_ColorTRANSPARENT;
+ }
+
+ /**
+ * The will only need to be overridden for images where the rows are not
scroggo 2015/09/22 18:02:48 This*
msarett 2015/09/23 13:22:39 Done.
+ * decoded in top down order.
+ */
+ virtual void* onGetFillDst(void* dstStart, size_t rowBytes, uint32_t decodedScanlines) const {
+ return SkTAddOffset<void>(dstStart, rowBytes * decodedScanlines);
+ }
+
+ /*
+ * Allows the subclass to indicate how many scanlines it failed to decode due to an
+ * incomplete input image. This value tells us how many uninitialized scanlines to fill
+ * in destination memory.
+ */
+ void setIncompleteScanlines(uint32_t incompleteScanlines) {
scroggo 2015/09/22 18:02:48 Maybe this should be returned by getPixels (in an
msarett 2015/09/23 13:22:40 Good idea! I like this better than what I have.
+ fIncompleteScanlines = incompleteScanlines;
+ }
+
+ /**
* Get method for the input stream
*/
SkStream* stream() {
@@ -279,5 +333,6 @@ private:
const SkImageInfo fInfo;
SkAutoTDelete<SkStream> fStream;
bool fNeedsRewind;
+ uint32_t fIncompleteScanlines;
};
#endif // SkCodec_DEFINED

Powered by Google App Engine
This is Rietveld 408576698