Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / cc / test / pixel_test_utils.h
blob81d20ce770ccd1827977d617d4fc12f8af401251
1 // Copyright (c) 2012 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.
5 #ifndef CC_TEST_PIXEL_TEST_UTILS_H_
6 #define CC_TEST_PIXEL_TEST_UTILS_H_
8 #include <string>
10 #include "base/files/file_path.h"
11 #include "cc/test/pixel_comparator.h"
13 class SkBitmap;
15 namespace cc {
17 // Encodes a bitmap into a PNG and write to disk. Returns true on success. The
18 // parent directory does not have to exist.
19 bool WritePNGFile(const SkBitmap& bitmap, const base::FilePath& file_path,
20 bool discard_transparency);
22 // Reads and decodes a PNG image to a bitmap. Returns true on success. The PNG
23 // should have been encoded using |gfx::PNGCodec::Encode|.
24 bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap);
26 std::string GetPNGDataUrl(const SkBitmap& bitmap);
28 // Compares with a PNG file on disk using the given PixelComparator, and returns
29 // true if the comparator returns a match. |ref_img_path| is absolute.
30 bool MatchesPNGFile(const SkBitmap& gen_bmp,
31 base::FilePath ref_img_path,
32 const PixelComparator& comparator);
34 } // namespace cc
36 #endif // CC_TEST_PIXEL_TEST_UTILS_H_