| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file input format is based loosely on | 5 // This file input format is based loosely on |
| 6 // Tools/DumpRenderTree/ImageDiff.m | 6 // Tools/DumpRenderTree/ImageDiff.m |
| 7 | 7 |
| 8 // The exact format of this tool's output to stdout is important, to match | 8 // The exact format of this tool's output to stdout is important, to match |
| 9 // what the run-webkit-tests script expects. | 9 // what the run-webkit-tests script expects. |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 std::vector<unsigned char> compressed; | 73 std::vector<unsigned char> compressed; |
| 74 const size_t kBufSize = 1024; | 74 const size_t kBufSize = 1024; |
| 75 unsigned char buf[kBufSize]; | 75 unsigned char buf[kBufSize]; |
| 76 size_t num_read = 0; | 76 size_t num_read = 0; |
| 77 while ((num_read = fread(buf, 1, kBufSize, f)) > 0) { | 77 while ((num_read = fread(buf, 1, kBufSize, f)) > 0) { |
| 78 compressed.insert(compressed.end(), buf, buf + num_read); | 78 compressed.insert(compressed.end(), buf, buf + num_read); |
| 79 } | 79 } |
| 80 | 80 |
| 81 fclose(f); | 81 fclose(f); |
| 82 | 82 |
| 83 if (!image_diff_png::DecodePNG(&compressed[0], compressed.size(), | 83 if (!image_diff_png::DecodePNG(compressed.data(), compressed.size(), &data_, |
| 84 &data_, &w_, &h_)) { | 84 &w_, &h_)) { |
| 85 Clear(); | 85 Clear(); |
| 86 return false; | 86 return false; |
| 87 } | 87 } |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void Clear() { | 91 void Clear() { |
| 92 w_ = h_ = 0; | 92 w_ = h_ = 0; |
| 93 data_.clear(); | 93 data_.clear(); |
| 94 } | 94 } |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 if (!diff_filename.empty()) { | 343 if (!diff_filename.empty()) { |
| 344 return DiffImages(filename1, filename2, diff_filename); | 344 return DiffImages(filename1, filename2, diff_filename); |
| 345 } | 345 } |
| 346 } else if (!filename2.empty()) { | 346 } else if (!filename2.empty()) { |
| 347 return CompareImages(filename1, filename2, histograms); | 347 return CompareImages(filename1, filename2, histograms); |
| 348 } | 348 } |
| 349 | 349 |
| 350 PrintHelp(); | 350 PrintHelp(); |
| 351 return kStatusError; | 351 return kStatusError; |
| 352 } | 352 } |
| OLD | NEW |