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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1017293002: guarded change to SkImageGenerator to make getInfo() const (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 unified diff | Download patch
OLDNEW
1 #include "DMSrcSink.h" 1 #include "DMSrcSink.h"
2 #include "SamplePipeControllers.h" 2 #include "SamplePipeControllers.h"
3 #include "SkCommonFlags.h" 3 #include "SkCommonFlags.h"
4 #include "SkCodec.h" 4 #include "SkCodec.h"
5 #include "SkDocument.h" 5 #include "SkDocument.h"
6 #include "SkError.h" 6 #include "SkError.h"
7 #include "SkMultiPictureDraw.h" 7 #include "SkMultiPictureDraw.h"
8 #include "SkNullCanvas.h" 8 #include "SkNullCanvas.h"
9 #include "SkOSFile.h" 9 #include "SkOSFile.h"
10 #include "SkPictureData.h" 10 #include "SkPictureData.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 const SkColorType dstColorType = canvas->imageInfo().colorType(); 49 const SkColorType dstColorType = canvas->imageInfo().colorType();
50 if (fDivisor == 0) { 50 if (fDivisor == 0) {
51 // Decode the full image. 51 // Decode the full image.
52 SkBitmap bitmap; 52 SkBitmap bitmap;
53 if (FLAGS_codec) { 53 if (FLAGS_codec) {
54 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); 54 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
55 if (!codec) { 55 if (!codec) {
56 return SkStringPrintf("Couldn't decode %s.", fPath.c_str()); 56 return SkStringPrintf("Couldn't decode %s.", fPath.c_str());
57 } 57 }
58 SkImageInfo info; 58 SkImageInfo info = codec->getInfo();
scroggo 2015/03/19 13:27:46 Yay! FYI: this (and the code in ImageSrc::size())
reed1 2015/03/19 15:20:45 Acknowledged.
59 if (!codec->getInfo(&info)) {
60 return SkStringPrintf("Couldn't getInfo %s.", fPath.c_str());
61 }
62 info = info.makeColorType(dstColorType); 59 info = info.makeColorType(dstColorType);
63 if (info.alphaType() == kUnpremul_SkAlphaType) { 60 if (info.alphaType() == kUnpremul_SkAlphaType) {
64 // FIXME: Currently we cannot draw unpremultiplied sources. 61 // FIXME: Currently we cannot draw unpremultiplied sources.
65 info = info.makeAlphaType(kPremul_SkAlphaType); 62 info = info.makeAlphaType(kPremul_SkAlphaType);
66 } 63 }
67 if (!bitmap.tryAllocPixels(info)) { 64 if (!bitmap.tryAllocPixels(info)) {
68 return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPat h.c_str(), 65 return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPat h.c_str(),
69 info.width(), info.height()); 66 info.width(), info.height());
70 } 67 }
71 SkAutoLockPixels alp(bitmap); 68 SkAutoLockPixels alp(bitmap);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return ""; 136 return "";
140 } 137 }
141 138
142 SkISize ImageSrc::size() const { 139 SkISize ImageSrc::size() const {
143 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); 140 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
144 if (FLAGS_codec) { 141 if (FLAGS_codec) {
145 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); 142 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
146 if (!codec) { 143 if (!codec) {
147 return SkISize::Make(0,0); 144 return SkISize::Make(0,0);
148 } 145 }
149 SkImageInfo info; 146 return codec->getInfo().dimensions();
150 if (!codec->getInfo(&info)) {
151 return SkISize::Make(0,0);
152 }
153 return info.dimensions();
154 } else { 147 } else {
155 SkBitmap bitmap; 148 SkBitmap bitmap;
156 if (!encoded || !SkImageDecoder::DecodeMemory(encoded->data(), 149 if (!encoded || !SkImageDecoder::DecodeMemory(encoded->data(),
157 encoded->size(), 150 encoded->size(),
158 &bitmap, 151 &bitmap,
159 kUnknown_SkColorType, 152 kUnknown_SkColorType,
160 SkImageDecoder::kDecodeBou nds_Mode)) { 153 SkImageDecoder::kDecodeBou nds_Mode)) {
161 return SkISize::Make(0,0); 154 return SkISize::Make(0,0);
162 } 155 }
163 return bitmap.dimensions(); 156 return bitmap.dimensions();
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 surfaces.unrefAll(); 550 surfaces.unrefAll();
558 return ""; 551 return "";
559 } 552 }
560 SkISize size() const SK_OVERRIDE { return fSize; } 553 SkISize size() const SK_OVERRIDE { return fSize; }
561 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this. 554 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this.
562 } proxy(fW, fH, pic, src.size()); 555 } proxy(fW, fH, pic, src.size());
563 return fSink->draw(proxy, bitmap, stream, log); 556 return fSink->draw(proxy, bitmap, stream, log);
564 } 557 }
565 558
566 } // namespace DM 559 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | gyp/skia_for_android_framework_defines.gypi » ('j') | gyp/skia_for_android_framework_defines.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698