Commit 79e2f5ab authored by David Bertoni's avatar David Bertoni Committed by Commit Bot

[EXTENSIONS] Fixed bug where height and width were swapped in...

[EXTENSIONS] Fixed bug where height and width were swapped in image_utils::IsIconSufficientlyVisible.

Bug: 805600
Change-Id: I8a56269864d6785d5eb895dc92b55271e5ca3e83
Reviewed-on: https://chromium-review.googlesource.com/1157210Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: David Bertoni <dbertoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579826}
parent cca6aa49
...@@ -173,8 +173,8 @@ bool IsIconSufficientlyVisible(const SkBitmap& bitmap) { ...@@ -173,8 +173,8 @@ bool IsIconSufficientlyVisible(const SkBitmap& bitmap) {
constexpr double kMinPercentVisiblePixels = 0.05; constexpr double kMinPercentVisiblePixels = 0.05;
const unsigned int total_pixels = bitmap.height() * bitmap.width(); const unsigned int total_pixels = bitmap.height() * bitmap.width();
unsigned int visible_pixels = 0; unsigned int visible_pixels = 0;
for (int y = 0; y < bitmap.width(); ++y) { for (int y = 0; y < bitmap.height(); ++y) {
for (int x = 0; x < bitmap.height(); ++x) { for (int x = 0; x < bitmap.width(); ++x) {
if (SkColorGetA(bitmap.getColor(x, y)) >= kAlphaThreshold) { if (SkColorGetA(bitmap.getColor(x, y)) >= kAlphaThreshold) {
++visible_pixels; ++visible_pixels;
} }
......
...@@ -228,6 +228,13 @@ TEST(ImageUtilTest, IsIconSufficientlyVisible) { ...@@ -228,6 +228,13 @@ TEST(ImageUtilTest, IsIconSufficientlyVisible) {
ASSERT_TRUE(LoadPngFromFile(icon_path, &visible_icon)); ASSERT_TRUE(LoadPngFromFile(icon_path, &visible_icon));
EXPECT_TRUE(image_util::IsIconSufficientlyVisible(visible_icon)); EXPECT_TRUE(image_util::IsIconSufficientlyVisible(visible_icon));
} }
{
// Test with an icon that is rectangular.
icon_path = test_dir.AppendASCII("rectangle.png");
SkBitmap visible_icon;
ASSERT_TRUE(LoadPngFromFile(icon_path, &visible_icon));
EXPECT_TRUE(image_util::IsIconSufficientlyVisible(visible_icon));
}
} }
} // namespace extensions } // namespace extensions
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment