Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "cc/layers/layer_impl.h" | 22 #include "cc/layers/layer_impl.h" |
| 23 #include "cc/layers/scrollbar_layer_interface.h" | 23 #include "cc/layers/scrollbar_layer_interface.h" |
| 24 #include "cc/output/copy_output_request.h" | 24 #include "cc/output/copy_output_request.h" |
| 25 #include "cc/output/copy_output_result.h" | 25 #include "cc/output/copy_output_result.h" |
| 26 #include "cc/trees/draw_property_utils.h" | 26 #include "cc/trees/draw_property_utils.h" |
| 27 #include "cc/trees/effect_node.h" | 27 #include "cc/trees/effect_node.h" |
| 28 #include "cc/trees/layer_tree_host.h" | 28 #include "cc/trees/layer_tree_host.h" |
| 29 #include "cc/trees/layer_tree_impl.h" | 29 #include "cc/trees/layer_tree_impl.h" |
| 30 #include "cc/trees/mutable_properties.h" | 30 #include "cc/trees/mutable_properties.h" |
| 31 #include "cc/trees/mutator_host.h" | 31 #include "cc/trees/mutator_host.h" |
| 32 #include "cc/trees/scroll_node.h" | |
| 32 #include "cc/trees/transform_node.h" | 33 #include "cc/trees/transform_node.h" |
| 33 #include "third_party/skia/include/core/SkImageFilter.h" | 34 #include "third_party/skia/include/core/SkImageFilter.h" |
| 34 #include "ui/gfx/geometry/rect_conversions.h" | 35 #include "ui/gfx/geometry/rect_conversions.h" |
| 35 #include "ui/gfx/geometry/vector2d_conversions.h" | 36 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 36 | 37 |
| 37 namespace cc { | 38 namespace cc { |
| 38 | 39 |
| 39 base::StaticAtomicSequenceNumber g_next_layer_id; | 40 base::StaticAtomicSequenceNumber g_next_layer_id; |
| 40 | 41 |
| 41 Layer::Inputs::Inputs(int layer_id) | 42 Layer::Inputs::Inputs(int layer_id) |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 id())) { | 578 id())) { |
| 578 DCHECK_EQ(transform_tree_index(), | 579 DCHECK_EQ(transform_tree_index(), |
| 579 property_trees->layer_id_to_transform_node_index[id()]); | 580 property_trees->layer_id_to_transform_node_index[id()]); |
| 580 TransformNode* transform_node = | 581 TransformNode* transform_node = |
| 581 property_trees->transform_tree.Node(transform_tree_index()); | 582 property_trees->transform_tree.Node(transform_tree_index()); |
| 582 transform_node->update_post_local_transform(position, transform_origin()); | 583 transform_node->update_post_local_transform(position, transform_origin()); |
| 583 if (transform_node->sticky_position_constraint_id >= 0) { | 584 if (transform_node->sticky_position_constraint_id >= 0) { |
| 584 StickyPositionNodeData* sticky_data = | 585 StickyPositionNodeData* sticky_data = |
| 585 property_trees->transform_tree.StickyPositionData( | 586 property_trees->transform_tree.StickyPositionData( |
| 586 transform_tree_index()); | 587 transform_tree_index()); |
| 588 gfx::Point sticky_box_offset( | |
| 589 sticky_data->constraints.parent_relative_sticky_box_offset); | |
| 590 | |
| 591 // The sticky box offset calculated in CompositedLayerMapping must be | |
| 592 // adjusted for the enclosing layer's scroll position and sticky offset. | |
| 593 // TODO(smcgruer): Maybe rename parent_relative_sticky_box_offset ? | |
|
smcgruer
2017/02/14 17:02:06
flackr : Thoughts on renaming this?
| |
| 594 ScrollNode* scroll_ancestor = | |
| 595 property_trees->scroll_tree.Node(scroll_tree_index()); | |
| 596 if (scroll_ancestor->owning_layer_id == id()) { | |
| 597 // We are a scroller, so we need our parent's scroll_ancestor instead. | |
| 598 scroll_ancestor = | |
| 599 property_trees->scroll_tree.Node(parent()->scroll_tree_index()); | |
| 600 } | |
| 601 if (parent()->id() != scroll_ancestor->owning_layer_id) { | |
| 602 sticky_box_offset -= gfx::ScrollOffsetToFlooredVector2d( | |
| 603 property_trees->scroll_tree.current_scroll_offset( | |
| 604 scroll_ancestor->owning_layer_id)); | |
| 605 sticky_box_offset += gfx::ToFlooredVector2d( | |
| 606 draw_property_utils::CalculateTotalStickyOffsetToScroller( | |
| 607 parent(), scroll_ancestor->owning_layer_id)); | |
| 608 } | |
| 587 sticky_data->main_thread_offset = | 609 sticky_data->main_thread_offset = |
| 588 position.OffsetFromOrigin() - | 610 position.OffsetFromOrigin() - sticky_box_offset.OffsetFromOrigin(); |
| 589 sticky_data->constraints.parent_relative_sticky_box_offset | 611 if (Layer* layer = |
| 590 .OffsetFromOrigin(); | 612 sticky_data->constraints.nearest_layer_shifting_sticky_box) { |
| 613 sticky_data->nearest_node_shifting_sticky_box = | |
| 614 layer->transform_tree_index(); | |
| 615 } | |
| 616 if (Layer* layer = sticky_data->constraints | |
| 617 .nearest_layer_shifting_containing_block) { | |
| 618 sticky_data->nearest_node_shifting_containing_block = | |
| 619 layer->transform_tree_index(); | |
| 620 } | |
| 591 } | 621 } |
| 592 transform_node->needs_local_transform_update = true; | 622 transform_node->needs_local_transform_update = true; |
| 593 transform_node->transform_changed = true; | 623 transform_node->transform_changed = true; |
| 594 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 624 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
| 595 SetNeedsCommitNoRebuild(); | 625 SetNeedsCommitNoRebuild(); |
| 596 return; | 626 return; |
| 597 } | 627 } |
| 598 | 628 |
| 599 SetNeedsCommit(); | 629 SetNeedsCommit(); |
| 600 } | 630 } |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1573 ->num_copy_requests_in_subtree; | 1603 ->num_copy_requests_in_subtree; |
| 1574 } | 1604 } |
| 1575 | 1605 |
| 1576 gfx::Transform Layer::screen_space_transform() const { | 1606 gfx::Transform Layer::screen_space_transform() const { |
| 1577 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1607 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
| 1578 return draw_property_utils::ScreenSpaceTransform( | 1608 return draw_property_utils::ScreenSpaceTransform( |
| 1579 this, layer_tree_host_->property_trees()->transform_tree); | 1609 this, layer_tree_host_->property_trees()->transform_tree); |
| 1580 } | 1610 } |
| 1581 | 1611 |
| 1582 } // namespace cc | 1612 } // namespace cc |
| OLD | NEW |