| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 &data_, &w_, &h_)) { | 89 &data_, &w_, &h_)) { |
| 90 Clear(); | 90 Clear(); |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Creates the image from the given filename on disk, and returns true on | 96 // Creates the image from the given filename on disk, and returns true on |
| 97 // success. | 97 // success. |
| 98 bool CreateFromFilename(const base::FilePath& path) { | 98 bool CreateFromFilename(const base::FilePath& path) { |
| 99 FILE* f = file_util::OpenFile(path, "rb"); | 99 FILE* f = base::OpenFile(path, "rb"); |
| 100 if (!f) | 100 if (!f) |
| 101 return false; | 101 return false; |
| 102 | 102 |
| 103 std::vector<unsigned char> compressed; | 103 std::vector<unsigned char> compressed; |
| 104 const int buf_size = 1024; | 104 const int buf_size = 1024; |
| 105 unsigned char buf[buf_size]; | 105 unsigned char buf[buf_size]; |
| 106 size_t num_read = 0; | 106 size_t num_read = 0; |
| 107 while ((num_read = fread(buf, 1, buf_size, f)) > 0) { | 107 while ((num_read = fread(buf, 1, buf_size, f)) > 0) { |
| 108 compressed.insert(compressed.end(), buf, buf + num_read); | 108 compressed.insert(compressed.end(), buf, buf + num_read); |
| 109 } | 109 } |
| 110 | 110 |
| 111 file_util::CloseFile(f); | 111 base::CloseFile(f); |
| 112 | 112 |
| 113 if (!image_diff_png::DecodePNG(&compressed[0], compressed.size(), | 113 if (!image_diff_png::DecodePNG(&compressed[0], compressed.size(), |
| 114 &data_, &w_, &h_)) { | 114 &data_, &w_, &h_)) { |
| 115 Clear(); | 115 Clear(); |
| 116 return false; | 116 return false; |
| 117 } | 117 } |
| 118 return true; | 118 return true; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void Clear() { | 121 void Clear() { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 base::FilePath(args[2])); | 440 base::FilePath(args[2])); |
| 441 } | 441 } |
| 442 } else if (args.size() == 2) { | 442 } else if (args.size() == 2) { |
| 443 return CompareImages( | 443 return CompareImages( |
| 444 base::FilePath(args[0]), base::FilePath(args[1]), histograms); | 444 base::FilePath(args[0]), base::FilePath(args[1]), histograms); |
| 445 } | 445 } |
| 446 | 446 |
| 447 PrintHelp(); | 447 PrintHelp(); |
| 448 return kStatusError; | 448 return kStatusError; |
| 449 } | 449 } |
| OLD | NEW |