Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: ui/gfx/color_analysis.h

Issue 10272004: Move RefCountedMemory class to base namespace. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/theme_provider.h ('k') | ui/gfx/color_analysis.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef UI_GFX_COLOR_ANALYSIS_H_ 5 #ifndef UI_GFX_COLOR_ANALYSIS_H_
6 #define UI_GFX_COLOR_ANALYSIS_H_ 6 #define UI_GFX_COLOR_ANALYSIS_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 int calls_; 50 int calls_;
51 }; 51 };
52 52
53 // Returns a recommended background color for a PNG image. This color might 53 // Returns a recommended background color for a PNG image. This color might
54 // not even exist in the image, but it is typically representative of the 54 // not even exist in the image, but it is typically representative of the
55 // image and tinted towards the white end of the spectrum. 55 // image and tinted towards the white end of the spectrum.
56 // The function CalculateKMeanColorOfPNG is used to grab the KMean calculated 56 // The function CalculateKMeanColorOfPNG is used to grab the KMean calculated
57 // color of the image, then the color is moved to HSV space so the saturation 57 // color of the image, then the color is moved to HSV space so the saturation
58 // and luminance can be modified to move the color towards the white end of 58 // and luminance can be modified to move the color towards the white end of
59 // the spectrum. The color is then moved back to RGB space and returned. 59 // the spectrum. The color is then moved back to RGB space and returned.
60 SkColor CalculateRecommendedBgColorForPNG(scoped_refptr<RefCountedMemory> png); 60 SkColor CalculateRecommendedBgColorForPNG(
61 scoped_refptr<base::RefCountedMemory> png);
61 62
62 SkColor CalculateRecommendedBgColorForPNG(scoped_refptr<RefCountedMemory> png, 63 SkColor CalculateRecommendedBgColorForPNG(
63 KMeanImageSampler& sampler); 64 scoped_refptr<base::RefCountedMemory> png,
65 KMeanImageSampler& sampler);
64 66
65 // Returns an SkColor that represents the calculated dominant color in the png. 67 // Returns an SkColor that represents the calculated dominant color in the png.
66 // This uses a KMean clustering algorithm to find clusters of pixel colors in 68 // This uses a KMean clustering algorithm to find clusters of pixel colors in
67 // RGB space. 69 // RGB space.
68 // |png| represents the data of a png encoded image. 70 // |png| represents the data of a png encoded image.
69 // |darkness_limit| represents the minimum sum of the RGB components that is 71 // |darkness_limit| represents the minimum sum of the RGB components that is
70 // acceptable as a color choice. This can be from 0 to 765. 72 // acceptable as a color choice. This can be from 0 to 765.
71 // |brightness_limit| represents the maximum sum of the RGB components that is 73 // |brightness_limit| represents the maximum sum of the RGB components that is
72 // acceptable as a color choice. This can be from 0 to 765. 74 // acceptable as a color choice. This can be from 0 to 765.
73 // 75 //
(...skipping 18 matching lines...) Expand all
92 // b) If any centroid moved, repeat step 2 with the new centroids for up 94 // b) If any centroid moved, repeat step 2 with the new centroids for up
93 // to M iterations. 95 // to M iterations.
94 // 5.Once the clusters have converged or M iterations have been tried, sort 96 // 5.Once the clusters have converged or M iterations have been tried, sort
95 // the clusters by weight (where weight is the number of pixels that make up 97 // the clusters by weight (where weight is the number of pixels that make up
96 // this cluster). 98 // this cluster).
97 // 6.Going through the sorted list of clusters, pick the first cluster with the 99 // 6.Going through the sorted list of clusters, pick the first cluster with the
98 // largest weight that's centroid fulfills the equation 100 // largest weight that's centroid fulfills the equation
99 // |darkness_limit| < SUM(R, G, B) < |brightness_limit|. Return that color. 101 // |darkness_limit| < SUM(R, G, B) < |brightness_limit|. Return that color.
100 // If no color fulfills that requirement return the color with the largest 102 // If no color fulfills that requirement return the color with the largest
101 // weight regardless of whether or not it fulfills the equation above. 103 // weight regardless of whether or not it fulfills the equation above.
102 SkColor CalculateKMeanColorOfPNG(scoped_refptr<RefCountedMemory> png, 104 SkColor CalculateKMeanColorOfPNG(scoped_refptr<base::RefCountedMemory> png,
103 uint32_t darkness_limit, 105 uint32_t darkness_limit,
104 uint32_t brightness_limit); 106 uint32_t brightness_limit);
105 107
106 UI_EXPORT SkColor CalculateKMeanColorOfPNG(scoped_refptr<RefCountedMemory> png, 108 UI_EXPORT SkColor CalculateKMeanColorOfPNG(
107 uint32_t darkness_limit, 109 scoped_refptr<base::RefCountedMemory> png,
108 uint32_t brightness_limit, 110 uint32_t darkness_limit,
109 KMeanImageSampler& sampler); 111 uint32_t brightness_limit,
112 KMeanImageSampler& sampler);
110 113
111 } // namespace color_utils 114 } // namespace color_utils
112 115
113 #endif // UI_GFX_COLOR_ANALYSIS_H_ 116 #endif // UI_GFX_COLOR_ANALYSIS_H_
OLDNEW
« no previous file with comments | « ui/base/theme_provider.h ('k') | ui/gfx/color_analysis.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698