// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CC_TEST_PIXEL_COMPARATOR_H_ #define CC_TEST_PIXEL_COMPARATOR_H_ #include "base/compiler_specific.h" #include "third_party/skia/include/core/SkBitmap.h" namespace cc { // Interface for pixel comparators. class PixelComparator { … }; // Exact pixel comparator. Counts the number of pixel with an error. class ExactPixelComparator : public PixelComparator { … }; class AlphaDiscardingExactPixelComparator : public ExactPixelComparator { … }; // Different platforms have slightly different pixel output, due to different // graphics implementations. Slightly different pixels (in BGR space) are still // counted as a matching pixel by this simple manhattan distance threshold. // If, at any pixel, the sum of the absolute differences in each color component // (excluding alpha) exceeds the threshold the test is failed. class ManhattanDistancePixelComparator : public PixelComparator { … }; // Fuzzy pixel comparator. Counts small and arbitrary errors separately and // computes average and maximum absolute errors per color channel. It can be // configured to discard alpha channel. If alpha channel is not discarded // (by default), alpha changing among fully transparent, translucent and fully // opaque (e.g. 0 to 1, 254 to 255) are always reported. class FuzzyPixelComparator : public PixelComparator { … }; // All pixels can be off by one, but any more than that is an error. class FuzzyPixelOffByOneComparator : public FuzzyPixelComparator { … }; class AlphaDiscardingFuzzyPixelOffByOneComparator : public FuzzyPixelOffByOneComparator { … }; } // namespace cc #endif // CC_TEST_PIXEL_COMPARATOR_H_