| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkCommandLineFlags.h" | 10 #include "SkCommandLineFlags.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 stream.rewind(); | 176 stream.rewind(); |
| 177 if (!codec->decode(&stream, &bitmap, SkBitmap::kARGB_8888_Config, | 177 if (!codec->decode(&stream, &bitmap, SkBitmap::kARGB_8888_Config, |
| 178 SkImageDecoder::kDecodePixels_Mode)) { | 178 SkImageDecoder::kDecodePixels_Mode)) { |
| 179 gDecodeFailures.push_back().set(srcPath); | 179 gDecodeFailures.push_back().set(srcPath); |
| 180 return; | 180 return; |
| 181 } | 181 } |
| 182 | 182 |
| 183 gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.width(),
bitmap.height()); | 183 gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.width(),
bitmap.height()); |
| 184 | 184 |
| 185 if (FLAGS_testSubsetDecoding) { | 185 if (FLAGS_testSubsetDecoding) { |
| 186 bool couldRewind = stream.rewind(); | 186 SkDEBUGCODE(bool couldRewind =) stream.rewind(); |
| 187 SkASSERT(couldRewind); | 187 SkASSERT(couldRewind); |
| 188 int width, height; | 188 int width, height; |
| 189 // Build the tile index for decoding subsets. If the image is 1x1, skip
subset | 189 // Build the tile index for decoding subsets. If the image is 1x1, skip
subset |
| 190 // decoding since there are no smaller subsets. | 190 // decoding since there are no smaller subsets. |
| 191 if (codec->buildTileIndex(&stream, &width, &height) && width > 1 && heig
ht > 1) { | 191 if (codec->buildTileIndex(&stream, &width, &height) && width > 1 && heig
ht > 1) { |
| 192 SkASSERT(bitmap.width() == width && bitmap.height() == height); | 192 SkASSERT(bitmap.width() == width && bitmap.height() == height); |
| 193 // Call decodeSubset multiple times: | 193 // Call decodeSubset multiple times: |
| 194 SkRandom rand(0); | 194 SkRandom rand(0); |
| 195 for (int i = 0; i < 5; i++) { | 195 for (int i = 0; i < 5; i++) { |
| 196 SkBitmap bitmapFromDecodeSubset; | 196 SkBitmap bitmapFromDecodeSubset; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 208 make_outname(&outPath, writePath->c_str(), srcPath, suff
ix.c_str()); | 208 make_outname(&outPath, writePath->c_str(), srcPath, suff
ix.c_str()); |
| 209 SkDEBUGCODE(bool success =) | 209 SkDEBUGCODE(bool success =) |
| 210 write_bitmap(outPath.c_str(), &bitmapFromDecodeSubset); | 210 write_bitmap(outPath.c_str(), &bitmapFromDecodeSubset); |
| 211 SkASSERT(success); | 211 SkASSERT(success); |
| 212 gSuccessfulSubsetDecodes.push_back().printf("\twrote %s"
, outPath.c_str()); | 212 gSuccessfulSubsetDecodes.push_back().printf("\twrote %s"
, outPath.c_str()); |
| 213 // Also use extractSubset from the original for visual c
omparison. | 213 // Also use extractSubset from the original for visual c
omparison. |
| 214 SkBitmap extractedSubset; | 214 SkBitmap extractedSubset; |
| 215 if (bitmap.extractSubset(&extractedSubset, rect)) { | 215 if (bitmap.extractSubset(&extractedSubset, rect)) { |
| 216 suffix.printf("_%s_extracted.png", subsetDim.c_str()
); | 216 suffix.printf("_%s_extracted.png", subsetDim.c_str()
); |
| 217 make_outname(&outPath, writePath->c_str(), srcPath,
suffix.c_str()); | 217 make_outname(&outPath, writePath->c_str(), srcPath,
suffix.c_str()); |
| 218 success = write_bitmap(outPath.c_str(), &extractedSu
bset); | 218 SkDEBUGCODE(success =) write_bitmap(outPath.c_str(),
&extractedSubset); |
| 219 SkASSERT(success); | 219 SkASSERT(success); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 } else { | 222 } else { |
| 223 gFailedSubsetDecodes.push_back().printf("Failed to decode re
gion %s from %s\n", | 223 gFailedSubsetDecodes.push_back().printf("Failed to decode re
gion %s from %s\n", |
| 224 subsetDim.c_str(), s
rcPath); | 224 subsetDim.c_str(), s
rcPath); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 } | 228 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 } | 384 } |
| 385 | 385 |
| 386 return failed ? -1 : 0; | 386 return failed ? -1 : 0; |
| 387 } | 387 } |
| 388 | 388 |
| 389 #if !defined SK_BUILD_FOR_IOS | 389 #if !defined SK_BUILD_FOR_IOS |
| 390 int main(int argc, char * const argv[]) { | 390 int main(int argc, char * const argv[]) { |
| 391 return tool_main(argc, (char**) argv); | 391 return tool_main(argc, (char**) argv); |
| 392 } | 392 } |
| 393 #endif | 393 #endif |
| OLD | NEW |