Fix bug testing SkCodec for ICO

Looking in Gold, I see some ICO images that only show the upper left
corner of the originals. It is happening because we use different ways
of deciding what the dimensions are:

In CodecSrc::size(), we use an SkScaledCodec to get the dimensions,
even when fMode is not kScaledCodec_Mode.

In CodecSrc::draw(), we only use SkScaledCodec in kScaledCodec_Mode.

My recent CL to combine SkScanlineDecoder with SkCodec revealed this
bug, because now SkScaledCodec::NewFromStream will succeed on ICO.
(Previously, it failed because we do not yet have a scanline decoder
for ICO (skbug.com/4404). Now that they are combined, we would need
to specially flag ICO to stop returning an SkScaledCodec.)

Switch size() to use the correct type of codec.

Review URL: https://codereview.chromium.org/1373253004
This commit is contained in:
scroggo 2015-09-30 11:33:12 -07:00 committed by Commit bot
parent 56c6a117b2
commit 7fac5af5e9

View File

@ -641,16 +641,18 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
SkISize CodecSrc::size() const {
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded));
if (nullptr == codec) {
// scaledCodec not supported, try regular codec
SkAutoTDelete<SkCodec> codec(nullptr);
if (kScaledCodec_Mode == fMode) {
codec.reset(SkScaledCodec::NewFromData(encoded));
} else {
codec.reset(SkCodec::NewFromData(encoded));
}
if (nullptr == codec) {
return SkISize::Make(0, 0);
}
}
SkISize size = codec->getScaledDimensions(fScale);
return size;
return codec->getScaledDimensions(fScale);
}
Name CodecSrc::name() const {