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

Unified Diff: src/codec/SkBmpMaskCodec.cpp

Issue 1287423002: Scanline decoding for bmp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Scanline decoding for bmp without reordering Created 5 years, 4 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/SkBmpMaskCodec.cpp
diff --git a/src/codec/SkBmpMaskCodec.cpp b/src/codec/SkBmpMaskCodec.cpp
index 7d1706e697f0e3b955a866e53d77ae65def773f4..5cc0d4b348ad519251358356275014a600069aa4 100644
--- a/src/codec/SkBmpMaskCodec.cpp
+++ b/src/codec/SkBmpMaskCodec.cpp
@@ -40,9 +40,10 @@ static bool conversion_possible(const SkImageInfo& dst,
* Creates an instance of the decoder
*/
SkBmpMaskCodec::SkBmpMaskCodec(const SkImageInfo& info, SkStream* stream,
+ SkBmpCodec::BmpInputFormat inputFormat,
uint16_t bitsPerPixel, SkMasks* masks,
SkBmpCodec::RowOrder rowOrder)
- : INHERITED(info, stream, bitsPerPixel, rowOrder)
+ : INHERITED(info, stream, inputFormat, bitsPerPixel, rowOrder)
, fMasks(masks)
, fMaskSwizzler(NULL)
, fSrcBuffer(NULL)
@@ -135,3 +136,48 @@ SkCodec::Result SkBmpMaskCodec::decode(const SkImageInfo& dstInfo,
// Finished decoding the entire image
return kSuccess;
}
+
+SkBmpMaskScanlineDecoder::SkBmpMaskScanlineDecoder(SkBmpMaskCodec* codec)
+ : INHERITED(codec->getInfo())
+ , fCodec(codec)
+{}
+
+SkCodec::Result SkBmpMaskScanlineDecoder::onStart(const SkImageInfo& dstInfo,
+ const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) {
+ if (!fCodec->rewindIfNeeded()) {
+ return SkCodec::kCouldNotRewind;
+ }
+ if (options.fSubset) {
+ // Subsets are not supported.
+ return SkCodec::kUnimplemented;
+ }
+ if (dstInfo.dimensions() != fCodec->getInfo().dimensions()) {
+ SkCodecPrintf("Error: scaling not supported.\n");
+ return SkCodec::kInvalidScale;
+ }
+
+ if (!conversion_possible(dstInfo, fCodec->getInfo())) {
+ SkCodecPrintf("Error: cannot convert input type to output type.\n");
+ return SkCodec::kInvalidConversion;
+ }
+
+ // Initialize a the mask swizzler
+ if (!fCodec->initializeSwizzler(dstInfo)) {
+ SkCodecPrintf("Error: cannot initialize swizzler.\n");
+ return SkCodec::kInvalidConversion;
+ }
+
+ fDstInfo = dstInfo;
scroggo 2015/08/13 21:25:36 Can you get this from the base class, which also s
msarett 2015/08/14 15:44:48 Done.
+ fOpts = options;
scroggo 2015/08/13 21:25:36 Maybe this should be stored in the base class as w
msarett 2015/08/14 15:44:48 fOptions is now stored in the base class.
+
+ return SkCodec::kSuccess;
+}
+
+SkCodec::Result SkBmpMaskScanlineDecoder::onGetScanlines(void* dst,
+ int count, size_t rowBytes) {
+ // Create a new image info representing the portion of the image to decode
+ SkImageInfo rowInfo = fDstInfo.makeWH(dstInfo().width(), count);
scroggo 2015/08/13 21:25:35 nit: this->dstInfo()...
msarett 2015/08/14 15:44:48 Done.
+
+ // Decode the requested rows
+ SkCodec::Result r = fCodec->decode(rowInfo, dst, rowBytes, fOpts);
+}

Powered by Google App Engine
This is Rietveld 408576698