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 "chrome/browser/thumbnails/content_analysis.h" | 5 #include "chrome/browser/thumbnails/content_analysis.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 return total; | 49 return total; |
50 } | 50 } |
51 | 51 |
52 bool CompareImageFragments(const SkBitmap& bitmap_left, | 52 bool CompareImageFragments(const SkBitmap& bitmap_left, |
53 const SkBitmap& bitmap_right, | 53 const SkBitmap& bitmap_right, |
54 const gfx::Size& comparison_area, | 54 const gfx::Size& comparison_area, |
55 const gfx::Point& origin_left, | 55 const gfx::Point& origin_left, |
56 const gfx::Point& origin_right) { | 56 const gfx::Point& origin_right) { |
57 SkAutoLockPixels left_lock(bitmap_left); | |
58 SkAutoLockPixels right_lock(bitmap_right); | |
59 for (int r = 0; r < comparison_area.height(); ++r) { | 57 for (int r = 0; r < comparison_area.height(); ++r) { |
60 for (int c = 0; c < comparison_area.width(); ++c) { | 58 for (int c = 0; c < comparison_area.width(); ++c) { |
61 SkColor color_left = bitmap_left.getColor(origin_left.x() + c, | 59 SkColor color_left = bitmap_left.getColor(origin_left.x() + c, |
62 origin_left.y() + r); | 60 origin_left.y() + r); |
63 SkColor color_right = bitmap_right.getColor(origin_right.x() + c, | 61 SkColor color_right = bitmap_right.getColor(origin_right.x() + c, |
64 origin_right.y() + r); | 62 origin_right.y() + r); |
65 if (color_left != color_right) | 63 if (color_left != color_right) |
66 return false; | 64 return false; |
67 } | 65 } |
68 } | 66 } |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 | 678 |
681 int histogram[256] = {}; | 679 int histogram[256] = {}; |
682 color_utils::BuildLumaHistogram(result, histogram); | 680 color_utils::BuildLumaHistogram(result, histogram); |
683 int non_zero_color_count = std::count_if( | 681 int non_zero_color_count = std::count_if( |
684 histogram, histogram + 256, [](int value) { return value > 0; }); | 682 histogram, histogram + 256, [](int value) { return value > 0; }); |
685 EXPECT_GT(non_zero_color_count, 4); | 683 EXPECT_GT(non_zero_color_count, 4); |
686 | 684 |
687 } | 685 } |
688 | 686 |
689 } // namespace thumbnailing_utils | 687 } // namespace thumbnailing_utils |
OLD | NEW |