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

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

Issue 7328011: Introduce ui.dll / libui.so for the component build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
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"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
13 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
14 #include "ui/ui_api.h"
14 15
15 namespace color_utils { 16 namespace color_utils {
16 17
17 // This class exposes the sampling method to the caller, which allows 18 // This class exposes the sampling method to the caller, which allows
18 // stubbing out for things like unit tests. Might be useful to pass more 19 // stubbing out for things like unit tests. Might be useful to pass more
19 // arguments into the GetSample method in the future (such as which 20 // arguments into the GetSample method in the future (such as which
20 // cluster is being worked on, etc.). 21 // cluster is being worked on, etc.).
21 class KMeanImageSampler { 22 class UI_API KMeanImageSampler {
22 public: 23 public:
23 virtual int GetSample(int width, int height) = 0; 24 virtual int GetSample(int width, int height) = 0;
24 25
25 protected: 26 protected:
26 KMeanImageSampler(); 27 KMeanImageSampler();
27 virtual ~KMeanImageSampler(); 28 virtual ~KMeanImageSampler();
28 }; 29 };
29 30
30 // This sampler will pick a random pixel as a sample centroid. 31 // This sampler will pick a random pixel as a sample centroid.
31 class RandomSampler : public KMeanImageSampler { 32 class RandomSampler : public KMeanImageSampler {
32 public: 33 public:
33 RandomSampler(); 34 RandomSampler();
34 virtual ~RandomSampler(); 35 virtual ~RandomSampler();
35 36
36 virtual int GetSample(int width, int height) OVERRIDE; 37 virtual int GetSample(int width, int height) OVERRIDE;
37 }; 38 };
38 39
39 // This sampler will pick pixels from an evenly spaced grid. 40 // This sampler will pick pixels from an evenly spaced grid.
40 class GridSampler : public KMeanImageSampler { 41 class UI_API GridSampler : public KMeanImageSampler {
41 public: 42 public:
42 GridSampler(); 43 GridSampler();
43 virtual ~GridSampler(); 44 virtual ~GridSampler();
44 45
45 virtual int GetSample(int width, int height) OVERRIDE; 46 virtual int GetSample(int width, int height) OVERRIDE;
46 47
47 private: 48 private:
48 // The number of times GetSample has been called. 49 // The number of times GetSample has been called.
49 int calls_; 50 int calls_;
50 }; 51 };
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // this cluster). 96 // this cluster).
96 // 6.Going through the sorted list of clusters, pick the first cluster with the 97 // 6.Going through the sorted list of clusters, pick the first cluster with the
97 // largest weight that's centroid fulfills the equation 98 // largest weight that's centroid fulfills the equation
98 // |darkness_limit| < SUM(R, G, B) < |brightness_limit|. Return that color. 99 // |darkness_limit| < SUM(R, G, B) < |brightness_limit|. Return that color.
99 // If no color fulfills that requirement return the color with the largest 100 // If no color fulfills that requirement return the color with the largest
100 // weight regardless of whether or not it fulfills the equation above. 101 // weight regardless of whether or not it fulfills the equation above.
101 SkColor CalculateKMeanColorOfPNG(scoped_refptr<RefCountedMemory> png, 102 SkColor CalculateKMeanColorOfPNG(scoped_refptr<RefCountedMemory> png,
102 uint32_t darkness_limit, 103 uint32_t darkness_limit,
103 uint32_t brightness_limit); 104 uint32_t brightness_limit);
104 105
105 SkColor CalculateKMeanColorOfPNG(scoped_refptr<RefCountedMemory> png, 106 UI_API SkColor CalculateKMeanColorOfPNG(scoped_refptr<RefCountedMemory> png,
106 uint32_t darkness_limit, 107 uint32_t darkness_limit,
107 uint32_t brightness_limit, 108 uint32_t brightness_limit,
108 KMeanImageSampler& sampler); 109 KMeanImageSampler& sampler);
109 110
110 } // namespace color_utils 111 } // namespace color_utils
111 112
112 #endif // UI_GFX_COLOR_ANALYSIS_H_ 113 #endif // UI_GFX_COLOR_ANALYSIS_H_
OLDNEW
« no previous file with comments | « ui/gfx/codec/png_codec.h ('k') | ui/gfx/color_utils.h » ('j') | ui/ui.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698