| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef CC_TEST_PIXEL_TEST_UTILS_H_ | 5 #ifndef CC_TEST_PIXEL_TEST_UTILS_H_ | 
| 6 #define CC_TEST_PIXEL_TEST_UTILS_H_ | 6 #define CC_TEST_PIXEL_TEST_UTILS_H_ | 
| 7 | 7 | 
|  | 8 #include <string> | 
|  | 9 | 
| 8 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" | 
| 9 #include "cc/test/pixel_comparator.h" | 11 #include "cc/test/pixel_comparator.h" | 
| 10 | 12 | 
| 11 class SkBitmap; | 13 class SkBitmap; | 
| 12 | 14 | 
| 13 namespace cc { | 15 namespace cc { | 
| 14 | 16 | 
| 15 // Encodes a bitmap into a PNG and write to disk. Returns true on success. The | 17 // Encodes a bitmap into a PNG and write to disk. Returns true on success. The | 
| 16 // parent directory does not have to exist. | 18 // parent directory does not have to exist. | 
| 17 bool WritePNGFile(const SkBitmap& bitmap, const base::FilePath& file_path, | 19 bool WritePNGFile(const SkBitmap& bitmap, const base::FilePath& file_path, | 
| 18     bool discard_transparency); | 20     bool discard_transparency); | 
| 19 | 21 | 
| 20 // Reads and decodes a PNG image to a bitmap. Returns true on success. The PNG | 22 // Reads and decodes a PNG image to a bitmap. Returns true on success. The PNG | 
| 21 // should have been encoded using |gfx::PNGCodec::Encode|. | 23 // should have been encoded using |gfx::PNGCodec::Encode|. | 
| 22 bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap); | 24 bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap); | 
| 23 | 25 | 
| 24 std::string GetPNGDataUrl(const SkBitmap& bitmap); | 26 std::string GetPNGDataUrl(const SkBitmap& bitmap); | 
| 25 | 27 | 
| 26 // Compares with a PNG file on disk using the given PixelComparator, and returns | 28 // Compares with a PNG file on disk using the given PixelComparator, and returns | 
| 27 // true if the comparator returns a match. |ref_img_path| is absolute. | 29 // true if the comparator returns a match. |ref_img_path| is absolute. | 
| 28 bool MatchesPNGFile(const SkBitmap& gen_bmp, | 30 bool MatchesPNGFile(const SkBitmap& gen_bmp, | 
| 29                     base::FilePath ref_img_path, | 31                     base::FilePath ref_img_path, | 
| 30                     const PixelComparator& comparator); | 32                     const PixelComparator& comparator); | 
| 31 | 33 | 
| 32 }  // namespace cc | 34 }  // namespace cc | 
| 33 | 35 | 
| 34 #endif  // CC_TEST_PIXEL_TEST_UTILS_H_ | 36 #endif  // CC_TEST_PIXEL_TEST_UTILS_H_ | 
| OLD | NEW | 
|---|