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