| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_ | 5 #ifndef COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_ |
| 6 #define COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_ | 6 #define COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 10 | 10 |
| 11 namespace favicon_base { | 11 namespace favicon_base { |
| 12 | 12 |
| 13 // Styling specifications of a fallback icon. The icon is composed of a solid | 13 // Styling specifications of a fallback icon. The icon is composed of a solid |
| 14 // rounded square containing a single letter. The specification excludes the | 14 // rounded square containing a single letter. The specification excludes the |
| 15 // icon URL and size, which are given when the icon is rendered. | 15 // icon URL and size, which are given when the icon is rendered. |
| 16 struct FallbackIconStyle { | 16 struct FallbackIconStyle { |
| 17 FallbackIconStyle(); | 17 FallbackIconStyle(); |
| 18 ~FallbackIconStyle(); | 18 ~FallbackIconStyle(); |
| 19 | 19 |
| 20 // If any member changes, also update FallbackIconStyleBuilder. | |
| 21 | |
| 22 // Icon background fill color. | 20 // Icon background fill color. |
| 23 SkColor background_color; | 21 SkColor background_color; |
| 24 bool is_default_background_color; | 22 bool is_default_background_color; |
| 25 | 23 |
| 26 // Icon text color. | 24 // Icon text color. |
| 27 SkColor text_color; | 25 SkColor text_color; |
| 28 | 26 |
| 29 // Ratio in [0.0, 1.0] of the text font size (pixels) to the icon size. | |
| 30 double font_size_ratio; | |
| 31 | |
| 32 // The roundness of the icon's corners. 0 => square icon, 1 => circle icon. | |
| 33 double roundness; | |
| 34 | |
| 35 bool operator==(const FallbackIconStyle& other) const; | 27 bool operator==(const FallbackIconStyle& other) const; |
| 36 }; | 28 }; |
| 37 | 29 |
| 38 // Reassigns |style|'s |text_color| to matches well against |background_color|. | |
| 39 void MatchFallbackIconTextColorAgainstBackgroundColor(FallbackIconStyle* style); | |
| 40 | |
| 41 // Returns whether |style| values are within bounds. | |
| 42 bool ValidateFallbackIconStyle(const FallbackIconStyle& style); | |
| 43 | |
| 44 // Set |style|'s background color to the dominant color of |bitmap_data|, | 30 // Set |style|'s background color to the dominant color of |bitmap_data|, |
| 45 // clamping luminance down to a reasonable maximum value so that light text is | 31 // clamping luminance down to a reasonable maximum value so that light text is |
| 46 // readable. | 32 // readable. |
| 47 void SetDominantColorAsBackground( | 33 void SetDominantColorAsBackground( |
| 48 const scoped_refptr<base::RefCountedMemory>& bitmap_data, | 34 const scoped_refptr<base::RefCountedMemory>& bitmap_data, |
| 49 FallbackIconStyle* style); | 35 FallbackIconStyle* style); |
| 50 | 36 |
| 51 } // namespace favicon_base | 37 } // namespace favicon_base |
| 52 | 38 |
| 53 #endif // COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_ | 39 #endif // COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_ |
| OLD | NEW |