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 #include "cc/test/pixel_test_utils.h" | 5 #include "cc/test/pixel_test_utils.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
10 #include "ui/gfx/codec/png_codec.h" | 10 #include "ui/gfx/codec/png_codec.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 namespace test { | |
14 | 13 |
15 bool WritePNGFile(const SkBitmap& bitmap, const FilePath& file_path) { | 14 bool WritePNGFile(const SkBitmap& bitmap, const FilePath& file_path) { |
16 std::vector<unsigned char> png_data; | 15 std::vector<unsigned char> png_data; |
17 const bool discard_transparency = true; | 16 const bool discard_transparency = true; |
18 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, | 17 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, |
19 discard_transparency, | 18 discard_transparency, |
20 &png_data) && | 19 &png_data) && |
21 file_util::CreateDirectory(file_path.DirName())) { | 20 file_util::CreateDirectory(file_path.DirName())) { |
22 char* data = reinterpret_cast<char*>(&png_data[0]); | 21 char* data = reinterpret_cast<char*>(&png_data[0]); |
23 int size = static_cast<int>(png_data.size()); | 22 int size = static_cast<int>(png_data.size()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 68 } |
70 | 69 |
71 if (diff_pixels_count != 0) { | 70 if (diff_pixels_count != 0) { |
72 LOG(ERROR) << "Images differ by pixel count: " << diff_pixels_count; | 71 LOG(ERROR) << "Images differ by pixel count: " << diff_pixels_count; |
73 return false; | 72 return false; |
74 } | 73 } |
75 | 74 |
76 return true; | 75 return true; |
77 } | 76 } |
78 | 77 |
79 } // namespace test | |
80 } // namespace cc | 78 } // namespace cc |
81 | |
OLD | NEW |