| 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 |
| 11 #include <stddef.h> | 11 #include <stddef.h> |
| 12 #include <stdint.h> | 12 #include <stdint.h> |
| 13 | 13 |
| 14 #include <algorithm> | 14 #include <algorithm> |
| 15 #include <iostream> | 15 #include <iostream> |
| 16 #include <memory> |
| 16 #include <string> | 17 #include <string> |
| 17 #include <vector> | 18 #include <vector> |
| 18 | 19 |
| 19 #include "base/command_line.h" | 20 #include "base/command_line.h" |
| 20 #include "base/containers/hash_tables.h" | 21 #include "base/containers/hash_tables.h" |
| 21 #include "base/files/file_path.h" | 22 #include "base/files/file_path.h" |
| 22 #include "base/files/file_util.h" | 23 #include "base/files/file_util.h" |
| 23 #include "base/logging.h" | 24 #include "base/logging.h" |
| 24 #include "base/memory/scoped_ptr.h" | |
| 25 #include "base/numerics/safe_conversions.h" | 25 #include "base/numerics/safe_conversions.h" |
| 26 #include "base/process/memory.h" | 26 #include "base/process/memory.h" |
| 27 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
| 28 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 30 #include "tools/imagediff/image_diff_png.h" | 30 #include "tools/imagediff/image_diff_png.h" |
| 31 | 31 |
| 32 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 33 #include "windows.h" | 33 #include "windows.h" |
| 34 #endif | 34 #endif |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 const unsigned char* data() const { | 77 const unsigned char* data() const { |
| 78 return &data_.front(); | 78 return &data_.front(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Creates the image from stdin with the given data length. On success, it | 81 // Creates the image from stdin with the given data length. On success, it |
| 82 // will return true. On failure, no other methods should be accessed. | 82 // will return true. On failure, no other methods should be accessed. |
| 83 bool CreateFromStdin(size_t byte_length) { | 83 bool CreateFromStdin(size_t byte_length) { |
| 84 if (byte_length == 0) | 84 if (byte_length == 0) |
| 85 return false; | 85 return false; |
| 86 | 86 |
| 87 scoped_ptr<unsigned char[]> source(new unsigned char[byte_length]); | 87 std::unique_ptr<unsigned char[]> source(new unsigned char[byte_length]); |
| 88 if (fread(source.get(), 1, byte_length, stdin) != byte_length) | 88 if (fread(source.get(), 1, byte_length, stdin) != byte_length) |
| 89 return false; | 89 return false; |
| 90 | 90 |
| 91 if (!image_diff_png::DecodePNG(source.get(), byte_length, | 91 if (!image_diff_png::DecodePNG(source.get(), byte_length, |
| 92 &data_, &w_, &h_)) { | 92 &data_, &w_, &h_)) { |
| 93 Clear(); | 93 Clear(); |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 return true; | 96 return true; |
| 97 } | 97 } |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 base::FilePath(args[2])); | 444 base::FilePath(args[2])); |
| 445 } | 445 } |
| 446 } else if (args.size() == 2) { | 446 } else if (args.size() == 2) { |
| 447 return CompareImages( | 447 return CompareImages( |
| 448 base::FilePath(args[0]), base::FilePath(args[1]), histograms); | 448 base::FilePath(args[0]), base::FilePath(args[1]), histograms); |
| 449 } | 449 } |
| 450 | 450 |
| 451 PrintHelp(); | 451 PrintHelp(); |
| 452 return kStatusError; | 452 return kStatusError; |
| 453 } | 453 } |
| OLD | NEW |