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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <cmath> | 9 #include <cmath> |
10 | 10 |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 | 1166 |
1167 // encode | 1167 // encode |
1168 std::vector<unsigned char> encoded_normal; | 1168 std::vector<unsigned char> encoded_normal; |
1169 EXPECT_TRUE( | 1169 EXPECT_TRUE( |
1170 PNGCodec::EncodeBGRASkBitmap(original_bitmap, false, &encoded_normal)); | 1170 PNGCodec::EncodeBGRASkBitmap(original_bitmap, false, &encoded_normal)); |
1171 | 1171 |
1172 std::vector<unsigned char> encoded_fast; | 1172 std::vector<unsigned char> encoded_fast; |
1173 EXPECT_TRUE( | 1173 EXPECT_TRUE( |
1174 PNGCodec::FastEncodeBGRASkBitmap(original_bitmap, false, &encoded_fast)); | 1174 PNGCodec::FastEncodeBGRASkBitmap(original_bitmap, false, &encoded_fast)); |
1175 | 1175 |
| 1176 std::vector<unsigned char> encoded_no_compress; |
| 1177 EXPECT_TRUE(PNGCodec::FastEncodeBGRASkBitmap(original_bitmap, false, |
| 1178 &encoded_no_compress)); |
| 1179 |
1176 // Make sure the different compression settings actually do something; the | 1180 // Make sure the different compression settings actually do something; the |
1177 // sizes should be different. | 1181 // sizes should be different. |
1178 EXPECT_NE(encoded_normal.size(), encoded_fast.size()); | 1182 EXPECT_GT(encoded_normal.size(), encoded_fast.size()); |
| 1183 EXPECT_GT(encoded_fast.size(), encoded_no_compress.size()); |
1179 | 1184 |
1180 // decode, they should be identical to the original. | 1185 // decode, they should be identical to the original. |
1181 SkBitmap decoded; | 1186 SkBitmap decoded; |
1182 EXPECT_TRUE( | 1187 EXPECT_TRUE( |
1183 PNGCodec::Decode(&encoded_normal[0], encoded_normal.size(), &decoded)); | 1188 PNGCodec::Decode(&encoded_normal[0], encoded_normal.size(), &decoded)); |
1184 EXPECT_TRUE(BitmapsAreEqual(decoded, original_bitmap)); | 1189 EXPECT_TRUE(BitmapsAreEqual(decoded, original_bitmap)); |
1185 | 1190 |
1186 EXPECT_TRUE( | 1191 EXPECT_TRUE( |
1187 PNGCodec::Decode(&encoded_fast[0], encoded_fast.size(), &decoded)); | 1192 PNGCodec::Decode(&encoded_fast[0], encoded_fast.size(), &decoded)); |
1188 EXPECT_TRUE(BitmapsAreEqual(decoded, original_bitmap)); | 1193 EXPECT_TRUE(BitmapsAreEqual(decoded, original_bitmap)); |
| 1194 |
| 1195 EXPECT_TRUE(PNGCodec::Decode(&encoded_no_compress[0], |
| 1196 encoded_no_compress.size(), &decoded)); |
| 1197 EXPECT_TRUE(BitmapsAreEqual(decoded, original_bitmap)); |
1189 } | 1198 } |
1190 | 1199 |
1191 | 1200 |
1192 } // namespace gfx | 1201 } // namespace gfx |
OLD | NEW |