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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <cstdlib> | 9 #include <cstdlib> |
10 #include <functional> | 10 #include <functional> |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 #ifndef M_PI | 28 #ifndef M_PI |
29 #define M_PI 3.14159265358979323846 | 29 #define M_PI 3.14159265358979323846 |
30 #endif | 30 #endif |
31 | 31 |
32 unsigned long ImagePixelSum(const SkBitmap& bitmap, const gfx::Rect& rect) { | 32 unsigned long ImagePixelSum(const SkBitmap& bitmap, const gfx::Rect& rect) { |
33 // Get the sum of pixel values in the rectangle. Applicable only to | 33 // Get the sum of pixel values in the rectangle. Applicable only to |
34 // monochrome bitmaps. | 34 // monochrome bitmaps. |
35 DCHECK_EQ(SkBitmap::kA8_Config, bitmap.config()); | 35 DCHECK_EQ(kAlpha_8_SkColorType, bitmap.colorType()); |
36 unsigned long total = 0; | 36 unsigned long total = 0; |
37 for (int r = rect.y(); r < rect.bottom(); ++r) { | 37 for (int r = rect.y(); r < rect.bottom(); ++r) { |
38 const uint8* row_data = static_cast<const uint8*>( | 38 const uint8* row_data = static_cast<const uint8*>( |
39 bitmap.getPixels()) + r * bitmap.rowBytes(); | 39 bitmap.getPixels()) + r * bitmap.rowBytes(); |
40 for (int c = rect.x(); c < rect.right(); ++c) | 40 for (int c = rect.x(); c < rect.right(); ++c) |
41 total += row_data[c]; | 41 total += row_data[c]; |
42 } | 42 } |
43 | 43 |
44 return total; | 44 return total; |
45 } | 45 } |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 701 |
702 int histogram[256] = {}; | 702 int histogram[256] = {}; |
703 color_utils::BuildLumaHistogram(result, histogram); | 703 color_utils::BuildLumaHistogram(result, histogram); |
704 int non_zero_color_count = std::count_if( | 704 int non_zero_color_count = std::count_if( |
705 histogram, histogram + 256, std::bind2nd(std::greater<int>(), 0)); | 705 histogram, histogram + 256, std::bind2nd(std::greater<int>(), 0)); |
706 EXPECT_GT(non_zero_color_count, 4); | 706 EXPECT_GT(non_zero_color_count, 4); |
707 | 707 |
708 } | 708 } |
709 | 709 |
710 } // namespace thumbnailing_utils | 710 } // namespace thumbnailing_utils |
OLD | NEW |