#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <iostream>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
#include "base/check.h"
#include "base/command_line.h"
#include "base/containers/heap_array.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/numerics/safe_conversions.h"
#include "base/process/memory.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "tools/imagediff/image_diff_png.h"
#if BUILDFLAG(IS_WIN)
#include "windows.h"
#endif
static const char kOptionPollStdin[] = …;
static const char kOptionCompareHistograms[] = …;
static const char kOptionGenerateDiff[] = …;
static const char kOptionFuzzyDiff[] = …;
static const char kOptionFuzzyMaxChannelDiff[] = …;
static const char kOptionFuzzyMaxPixelsDiff[] = …;
static const int kStatusSame = …;
static const int kStatusDifferent = …;
static const int kStatusError = …;
static const uint32_t RGBA_RED = …;
static const uint32_t RGBA_ALPHA = …;
class Image { … };
float PercentageDifferent(const Image& baseline,
const Image& actual,
bool fuzzy_diff) { … }
RgbaToCountMap;
float HistogramPercentageDifferent(const Image& baseline, const Image& actual) { … }
void PrintHelp() { … }
int CompareImages(const base::FilePath& file1,
const base::FilePath& file2,
bool compare_histograms,
bool fuzzy_diff) { … }
uint8_t GetChannelDiff(int c, uint32_t base_pixel, uint32_t actual_pixel) { … }
bool CreateImageDiff(const Image& image1,
const Image& image2,
bool fuzzy_diff,
std::vector<int> fuzzy_allowed_max_channel_diff,
std::vector<int> fuzzy_allowed_pixels_diff,
Image* out) { … }
int DiffImages(const base::FilePath& file1,
const base::FilePath& file2,
bool fuzzy_diff,
std::vector<int> max_per_channel,
std::vector<int> max_pixels_different,
const base::FilePath& out_file) { … }
base::FilePath FilePathFromASCII(const std::string& str) { … }
int ParseRangeOption(const std::string& range, std::vector<int>& parsed_range) { … }
int main(int argc, const char* argv[]) { … }