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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if !defined(OS_WIN) | 7 #if !defined(OS_WIN) |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void SaveToFile(const base::FilePath& filename) { | 128 void SaveToFile(const base::FilePath& filename) { |
129 std::vector<unsigned char> compressed; | 129 std::vector<unsigned char> compressed; |
130 ASSERT_TRUE(gfx::PNGCodec::Encode(&*data_.begin(), | 130 ASSERT_TRUE(gfx::PNGCodec::Encode(&*data_.begin(), |
131 gfx::PNGCodec::FORMAT_BGRA, | 131 gfx::PNGCodec::FORMAT_BGRA, |
132 gfx::Size(width_, height_), | 132 gfx::Size(width_, height_), |
133 row_length_, | 133 row_length_, |
134 true, | 134 true, |
135 std::vector<gfx::PNGCodec::Comment>(), | 135 std::vector<gfx::PNGCodec::Comment>(), |
136 &compressed)); | 136 &compressed)); |
137 ASSERT_TRUE(compressed.size()); | 137 ASSERT_TRUE(compressed.size()); |
138 FILE* f = base::OpenFile(filename, "wb"); | 138 FILE* f = file_util::OpenFile(filename, "wb"); |
139 ASSERT_TRUE(f); | 139 ASSERT_TRUE(f); |
140 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), | 140 ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f), |
141 compressed.size()); | 141 compressed.size()); |
142 base::CloseFile(f); | 142 file_util::CloseFile(f); |
143 } | 143 } |
144 | 144 |
145 // Returns the percentage of the image that is different from the other, | 145 // Returns the percentage of the image that is different from the other, |
146 // between 0 and 100. | 146 // between 0 and 100. |
147 double PercentageDifferent(const Image& rhs) const { | 147 double PercentageDifferent(const Image& rhs) const { |
148 if (width_ != rhs.width_ || | 148 if (width_ != rhs.width_ || |
149 height_ != rhs.height_ || | 149 height_ != rhs.height_ || |
150 row_length_ != rhs.row_length_ || | 150 row_length_ != rhs.row_length_ || |
151 width_ == 0 || | 151 width_ == 0 || |
152 height_ == 0) { | 152 height_ == 0) { |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 pcanvas_->rotate(67); | 960 pcanvas_->rotate(67); |
961 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 961 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
962 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 962 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
963 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); | 963 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); |
964 } | 964 } |
965 } | 965 } |
966 | 966 |
967 #endif // !defined(USE_AURA) | 967 #endif // !defined(USE_AURA) |
968 | 968 |
969 } // namespace skia | 969 } // namespace skia |
OLD | NEW |