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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 947283002: Bmp Image Decoding (Closed) Base URL: https://skia.googlesource.com/skia.git@decode-leon-3
Patch Set: separate swizzler for masks 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
« no previous file with comments | « no previous file | gyp/codec.gyp » ('j') | src/codec/SkCodec_libbmp.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkMultiPictureDraw.h" 6 #include "SkMultiPictureDraw.h"
7 #include "SkNullCanvas.h" 7 #include "SkNullCanvas.h"
8 #include "SkOSFile.h" 8 #include "SkOSFile.h"
9 #include "SkPictureRecorder.h" 9 #include "SkPictureRecorder.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 info = info.makeColorType(dstColorType); 60 info = info.makeColorType(dstColorType);
61 if (info.alphaType() == kUnpremul_SkAlphaType) { 61 if (info.alphaType() == kUnpremul_SkAlphaType) {
62 // FIXME: Currently we cannot draw unpremultiplied sources. 62 // FIXME: Currently we cannot draw unpremultiplied sources.
63 info = info.makeAlphaType(kPremul_SkAlphaType); 63 info = info.makeAlphaType(kPremul_SkAlphaType);
64 } 64 }
65 bitmap.allocPixels(info); 65 bitmap.allocPixels(info);
66 SkAutoLockPixels alp(bitmap); 66 SkAutoLockPixels alp(bitmap);
67 const SkImageGenerator::Result result = codec->getPixels(info, bitma p.getPixels(), 67 const SkImageGenerator::Result result = codec->getPixels(info, bitma p.getPixels(),
68 bitmap.rowB ytes()); 68 bitmap.rowB ytes());
69 if (result != SkImageGenerator::kSuccess) { 69 if (result != SkImageGenerator::kSuccess &&
70 result != SkImageGenerator::kIncompleteInput) {
70 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str()); 71 return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str());
71 } 72 }
72 } else { 73 } else {
73 if (!SkImageDecoder::DecodeMemory(encoded->data(), encoded->size(), &bitmap, 74 if (!SkImageDecoder::DecodeMemory(encoded->data(), encoded->size(), &bitmap,
74 dstColorType, SkImageDecoder::kDec odePixels_Mode)) { 75 dstColorType, SkImageDecoder::kDec odePixels_Mode)) {
75 return SkStringPrintf("Couldn't decode %s.", fPath.c_str()); 76 return SkStringPrintf("Couldn't decode %s.", fPath.c_str());
76 } 77 }
77 } 78 }
78 encoded.reset((SkData*)NULL); // Might as well drop this when we're don e with it. 79 encoded.reset((SkData*)NULL); // Might as well drop this when we're don e with it.
79 canvas->drawBitmap(bitmap, 0,0); 80 canvas->drawBitmap(bitmap, 0,0);
(...skipping 27 matching lines...) Expand all
107 x, y, x+subsetWidth, y+subsetHeight); 108 x, y, x+subsetWidth, y+subsetHeight);
108 } 109 }
109 canvas->drawBitmap(subset, SkIntToScalar(x), SkIntToScalar(y)); 110 canvas->drawBitmap(subset, SkIntToScalar(x), SkIntToScalar(y));
110 } 111 }
111 } 112 }
112 return ""; 113 return "";
113 } 114 }
114 115
115 SkISize ImageSrc::size() const { 116 SkISize ImageSrc::size() const {
116 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); 117 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
117 SkBitmap bitmap; 118 if (FLAGS_codec) {
msarett 2015/03/07 00:19:50 I couldn't figure out how to get rid of these chan
118 if (!encoded || !SkImageDecoder::DecodeMemory(encoded->data(), 119 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
119 encoded->size(), 120 if (!codec) {
120 &bitmap, 121 return SkISize::Make(0,0);
121 kUnknown_SkColorType, 122 }
122 SkImageDecoder::kDecodeBounds_ Mode)) { 123 SkImageInfo info;
123 return SkISize::Make(0,0); 124 if (!codec->getInfo(&info)) {
125 return SkISize::Make(0,0);
126 }
127 return info.dimensions();
128 } else {
129 SkBitmap bitmap;
130 if (!encoded || !SkImageDecoder::DecodeMemory(encoded->data(),
131 encoded->size(),
132 &bitmap,
133 kUnknown_SkColorType,
134 SkImageDecoder::kDecodeBou nds_Mode)) {
135 return SkISize::Make(0,0);
136 }
137 return bitmap.dimensions();
124 } 138 }
125 return bitmap.dimensions();
126 } 139 }
127 140
128 Name ImageSrc::name() const { 141 Name ImageSrc::name() const {
129 return SkOSPath::Basename(fPath.c_str()); 142 return SkOSPath::Basename(fPath.c_str());
130 } 143 }
131 144
132 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 145 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
133 146
134 static const SkRect kSKPViewport = {0,0, 1000,1000}; 147 static const SkRect kSKPViewport = {0,0, 1000,1000};
135 148
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 surfaces.unrefAll(); 496 surfaces.unrefAll();
484 return ""; 497 return "";
485 } 498 }
486 SkISize size() const SK_OVERRIDE { return fSize; } 499 SkISize size() const SK_OVERRIDE { return fSize; }
487 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this. 500 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this.
488 } proxy(fW, fH, pic, src.size()); 501 } proxy(fW, fH, pic, src.size());
489 return fSink->draw(proxy, bitmap, stream, log); 502 return fSink->draw(proxy, bitmap, stream, log);
490 } 503 }
491 504
492 } // namespace DM 505 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | gyp/codec.gyp » ('j') | src/codec/SkCodec_libbmp.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698