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

Unified Diff: src/codec/SkJpegCodec.cpp

Issue 1267543002: Make SkSwizzler::Fill() support 565 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Check if pixel memory is zero initialized Created 5 years, 5 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
« no previous file with comments | « no previous file | src/codec/SkSwizzler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkJpegCodec.cpp
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 5acc0b396c54d34abb922f80687104b54f85990a..84e90d444249142d69a68cd52cab59cebb37c30a 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -354,7 +354,14 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
// the fill color for opaque images. If the destination is kGray,
// the low 8 bits of SK_ColorBLACK will be used. Conveniently,
// these are zeros, which is the representation for black in kGray.
- SkSwizzler::Fill(dstRow, dstInfo, dstRowBytes, dstHeight - y, SK_ColorBLACK, NULL);
+ // If the destination is kRGB_565, the low 16 bits of SK_ColorBLACK
+ // will be used. Conveniently, these are zeros, which is the
+ // representation for black in kRGB_565.
+ if (kNo_ZeroInitialized == options.fZeroInitialized ||
+ kN32_SkColorType == dstInfo.colorType()) {
+ SkSwizzler::Fill(dstRow, dstInfo, dstRowBytes, dstHeight - y,
+ SK_ColorBLACK, NULL);
+ }
// Prevent libjpeg from failing on incomplete decode
dinfo->output_scanline = dstHeight;
@@ -382,9 +389,11 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
*/
class SkJpegScanlineDecoder : public SkScanlineDecoder {
public:
- SkJpegScanlineDecoder(const SkImageInfo& dstInfo, SkJpegCodec* codec)
+ SkJpegScanlineDecoder(const SkImageInfo& dstInfo, SkJpegCodec* codec,
+ const SkCodec::Options& opts)
: INHERITED(dstInfo)
, fCodec(codec)
+ , fOpts(opts)
{}
virtual ~SkJpegScanlineDecoder() {
@@ -412,8 +421,11 @@ public:
uint32_t rowsDecoded =
turbo_jpeg_read_scanlines(fCodec->fDecoderMgr->dinfo(), &dstRow, 1);
if (rowsDecoded != 1) {
- SkSwizzler::Fill(
- dstRow, this->dstInfo(), rowBytes, count - y, SK_ColorBLACK, NULL);
+ if (SkCodec::kNo_ZeroInitialized == fOpts.fZeroInitialized ||
+ kN32_SkColorType == this->dstInfo().colorType()) {
+ SkSwizzler::Fill(dstRow, this->dstInfo(), rowBytes,
+ count - y, SK_ColorBLACK, NULL);
+ }
fCodec->fDecoderMgr->dinfo()->output_scanline = this->dstInfo().height();
return SkCodec::kIncompleteInput;
}
@@ -452,6 +464,7 @@ public:
private:
SkAutoTDelete<SkJpegCodec> fCodec;
+ const SkCodec::Options& fOpts;
scroggo 2015/08/03 18:41:24 I missed this when I first reviewed, but mention i
typedef SkScanlineDecoder INHERITED;
};
@@ -499,5 +512,5 @@ SkScanlineDecoder* SkJpegCodec::onGetScanlineDecoder(const SkImageInfo& dstInfo,
}
// Return the new scanline decoder
- return SkNEW_ARGS(SkJpegScanlineDecoder, (dstInfo, codec.detach()));
+ return SkNEW_ARGS(SkJpegScanlineDecoder, (dstInfo, codec.detach(), options));
}
« no previous file with comments | « no previous file | src/codec/SkSwizzler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698