Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: ui/gfx/codec/png_codec_unittest.cc

Issue 10831031: Fix the PNCodec error on Android caused by different Skia color format. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix the test case Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/gtest_filter/ui_unittests_disabled ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if defined(USE_SYSTEM_LIBPNG) 5 #if defined(USE_SYSTEM_LIBPNG)
6 #include <png.h> 6 #include <png.h>
7 #else 7 #else
8 #include "third_party/libpng/png.h" 8 #include "third_party/libpng/png.h"
9 #endif 9 #endif
10 10
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1027
1028 // Compare the original bitmap and the output bitmap. We need to 1028 // Compare the original bitmap and the output bitmap. We need to
1029 // unpremultiply original_pixel, as the decoded bitmap doesn't have an alpha 1029 // unpremultiply original_pixel, as the decoded bitmap doesn't have an alpha
1030 // channel. 1030 // channel.
1031 for (int x = 0; x < w; x++) { 1031 for (int x = 0; x < w; x++) {
1032 for (int y = 0; y < h; y++) { 1032 for (int y = 0; y < h; y++) {
1033 uint32_t original_pixel = original_bitmap.getAddr32(0, y)[x]; 1033 uint32_t original_pixel = original_bitmap.getAddr32(0, y)[x];
1034 uint32_t unpremultiplied = 1034 uint32_t unpremultiplied =
1035 SkUnPreMultiply::PMColorToColor(original_pixel); 1035 SkUnPreMultiply::PMColorToColor(original_pixel);
1036 uint32_t decoded_pixel = decoded_bitmap.getAddr32(0, y)[x]; 1036 uint32_t decoded_pixel = decoded_bitmap.getAddr32(0, y)[x];
1037 EXPECT_TRUE(NonAlphaColorsClose(unpremultiplied, decoded_pixel)) 1037 uint32_t unpremultiplied_decoded =
1038 SkUnPreMultiply::PMColorToColor(decoded_pixel);
1039
1040 EXPECT_TRUE(NonAlphaColorsClose(unpremultiplied, unpremultiplied_decoded))
1038 << "Original_pixel: (" 1041 << "Original_pixel: ("
1039 << SkColorGetR(unpremultiplied) << ", " 1042 << SkColorGetR(unpremultiplied) << ", "
1040 << SkColorGetG(unpremultiplied) << ", " 1043 << SkColorGetG(unpremultiplied) << ", "
1041 << SkColorGetB(unpremultiplied) << "), " 1044 << SkColorGetB(unpremultiplied) << "), "
1042 << "Decoded pixel: (" 1045 << "Decoded pixel: ("
1043 << SkColorGetR(decoded_pixel) << ", " 1046 << SkColorGetR(unpremultiplied_decoded) << ", "
1044 << SkColorGetG(decoded_pixel) << ", " 1047 << SkColorGetG(unpremultiplied_decoded) << ", "
1045 << SkColorGetB(decoded_pixel) << ")"; 1048 << SkColorGetB(unpremultiplied_decoded) << ")";
1046 } 1049 }
1047 } 1050 }
1048 } 1051 }
1049 1052
1050 TEST(PNGCodec, EncodeWithComment) { 1053 TEST(PNGCodec, EncodeWithComment) {
1051 const int w = 10, h = 10; 1054 const int w = 10, h = 10;
1052 1055
1053 std::vector<unsigned char> original; 1056 std::vector<unsigned char> original;
1054 MakeRGBImage(w, h, &original); 1057 MakeRGBImage(w, h, &original);
1055 1058
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 ASSERT_EQ(w, outw); 1124 ASSERT_EQ(w, outw);
1122 ASSERT_EQ(h, outh); 1125 ASSERT_EQ(h, outh);
1123 ASSERT_EQ(original.size(), decoded.size()); 1126 ASSERT_EQ(original.size(), decoded.size());
1124 1127
1125 // Images must be exactly equal 1128 // Images must be exactly equal
1126 ASSERT_TRUE(original == decoded); 1129 ASSERT_TRUE(original == decoded);
1127 } 1130 }
1128 1131
1129 1132
1130 } // namespace gfx 1133 } // namespace gfx
OLDNEW
« no previous file with comments | « build/android/gtest_filter/ui_unittests_disabled ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698