Chromium Code Reviews| Index: ui/views/bubble/bubble_border.cc |
| diff --git a/ui/views/bubble/bubble_border.cc b/ui/views/bubble/bubble_border.cc |
| index c2892ca0fc7094b78cab5e286fcd496c30e6133a..6f40b7f0643ed533f1bf178e02aaf5691999350b 100644 |
| --- a/ui/views/bubble/bubble_border.cc |
| +++ b/ui/views/bubble/bubble_border.cc |
| @@ -12,6 +12,7 @@ |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/geometry/rect.h" |
| +#include "ui/gfx/path.h" |
| #include "ui/gfx/skia_util.h" |
| #include "ui/resources/grit/ui_resources.h" |
| #include "ui/views/painter.h" |
| @@ -141,11 +142,17 @@ BubbleBorder::BubbleBorder(Arrow arrow, Shadow shadow, SkColor color) |
| arrow_offset_(0), |
| arrow_paint_type_(PAINT_NORMAL), |
| alignment_(ALIGN_ARROW_TO_MID_ANCHOR), |
| - shadow_(shadow), |
| background_color_(color), |
| use_theme_background_color_(false) { |
| - DCHECK(shadow < SHADOW_COUNT); |
| - images_ = GetBorderImages(shadow); |
| +// On Mac, use the NO_ASSETS bubble border. WindowServer on Mac is able to |
|
tapted
2016/01/28 05:59:22
nit: I think we should have the initializer still,
karandeepb
2016/02/04 03:39:27
Done.
|
| +// generate drop shadows for dialogs, hence we don't use raster shadows. |
| +#if defined(OS_MACOSX) |
| + shadow_ = NO_ASSETS; |
| +#else |
| + shadow_ = shadow; |
| +#endif // OS_MACOSX |
| + DCHECK(shadow_ < SHADOW_COUNT); |
| + images_ = GetBorderImages(shadow_); |
| } |
| BubbleBorder::~BubbleBorder() {} |
| @@ -211,6 +218,14 @@ int BubbleBorder::GetArrowOffset(const gfx::Size& border_size) const { |
| return std::max(min, std::min(arrow_offset_, edge_length - min)); |
| } |
| +void BubbleBorder::GetArrowMask(const gfx::Rect& view_bounds, |
| + gfx::Path* mask) const { |
| + if (!has_arrow(arrow_) || arrow_paint_type_ != PAINT_NORMAL) |
| + return; |
| + |
| + return GetArrowMaskFromArrowBounds(GetArrowRect(view_bounds), mask); |
| +} |
| + |
| void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) { |
| gfx::Rect bounds(view.GetContentsBounds()); |
| bounds.Inset(-GetBorderThickness(), -GetBorderThickness()); |
| @@ -328,9 +343,8 @@ gfx::Rect BubbleBorder::GetArrowRect(const gfx::Rect& bounds) const { |
| return gfx::Rect(origin, gfx::Size(width, height)); |
| } |
| -void BubbleBorder::DrawArrow(gfx::Canvas* canvas, |
| - const gfx::Rect& arrow_bounds) const { |
| - canvas->DrawImageInt(*GetArrowImage(), arrow_bounds.x(), arrow_bounds.y()); |
| +void BubbleBorder::GetArrowMaskFromArrowBounds(const gfx::Rect& arrow_bounds, |
| + SkPath* mask) const { |
| const bool horizontal = is_arrow_on_horizontal(arrow_); |
| const int thickness = images_->arrow_interior_thickness; |
| float tip_x = horizontal ? arrow_bounds.CenterPoint().x() : |
| @@ -344,16 +358,21 @@ void BubbleBorder::DrawArrow(gfx::Canvas* canvas, |
| const int offset_to_next_vertex = positive_offset ? |
| images_->arrow_interior_thickness : -images_->arrow_interior_thickness; |
| - SkPath path; |
| - path.incReserve(4); |
| - path.moveTo(SkDoubleToScalar(tip_x), SkDoubleToScalar(tip_y)); |
| - path.lineTo(SkDoubleToScalar(tip_x + offset_to_next_vertex), |
| - SkDoubleToScalar(tip_y + offset_to_next_vertex)); |
| + mask->incReserve(4); |
| + mask->moveTo(SkDoubleToScalar(tip_x), SkDoubleToScalar(tip_y)); |
| + mask->lineTo(SkDoubleToScalar(tip_x + offset_to_next_vertex), |
| + SkDoubleToScalar(tip_y + offset_to_next_vertex)); |
| const int multiplier = horizontal ? 1 : -1; |
| - path.lineTo(SkDoubleToScalar(tip_x - multiplier * offset_to_next_vertex), |
| - SkDoubleToScalar(tip_y + multiplier * offset_to_next_vertex)); |
| - path.close(); |
| + mask->lineTo(SkDoubleToScalar(tip_x - multiplier * offset_to_next_vertex), |
| + SkDoubleToScalar(tip_y + multiplier * offset_to_next_vertex)); |
| + mask->close(); |
| +} |
| +void BubbleBorder::DrawArrow(gfx::Canvas* canvas, |
| + const gfx::Rect& arrow_bounds) const { |
| + canvas->DrawImageInt(*GetArrowImage(), arrow_bounds.x(), arrow_bounds.y()); |
| + SkPath path; |
| + GetArrowMaskFromArrowBounds(arrow_bounds, &path); |
| SkPaint paint; |
| paint.setStyle(SkPaint::kFill_Style); |
| paint.setColor(background_color_); |