#include "ui/views/bubble/bubble_border.h"
#include <algorithm>
#include <map>
#include <tuple>
#include <utility>
#include "base/check.h"
#include "base/check_op.h"
#include "base/no_destructor.h"
#include "cc/paint/paint_flags.h"
#include "third_party/skia/include/core/SkBlendMode.h"
#include "third_party/skia/include/core/SkClipOp.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkRRect.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkScalar.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rrect_f.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/scoped_canvas.h"
#include "ui/gfx/shadow_value.h"
#include "ui/gfx/skia_paint_util.h"
#include "ui/views/bubble/bubble_border_arrow_utils.h"
#include "ui/views/view.h"
#include "ui/wm/core/shadow_controller.h"
namespace views {
namespace {
ShadowCacheKey;
constexpr int kDefaultShadowType = …;
ui::Shadow::ElevationToColorsMap ShadowElevationToColorsMap(
BubbleBorder::Shadow shadow,
const ui::ColorProvider* color_provider) { … }
enum class BubbleArrowPart { … };
SkPath GetVisibleArrowPath(BubbleBorder::Arrow arrow,
const gfx::Rect& bounds,
BubbleArrowPart part) { … }
const gfx::ShadowValues& GetShadowValues(
const ui::ColorProvider* color_provider,
const std::optional<int>& elevation,
BubbleBorder::Shadow shadow_type) { … }
bool ShouldDrawStrokeForArgs(const std::optional<bool>& draw_border_stroke,
const std::optional<int>& elevation,
BubbleBorder::Shadow shadow_type) { … }
const cc::PaintFlags& GetBorderAndShadowFlags(
const ui::ColorProvider* color_provider,
const std::optional<int>& elevation,
BubbleBorder::Shadow shadow_type) { … }
template <typename T>
void DrawBorderAndShadowImpl(
T rect,
void (cc::PaintCanvas::*draw)(const T&, const cc::PaintFlags&),
gfx::Canvas* canvas,
const ui::ColorProvider* color_provider,
bool draw_stroke = true,
const std::optional<int>& elevation = std::nullopt,
BubbleBorder::Shadow shadow_type = BubbleBorder::STANDARD_SHADOW) { … }
}
BubbleBorder::BubbleBorder(Arrow arrow, Shadow shadow, ui::ColorId color_id)
: … { … }
BubbleBorder::~BubbleBorder() = default;
gfx::Insets BubbleBorder::GetBorderAndShadowInsets(
const std::optional<int>& elevation,
const std::optional<bool>& draw_border_stroke,
BubbleBorder::Shadow shadow_type) { … }
void BubbleBorder::SetCornerRadius(int corner_radius) { … }
void BubbleBorder::SetColor(SkColor color) { … }
gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& anchor_rect,
const gfx::Size& contents_size) const { … }
gfx::Vector2d BubbleBorder::GetContentsBoundsOffsetToPlaceVisibleArrow(
BubbleBorder::Arrow arrow,
bool include_gap) { … }
void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) { … }
void BubbleBorder::DrawBorderAndShadow(
SkRect rect,
gfx::Canvas* canvas,
const ui::ColorProvider* color_provider) { … }
gfx::Insets BubbleBorder::GetInsets() const { … }
gfx::Size BubbleBorder::GetMinimumSize() const { … }
void BubbleBorder::OnViewThemeChanged(View* view) { … }
gfx::Size BubbleBorder::GetSizeForContentsSize(
const gfx::Size& contents_size) const { … }
bool BubbleBorder::AddArrowToBubbleCornerAndPointTowardsAnchor(
const gfx::Rect& anchor_rect,
gfx::Rect& popup_bounds,
int popup_min_y) { … }
void BubbleBorder::CalculateVisibleArrowRect(
const gfx::Rect& contents_bounds,
const gfx::Point& anchor_point) const { … }
SkRRect BubbleBorder::GetClientRect(const View& view) const { … }
bool BubbleBorder::ShouldDrawStroke() const { … }
void BubbleBorder::UpdateColor(View* view) { … }
void BubbleBorder::PaintNoShadow(const View& view, gfx::Canvas* canvas) { … }
void BubbleBorder::PaintVisibleArrow(const View& view, gfx::Canvas* canvas) { … }
void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const { … }
}