| 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> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <algorithm> | 10 #include <algorithm> |
| 8 #include <cmath> | 11 #include <cmath> |
| 9 #include <cstdlib> | 12 #include <cstdlib> |
| 10 #include <functional> | 13 #include <functional> |
| 11 #include <limits> | 14 #include <limits> |
| 12 #include <numeric> | 15 #include <numeric> |
| 13 #include <vector> | 16 #include <vector> |
| 14 | 17 |
| 15 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 28 #ifndef M_PI | 31 #ifndef M_PI |
| 29 #define M_PI 3.14159265358979323846 | 32 #define M_PI 3.14159265358979323846 |
| 30 #endif | 33 #endif |
| 31 | 34 |
| 32 unsigned long ImagePixelSum(const SkBitmap& bitmap, const gfx::Rect& rect) { | 35 unsigned long ImagePixelSum(const SkBitmap& bitmap, const gfx::Rect& rect) { |
| 33 // Get the sum of pixel values in the rectangle. Applicable only to | 36 // Get the sum of pixel values in the rectangle. Applicable only to |
| 34 // monochrome bitmaps. | 37 // monochrome bitmaps. |
| 35 DCHECK_EQ(kAlpha_8_SkColorType, bitmap.colorType()); | 38 DCHECK_EQ(kAlpha_8_SkColorType, bitmap.colorType()); |
| 36 unsigned long total = 0; | 39 unsigned long total = 0; |
| 37 for (int r = rect.y(); r < rect.bottom(); ++r) { | 40 for (int r = rect.y(); r < rect.bottom(); ++r) { |
| 38 const uint8* row_data = static_cast<const uint8*>( | 41 const uint8_t* row_data = |
| 39 bitmap.getPixels()) + r * bitmap.rowBytes(); | 42 static_cast<const uint8_t*>(bitmap.getPixels()) + r * bitmap.rowBytes(); |
| 40 for (int c = rect.x(); c < rect.right(); ++c) | 43 for (int c = rect.x(); c < rect.right(); ++c) |
| 41 total += row_data[c]; | 44 total += row_data[c]; |
| 42 } | 45 } |
| 43 | 46 |
| 44 return total; | 47 return total; |
| 45 } | 48 } |
| 46 | 49 |
| 47 bool CompareImageFragments(const SkBitmap& bitmap_left, | 50 bool CompareImageFragments(const SkBitmap& bitmap_left, |
| 48 const SkBitmap& bitmap_right, | 51 const SkBitmap& bitmap_right, |
| 49 const gfx::Size& comparison_area, | 52 const gfx::Size& comparison_area, |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 | 679 |
| 677 int histogram[256] = {}; | 680 int histogram[256] = {}; |
| 678 color_utils::BuildLumaHistogram(result, histogram); | 681 color_utils::BuildLumaHistogram(result, histogram); |
| 679 int non_zero_color_count = std::count_if( | 682 int non_zero_color_count = std::count_if( |
| 680 histogram, histogram + 256, [](int value) { return value > 0; }); | 683 histogram, histogram + 256, [](int value) { return value > 0; }); |
| 681 EXPECT_GT(non_zero_color_count, 4); | 684 EXPECT_GT(non_zero_color_count, 4); |
| 682 | 685 |
| 683 } | 686 } |
| 684 | 687 |
| 685 } // namespace thumbnailing_utils | 688 } // namespace thumbnailing_utils |
| OLD | NEW |