| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/animation/ink_drop_host_view.h" | 5 #include "ui/views/animation/ink_drop_host_view.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/compositor/layer_type.h" |
| 8 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 9 #include "ui/events/scoped_target_handler.h" | 10 #include "ui/events/scoped_target_handler.h" |
| 10 #include "ui/gfx/color_palette.h" | 11 #include "ui/gfx/color_palette.h" |
| 11 #include "ui/gfx/geometry/size_conversions.h" | 12 #include "ui/gfx/geometry/size_conversions.h" |
| 12 #include "ui/views/animation/ink_drop.h" | 13 #include "ui/views/animation/ink_drop.h" |
| 13 #include "ui/views/animation/ink_drop_highlight.h" | 14 #include "ui/views/animation/ink_drop_highlight.h" |
| 14 #include "ui/views/animation/ink_drop_impl.h" | 15 #include "ui/views/animation/ink_drop_impl.h" |
| 15 #include "ui/views/animation/ink_drop_mask.h" | 16 #include "ui/views/animation/ink_drop_mask.h" |
| 16 #include "ui/views/animation/ink_drop_stub.h" | 17 #include "ui/views/animation/ink_drop_stub.h" |
| 17 #include "ui/views/animation/square_ink_drop_ripple.h" | 18 #include "ui/views/animation/square_ink_drop_ripple.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 destroying_(false) {} | 124 destroying_(false) {} |
| 124 | 125 |
| 125 InkDropHostView::~InkDropHostView() { | 126 InkDropHostView::~InkDropHostView() { |
| 126 // TODO(bruthig): Improve InkDropImpl to be safer about calling back to | 127 // TODO(bruthig): Improve InkDropImpl to be safer about calling back to |
| 127 // potentially destroyed InkDropHosts and remove |destroying_|. | 128 // potentially destroyed InkDropHosts and remove |destroying_|. |
| 128 destroying_ = true; | 129 destroying_ = true; |
| 129 } | 130 } |
| 130 | 131 |
| 131 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 132 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 132 old_paint_to_layer_ = layer() != nullptr; | 133 old_paint_to_layer_ = layer() != nullptr; |
| 133 SetPaintToLayer(true); | 134 SetPaintToLayer(ui::LAYER_TEXTURED); |
| 134 layer()->SetFillsBoundsOpaquely(false); | 135 layer()->SetFillsBoundsOpaquely(false); |
| 135 ink_drop_mask_ = CreateInkDropMask(); | 136 ink_drop_mask_ = CreateInkDropMask(); |
| 136 if (ink_drop_mask_) | 137 if (ink_drop_mask_) |
| 137 ink_drop_layer->SetMaskLayer(ink_drop_mask_->layer()); | 138 ink_drop_layer->SetMaskLayer(ink_drop_mask_->layer()); |
| 138 layer()->Add(ink_drop_layer); | 139 layer()->Add(ink_drop_layer); |
| 139 layer()->StackAtBottom(ink_drop_layer); | 140 layer()->StackAtBottom(ink_drop_layer); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 143 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 143 // No need to do anything when called during shutdown, and if a derived | 144 // No need to do anything when called during shutdown, and if a derived |
| 144 // class has overridden Add/RemoveInkDropLayer, running this implementation | 145 // class has overridden Add/RemoveInkDropLayer, running this implementation |
| 145 // would be wrong. | 146 // would be wrong. |
| 146 if (destroying_) | 147 if (destroying_) |
| 147 return; | 148 return; |
| 148 layer()->Remove(ink_drop_layer); | 149 layer()->Remove(ink_drop_layer); |
| 149 // Layers safely handle destroying a mask layer before the masked layer. | 150 // Layers safely handle destroying a mask layer before the masked layer. |
| 150 ink_drop_mask_.reset(); | 151 ink_drop_mask_.reset(); |
| 151 SetPaintToLayer(old_paint_to_layer_); | 152 SetPaintToLayer(old_paint_to_layer_ ? ui::LAYER_TEXTURED |
| 153 : ui::LAYER_NOT_DRAWN); |
| 152 } | 154 } |
| 153 | 155 |
| 154 std::unique_ptr<InkDrop> InkDropHostView::CreateInkDrop() { | 156 std::unique_ptr<InkDrop> InkDropHostView::CreateInkDrop() { |
| 155 return CreateDefaultInkDropImpl(); | 157 return CreateDefaultInkDropImpl(); |
| 156 } | 158 } |
| 157 | 159 |
| 158 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { | 160 std::unique_ptr<InkDropRipple> InkDropHostView::CreateInkDropRipple() const { |
| 159 return CreateDefaultInkDropRipple(GetLocalBounds().CenterPoint()); | 161 return CreateDefaultInkDropRipple(GetLocalBounds().CenterPoint()); |
| 160 } | 162 } |
| 161 | 163 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 std::unique_ptr<InkDropImpl> | 294 std::unique_ptr<InkDropImpl> |
| 293 InkDropHostView::CreateDefaultFloodFillInkDropImpl() { | 295 InkDropHostView::CreateDefaultFloodFillInkDropImpl() { |
| 294 std::unique_ptr<views::InkDropImpl> ink_drop = | 296 std::unique_ptr<views::InkDropImpl> ink_drop = |
| 295 InkDropHostView::CreateDefaultInkDropImpl(); | 297 InkDropHostView::CreateDefaultInkDropImpl(); |
| 296 ink_drop->SetAutoHighlightMode( | 298 ink_drop->SetAutoHighlightMode( |
| 297 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE); | 299 views::InkDropImpl::AutoHighlightMode::SHOW_ON_RIPPLE); |
| 298 return ink_drop; | 300 return ink_drop; |
| 299 } | 301 } |
| 300 | 302 |
| 301 } // namespace views | 303 } // namespace views |
| OLD | NEW |