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_PIXEL_COMPARATOR_H_ |
| 6 #define CC_TEST_PIXEL_COMPARATOR_H_ |
| 7 |
| 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 // Interface for pixel comparators. |
| 13 class PixelComparator { |
| 14 public: |
| 15 virtual bool Compare(const SkBitmap& actual_bmp, |
| 16 const SkBitmap& expected_bmp) const = 0; |
| 17 |
| 18 protected: |
| 19 virtual ~PixelComparator() {} |
| 20 }; |
| 21 |
| 22 // Exact pixel comparator. Counts the number of pixel with an error. |
| 23 class ExactPixelComparator : public PixelComparator { |
| 24 public: |
| 25 // Returns true if the two bitmaps are identical. Otherwise, returns false |
| 26 // and report the number of pixels with an error on LOG(ERROR). Differences |
| 27 // in the alpha channel are ignored. |
| 28 bool Compare(const SkBitmap& actual_bmp, const SkBitmap& expected_bmp) const; |
| 29 }; |
| 30 |
| 31 // Fuzzy pixel comparator. Counts small and arbitrary errors separately and |
| 32 // computes average and maximum absolute errors per color channel. |
| 33 class FuzzyPixelComparator : public PixelComparator { |
| 34 public: |
| 35 FuzzyPixelComparator(const float error_pixels_percentage_limit, |
| 36 const float small_error_pixels_percentage_limit, |
| 37 const float avg_abs_error_limit, |
| 38 const int max_abs_error_limit, |
| 39 const int small_error_threshold); |
| 40 // Computes error metrics and returns true if the errors don't exceed the |
| 41 // specified limits. Otherwise, returns false and reports the error metrics on |
| 42 // LOG(ERROR). Differences in the alpha channel are ignored. |
| 43 bool Compare(const SkBitmap& actual_bmp, const SkBitmap& expected_bmp) const; |
| 44 |
| 45 private: |
| 46 // Limit for percentage of pixels with an error |
| 47 float error_pixels_percentage_limit_; |
| 48 // Limit for percentage of pixels with a small error |
| 49 float small_error_pixels_percentage_limit_; |
| 50 // Limit for average absolute error (excluding identical pixels) |
| 51 float avg_abs_error_limit_; |
| 52 // Limit for largest absolute error |
| 53 int max_abs_error_limit_; |
| 54 // Threshold for small errors |
| 55 int small_error_threshold_; |
| 56 }; |
| 57 |
| 58 } // namespace cc |
| 59 |
| 60 #endif // CC_TEST_PIXEL_COMPARATOR_H_ |
OLD | NEW |