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() {}; | |
reveman
2013/03/07 21:41:25
don't need a ; after a }
ernstm
2013/03/08 00:14:46
Done.
| |
20 // Returns true if the two bitmaps have the same dimensions. Otherwise returns | |
21 // false and outputs a message on LOG(ERROR) | |
22 bool CompareSize(const SkBitmap& actual_bmp, | |
23 const SkBitmap& expected_bmp) const; | |
reveman
2013/03/07 21:41:25
To keep this as clean as possible, I'd prefer to k
ernstm
2013/03/08 00:14:46
Done.
| |
24 }; | |
25 | |
26 // Exact pixel comparator. Counts the number of pixel with an error. | |
27 class ExactPixelComparator : public PixelComparator { | |
28 public: | |
29 // Returns true if the two bitmaps are identical. Otherwise, returns false | |
30 // and report the number of pixels with an error on LOG(ERROR). | |
31 bool Compare(const SkBitmap& actual_bmp, const SkBitmap& expected_bmp) const; | |
32 }; | |
33 | |
34 // Fuzzy pixel comparator. Counts small and arbitrary errors separately and | |
35 // computes average and maximum absolute errors per color channel. | |
36 class FuzzyPixelComparator : public PixelComparator { | |
37 public: | |
38 // Default values for constructor make comparator tolareate an arbitrary | |
39 // number of off-by-one errors. | |
40 FuzzyPixelComparator(const float error_pixels_percentage_limit = 100.0f, | |
41 const float small_error_pixels_percentage_limit = 100.0f, | |
42 const float avg_abs_error_limit = 1.0f, | |
43 const unsigned int max_abs_error_limit = 1, | |
44 const unsigned int small_error_threshold = 1); | |
reveman
2013/03/07 21:41:25
Style guide doesn't allow default function paramet
ernstm
2013/03/08 00:14:46
Done.
| |
45 // Computes error metrics and returns true if the errors don't exceed the | |
46 // specified limits. Otherwise, returns false and reports the error metrics on | |
47 // LOG(ERROR). | |
48 bool Compare(const SkBitmap& actual_bmp, const SkBitmap& expected_bmp) const; | |
49 | |
50 private: | |
51 // Limit for percentage of pixels with an error | |
52 float error_pixels_percentage_limit_; | |
53 // Limit for percentage of pixels with a small error | |
54 float small_error_pixels_percentage_limit_; | |
55 // Limit for average absolute error (excluding identical pixels) | |
56 float avg_abs_error_limit_; | |
57 // Limit for largest absolute error | |
58 unsigned int max_abs_error_limit_; | |
59 // Threshold for small errors | |
60 unsigned int small_error_threshold_; | |
61 }; | |
62 | |
63 } // namespace cc | |
64 | |
65 #endif // CC_TEST_PIXEL_COMPARATOR_H_ | |
OLD | NEW |