diff options
author | 2015-08-13 11:26:57 -0700 | |
---|---|---|
committer | 2015-08-13 11:26:57 -0700 | |
commit | 0944100ac89f797714eeae0cf2875e2335ff52ee (patch) | |
tree | 4eecdf5aa0aa3c0285b319c63b148fd672c2508b /dm/DMSrcSink.cpp | |
parent | e516e4fa2b681dc97775c1581eef38d7559f33d1 (diff) |
SkScaledCodec class
This class does scaling by using a scanlineDecoder.
getScanlines and skipScanlines are used for y sampling,
the swizzler is used for x sampling
this class is currently only working for png and jpeg images
I will update other Codec types to work soon
For SkJpegCodec to implement width wise swizzling it now
uses a swizzler. I ran performance tests on this change.
Here are the performance test results:
https://docs.google.com/a/google.com/spreadsheets/d/1D7-Q_GXD_dI68LZO005NNvb8Wq2Ee0wEBEPG72671yw/edit?usp=sharing
BUG=skia:
Review URL: https://codereview.chromium.org/1260673002
Diffstat (limited to 'dm/DMSrcSink.cpp')
-rw-r--r-- | dm/DMSrcSink.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index f555b9fcbd..9826f97822 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -27,6 +27,7 @@ #include "SkScanlineDecoder.h" #include "SkStream.h" #include "SkXMLWriter.h" +#include "SkScaledCodec.h" DEFINE_bool(multiPage, false, "For document-type backends, render the source" " into multiple pages"); @@ -84,9 +85,13 @@ Error CodecSrc::draw(SkCanvas* canvas) const { if (!encoded) { return SkStringPrintf("Couldn't read %s.", fPath.c_str()); } - SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); + SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded)); if (NULL == codec.get()) { - return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str()); + // scaledCodec not supported, try normal codec + codec.reset(SkCodec::NewFromData(encoded)); + if (NULL == codec.get()) { + return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str()); + } } // Choose the color type to decode to @@ -446,13 +451,16 @@ Error CodecSrc::draw(SkCanvas* canvas) const { SkISize CodecSrc::size() const { SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); - SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); - if (NULL != codec) { - SkISize size = codec->getScaledDimensions(fScale); - return size; - } else { - return SkISize::Make(0, 0); + SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromData(encoded)); + if (NULL == codec) { + // scaledCodec not supported, try regular codec + codec.reset(SkCodec::NewFromData(encoded)); + if (NULL == codec) { + return SkISize::Make(0, 0); + } } + SkISize size = codec->getScaledDimensions(fScale); + return size; } Name CodecSrc::name() const { |