diff options
author | michaelpg@chromium.org <michaelpg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-07 11:24:09 +0000 |
---|---|---|
committer | michaelpg@chromium.org <michaelpg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-07 11:24:09 +0000 |
commit | c0dc4b1762ad2ebde1992d1c28ab89da17905a49 (patch) | |
tree | c7716c0c023a7e94e1ae752cd8cbc68c42739162 | |
parent | 7e8d9d5c6e9b3d04781fd0809c5a568e48ac5249 (diff) | |
download | chromium_src-c0dc4b1762ad2ebde1992d1c28ab89da17905a49.zip chromium_src-c0dc4b1762ad2ebde1992d1c28ab89da17905a49.tar.gz chromium_src-c0dc4b1762ad2ebde1992d1c28ab89da17905a49.tar.bz2 |
Revert "Retain tray bubble's rounded corners when the bubble animates out"
This reverts commit 7b1cac3592db1009adf4e11c2d9f87a81626630f.
BUG=330744, 330745, 331852
TBR=piman@chromium.org, msw@chromium.org
Review URL: https://codereview.chromium.org/125433002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243261 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/compositor/layer.cc | 36 | ||||
-rw-r--r-- | ui/compositor/layer.h | 15 | ||||
-rw-r--r-- | ui/views/bubble/tray_bubble_view.cc | 29 |
3 files changed, 47 insertions, 33 deletions
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index 09d2660..51322be 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -56,6 +56,8 @@ Layer::Layer() layer_brightness_(0.0f), layer_grayscale_(0.0f), layer_inverted_(false), + layer_mask_(NULL), + layer_mask_back_link_(NULL), zoom_(1), zoom_inset_(0), delegate_(NULL), @@ -78,6 +80,8 @@ Layer::Layer(LayerType type) layer_brightness_(0.0f), layer_grayscale_(0.0f), layer_inverted_(false), + layer_mask_(NULL), + layer_mask_back_link_(NULL), zoom_(1), zoom_inset_(0), delegate_(NULL), @@ -96,10 +100,12 @@ Layer::~Layer() { animator_ = NULL; if (compositor_) compositor_->SetRootLayer(NULL); - if (layer_mask_.get()) - SetMaskLayer(scoped_ptr<Layer>()); if (parent_) parent_->Remove(this); + if (layer_mask_) + SetMaskLayer(NULL); + if (layer_mask_back_link_) + layer_mask_back_link_->SetMaskLayer(NULL); for (size_t i = 0; i < children_.size(); ++i) children_[i]->parent_ = NULL; cc_layer_->RemoveLayerAnimationEventObserver(this); @@ -274,18 +280,28 @@ void Layer::SetLayerInverted(bool inverted) { SetLayerFilters(); } -void Layer::SetMaskLayer(scoped_ptr<Layer> layer_mask) { +void Layer::SetMaskLayer(Layer* layer_mask) { // The provided mask should not have a layer mask itself. - DCHECK(!layer_mask.get() || + DCHECK(!layer_mask || (!layer_mask->layer_mask_layer() && - layer_mask->children().empty())); - if (layer_mask_.get() == layer_mask.get()) + layer_mask->children().empty() && + !layer_mask->layer_mask_back_link_)); + DCHECK(!layer_mask_back_link_); + if (layer_mask_ == layer_mask) return; - layer_mask_ = layer_mask.Pass(); + // We need to de-reference the currently linked object so that no problem + // arises if the mask layer gets deleted before this object. + if (layer_mask_) + layer_mask_->layer_mask_back_link_ = NULL; + layer_mask_ = layer_mask; cc_layer_->SetMaskLayer( - layer_mask_.get() ? layer_mask_->cc_layer() : NULL); - if (layer_mask_.get()) - layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor_); + layer_mask ? layer_mask->cc_layer() : NULL); + // We need to reference the linked object so that it can properly break the + // link to us when it gets deleted. + if (layer_mask) { + layer_mask->layer_mask_back_link_ = this; + layer_mask->OnDeviceScaleFactorChanged(device_scale_factor_); + } } void Layer::SetBackgroundZoom(float zoom, int inset) { diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h index 3ce1c96..ff2f7da 100644 --- a/ui/compositor/layer.h +++ b/ui/compositor/layer.h @@ -198,10 +198,11 @@ class COMPOSITOR_EXPORT Layer // Set a layer mask for a layer. // Note the provided layer mask can neither have a layer mask itself nor can - // it have any children. + // it have any children. The ownership of |layer_mask| will not be + // transferred with this call. // Furthermore: A mask layer can only be set to one layer. - void SetMaskLayer(scoped_ptr<Layer> layer_mask); - Layer* layer_mask_layer() { return layer_mask_.get(); } + void SetMaskLayer(Layer* layer_mask); + Layer* layer_mask_layer() { return layer_mask_; } // Sets the visibility of the Layer. A Layer may be visible but not // drawn. This happens if any ancestor of a Layer is not visible. @@ -448,8 +449,12 @@ class COMPOSITOR_EXPORT Layer float layer_grayscale_; bool layer_inverted_; - // The mask layer associated with this layer. - scoped_ptr<Layer> layer_mask_; + // The associated mask layer with this layer. + Layer* layer_mask_; + // The back link from the mask layer to it's associated masked layer. + // We keep this reference for the case that if the mask layer gets deleted + // while attached to the main layer before the main layer is deleted. + Layer* layer_mask_back_link_; // The zoom factor to scale the layer by. Zooming is disabled when this is // set to 1. diff --git a/ui/views/bubble/tray_bubble_view.cc b/ui/views/bubble/tray_bubble_view.cc index 9259489..3f947ab 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(); - void set_bounds(gfx::Rect bounds) { bounds_ = bounds; } + ui::Layer* layer() { return &layer_; } // Overridden from LayerDelegate. virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; @@ -187,22 +187,25 @@ class TrayBubbleContentMask : public ui::LayerDelegate { virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE; private: - gfx::Rect bounds_; + ui::Layer layer_; SkScalar corner_radius_; DISALLOW_COPY_AND_ASSIGN(TrayBubbleContentMask); }; TrayBubbleContentMask::TrayBubbleContentMask(int corner_radius) - : corner_radius_(corner_radius) { + : layer_(ui::LAYER_TEXTURED), + corner_radius_(corner_radius) { + layer_.set_delegate(this); } TrayBubbleContentMask::~TrayBubbleContentMask() { + layer_.set_delegate(NULL); } void TrayBubbleContentMask::OnPaintLayer(gfx::Canvas* canvas) { SkPath path; - path.addRoundRect(gfx::RectToSkRect(gfx::Rect(bounds_.size())), + path.addRoundRect(gfx::RectToSkRect(gfx::Rect(layer()->bounds().size())), corner_radius_, corner_radius_); SkPaint paint; paint.setAlpha(255); @@ -337,10 +340,6 @@ TrayBubbleView::TrayBubbleView(gfx::NativeView parent_window, TrayBubbleView::~TrayBubbleView() { mouse_watcher_.reset(); - - if (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(); @@ -351,11 +350,8 @@ void TrayBubbleView::InitializeAndShowBubble() { SetAlignment(params_.arrow_alignment); bubble_border_->UpdateArrowOffset(); - 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()); - } + if (get_use_acceleration_when_possible()) + layer()->parent()->SetMaskLayer(bubble_content_mask_->layer()); GetWidget()->Show(); UpdateBubble(); @@ -363,11 +359,8 @@ void TrayBubbleView::InitializeAndShowBubble() { void TrayBubbleView::UpdateBubble() { SizeToContents(); - 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()); - } + if (get_use_acceleration_when_possible()) + bubble_content_mask_->layer()->SetBounds(layer()->bounds()); GetWidget()->GetRootView()->SchedulePaint(); } |