blob: 478efb8eb05ce32d17b6462d40a889e6179b789a [file] [log] [blame]
huangs3382fc9d2015-02-11 22:18:381// 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.
4
5#ifndef COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_
6#define COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_
7
beaudoin3e75e5922015-04-22 17:12:148#include "base/memory/ref_counted_memory.h"
huangs3382fc9d2015-02-11 22:18:389#include "third_party/skia/include/core/SkColor.h"
10
11namespace favicon_base {
12
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.
16struct FallbackIconStyle {
17 FallbackIconStyle();
18 ~FallbackIconStyle();
19
20 // If any member changes, also update FallbackIconStyleBuilder.
21
22 // Icon background fill color.
23 SkColor background_color;
24
25 // Icon text color.
26 SkColor text_color;
27
28 // Ratio in [0.0, 1.0] of the text font size (pixels) to the icon size.
29 double font_size_ratio;
30
31 // The roundness of the icon's corners. 0 => square icon, 1 => circle icon.
32 double roundness;
huangs73fa3242015-05-08 06:27:1533
34 bool operator==(const FallbackIconStyle& other) const;
huangs3382fc9d2015-02-11 22:18:3835};
36
37// Reassigns |style|'s |text_color| to matches well against |background_color|.
38void MatchFallbackIconTextColorAgainstBackgroundColor(FallbackIconStyle* style);
39
40// Returns whether |style| values are within bounds.
41bool ValidateFallbackIconStyle(const FallbackIconStyle& style);
42
beaudoin3e75e5922015-04-22 17:12:1443// 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
45// readable.
46void SetDominantColorAsBackground(
47 const scoped_refptr<base::RefCountedMemory>& bitmap_data,
48 FallbackIconStyle* style);
49
huangs3382fc9d2015-02-11 22:18:3850} // namespace favicon_base
51
52#endif // COMPONENTS_FAVICON_BASE_FALLBACK_ICON_STYLE_H_