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

Unified Diff: dm/DMSrcSink.cpp

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Stop DM from running large interlaced images on 32-bit Ubuntu GCE bots b/c they are running out of … Created 5 years, 4 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 | « dm/DM.cpp ('k') | gyp/codec.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index f555b9fcbdba78f485e47b9baf4be67d2fa1d83c..9826f978224d74dfc5f543164fc84bb0121f7a02 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 {
« no previous file with comments | « dm/DM.cpp ('k') | gyp/codec.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698