Chromium Code Reviews| Index: ui/views/bubble/tray_bubble_view.cc |
| diff --git a/ui/views/bubble/tray_bubble_view.cc b/ui/views/bubble/tray_bubble_view.cc |
| index 3f947ab913421ed01fc3069c37ef9788cb8ca18a..fe6b80332ce8ad41fd22d0bcd38f93b636ab7235 100644 |
| --- a/ui/views/bubble/tray_bubble_view.cc |
| +++ b/ui/views/bubble/tray_bubble_view.cc |
| @@ -179,7 +179,7 @@ class TrayBubbleContentMask : public ui::LayerDelegate { |
| explicit TrayBubbleContentMask(int corner_radius); |
| virtual ~TrayBubbleContentMask(); |
| - ui::Layer* layer() { return &layer_; } |
| + void set_bounds(gfx::Rect bounds) { bounds_ = bounds; } |
| // Overridden from LayerDelegate. |
| virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; |
| @@ -187,25 +187,22 @@ class TrayBubbleContentMask : public ui::LayerDelegate { |
| virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE; |
| private: |
| - ui::Layer layer_; |
| + gfx::Rect bounds_; |
| SkScalar corner_radius_; |
| DISALLOW_COPY_AND_ASSIGN(TrayBubbleContentMask); |
| }; |
| TrayBubbleContentMask::TrayBubbleContentMask(int corner_radius) |
| - : layer_(ui::LAYER_TEXTURED), |
| - corner_radius_(corner_radius) { |
| - layer_.set_delegate(this); |
| + : corner_radius_(corner_radius) { |
| } |
| TrayBubbleContentMask::~TrayBubbleContentMask() { |
| - layer_.set_delegate(NULL); |
| } |
| void TrayBubbleContentMask::OnPaintLayer(gfx::Canvas* canvas) { |
| SkPath path; |
|
Mr4D (OOO till 08-26)
2013/12/10 15:28:58
Could you please add a comment towards why you are
michaelpg
2013/12/10 22:01:34
As discussed, we are using the layer's bounds. :)
|
| - path.addRoundRect(gfx::RectToSkRect(gfx::Rect(layer()->bounds().size())), |
| + path.addRoundRect(gfx::RectToSkRect(gfx::Rect(bounds_.size())), |
| corner_radius_, corner_radius_); |
| SkPaint paint; |
| paint.setAlpha(255); |
| @@ -340,6 +337,11 @@ TrayBubbleView::TrayBubbleView(gfx::NativeView parent_window, |
| TrayBubbleView::~TrayBubbleView() { |
| mouse_watcher_.reset(); |
| + |
| + if (get_use_acceleration_when_possible() && |
|
stevenjb
2013/12/10 22:16:02
Do we need the first check? i.e. if it's false, th
michaelpg
2013/12/10 22:26:08
Yes, you're right. I added the second check becaus
|
| + layer()->parent()->layer_mask_layer()) |
| + layer()->parent()->layer_mask_layer()->set_delegate(NULL); |
| + |
| // Inform host items (models) that their views are being destroyed. |
| if (delegate_) |
| delegate_->BubbleViewDestroyed(); |
| @@ -350,8 +352,11 @@ void TrayBubbleView::InitializeAndShowBubble() { |
| SetAlignment(params_.arrow_alignment); |
| bubble_border_->UpdateArrowOffset(); |
| - if (get_use_acceleration_when_possible()) |
| - layer()->parent()->SetMaskLayer(bubble_content_mask_->layer()); |
| + if (get_use_acceleration_when_possible()) { |
| + scoped_ptr<ui::Layer> mask_layer(new ui::Layer(ui::LAYER_TEXTURED)); |
| + mask_layer->set_delegate(bubble_content_mask_.get()); |
| + layer()->parent()->SetMaskLayer(mask_layer.Pass()); |
| + } |
| GetWidget()->Show(); |
| UpdateBubble(); |
| @@ -359,8 +364,11 @@ void TrayBubbleView::InitializeAndShowBubble() { |
| void TrayBubbleView::UpdateBubble() { |
| SizeToContents(); |
| - if (get_use_acceleration_when_possible()) |
| - bubble_content_mask_->layer()->SetBounds(layer()->bounds()); |
| + if (get_use_acceleration_when_possible()) { |
| + bubble_content_mask_->set_bounds(layer()->bounds()); |
| + if (layer()->parent()->layer_mask_layer()) |
| + layer()->parent()->layer_mask_layer()->SetBounds(layer()->bounds()); |
| + } |
| GetWidget()->GetRootView()->SchedulePaint(); |
| } |