Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <cmath> | 6 #include <cmath> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include <GLES2/gl2.h> | 10 #include <GLES2/gl2.h> |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 849 ASSERT_GT(grid_pitch, 0); | 849 ASSERT_GT(grid_pitch, 0); |
| 850 ASSERT_GT(grid_width, 0); | 850 ASSERT_GT(grid_width, 0); |
| 851 ASSERT_NE(background_color, grid_color); | 851 ASSERT_NE(background_color, grid_color); |
| 852 | 852 |
| 853 for (int y = 0; y < h; ++y) { | 853 for (int y = 0; y < h; ++y) { |
| 854 bool y_on_grid = ((y % grid_pitch) < grid_width); | 854 bool y_on_grid = ((y % grid_pitch) < grid_width); |
| 855 | 855 |
| 856 for (int x = 0; x < w; ++x) { | 856 for (int x = 0; x < w; ++x) { |
| 857 bool on_grid = (y_on_grid || ((x % grid_pitch) < grid_width)); | 857 bool on_grid = (y_on_grid || ((x % grid_pitch) < grid_width)); |
| 858 | 858 |
| 859 if (bmp.getConfig() == SkBitmap::kARGB_8888_Config) { | 859 if (bmp.config() == SkBitmap::kARGB_8888_Config) { |
|
reed1
2014/05/07 18:06:22
Can we compare using colortypes instead of configs
| |
| 860 *bmp.getAddr32(x, y) = (on_grid ? grid_color : background_color); | 860 *bmp.getAddr32(x, y) = (on_grid ? grid_color : background_color); |
| 861 } else if (bmp.getConfig() == SkBitmap::kRGB_565_Config) { | 861 } else if (bmp.config() == SkBitmap::kRGB_565_Config) { |
| 862 *bmp.getAddr16(x, y) = (on_grid ? grid_color : background_color); | 862 *bmp.getAddr16(x, y) = (on_grid ? grid_color : background_color); |
| 863 } | 863 } |
| 864 } | 864 } |
| 865 } | 865 } |
| 866 } | 866 } |
| 867 | 867 |
| 868 void DrawCheckerToBitmap(int w, int h, | 868 void DrawCheckerToBitmap(int w, int h, |
| 869 SkColor color1, SkColor color2, | 869 SkColor color1, SkColor color2, |
| 870 int rect_w, int rect_h, | 870 int rect_w, int rect_h, |
| 871 SkBitmap& bmp) { | 871 SkBitmap& bmp) { |
| 872 ASSERT_GT(rect_w, 0); | 872 ASSERT_GT(rect_w, 0); |
| 873 ASSERT_GT(rect_h, 0); | 873 ASSERT_GT(rect_h, 0); |
| 874 ASSERT_NE(color1, color2); | 874 ASSERT_NE(color1, color2); |
| 875 | 875 |
| 876 for (int y = 0; y < h; ++y) { | 876 for (int y = 0; y < h; ++y) { |
| 877 bool y_bit = (((y / rect_h) & 0x1) == 0); | 877 bool y_bit = (((y / rect_h) & 0x1) == 0); |
| 878 | 878 |
| 879 for (int x = 0; x < w; ++x) { | 879 for (int x = 0; x < w; ++x) { |
| 880 bool x_bit = (((x / rect_w) & 0x1) == 0); | 880 bool x_bit = (((x / rect_w) & 0x1) == 0); |
| 881 | 881 |
| 882 bool use_color2 = (x_bit != y_bit); // xor | 882 bool use_color2 = (x_bit != y_bit); // xor |
| 883 if (bmp.getConfig() == SkBitmap::kARGB_8888_Config) { | 883 if (bmp.config() == SkBitmap::kARGB_8888_Config) { |
| 884 *bmp.getAddr32(x, y) = (use_color2 ? color2 : color1); | 884 *bmp.getAddr32(x, y) = (use_color2 ? color2 : color1); |
| 885 } else if (bmp.getConfig() == SkBitmap::kRGB_565_Config) { | 885 } else if (bmp.config() == SkBitmap::kRGB_565_Config) { |
| 886 *bmp.getAddr16(x, y) = (use_color2 ? color2 : color1); | 886 *bmp.getAddr16(x, y) = (use_color2 ? color2 : color1); |
| 887 } | 887 } |
| 888 } | 888 } |
| 889 } | 889 } |
| 890 } | 890 } |
| 891 | 891 |
| 892 bool ColorComponentsClose(SkColor component1, | 892 bool ColorComponentsClose(SkColor component1, |
| 893 SkColor component2, | 893 SkColor component2, |
| 894 SkBitmap::Config config) { | 894 SkBitmap::Config config) { |
| 895 int c1 = static_cast<int>(component1); | 895 int c1 = static_cast<int>(component1); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 924 } | 924 } |
| 925 | 925 |
| 926 bool IsEqual(const SkBitmap& bmp1, const SkBitmap& bmp2) { | 926 bool IsEqual(const SkBitmap& bmp1, const SkBitmap& bmp2) { |
| 927 if (bmp1.isNull() && bmp2.isNull()) | 927 if (bmp1.isNull() && bmp2.isNull()) |
| 928 return true; | 928 return true; |
| 929 if (bmp1.width() != bmp2.width() || | 929 if (bmp1.width() != bmp2.width() || |
| 930 bmp1.height() != bmp2.height()) { | 930 bmp1.height() != bmp2.height()) { |
| 931 LOG(ERROR) << "Bitmap geometry check failure"; | 931 LOG(ERROR) << "Bitmap geometry check failure"; |
| 932 return false; | 932 return false; |
| 933 } | 933 } |
| 934 if (bmp1.getConfig() != bmp2.getConfig()) | 934 if (bmp1.config() != bmp2.config()) |
| 935 return false; | 935 return false; |
| 936 | 936 |
| 937 SkAutoLockPixels lock1(bmp1); | 937 SkAutoLockPixels lock1(bmp1); |
| 938 SkAutoLockPixels lock2(bmp2); | 938 SkAutoLockPixels lock2(bmp2); |
| 939 if (!bmp1.getPixels() || !bmp2.getPixels()) { | 939 if (!bmp1.getPixels() || !bmp2.getPixels()) { |
| 940 LOG(ERROR) << "Empty Bitmap!"; | 940 LOG(ERROR) << "Empty Bitmap!"; |
| 941 return false; | 941 return false; |
| 942 } | 942 } |
| 943 for (int y = 0; y < bmp1.height(); ++y) { | 943 for (int y = 0; y < bmp1.height(); ++y) { |
| 944 for (int x = 0; x < bmp1.width(); ++x) { | 944 for (int x = 0; x < bmp1.width(); ++x) { |
| 945 if (!ColorsClose(bmp1.getColor(x,y), | 945 if (!ColorsClose(bmp1.getColor(x,y), |
| 946 bmp2.getColor(x,y), | 946 bmp2.getColor(x,y), |
| 947 bmp1.getConfig())) { | 947 bmp1.config())) { |
| 948 LOG(ERROR) << "Bitmap color comparision failure"; | 948 LOG(ERROR) << "Bitmap color comparision failure"; |
| 949 return false; | 949 return false; |
| 950 } | 950 } |
| 951 } | 951 } |
| 952 } | 952 } |
| 953 return true; | 953 return true; |
| 954 } | 954 } |
| 955 | 955 |
| 956 void BindAndAttachTextureWithPixels(GLuint src_texture, | 956 void BindAndAttachTextureWithPixels(GLuint src_texture, |
| 957 SkBitmap::Config bitmap_config, | 957 SkBitmap::Config bitmap_config, |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1666 base::TestSuite* suite = new content::ContentTestSuite(argc, argv); | 1666 base::TestSuite* suite = new content::ContentTestSuite(argc, argv); |
| 1667 #if defined(OS_MACOSX) | 1667 #if defined(OS_MACOSX) |
| 1668 base::mac::ScopedNSAutoreleasePool pool; | 1668 base::mac::ScopedNSAutoreleasePool pool; |
| 1669 #endif | 1669 #endif |
| 1670 gpu::ApplyGpuDriverBugWorkarounds(CommandLine::ForCurrentProcess()); | 1670 gpu::ApplyGpuDriverBugWorkarounds(CommandLine::ForCurrentProcess()); |
| 1671 | 1671 |
| 1672 content::UnitTestTestSuite runner(suite); | 1672 content::UnitTestTestSuite runner(suite); |
| 1673 base::MessageLoop message_loop; | 1673 base::MessageLoop message_loop; |
| 1674 return runner.Run(); | 1674 return runner.Run(); |
| 1675 } | 1675 } |
| OLD | NEW |