Index: include/codec/SkCodec.h |
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h |
index bdfa2326fba5acc4c89bdc346e2b972a0ddb25d4..b29c2c0c2e9910c7d7f636bdd11d9a40fa38c9ae 100644 |
--- a/include/codec/SkCodec.h |
+++ b/include/codec/SkCodec.h |
@@ -225,6 +225,42 @@ public: |
return this->onReallyHasAlpha(); |
} |
+ /** |
+ * Before returning kIncompleteInput, onGetPixels() indicates how many uninitialized |
+ * scanlines need to be filled. In order to fill these scanlines, we use this function |
+ * to determine what value to fill with. |
+ * |
+ * @param dstInfo Contains the destination colorType and alphaType, which may be |
+ * used to choose the fill value. |
+ * @return The value with which to fill uninitialized pixels. |
+ * |
+ * 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 { |
+ return this->onGetFillValue(dstInfo); |
+ } |
+ |
+ /** |
+ * Before returning kIncompleteInput, onGetPixels() indicates how many uninitialized |
+ * scanlines need to be filled. In order to fill these scanlines, we use this function |
+ * to determine where these pixels are located in destination memory. |
+ * |
+ * When encoded scanlines are arranged top-down, we fill the bottom of destination |
+ * memory. When encoded scanlines are arranged bottom-up, we fill the top of |
+ * destination memory. When encoded scanlines are arranged out of order, it is the |
+ * responsibility of the subclass to fill uninitialized memory. |
scroggo
2015/09/25 15:55:05
FWIW, it seems like getY could be used to make the
msarett
2015/10/01 12:44:52
We will be able to do this (and I intend to do thi
|
+ * |
+ * @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 { |
+ return this->onGetFillDst(dstStart, rowBytes, decodedScanlines); |
+ } |
+ |
protected: |
SkCodec(const SkImageInfo&, SkStream*); |
@@ -235,9 +271,16 @@ protected: |
virtual SkEncodedFormat onGetEncodedFormat() const = 0; |
+ /** |
+ * @param incompleteScanlines When the encoded image stream is incomplete, this function |
scroggo
2015/09/25 15:55:05
As I keep thinking about skbug.com/4284, I wonder
msarett
2015/10/01 12:44:52
That would be great if we could do that! For now,
|
+ * will return kIncompleteInput and incompleteScanlines will |
+ * be set to the number of scanlines that remain uninitialized. |
+ * This will allow getPixels() to fill the uninitialized memory. |
+ */ |
virtual Result onGetPixels(const SkImageInfo& info, |
void* pixels, size_t rowBytes, const Options&, |
- SkPMColor ctable[], int* ctableCount) = 0; |
+ SkPMColor ctable[], int* ctableCount, |
+ int* incompleteScanlines) = 0; |
virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const { |
// By default, subsets are not supported. |
@@ -269,6 +312,28 @@ 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; |
+ } |
+ |
+ /** |
+ * This will only need to be overridden for images where the rows are not |
+ * decoded in top-down order. |
+ */ |
+ virtual void* onGetFillDst(void* dstStart, size_t rowBytes, uint32_t decodedScanlines) const { |
+ return SkTAddOffset<void>(dstStart, rowBytes * decodedScanlines); |
+ } |
+ |
+ /** |
* Get method for the input stream |
*/ |
SkStream* stream() { |
@@ -279,5 +344,6 @@ private: |
const SkImageInfo fInfo; |
SkAutoTDelete<SkStream> fStream; |
bool fNeedsRewind; |
+ uint32_t fIncompleteScanlines; |
scroggo
2015/09/25 15:55:05
I think this no longer needs to be a member variab
msarett
2015/10/01 12:44:52
Done.
|
}; |
#endif // SkCodec_DEFINED |