Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/layers/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1021 bounds_.height() + bounds_delta_.y()); | 1021 bounds_.height() + bounds_delta_.y()); |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 void LayerImpl::SetBounds(const gfx::Size& bounds) { | 1024 void LayerImpl::SetBounds(const gfx::Size& bounds) { |
| 1025 if (bounds_ == bounds) | 1025 if (bounds_ == bounds) |
| 1026 return; | 1026 return; |
| 1027 | 1027 |
| 1028 bounds_ = bounds; | 1028 bounds_ = bounds; |
| 1029 | 1029 |
| 1030 layer_tree_impl()->DidUpdateScrollState(id()); | 1030 layer_tree_impl()->DidUpdateScrollState(id()); |
| 1031 | |
| 1031 if (masks_to_bounds()) | 1032 if (masks_to_bounds()) |
| 1032 NoteLayerPropertyChangedForSubtree(); | 1033 NoteLayerPropertyChangedForSubtree(); |
| 1033 else | 1034 else |
| 1034 NoteLayerPropertyChanged(); | 1035 NoteLayerPropertyChanged(); |
| 1035 } | 1036 } |
| 1036 | 1037 |
| 1038 void LayerImpl::SetBoundsForTesting(const gfx::Size& bounds) { | |
|
sunxd
2016/02/09 00:11:32
Dead code.
| |
| 1039 SetBounds(bounds); | |
| 1040 layer_tree_impl()->property_trees()->needs_rebuild = true; | |
| 1041 layer_tree_impl()->BuildPropertyTreesForTesting(); | |
| 1042 } | |
| 1043 | |
| 1037 void LayerImpl::SetBoundsDelta(const gfx::Vector2dF& bounds_delta) { | 1044 void LayerImpl::SetBoundsDelta(const gfx::Vector2dF& bounds_delta) { |
| 1038 DCHECK(IsActive()); | 1045 DCHECK(IsActive()); |
| 1039 if (bounds_delta_ == bounds_delta) | 1046 if (bounds_delta_ == bounds_delta) |
| 1040 return; | 1047 return; |
| 1041 | 1048 |
| 1042 bounds_delta_ = bounds_delta; | 1049 bounds_delta_ = bounds_delta; |
| 1043 | 1050 |
| 1044 TransformTree& transform_tree = | 1051 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); |
| 1045 layer_tree_impl()->property_trees()->transform_tree; | |
| 1046 if (this == layer_tree_impl()->InnerViewportContainerLayer()) | 1052 if (this == layer_tree_impl()->InnerViewportContainerLayer()) |
| 1047 transform_tree.SetInnerViewportBoundsDelta(bounds_delta); | 1053 property_trees->SetInnerViewportContainerBoundsDelta(bounds_delta); |
| 1048 else if (this == layer_tree_impl()->OuterViewportContainerLayer()) | 1054 else if (this == layer_tree_impl()->OuterViewportContainerLayer()) |
| 1049 transform_tree.SetOuterViewportBoundsDelta(bounds_delta); | 1055 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta); |
| 1056 else if (this == layer_tree_impl()->InnerViewportScrollLayer()) | |
| 1057 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta); | |
| 1050 | 1058 |
| 1051 layer_tree_impl()->DidUpdateScrollState(id()); | 1059 layer_tree_impl()->DidUpdateScrollState(id()); |
| 1052 | 1060 |
| 1053 if (masks_to_bounds()) { | 1061 if (masks_to_bounds()) { |
| 1054 // If layer is clipping, then update the clip node using the new bounds. | 1062 // If layer is clipping, then update the clip node using the new bounds. |
| 1055 ClipNode* clip_node = | 1063 ClipNode* clip_node = property_trees->clip_tree.Node(clip_tree_index()); |
| 1056 layer_tree_impl()->property_trees()->clip_tree.Node(clip_tree_index()); | |
| 1057 if (clip_node) { | 1064 if (clip_node) { |
| 1058 DCHECK(id() == clip_node->owner_id); | 1065 DCHECK(id() == clip_node->owner_id); |
| 1059 clip_node->data.clip = gfx::RectF( | 1066 clip_node->data.clip = gfx::RectF( |
| 1060 gfx::PointF() + offset_to_transform_parent(), gfx::SizeF(bounds())); | 1067 gfx::PointF() + offset_to_transform_parent(), gfx::SizeF(bounds())); |
| 1061 layer_tree_impl()->property_trees()->clip_tree.set_needs_update(true); | 1068 property_trees->clip_tree.set_needs_update(true); |
| 1062 } | 1069 } |
| 1063 | 1070 |
| 1064 NoteLayerPropertyChangedForSubtree(); | 1071 NoteLayerPropertyChangedForSubtree(); |
| 1065 } else { | 1072 } else { |
| 1066 NoteLayerPropertyChanged(); | 1073 NoteLayerPropertyChanged(); |
| 1067 } | 1074 } |
| 1068 } | 1075 } |
| 1069 | 1076 |
| 1070 void LayerImpl::SetMaskLayer(scoped_ptr<LayerImpl> mask_layer) { | 1077 void LayerImpl::SetMaskLayer(scoped_ptr<LayerImpl> mask_layer) { |
| 1071 int new_layer_id = mask_layer ? mask_layer->id() : -1; | 1078 int new_layer_id = mask_layer ? mask_layer->id() : -1; |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1612 } | 1619 } |
| 1613 | 1620 |
| 1614 void LayerImpl::DidBeginTracing() {} | 1621 void LayerImpl::DidBeginTracing() {} |
| 1615 | 1622 |
| 1616 void LayerImpl::ReleaseResources() {} | 1623 void LayerImpl::ReleaseResources() {} |
| 1617 | 1624 |
| 1618 void LayerImpl::RecreateResources() { | 1625 void LayerImpl::RecreateResources() { |
| 1619 } | 1626 } |
| 1620 | 1627 |
| 1621 gfx::ScrollOffset LayerImpl::MaxScrollOffset() const { | 1628 gfx::ScrollOffset LayerImpl::MaxScrollOffset() const { |
| 1622 LayerImpl* scroll_clip_layer = | 1629 return layer_tree_impl()->property_trees()->scroll_tree.MaxScrollOffset( |
|
sunxd
2016/02/09 00:11:32
This will be moved in the next CL.
| |
| 1623 layer_tree_impl()->LayerById(scroll_clip_layer_id_); | 1630 scroll_tree_index()); |
| 1624 if (!scroll_clip_layer || bounds().IsEmpty()) | |
| 1625 return gfx::ScrollOffset(); | |
| 1626 | |
| 1627 LayerImpl const* page_scale_layer = layer_tree_impl()->PageScaleLayer(); | |
| 1628 DCHECK(this != page_scale_layer); | |
| 1629 DCHECK(this != layer_tree_impl()->InnerViewportScrollLayer() || | |
| 1630 IsContainerForFixedPositionLayers()); | |
| 1631 | |
| 1632 float scale_factor = 1.f; | |
| 1633 DCHECK(scroll_clip_layer != page_scale_layer); | |
| 1634 if (!scroll_clip_layer->IsAffectedByPageScale() && IsAffectedByPageScale()) | |
| 1635 scale_factor = layer_tree_impl()->current_page_scale_factor(); | |
| 1636 | |
| 1637 gfx::SizeF scaled_scroll_bounds = | |
| 1638 gfx::ScaleSize(BoundsForScrolling(), scale_factor); | |
| 1639 scaled_scroll_bounds.SetSize(std::floor(scaled_scroll_bounds.width()), | |
| 1640 std::floor(scaled_scroll_bounds.height())); | |
| 1641 | |
| 1642 gfx::ScrollOffset max_offset( | |
| 1643 scaled_scroll_bounds.width() - scroll_clip_layer->bounds().width(), | |
| 1644 scaled_scroll_bounds.height() - scroll_clip_layer->bounds().height()); | |
| 1645 // We need the final scroll offset to be in CSS coords. | |
| 1646 max_offset.Scale(1 / scale_factor); | |
| 1647 max_offset.SetToMax(gfx::ScrollOffset()); | |
| 1648 return max_offset; | |
| 1649 } | 1631 } |
| 1650 | 1632 |
| 1651 gfx::ScrollOffset LayerImpl::ClampScrollOffsetToLimits( | 1633 gfx::ScrollOffset LayerImpl::ClampScrollOffsetToLimits( |
| 1652 gfx::ScrollOffset offset) const { | 1634 gfx::ScrollOffset offset) const { |
| 1653 offset.SetToMin(MaxScrollOffset()); | 1635 offset.SetToMin(MaxScrollOffset()); |
| 1654 offset.SetToMax(gfx::ScrollOffset()); | 1636 offset.SetToMax(gfx::ScrollOffset()); |
| 1655 return offset; | 1637 return offset; |
| 1656 } | 1638 } |
| 1657 | 1639 |
| 1658 gfx::Vector2dF LayerImpl::ClampScrollToMaxScrollOffset() { | 1640 gfx::Vector2dF LayerImpl::ClampScrollToMaxScrollOffset() { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1918 .layer_transforms_should_scale_layer_contents) { | 1900 .layer_transforms_should_scale_layer_contents) { |
| 1919 return default_scale; | 1901 return default_scale; |
| 1920 } | 1902 } |
| 1921 | 1903 |
| 1922 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1904 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1923 DrawTransform(), default_scale); | 1905 DrawTransform(), default_scale); |
| 1924 return std::max(transform_scales.x(), transform_scales.y()); | 1906 return std::max(transform_scales.x(), transform_scales.y()); |
| 1925 } | 1907 } |
| 1926 | 1908 |
| 1927 } // namespace cc | 1909 } // namespace cc |
| OLD | NEW |