epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 7 | |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 8 | #include "gm_expectations.h" |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 9 | #include "SkBitmap.h" |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 10 | #include "SkColorPriv.h" |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 11 | #include "SkCommandLineFlags.h" |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 12 | #include "SkData.h" |
scroggo@google.com | 7def5e1 | 2013-05-31 14:00:10 +0000 | [diff] [blame] | 13 | #include "SkForceLinking.h" |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 14 | #include "SkGraphics.h" |
| 15 | #include "SkImageDecoder.h" |
| 16 | #include "SkImageEncoder.h" |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 17 | #include "SkOSFile.h" |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 18 | #include "SkRandom.h" |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 19 | #include "SkStream.h" |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 20 | #include "SkTArray.h" |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 21 | #include "SkTemplates.h" |
| 22 | |
scroggo@google.com | 7def5e1 | 2013-05-31 14:00:10 +0000 | [diff] [blame] | 23 | __SK_FORCE_IMAGE_DECODER_LINKING; |
| 24 | |
scroggo@google.com | 6d99de1 | 2013-08-06 18:56:53 +0000 | [diff] [blame] | 25 | DEFINE_string(config, "None", "Preferred config to decode into. [None|8888|565|A8]"); |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 26 | DEFINE_string(createExpectationsPath, "", "Path to write JSON expectations."); |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 27 | DEFINE_string(mismatchPath, "", "Folder to write mismatched images to."); |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 28 | DEFINE_string2(readPath, r, "", "Folder(s) and files to decode images. Required."); |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 29 | DEFINE_string(readExpectationsPath, "", "Path to read JSON expectations from."); |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 30 | DEFINE_bool(reencode, true, "Reencode the images to test encoding."); |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 31 | DEFINE_bool(testSubsetDecoding, true, "Test decoding subsets of images."); |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 32 | DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 33 | |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 34 | struct Format { |
| 35 | SkImageEncoder::Type fType; |
| 36 | SkImageDecoder::Format fFormat; |
| 37 | const char* fSuffix; |
| 38 | }; |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 39 | |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 40 | static const Format gFormats[] = { |
| 41 | { SkImageEncoder::kBMP_Type, SkImageDecoder::kBMP_Format, ".bmp" }, |
| 42 | { SkImageEncoder::kGIF_Type, SkImageDecoder::kGIF_Format, ".gif" }, |
| 43 | { SkImageEncoder::kICO_Type, SkImageDecoder::kICO_Format, ".ico" }, |
| 44 | { SkImageEncoder::kJPEG_Type, SkImageDecoder::kJPEG_Format, ".jpg" }, |
| 45 | { SkImageEncoder::kPNG_Type, SkImageDecoder::kPNG_Format, ".png" }, |
| 46 | { SkImageEncoder::kWBMP_Type, SkImageDecoder::kWBMP_Format, ".wbmp" }, |
| 47 | { SkImageEncoder::kWEBP_Type, SkImageDecoder::kWEBP_Format, ".webp" } |
| 48 | }; |
| 49 | |
| 50 | static SkImageEncoder::Type format_to_type(SkImageDecoder::Format format) { |
| 51 | for (size_t i = 0; i < SK_ARRAY_COUNT(gFormats); i++) { |
| 52 | if (gFormats[i].fFormat == format) { |
| 53 | return gFormats[i].fType; |
| 54 | } |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 55 | } |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 56 | return SkImageEncoder::kUnknown_Type; |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 57 | } |
| 58 | |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 59 | static const char* suffix_for_type(SkImageEncoder::Type type) { |
| 60 | for (size_t i = 0; i < SK_ARRAY_COUNT(gFormats); i++) { |
| 61 | if (gFormats[i].fType == type) { |
| 62 | return gFormats[i].fSuffix; |
| 63 | } |
| 64 | } |
| 65 | return ""; |
| 66 | } |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 67 | |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 68 | static SkImageDecoder::Format guess_format_from_suffix(const char suffix[]) { |
| 69 | for (size_t i = 0; i < SK_ARRAY_COUNT(gFormats); i++) { |
| 70 | if (strcmp(suffix, gFormats[i].fSuffix) == 0) { |
| 71 | return gFormats[i].fFormat; |
| 72 | } |
| 73 | } |
| 74 | return SkImageDecoder::kUnknown_Format; |
| 75 | } |
| 76 | |
| 77 | static void make_outname(SkString* dst, const char outDir[], const char src[], |
| 78 | const char suffix[]) { |
scroggo@google.com | ccd7afb | 2013-05-28 16:45:07 +0000 | [diff] [blame] | 79 | SkString basename = SkOSPath::SkBasename(src); |
| 80 | dst->set(SkOSPath::SkPathJoin(outDir, basename.c_str())); |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 81 | if (!dst->endsWith(suffix)) { |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 82 | const char* cstyleDst = dst->c_str(); |
| 83 | const char* dot = strrchr(cstyleDst, '.'); |
| 84 | if (dot != NULL) { |
| 85 | int32_t index = SkToS32(dot - cstyleDst); |
| 86 | dst->remove(index, dst->size() - index); |
| 87 | } |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 88 | dst->append(suffix); |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 92 | // Store the names of the filenames to report later which ones failed, succeeded, and were |
| 93 | // invalid. |
| 94 | static SkTArray<SkString, false> gInvalidStreams; |
| 95 | static SkTArray<SkString, false> gMissingCodecs; |
| 96 | static SkTArray<SkString, false> gDecodeFailures; |
| 97 | static SkTArray<SkString, false> gEncodeFailures; |
| 98 | static SkTArray<SkString, false> gSuccessfulDecodes; |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 99 | static SkTArray<SkString, false> gSuccessfulSubsetDecodes; |
| 100 | static SkTArray<SkString, false> gFailedSubsetDecodes; |
scroggo@google.com | e339eb0 | 2013-08-06 18:51:30 +0000 | [diff] [blame] | 101 | // Files/subsets that do not have expectations. Not reported as a failure of the test so |
| 102 | // the bots will not turn red with each new image test. |
| 103 | static SkTArray<SkString, false> gMissingExpectations; |
| 104 | static SkTArray<SkString, false> gMissingSubsetExpectations; |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 105 | |
scroggo@google.com | 6d99de1 | 2013-08-06 18:56:53 +0000 | [diff] [blame] | 106 | static SkBitmap::Config gPrefConfig(SkBitmap::kNo_Config); |
| 107 | |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 108 | // Expections read from a file specified by readExpectationsPath. The expectations must have been |
| 109 | // previously written using createExpectationsPath. |
| 110 | SkAutoTUnref<skiagm::JsonExpectationsSource> gJsonExpectations; |
| 111 | |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 112 | static bool write_bitmap(const char outName[], const SkBitmap& bm) { |
| 113 | return SkImageEncoder::EncodeFile(outName, bm, SkImageEncoder::kPNG_Type, 100); |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 114 | } |
| 115 | |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 116 | /** |
| 117 | * Return a random SkIRect inside the range specified. |
| 118 | * @param rand Random number generator. |
| 119 | * @param maxX Exclusive maximum x-coordinate. SkIRect's fLeft and fRight will be |
| 120 | * in the range [0, maxX) |
| 121 | * @param maxY Exclusive maximum y-coordinate. SkIRect's fTop and fBottom will be |
| 122 | * in the range [0, maxY) |
| 123 | * @return SkIRect Non-empty, non-degenerate rectangle. |
| 124 | */ |
| 125 | static SkIRect generate_random_rect(SkRandom* rand, int32_t maxX, int32_t maxY) { |
| 126 | SkASSERT(maxX > 1 && maxY > 1); |
| 127 | int32_t left = rand->nextULessThan(maxX); |
| 128 | int32_t right = rand->nextULessThan(maxX); |
| 129 | int32_t top = rand->nextULessThan(maxY); |
| 130 | int32_t bottom = rand->nextULessThan(maxY); |
| 131 | SkIRect rect = SkIRect::MakeLTRB(left, top, right, bottom); |
| 132 | rect.sort(); |
| 133 | // Make sure rect is not empty. |
| 134 | if (rect.fLeft == rect.fRight) { |
| 135 | if (rect.fLeft > 0) { |
| 136 | rect.fLeft--; |
| 137 | } else { |
| 138 | rect.fRight++; |
| 139 | // This branch is only taken if 0 == rect.fRight, and |
| 140 | // maxX must be at least 2, so it must still be in |
| 141 | // range. |
| 142 | SkASSERT(rect.fRight < maxX); |
| 143 | } |
| 144 | } |
| 145 | if (rect.fTop == rect.fBottom) { |
| 146 | if (rect.fTop > 0) { |
| 147 | rect.fTop--; |
| 148 | } else { |
| 149 | rect.fBottom++; |
| 150 | // Again, this must be in range. |
| 151 | SkASSERT(rect.fBottom < maxY); |
| 152 | } |
| 153 | } |
| 154 | return rect; |
| 155 | } |
| 156 | |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 157 | // Stored expectations to be written to a file if createExpectationsPath is specified. |
| 158 | static Json::Value gExpectationsToWrite; |
| 159 | |
| 160 | /** |
epoger@google.com | d4993ff | 2013-05-24 14:33:28 +0000 | [diff] [blame] | 161 | * If expectations are to be recorded, record the bitmap expectations into global |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 162 | * expectations array. |
| 163 | */ |
| 164 | static void write_expectations(const SkBitmap& bitmap, const char* filename) { |
| 165 | if (!FLAGS_createExpectationsPath.isEmpty()) { |
| 166 | // Creates an Expectations object, and add it to the list to write. |
| 167 | skiagm::Expectations expectation(bitmap); |
| 168 | Json::Value value = expectation.asJsonValue(); |
| 169 | gExpectationsToWrite[filename] = value; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /** |
scroggo@google.com | bc91e8b | 2013-06-27 20:21:01 +0000 | [diff] [blame] | 174 | * Return true if this filename is a known failure, and therefore a failure |
| 175 | * to decode should be ignored. |
| 176 | */ |
| 177 | static bool expect_to_fail(const char* filename) { |
| 178 | if (NULL == gJsonExpectations.get()) { |
| 179 | return false; |
| 180 | } |
| 181 | skiagm::Expectations jsExpectations = gJsonExpectations->get(filename); |
| 182 | return jsExpectations.ignoreFailure(); |
| 183 | } |
| 184 | |
| 185 | /** |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 186 | * Compare against an expectation for this filename, if there is one. |
| 187 | * @param bitmap SkBitmap to compare to the expected value. |
| 188 | * @param filename String used to find the expected value. |
scroggo@google.com | e339eb0 | 2013-08-06 18:51:30 +0000 | [diff] [blame] | 189 | * @param failureArray Array to add a failure message to on failure. |
| 190 | * @param missingArray Array to add missing expectation to on failure. |
scroggo@google.com | 6ca30ca | 2013-05-14 17:30:17 +0000 | [diff] [blame] | 191 | * @return bool True in any of these cases: |
| 192 | * - the bitmap matches the expectation. |
scroggo@google.com | 6ca30ca | 2013-05-14 17:30:17 +0000 | [diff] [blame] | 193 | * False in any of these cases: |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 194 | * - there is no expectations file. |
scroggo@google.com | 6ca30ca | 2013-05-14 17:30:17 +0000 | [diff] [blame] | 195 | * - there is an expectations file, but no expectation for this bitmap. |
| 196 | * - there is an expectation for this bitmap, but it did not match. |
| 197 | * - expectation could not be computed from the bitmap. |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 198 | */ |
| 199 | static bool compare_to_expectations_if_necessary(const SkBitmap& bitmap, const char* filename, |
scroggo@google.com | e339eb0 | 2013-08-06 18:51:30 +0000 | [diff] [blame] | 200 | SkTArray<SkString, false>* failureArray, |
| 201 | SkTArray<SkString, false>* missingArray) { |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 202 | skiagm::GmResultDigest resultDigest(bitmap); |
| 203 | if (!resultDigest.isValid()) { |
| 204 | if (failureArray != NULL) { |
| 205 | failureArray->push_back().printf("decoded %s, but could not create a GmResultDigest.", |
| 206 | filename); |
| 207 | } |
| 208 | return false; |
| 209 | } |
| 210 | |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 211 | if (NULL == gJsonExpectations.get()) { |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 212 | return false; |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | skiagm::Expectations jsExpectation = gJsonExpectations->get(filename); |
| 216 | if (jsExpectation.empty()) { |
scroggo@google.com | e339eb0 | 2013-08-06 18:51:30 +0000 | [diff] [blame] | 217 | if (missingArray != NULL) { |
| 218 | missingArray->push_back().printf("decoded %s, but could not find expectation.", |
scroggo@google.com | 6ca30ca | 2013-05-14 17:30:17 +0000 | [diff] [blame] | 219 | filename); |
| 220 | } |
| 221 | return false; |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 222 | } |
| 223 | |
epoger@google.com | d4993ff | 2013-05-24 14:33:28 +0000 | [diff] [blame] | 224 | if (jsExpectation.match(resultDigest)) { |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 225 | return true; |
| 226 | } |
| 227 | |
| 228 | if (failureArray != NULL) { |
| 229 | failureArray->push_back().printf("decoded %s, but the result does not match " |
| 230 | "expectations.", |
| 231 | filename); |
| 232 | } |
| 233 | return false; |
| 234 | } |
| 235 | |
scroggo@google.com | 9da0e1d | 2013-05-15 18:14:36 +0000 | [diff] [blame] | 236 | /** |
| 237 | * Helper function to write a bitmap subset to a file. Only called if subsets were created |
| 238 | * and a writePath was provided. Creates a subdirectory called 'subsets' and writes a PNG to |
| 239 | * that directory. Also creates a subdirectory called 'extracted' and writes a bitmap created |
| 240 | * using extractSubset to a PNG in that directory. Both files will represent the same |
| 241 | * subrectangle and have the same name for comparison. |
| 242 | * @param writePath Parent directory to hold the folders for the PNG files to write. Must |
| 243 | * not be NULL. |
| 244 | * @param filename Basename of the original file. Used to name the new files. Must not be |
| 245 | * NULL. |
| 246 | * @param subsetDim String representing the dimensions of the subset. Used to name the new |
| 247 | * files. Must not be NULL. |
| 248 | * @param bitmapFromDecodeSubset Pointer to SkBitmap created by SkImageDecoder::DecodeSubset, |
| 249 | * using rect as the area to decode. |
| 250 | * @param rect Rectangle of the area decoded into bitmapFromDecodeSubset. Used to call |
| 251 | * extractSubset on originalBitmap to create a bitmap with the same dimensions/pixels as |
| 252 | * bitmapFromDecodeSubset (assuming decodeSubset worked properly). |
| 253 | * @param originalBitmap SkBitmap decoded from the same stream as bitmapFromDecodeSubset, |
| 254 | * using SkImageDecoder::decode to get the entire image. Used to create a PNG file for |
| 255 | * comparison to the PNG created by bitmapFromDecodeSubset. |
| 256 | * @return bool Whether the function succeeded at drawing the decoded subset and the extracted |
| 257 | * subset to files. |
| 258 | */ |
| 259 | static bool write_subset(const char* writePath, const char* filename, const char* subsetDim, |
| 260 | SkBitmap* bitmapFromDecodeSubset, SkIRect rect, |
| 261 | const SkBitmap& originalBitmap) { |
| 262 | // All parameters must be valid. |
| 263 | SkASSERT(writePath != NULL); |
| 264 | SkASSERT(filename != NULL); |
| 265 | SkASSERT(subsetDim != NULL); |
| 266 | SkASSERT(bitmapFromDecodeSubset != NULL); |
| 267 | |
| 268 | // Create a subdirectory to hold the results of decodeSubset. |
scroggo@google.com | ccd7afb | 2013-05-28 16:45:07 +0000 | [diff] [blame] | 269 | SkString dir = SkOSPath::SkPathJoin(writePath, "subsets"); |
scroggo@google.com | 9da0e1d | 2013-05-15 18:14:36 +0000 | [diff] [blame] | 270 | if (!sk_mkdir(dir.c_str())) { |
| 271 | gFailedSubsetDecodes.push_back().printf("Successfully decoded %s from %s, but failed to " |
| 272 | "create a directory to write to.", subsetDim, |
| 273 | filename); |
| 274 | return false; |
| 275 | } |
| 276 | |
| 277 | // Write the subset to a file whose name includes the dimensions. |
| 278 | SkString suffix = SkStringPrintf("_%s.png", subsetDim); |
| 279 | SkString outPath; |
| 280 | make_outname(&outPath, dir.c_str(), filename, suffix.c_str()); |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 281 | SkAssertResult(write_bitmap(outPath.c_str(), *bitmapFromDecodeSubset)); |
scroggo@google.com | 9da0e1d | 2013-05-15 18:14:36 +0000 | [diff] [blame] | 282 | gSuccessfulSubsetDecodes.push_back().printf("\twrote %s", outPath.c_str()); |
| 283 | |
| 284 | // Also use extractSubset from the original for visual comparison. |
| 285 | // Write the result to a file in a separate subdirectory. |
| 286 | SkBitmap extractedSubset; |
| 287 | if (!originalBitmap.extractSubset(&extractedSubset, rect)) { |
| 288 | gFailedSubsetDecodes.push_back().printf("Successfully decoded %s from %s, but failed to " |
| 289 | "extract a similar subset for comparison.", |
| 290 | subsetDim, filename); |
| 291 | return false; |
| 292 | } |
| 293 | |
scroggo@google.com | ccd7afb | 2013-05-28 16:45:07 +0000 | [diff] [blame] | 294 | SkString dirExtracted = SkOSPath::SkPathJoin(writePath, "extracted"); |
scroggo@google.com | 9da0e1d | 2013-05-15 18:14:36 +0000 | [diff] [blame] | 295 | if (!sk_mkdir(dirExtracted.c_str())) { |
| 296 | gFailedSubsetDecodes.push_back().printf("Successfully decoded %s from %s, but failed to " |
| 297 | "create a directory for extractSubset comparison.", |
| 298 | subsetDim, filename); |
| 299 | return false; |
| 300 | } |
| 301 | |
| 302 | make_outname(&outPath, dirExtracted.c_str(), filename, suffix.c_str()); |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 303 | SkAssertResult(write_bitmap(outPath.c_str(), extractedSubset)); |
scroggo@google.com | 9da0e1d | 2013-05-15 18:14:36 +0000 | [diff] [blame] | 304 | return true; |
| 305 | } |
| 306 | |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 307 | static void decodeFileAndWrite(const char srcPath[], const SkString* writePath) { |
| 308 | SkBitmap bitmap; |
| 309 | SkFILEStream stream(srcPath); |
| 310 | if (!stream.isValid()) { |
| 311 | gInvalidStreams.push_back().set(srcPath); |
| 312 | return; |
| 313 | } |
| 314 | |
| 315 | SkImageDecoder* codec = SkImageDecoder::Factory(&stream); |
| 316 | if (NULL == codec) { |
| 317 | gMissingCodecs.push_back().set(srcPath); |
| 318 | return; |
| 319 | } |
| 320 | |
| 321 | SkAutoTDelete<SkImageDecoder> ad(codec); |
| 322 | |
| 323 | stream.rewind(); |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 324 | |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 325 | // Create a string representing just the filename itself, for use in json expectations. |
scroggo@google.com | ccd7afb | 2013-05-28 16:45:07 +0000 | [diff] [blame] | 326 | SkString basename = SkOSPath::SkBasename(srcPath); |
| 327 | const char* filename = basename.c_str(); |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 328 | |
scroggo@google.com | 6d99de1 | 2013-08-06 18:56:53 +0000 | [diff] [blame] | 329 | if (!codec->decode(&stream, &bitmap, gPrefConfig, |
scroggo@google.com | bc91e8b | 2013-06-27 20:21:01 +0000 | [diff] [blame] | 330 | SkImageDecoder::kDecodePixels_Mode)) { |
| 331 | if (expect_to_fail(filename)) { |
| 332 | gSuccessfulDecodes.push_back().appendf( |
| 333 | "failed to decode %s, which is a known failure.", srcPath); |
| 334 | } else { |
| 335 | gDecodeFailures.push_back().set(srcPath); |
| 336 | } |
| 337 | return; |
| 338 | } |
| 339 | |
scroggo@google.com | 6f67b3b | 2013-07-18 20:08:26 +0000 | [diff] [blame] | 340 | // Test decoding just the bounds. The bounds should always match. |
| 341 | { |
| 342 | stream.rewind(); |
| 343 | SkBitmap dim; |
| 344 | if (!codec->decode(&stream, &dim, SkImageDecoder::kDecodeBounds_Mode)) { |
| 345 | SkString failure = SkStringPrintf("failed to decode bounds for %s", srcPath); |
| 346 | gDecodeFailures.push_back() = failure; |
| 347 | } else { |
| 348 | // Now check that the bounds match: |
| 349 | if (dim.width() != bitmap.width() || dim.height() != bitmap.height()) { |
| 350 | SkString failure = SkStringPrintf("bounds do not match for %s", srcPath); |
| 351 | gDecodeFailures.push_back() = failure; |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | |
scroggo@google.com | e339eb0 | 2013-08-06 18:51:30 +0000 | [diff] [blame] | 356 | if (compare_to_expectations_if_necessary(bitmap, filename, |
| 357 | &gDecodeFailures, |
| 358 | &gMissingExpectations)) { |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 359 | gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.width(), |
| 360 | bitmap.height()); |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 361 | } else if (!FLAGS_mismatchPath.isEmpty()) { |
| 362 | SkString outPath; |
| 363 | make_outname(&outPath, FLAGS_mismatchPath[0], srcPath, ".png"); |
| 364 | if (write_bitmap(outPath.c_str(), bitmap)) { |
| 365 | gSuccessfulDecodes.push_back().appendf("\twrote %s", outPath.c_str()); |
| 366 | } else { |
| 367 | gEncodeFailures.push_back().set(outPath); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | if (writePath != NULL) { |
| 372 | SkString outPath; |
| 373 | make_outname(&outPath, writePath->c_str(), srcPath, ".png"); |
| 374 | if (write_bitmap(outPath.c_str(), bitmap)) { |
| 375 | gSuccessfulDecodes.push_back().appendf("\twrote %s", outPath.c_str()); |
| 376 | } else { |
| 377 | gEncodeFailures.push_back().set(outPath); |
| 378 | } |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | write_expectations(bitmap, filename); |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 382 | |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 383 | if (FLAGS_testSubsetDecoding) { |
scroggo@google.com | 0018f75 | 2013-05-03 20:39:22 +0000 | [diff] [blame] | 384 | SkDEBUGCODE(bool couldRewind =) stream.rewind(); |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 385 | SkASSERT(couldRewind); |
| 386 | int width, height; |
| 387 | // Build the tile index for decoding subsets. If the image is 1x1, skip subset |
| 388 | // decoding since there are no smaller subsets. |
| 389 | if (codec->buildTileIndex(&stream, &width, &height) && width > 1 && height > 1) { |
| 390 | SkASSERT(bitmap.width() == width && bitmap.height() == height); |
| 391 | // Call decodeSubset multiple times: |
| 392 | SkRandom rand(0); |
| 393 | for (int i = 0; i < 5; i++) { |
| 394 | SkBitmap bitmapFromDecodeSubset; |
| 395 | // FIXME: Come up with a more representative set of rectangles. |
| 396 | SkIRect rect = generate_random_rect(&rand, width, height); |
| 397 | SkString subsetDim = SkStringPrintf("[%d,%d,%d,%d]", rect.fLeft, rect.fTop, |
| 398 | rect.fRight, rect.fBottom); |
scroggo@google.com | 6d99de1 | 2013-08-06 18:56:53 +0000 | [diff] [blame] | 399 | if (codec->decodeSubset(&bitmapFromDecodeSubset, rect, gPrefConfig)) { |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 400 | SkString subsetName = SkStringPrintf("%s_%s", filename, subsetDim.c_str()); |
| 401 | if (compare_to_expectations_if_necessary(bitmapFromDecodeSubset, |
| 402 | subsetName.c_str(), |
scroggo@google.com | e339eb0 | 2013-08-06 18:51:30 +0000 | [diff] [blame] | 403 | &gFailedSubsetDecodes, |
| 404 | &gMissingSubsetExpectations)) { |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 405 | gSuccessfulSubsetDecodes.push_back().printf("Decoded subset %s from %s", |
| 406 | subsetDim.c_str(), srcPath); |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 407 | } else if (!FLAGS_mismatchPath.isEmpty()) { |
| 408 | write_subset(FLAGS_mismatchPath[0], filename, subsetDim.c_str(), |
| 409 | &bitmapFromDecodeSubset, rect, bitmap); |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | write_expectations(bitmapFromDecodeSubset, subsetName.c_str()); |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 413 | if (writePath != NULL) { |
scroggo@google.com | 9da0e1d | 2013-05-15 18:14:36 +0000 | [diff] [blame] | 414 | write_subset(writePath->c_str(), filename, subsetDim.c_str(), |
| 415 | &bitmapFromDecodeSubset, rect, bitmap); |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 416 | } |
| 417 | } else { |
scroggo@google.com | 9da0e1d | 2013-05-15 18:14:36 +0000 | [diff] [blame] | 418 | gFailedSubsetDecodes.push_back().printf("Failed to decode region %s from %s", |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 419 | subsetDim.c_str(), srcPath); |
| 420 | } |
| 421 | } |
| 422 | } |
| 423 | } |
scroggo@google.com | 9da0e1d | 2013-05-15 18:14:36 +0000 | [diff] [blame] | 424 | |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 425 | if (FLAGS_reencode) { |
| 426 | // Encode to the format the file was originally in, or PNG if the encoder for the same |
| 427 | // format is unavailable. |
| 428 | SkImageDecoder::Format format = codec->getFormat(); |
| 429 | if (SkImageDecoder::kUnknown_Format == format) { |
| 430 | if (stream.rewind()) { |
| 431 | format = SkImageDecoder::GetStreamFormat(&stream); |
| 432 | } |
| 433 | if (SkImageDecoder::kUnknown_Format == format) { |
| 434 | const char* dot = strrchr(srcPath, '.'); |
| 435 | if (NULL != dot) { |
| 436 | format = guess_format_from_suffix(dot); |
| 437 | } |
| 438 | if (SkImageDecoder::kUnknown_Format == format) { |
| 439 | SkDebugf("Could not determine type for '%s'\n", srcPath); |
| 440 | format = SkImageDecoder::kPNG_Format; |
| 441 | } |
| 442 | |
| 443 | } |
| 444 | } else { |
| 445 | SkASSERT(!stream.rewind() || SkImageDecoder::GetStreamFormat(&stream) == format); |
| 446 | } |
| 447 | SkImageEncoder::Type type = format_to_type(format); |
| 448 | // format should never be kUnknown_Format, so type should never be kUnknown_Type. |
| 449 | SkASSERT(type != SkImageEncoder::kUnknown_Type); |
| 450 | |
| 451 | SkImageEncoder* encoder = SkImageEncoder::Create(type); |
| 452 | if (NULL == encoder) { |
| 453 | type = SkImageEncoder::kPNG_Type; |
| 454 | encoder = SkImageEncoder::Create(type); |
| 455 | SkASSERT(encoder); |
| 456 | } |
| 457 | SkAutoTDelete<SkImageEncoder> ade(encoder); |
| 458 | // Encode to a stream. |
| 459 | SkDynamicMemoryWStream wStream; |
| 460 | if (!encoder->encodeStream(&wStream, bitmap, 100)) { |
| 461 | gEncodeFailures.push_back().printf("Failed to reencode %s to type '%s'", srcPath, |
| 462 | suffix_for_type(type)); |
| 463 | return; |
| 464 | } |
| 465 | |
| 466 | SkAutoTUnref<SkData> data(wStream.copyToData()); |
| 467 | if (writePath != NULL && type != SkImageEncoder::kPNG_Type) { |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 468 | // Write the encoded data to a file. Do not write to PNG, which was already written. |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 469 | SkString outPath; |
| 470 | make_outname(&outPath, writePath->c_str(), srcPath, suffix_for_type(type)); |
| 471 | SkFILEWStream file(outPath.c_str()); |
| 472 | if(file.write(data->data(), data->size())) { |
| 473 | gSuccessfulDecodes.push_back().appendf("\twrote %s", outPath.c_str()); |
| 474 | } else { |
| 475 | gEncodeFailures.push_back().printf("Failed to write %s", outPath.c_str()); |
| 476 | } |
| 477 | } |
| 478 | // Ensure that the reencoded data can still be decoded. |
| 479 | SkMemoryStream memStream(data); |
| 480 | SkBitmap redecodedBitmap; |
| 481 | SkImageDecoder::Format formatOnSecondDecode; |
scroggo@google.com | 6d99de1 | 2013-08-06 18:56:53 +0000 | [diff] [blame] | 482 | if (SkImageDecoder::DecodeStream(&memStream, &redecodedBitmap, gPrefConfig, |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 483 | SkImageDecoder::kDecodePixels_Mode, |
| 484 | &formatOnSecondDecode)) { |
| 485 | SkASSERT(format_to_type(formatOnSecondDecode) == type); |
| 486 | } else { |
| 487 | gDecodeFailures.push_back().printf("Failed to redecode %s after reencoding to '%s'", |
| 488 | srcPath, suffix_for_type(type)); |
| 489 | } |
| 490 | } |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | /////////////////////////////////////////////////////////////////////////////// |
| 494 | |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 495 | // If strings is not empty, print title, followed by each string on its own line starting |
| 496 | // with a tab. |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 497 | // @return bool True if strings had at least one entry. |
| 498 | static bool print_strings(const char* title, const SkTArray<SkString, false>& strings) { |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 499 | if (strings.count() > 0) { |
| 500 | SkDebugf("%s:\n", title); |
| 501 | for (int i = 0; i < strings.count(); i++) { |
| 502 | SkDebugf("\t%s\n", strings[i].c_str()); |
| 503 | } |
| 504 | SkDebugf("\n"); |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 505 | return true; |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 506 | } |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 507 | return false; |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 508 | } |
| 509 | |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 510 | /** |
| 511 | * If directory is non null and does not end with a path separator, append one. |
| 512 | * @param directory SkString representing the path to a directory. If the last character is not a |
| 513 | * path separator (specific to the current OS), append one. |
| 514 | */ |
| 515 | static void append_path_separator_if_necessary(SkString* directory) { |
| 516 | if (directory != NULL && directory->c_str()[directory->size() - 1] != SkPATH_SEPARATOR) { |
| 517 | directory->appendf("%c", SkPATH_SEPARATOR); |
| 518 | } |
| 519 | } |
| 520 | |
scroggo@google.com | 925cdca | 2013-06-28 20:04:42 +0000 | [diff] [blame] | 521 | /** |
| 522 | * Return true if the filename represents an image. |
| 523 | */ |
| 524 | static bool is_image_file(const char* filename) { |
| 525 | const char* gImageExtensions[] = { |
| 526 | ".png", ".PNG", ".jpg", ".JPG", ".jpeg", ".JPEG", ".bmp", ".BMP", |
| 527 | ".webp", ".WEBP", ".ico", ".ICO", ".wbmp", ".WBMP", ".gif", ".GIF" |
| 528 | }; |
| 529 | for (size_t i = 0; i < SK_ARRAY_COUNT(gImageExtensions); ++i) { |
| 530 | if (SkStrEndsWith(filename, gImageExtensions[i])) { |
| 531 | return true; |
| 532 | } |
| 533 | } |
| 534 | return false; |
| 535 | } |
| 536 | |
caryclark@google.com | 5987f58 | 2012-10-02 18:33:14 +0000 | [diff] [blame] | 537 | int tool_main(int argc, char** argv); |
| 538 | int tool_main(int argc, char** argv) { |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 539 | SkCommandLineFlags::SetUsage("Decode files, and optionally write the results to files."); |
| 540 | SkCommandLineFlags::Parse(argc, argv); |
| 541 | |
| 542 | if (FLAGS_readPath.count() < 1) { |
| 543 | SkDebugf("Folder(s) or image(s) to decode are required.\n"); |
| 544 | return -1; |
| 545 | } |
| 546 | |
| 547 | |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 548 | SkAutoGraphics ag; |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 549 | |
scroggo@google.com | 3832da1 | 2013-06-19 19:12:53 +0000 | [diff] [blame] | 550 | if (!FLAGS_readExpectationsPath.isEmpty() && sk_exists(FLAGS_readExpectationsPath[0])) { |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 551 | gJsonExpectations.reset(SkNEW_ARGS(skiagm::JsonExpectationsSource, |
| 552 | (FLAGS_readExpectationsPath[0]))); |
| 553 | } |
| 554 | |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 555 | SkString outDir; |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 556 | SkString* outDirPtr; |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 557 | |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 558 | if (FLAGS_writePath.count() == 1) { |
| 559 | outDir.set(FLAGS_writePath[0]); |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 560 | append_path_separator_if_necessary(&outDir); |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 561 | outDirPtr = &outDir; |
| 562 | } else { |
| 563 | outDirPtr = NULL; |
| 564 | } |
| 565 | |
scroggo@google.com | 6d99de1 | 2013-08-06 18:56:53 +0000 | [diff] [blame] | 566 | if (FLAGS_config.count() == 1) { |
| 567 | // Only consider the first config specified on the command line. |
| 568 | const char* config = FLAGS_config[0]; |
| 569 | if (0 == strcmp(config, "8888")) { |
| 570 | gPrefConfig = SkBitmap::kARGB_8888_Config; |
| 571 | } else if (0 == strcmp(config, "565")) { |
| 572 | gPrefConfig = SkBitmap::kRGB_565_Config; |
| 573 | } else if (0 == strcmp(config, "A8")) { |
| 574 | gPrefConfig = SkBitmap::kA8_Config; |
| 575 | } else if (0 != strcmp(config, "None")) { |
| 576 | SkDebugf("Invalid preferred config\n"); |
| 577 | return -1; |
| 578 | } |
| 579 | } |
| 580 | |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 581 | for (int i = 0; i < FLAGS_readPath.count(); i++) { |
scroggo@google.com | 2b9424b | 2013-06-21 19:12:47 +0000 | [diff] [blame] | 582 | const char* readPath = FLAGS_readPath[i]; |
| 583 | if (strlen(readPath) < 1) { |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 584 | break; |
| 585 | } |
scroggo@google.com | 2b9424b | 2013-06-21 19:12:47 +0000 | [diff] [blame] | 586 | if (sk_isdir(readPath)) { |
| 587 | const char* dir = readPath; |
| 588 | SkOSFile::Iter iter(dir); |
| 589 | SkString filename; |
| 590 | while (iter.next(&filename)) { |
scroggo@google.com | 925cdca | 2013-06-28 20:04:42 +0000 | [diff] [blame] | 591 | if (!is_image_file(filename.c_str())) { |
| 592 | continue; |
| 593 | } |
scroggo@google.com | 2b9424b | 2013-06-21 19:12:47 +0000 | [diff] [blame] | 594 | SkString fullname = SkOSPath::SkPathJoin(dir, filename.c_str()); |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 595 | decodeFileAndWrite(fullname.c_str(), outDirPtr); |
scroggo@google.com | 2b9424b | 2013-06-21 19:12:47 +0000 | [diff] [blame] | 596 | } |
scroggo@google.com | 925cdca | 2013-06-28 20:04:42 +0000 | [diff] [blame] | 597 | } else if (sk_exists(readPath) && is_image_file(readPath)) { |
scroggo@google.com | 2b9424b | 2013-06-21 19:12:47 +0000 | [diff] [blame] | 598 | decodeFileAndWrite(readPath, outDirPtr); |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 599 | } |
| 600 | } |
| 601 | |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 602 | if (!FLAGS_createExpectationsPath.isEmpty()) { |
| 603 | // Use an empty value for everything besides expectations, since the reader only cares |
| 604 | // about the expectations. |
| 605 | Json::Value nullValue; |
| 606 | Json::Value root = skiagm::CreateJsonTree(gExpectationsToWrite, nullValue, nullValue, |
| 607 | nullValue, nullValue); |
| 608 | std::string jsonStdString = root.toStyledString(); |
scroggo@google.com | cf5eb6a | 2013-06-07 12:43:15 +0000 | [diff] [blame] | 609 | SkFILEWStream stream(FLAGS_createExpectationsPath[0]); |
scroggo@google.com | 6843bdb | 2013-05-08 19:14:23 +0000 | [diff] [blame] | 610 | stream.write(jsonStdString.c_str(), jsonStdString.length()); |
| 611 | } |
scroggo@google.com | b41ff95 | 2013-04-11 15:53:35 +0000 | [diff] [blame] | 612 | // Add some space, since codecs may print warnings without newline. |
| 613 | SkDebugf("\n\n"); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 614 | |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 615 | bool failed = print_strings("Invalid files", gInvalidStreams); |
| 616 | failed |= print_strings("Missing codec", gMissingCodecs); |
| 617 | failed |= print_strings("Failed to decode", gDecodeFailures); |
| 618 | failed |= print_strings("Failed to encode", gEncodeFailures); |
| 619 | print_strings("Decoded", gSuccessfulDecodes); |
scroggo@google.com | e339eb0 | 2013-08-06 18:51:30 +0000 | [diff] [blame] | 620 | print_strings("Missing expectations", gMissingExpectations); |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 621 | |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 622 | if (FLAGS_testSubsetDecoding) { |
| 623 | failed |= print_strings("Failed subset decodes", gFailedSubsetDecodes); |
| 624 | print_strings("Decoded subsets", gSuccessfulSubsetDecodes); |
scroggo@google.com | e339eb0 | 2013-08-06 18:51:30 +0000 | [diff] [blame] | 625 | print_strings("Missing subset expectations", gMissingSubsetExpectations); |
scroggo@google.com | 7e6fcee | 2013-05-03 20:14:28 +0000 | [diff] [blame] | 626 | } |
| 627 | |
scroggo@google.com | 39edf4c | 2013-04-25 17:33:51 +0000 | [diff] [blame] | 628 | return failed ? -1 : 0; |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 629 | } |
| 630 | |
caryclark@google.com | 5987f58 | 2012-10-02 18:33:14 +0000 | [diff] [blame] | 631 | #if !defined SK_BUILD_FOR_IOS |
| 632 | int main(int argc, char * const argv[]) { |
| 633 | return tool_main(argc, (char**) argv); |
| 634 | } |
| 635 | #endif |