OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "LazyDecodeBitmap.h" | 8 #include "LazyDecodeBitmap.h" |
9 #include "CopyTilesRenderer.h" | 9 #include "CopyTilesRenderer.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 * Write the raw encoded bitmap data to a file. | 117 * Write the raw encoded bitmap data to a file. |
118 */ | 118 */ |
119 static bool write_image_to_file(const void* buffer, size_t size, SkBitmap* bitma
p) { | 119 static bool write_image_to_file(const void* buffer, size_t size, SkBitmap* bitma
p) { |
120 SkASSERT(!FLAGS_writePath.isEmpty()); | 120 SkASSERT(!FLAGS_writePath.isEmpty()); |
121 SkMemoryStream memStream(buffer, size); | 121 SkMemoryStream memStream(buffer, size); |
122 SkString outPath; | 122 SkString outPath; |
123 SkImageDecoder::Format format = SkImageDecoder::GetStreamFormat(&memStream); | 123 SkImageDecoder::Format format = SkImageDecoder::GetStreamFormat(&memStream); |
124 SkString name = SkStringPrintf("%s_%d%s", gInputFileName.c_str(), gImageNo++
, | 124 SkString name = SkStringPrintf("%s_%d%s", gInputFileName.c_str(), gImageNo++
, |
125 get_suffix_from_format(format)); | 125 get_suffix_from_format(format)); |
126 SkString dir(FLAGS_writePath[0]); | 126 SkString dir(FLAGS_writePath[0]); |
127 sk_tools::make_filepath(&outPath, dir, name); | 127 outPath = SkOSPath::SkPathJoin(dir.c_str(), name.c_str()); |
128 SkFILEWStream fileStream(outPath.c_str()); | 128 SkFILEWStream fileStream(outPath.c_str()); |
129 if (!(fileStream.isValid() && fileStream.write(buffer, size))) { | 129 if (!(fileStream.isValid() && fileStream.write(buffer, size))) { |
130 SkDebugf("Failed to write encoded data to \"%s\"\n", outPath.c_str()); | 130 SkDebugf("Failed to write encoded data to \"%s\"\n", outPath.c_str()); |
131 } | 131 } |
132 // Put in a dummy bitmap. | 132 // Put in a dummy bitmap. |
133 return SkImageDecoder::DecodeStream(&memStream, bitmap, SkBitmap::kNo_Config
, | 133 return SkImageDecoder::DecodeStream(&memStream, bitmap, SkBitmap::kNo_Config
, |
134 SkImageDecoder::kDecodeBounds_Mode); | 134 SkImageDecoder::kDecodeBounds_Mode); |
135 } | 135 } |
136 | 136 |
137 ////////////////////////////////////////////////////////////////////////////////
//////////////////// | 137 ////////////////////////////////////////////////////////////////////////////////
//////////////////// |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 379 |
380 static int process_input(const char* input, const SkString* writePath, | 380 static int process_input(const char* input, const SkString* writePath, |
381 const SkString* mismatchPath, sk_tools::PictureRenderer
& renderer, | 381 const SkString* mismatchPath, sk_tools::PictureRenderer
& renderer, |
382 sk_tools::ImageResultsAndExpectations *jsonSummaryPtr)
{ | 382 sk_tools::ImageResultsAndExpectations *jsonSummaryPtr)
{ |
383 SkOSFile::Iter iter(input, "skp"); | 383 SkOSFile::Iter iter(input, "skp"); |
384 SkString inputFilename; | 384 SkString inputFilename; |
385 int failures = 0; | 385 int failures = 0; |
386 SkDebugf("process_input, %s\n", input); | 386 SkDebugf("process_input, %s\n", input); |
387 if (iter.next(&inputFilename)) { | 387 if (iter.next(&inputFilename)) { |
388 do { | 388 do { |
389 SkString inputPath; | 389 SkString inputPath = SkOSPath::SkPathJoin(input, inputFilename.c_str
()); |
390 SkString inputAsSkString(input); | |
391 sk_tools::make_filepath(&inputPath, inputAsSkString, inputFilename); | |
392 if (!render_picture(inputPath, writePath, mismatchPath, renderer, js
onSummaryPtr)) { | 390 if (!render_picture(inputPath, writePath, mismatchPath, renderer, js
onSummaryPtr)) { |
393 ++failures; | 391 ++failures; |
394 } | 392 } |
395 } while(iter.next(&inputFilename)); | 393 } while(iter.next(&inputFilename)); |
396 } else if (SkStrEndsWith(input, ".skp")) { | 394 } else if (SkStrEndsWith(input, ".skp")) { |
397 SkString inputPath(input); | 395 SkString inputPath(input); |
398 if (!render_picture(inputPath, writePath, mismatchPath, renderer, jsonSu
mmaryPtr)) { | 396 if (!render_picture(inputPath, writePath, mismatchPath, renderer, jsonSu
mmaryPtr)) { |
399 ++failures; | 397 ++failures; |
400 } | 398 } |
401 } else { | 399 } else { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); | 494 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); |
497 } | 495 } |
498 return 0; | 496 return 0; |
499 } | 497 } |
500 | 498 |
501 #if !defined SK_BUILD_FOR_IOS | 499 #if !defined SK_BUILD_FOR_IOS |
502 int main(int argc, char * const argv[]) { | 500 int main(int argc, char * const argv[]) { |
503 return tool_main(argc, (char**) argv); | 501 return tool_main(argc, (char**) argv); |
504 } | 502 } |
505 #endif | 503 #endif |
OLD | NEW |