#include "components/media_message_center/media_notification_background_impl.h"
#include <algorithm>
#include <vector>
#include "base/i18n/rtl.h"
#include "cc/paint/paint_shader.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkPathTypes.h"
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkScalar.h"
#include "third_party/skia/include/core/SkTileMode.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_analysis.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/scoped_canvas.h"
#include "ui/views/style/typography.h"
#include "ui/views/style/typography_provider.h"
#include "ui/views/view.h"
namespace media_message_center {
namespace {
constexpr int kMediaImageGradientWidth = …;
constexpr double kMediaNotificationBackgroundColorVeryPopularRatio = …;
constexpr double kMediaNotificationForegroundColorMostPopularRatio = …;
constexpr double kMediaNotificationForegroundColorMostPopularMinSaturation = …;
constexpr double kMediaNotificationForegroundColorMoreVibrantRatio = …;
constexpr float kMediaNotificationMinimumContrastRatio = …;
bool IsNearlyWhiteOrBlack(SkColor color) { … }
int GetHueDegrees(const SkColor& color) { … }
double GetSaturation(const color_utils::Swatch& swatch) { … }
bool IsForegroundColorSwatchAllowed(const SkColor& background,
const SkColor& candidate) { … }
std::optional<SkColor> GetNotificationBackgroundColor(const SkBitmap* source) { … }
color_utils::Swatch SelectVibrantSwatch(const color_utils::Swatch& more_vibrant,
const color_utils::Swatch& vibrant) { … }
color_utils::Swatch SelectMutedSwatch(const color_utils::Swatch& muted,
const color_utils::Swatch& more_muted) { … }
std::optional<SkColor> GetNotificationForegroundColor(
const std::optional<SkColor>& background_color,
const SkBitmap* source) { … }
}
MediaNotificationBackgroundImpl::MediaNotificationBackgroundImpl(
int top_radius,
int bottom_radius,
double artwork_max_width_pct)
: … { … }
MediaNotificationBackgroundImpl::~MediaNotificationBackgroundImpl() = default;
void MediaNotificationBackgroundImpl::Paint(gfx::Canvas* canvas,
views::View* view) const { … }
void MediaNotificationBackgroundImpl::UpdateArtwork(
const gfx::ImageSkia& image) { … }
bool MediaNotificationBackgroundImpl::UpdateCornerRadius(int top_radius,
int bottom_radius) { … }
bool MediaNotificationBackgroundImpl::UpdateArtworkMaxWidthPct(
double max_width_pct) { … }
void MediaNotificationBackgroundImpl::UpdateFavicon(
const gfx::ImageSkia& icon) { … }
void MediaNotificationBackgroundImpl::UpdateDeviceSelectorVisibility(
bool visible) { … }
SkColor MediaNotificationBackgroundImpl::GetBackgroundColor(
const views::View& owner) const { … }
SkColor MediaNotificationBackgroundImpl::GetForegroundColor(
const views::View& owner) const { … }
int MediaNotificationBackgroundImpl::GetArtworkWidth(
const gfx::Size& view_size) const { … }
int MediaNotificationBackgroundImpl::GetArtworkVisibleWidth(
const gfx::Size& view_size) const { … }
gfx::Rect MediaNotificationBackgroundImpl::GetArtworkBounds(
const views::View& owner) const { … }
gfx::Rect MediaNotificationBackgroundImpl::GetFilledBackgroundBounds(
const views::View& owner) const { … }
gfx::Rect MediaNotificationBackgroundImpl::GetGradientBounds(
const views::View& owner) const { … }
gfx::Rect MediaNotificationBackgroundImpl::GetBottomGradientBounds(
const views::View& owner) const { … }
SkPoint MediaNotificationBackgroundImpl::GetGradientStartPoint(
const gfx::Rect& draw_bounds) const { … }
SkPoint MediaNotificationBackgroundImpl::GetGradientEndPoint(
const gfx::Rect& draw_bounds) const { … }
SkColor MediaNotificationBackgroundImpl::GetDefaultBackgroundColor(
const views::View& owner) const { … }
void MediaNotificationBackgroundImpl::UpdateColorsInternal() { … }
}