aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2015-10-09 08:40:59 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-09 08:40:59 -0700
commit2c3b218f74aa0ccd544a73feb506a0be56d90abe (patch)
tree123b2ad26b902a119f2192e6c9d7cb2072fa295e /src/codec
parent0a3cac8a90e4aed24555815a43fafd53aed009ee (diff)
Focus SkScaledCodec on BitmapRegionDecoder
The primary goal of SkScaledCodec is to replace the current implementation of BitmapRegionDecoder, which depends on modified versions of libjpeg and libpng, with an implementation that uses standard versions of the libaries. Since BitmapRegionDecoder only supports PNG, WEBP and JPEG, limit SkScaledCodec to those classes. We will focus on those three until we complete this primary goal. Then we can continue to make SkScaledCodec work for other formats. Fix some bugs in SkScaledCodec::NewFromStream: - Handle a NULL input stream properly - Ensure that the input stream is deleted as expected on bad data Add tests for these error cases. BUG=skia:4428 Review URL: https://codereview.chromium.org/1389053002
Diffstat (limited to 'src/codec')
-rw-r--r--src/codec/SkScaledCodec.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/codec/SkScaledCodec.cpp b/src/codec/SkScaledCodec.cpp
index 65fd93c8c0..fc51613f31 100644
--- a/src/codec/SkScaledCodec.cpp
+++ b/src/codec/SkScaledCodec.cpp
@@ -12,22 +12,25 @@
SkCodec* SkScaledCodec::NewFromStream(SkStream* stream) {
- bool isWebp = SkWebpCodec::IsWebp(stream);
- if (!stream->rewind()) {
- return nullptr;
- }
- if (isWebp) {
- // Webp codec supports scaling and subsetting natively
- return SkWebpCodec::NewFromStream(stream);
- }
-
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream));
if (nullptr == codec) {
return nullptr;
}
- // wrap in new SkScaledCodec
- return new SkScaledCodec(codec.detach());
+ switch (codec->getEncodedFormat()) {
+ case kWEBP_SkEncodedFormat:
+ // Webp codec supports scaling and subsetting natively
+ return codec.detach();
+ case kPNG_SkEncodedFormat:
+ case kJPEG_SkEncodedFormat:
+ // wrap in new SkScaledCodec
+ return new SkScaledCodec(codec.detach());
+ default:
+ // FIXME: SkScaledCodec is temporarily disabled for other formats
+ // while focusing on the formats that are supported by
+ // BitmapRegionDecoder.
+ return nullptr;
+ }
}
SkCodec* SkScaledCodec::NewFromData(SkData* data) {