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

Unified Diff: dm/DMSrcSink.cpp

Issue 1016443003: Revert "Revert of fix for invalid for loop syntax broke build (patchset #1 id:1 of https://coderevi… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | 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 91f4e238c28b2aa96ec761b019f3816ffc8f171f..6f6664f27ce2266bd12156f1ae973cada399ec25 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -141,15 +141,27 @@ Error ImageSrc::draw(SkCanvas* canvas) const {
SkISize ImageSrc::size() const {
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
- SkBitmap bitmap;
- if (!encoded || !SkImageDecoder::DecodeMemory(encoded->data(),
- encoded->size(),
- &bitmap,
- kUnknown_SkColorType,
- SkImageDecoder::kDecodeBounds_Mode)) {
- return SkISize::Make(0,0);
+ if (FLAGS_codec) {
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
+ if (!codec) {
+ return SkISize::Make(0,0);
+ }
+ SkImageInfo info;
+ if (!codec->getInfo(&info)) {
+ return SkISize::Make(0,0);
+ }
+ return info.dimensions();
+ } else {
+ SkBitmap bitmap;
+ if (!encoded || !SkImageDecoder::DecodeMemory(encoded->data(),
+ encoded->size(),
+ &bitmap,
+ kUnknown_SkColorType,
+ SkImageDecoder::kDecodeBounds_Mode)) {
+ return SkISize::Make(0,0);
+ }
+ return bitmap.dimensions();
}
- return bitmap.dimensions();
}
Name ImageSrc::name() const {
« no previous file with comments | « no previous file | gyp/codec.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698