| Index: cc/test/image_comparator.h
|
| diff --git a/cc/test/image_comparator.h b/cc/test/image_comparator.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3dfd33ce39c568436225b7c8f34f5fbf6a6ed481
|
| --- /dev/null
|
| +++ b/cc/test/image_comparator.h
|
| @@ -0,0 +1,61 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CC_TEST_IMAGE_COMPARATOR_H_
|
| +#define CC_TEST_IMAGE_COMPARATOR_H_
|
| +
|
| +#include "third_party/skia/include/core/SkBitmap.h"
|
| +
|
| +namespace cc {
|
| +
|
| +class ImageComparator {
|
| + public:
|
| +
|
| + struct ErrorMetrics {
|
| + ErrorMetrics(float error_pixels_percentage = 0.0f,
|
| + float small_error_pixels_percentage = 0.0f,
|
| + float avg_abs_error_r = 0.0f,
|
| + float avg_abs_error_g = 0.0f,
|
| + float avg_abs_error_b = 0.0f,
|
| + unsigned int max_abs_error_r = 0,
|
| + unsigned int max_abs_error_g = 0,
|
| + unsigned int max_abs_error_b = 0,
|
| + unsigned int small_error_threshold = 1);
|
| + // Percentage of pixels that are different in any way.
|
| + float error_pixels_percentage;
|
| + // Percentage of pixels that are at most off by small_error_threshold
|
| + // in each color channel.
|
| + float small_error_pixels_percentage;
|
| + // The per channel average absolute error over all pixels that are different.
|
| + float avg_abs_error_r;
|
| + float avg_abs_error_g;
|
| + float avg_abs_error_b;
|
| + // The per channel maxiumum absolute error over all pixels that are different
|
| + // (average over all pixels is the same).
|
| + unsigned int max_abs_error_r;
|
| + unsigned int max_abs_error_g;
|
| + unsigned int max_abs_error_b;
|
| + // The threshold that was used to classify small vs. large errors.
|
| + // Small errors are less or equal to this value.
|
| + unsigned int small_error_threshold;
|
| + };
|
| +
|
| + // Strict image comparator with zero thresholds.
|
| + ImageComparator();
|
| + // User defined comparator with given thresholds.
|
| + ImageComparator(const ErrorMetrics& thresholds);
|
| +
|
| + // Configure the comparator to allow a given percentage of off-by-one pixel errors
|
| + void AllowOffByOneErrors(float off_by_one_pixels_percentage = 100.0f);
|
| +
|
| + // Compare two bitmaps. Return true if they are equal within the given thresholds
|
| + bool Compare(const SkBitmap& a, const SkBitmap& b, ErrorMetrics* return_metrics = NULL) const;
|
| +
|
| + private:
|
| + ErrorMetrics thresholds_;
|
| +};
|
| +
|
| +} // namespace cc
|
| +
|
| +#endif // CC_TEST_IMAGE_COMPARATOR_H_
|
|
|