aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2015-09-30 11:33:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-30 11:33:12 -0700
commit7fac5af5e9310826721ff416bdbe71294d607b2a (patch)
treeb199371e4f4e00d5a8f870ec5872a05d04c9ba22
parent56c6a117b222aa7d94843cfe6058e085d4394d97 (diff)
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
-rw-r--r--dm/DMSrcSink.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 2e22556335..d98a9cab7a 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -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;
+
+ if (nullptr == codec) {
+ return SkISize::Make(0, 0);
+ }
+ return codec->getScaledDimensions(fScale);
}
Name CodecSrc::name() const {