| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor); | 749 layer_mask_->OnDeviceScaleFactorChanged(device_scale_factor); |
| 750 } | 750 } |
| 751 | 751 |
| 752 void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { | 752 void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { |
| 753 DCHECK(surface_layer_.get()); | 753 DCHECK(surface_layer_.get()); |
| 754 if (!delegate_) | 754 if (!delegate_) |
| 755 return; | 755 return; |
| 756 delegate_->OnDelegatedFrameDamage(damage_rect_in_dip); | 756 delegate_->OnDelegatedFrameDamage(damage_rect_in_dip); |
| 757 } | 757 } |
| 758 | 758 |
| 759 void Layer::SetScrollable(Layer* parent_clip_layer, |
| 760 const base::Closure& on_scroll) { |
| 761 cc_layer_->SetScrollClipLayerId(parent_clip_layer->cc_layer_->id()); |
| 762 cc_layer_->set_did_scroll_callback(on_scroll); |
| 763 cc_layer_->SetUserScrollable(true, true); |
| 764 } |
| 765 |
| 766 gfx::ScrollOffset Layer::CurrentScrollOffset() const { |
| 767 const Compositor* compositor = GetCompositor(); |
| 768 gfx::ScrollOffset offset; |
| 769 if (compositor && |
| 770 compositor->GetScrollOffsetForLayer(cc_layer_->id(), &offset)) |
| 771 return offset; |
| 772 return cc_layer_->scroll_offset(); |
| 773 } |
| 774 |
| 775 void Layer::SetScrollOffset(const gfx::ScrollOffset& offset) { |
| 776 Compositor* compositor = GetCompositor(); |
| 777 bool scrolled_on_impl_side = |
| 778 compositor && compositor->ScrollLayerTo(cc_layer_->id(), offset); |
| 779 |
| 780 if (!scrolled_on_impl_side) |
| 781 cc_layer_->SetScrollOffset(offset); |
| 782 |
| 783 DCHECK_EQ(offset.x(), CurrentScrollOffset().x()); |
| 784 DCHECK_EQ(offset.y(), CurrentScrollOffset().y()); |
| 785 } |
| 786 |
| 759 void Layer::RequestCopyOfOutput( | 787 void Layer::RequestCopyOfOutput( |
| 760 std::unique_ptr<cc::CopyOutputRequest> request) { | 788 std::unique_ptr<cc::CopyOutputRequest> request) { |
| 761 cc_layer_->RequestCopyOfOutput(std::move(request)); | 789 cc_layer_->RequestCopyOfOutput(std::move(request)); |
| 762 } | 790 } |
| 763 | 791 |
| 764 gfx::Rect Layer::PaintableRegion() { | 792 gfx::Rect Layer::PaintableRegion() { |
| 765 return gfx::Rect(size()); | 793 return gfx::Rect(size()); |
| 766 } | 794 } |
| 767 | 795 |
| 768 scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList( | 796 scoped_refptr<cc::DisplayItemList> Layer::PaintContentsToDisplayList( |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 if (animator_) { | 1095 if (animator_) { |
| 1068 animator_->ResetCompositor(compositor); | 1096 animator_->ResetCompositor(compositor); |
| 1069 animator_->RemoveFromCollection(collection); | 1097 animator_->RemoveFromCollection(collection); |
| 1070 } | 1098 } |
| 1071 | 1099 |
| 1072 for (auto* child : children_) | 1100 for (auto* child : children_) |
| 1073 child->ResetCompositorForAnimatorsInTree(compositor); | 1101 child->ResetCompositorForAnimatorsInTree(compositor); |
| 1074 } | 1102 } |
| 1075 | 1103 |
| 1076 } // namespace ui | 1104 } // namespace ui |
| OLD | NEW |