OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_TEST_IMAGE_COMPARATOR_H_ |
| 6 #define CC_TEST_IMAGE_COMPARATOR_H_ |
| 7 |
| 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 class ImageComparator { |
| 13 public: |
| 14 |
| 15 struct ErrorMetrics { |
| 16 ErrorMetrics(float error_pixels_percentage = 0.0f, |
| 17 float small_error_pixels_percentage = 0.0f, |
| 18 float avg_abs_error_r = 0.0f, |
| 19 float avg_abs_error_g = 0.0f, |
| 20 float avg_abs_error_b = 0.0f, |
| 21 unsigned int max_abs_error_r = 0, |
| 22 unsigned int max_abs_error_g = 0, |
| 23 unsigned int max_abs_error_b = 0, |
| 24 unsigned int small_error_threshold = 1); |
| 25 // Percentage of pixels that are different in any way. |
| 26 float error_pixels_percentage; |
| 27 // Percentage of pixels that are at most off by small_error_threshold |
| 28 // in each color channel. |
| 29 float small_error_pixels_percentage; |
| 30 // The per channel average absolute error over all pixels that are different
. |
| 31 float avg_abs_error_r; |
| 32 float avg_abs_error_g; |
| 33 float avg_abs_error_b; |
| 34 // The per channel maxiumum absolute error over all pixels that are differen
t |
| 35 // (average over all pixels is the same). |
| 36 unsigned int max_abs_error_r; |
| 37 unsigned int max_abs_error_g; |
| 38 unsigned int max_abs_error_b; |
| 39 // The threshold that was used to classify small vs. large errors. |
| 40 // Small errors are less or equal to this value. |
| 41 unsigned int small_error_threshold; |
| 42 }; |
| 43 |
| 44 // Strict image comparator with zero thresholds. |
| 45 ImageComparator(); |
| 46 // User defined comparator with given thresholds. |
| 47 ImageComparator(const ErrorMetrics& thresholds); |
| 48 |
| 49 // Configure the comparator to allow a given percentage of off-by-one pixel e
rrors |
| 50 void AllowOffByOneErrors(float off_by_one_pixels_percentage = 100.0f); |
| 51 |
| 52 // Compare two bitmaps. Return true if they are equal within the given thresho
lds |
| 53 bool Compare(const SkBitmap& a, const SkBitmap& b, ErrorMetrics* return_metric
s = NULL) const; |
| 54 |
| 55 private: |
| 56 ErrorMetrics thresholds_; |
| 57 }; |
| 58 |
| 59 } // namespace cc |
| 60 |
| 61 #endif // CC_TEST_IMAGE_COMPARATOR_H_ |
OLD | NEW |