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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_
6 #define COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_
8 #include "base/memory/ref_counted_memory.h"
9 #include "third_party/skia/include/core/SkColor.h"
11 namespace favicon_base
{
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
15 // icon URL and size, which are given when the icon is rendered.
16 struct FallbackIconStyle
{
20 // If any member changes, also update FallbackIconStyleBuilder.
22 // Icon background fill color.
23 SkColor background_color
;
28 // Ratio in [0.0, 1.0] of the text font size (pixels) to the icon size.
29 double font_size_ratio
;
31 // The roundness of the icon's corners. 0 => square icon, 1 => circle icon.
34 bool operator==(const FallbackIconStyle
& other
) const;
37 // Reassigns |style|'s |text_color| to matches well against |background_color|.
38 void MatchFallbackIconTextColorAgainstBackgroundColor(FallbackIconStyle
* style
);
40 // Returns whether |style| values are within bounds.
41 bool ValidateFallbackIconStyle(const FallbackIconStyle
& style
);
43 // Set |style|'s background color to the dominant color of |bitmap_data|,
44 // clamping luminance down to a reasonable maximum value so that light text is
46 void SetDominantColorAsBackground(
47 const scoped_refptr
<base::RefCountedMemory
>& bitmap_data
,
48 FallbackIconStyle
* style
);
50 } // namespace favicon_base
52 #endif // COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_