| 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 id())) { | 587 id())) { |
| 587 DCHECK_EQ(transform_tree_index(), | 588 DCHECK_EQ(transform_tree_index(), |
| 588 property_trees->layer_id_to_transform_node_index[id()]); | 589 property_trees->layer_id_to_transform_node_index[id()]); |
| 589 TransformNode* transform_node = | 590 TransformNode* transform_node = |
| 590 property_trees->transform_tree.Node(transform_tree_index()); | 591 property_trees->transform_tree.Node(transform_tree_index()); |
| 591 transform_node->update_post_local_transform(position, transform_origin()); | 592 transform_node->update_post_local_transform(position, transform_origin()); |
| 592 if (transform_node->sticky_position_constraint_id >= 0) { | 593 if (transform_node->sticky_position_constraint_id >= 0) { |
| 593 StickyPositionNodeData* sticky_data = | 594 StickyPositionNodeData* sticky_data = |
| 594 property_trees->transform_tree.StickyPositionData( | 595 property_trees->transform_tree.StickyPositionData( |
| 595 transform_tree_index()); | 596 transform_tree_index()); |
| 597 gfx::Point sticky_box_offset( |
| 598 sticky_data->constraints.parent_relative_sticky_box_offset); |
| 599 |
| 600 // The sticky box offset calculated in CompositedLayerMapping must be |
| 601 // adjusted for the enclosing layer's scroll position and sticky offset. |
| 602 // TODO(smcgruer): Maybe rename parent_relative_sticky_box_offset ? |
| 603 ScrollNode* scroll_ancestor = |
| 604 property_trees->scroll_tree.Node(scroll_tree_index()); |
| 605 if (scroll_ancestor->owning_layer_id == id()) { |
| 606 // We are a scroller, so we need our parent's scroll_ancestor instead. |
| 607 scroll_ancestor = |
| 608 property_trees->scroll_tree.Node(parent()->scroll_tree_index()); |
| 609 } |
| 610 if (parent()->id() != scroll_ancestor->owning_layer_id) { |
| 611 sticky_box_offset -= gfx::ScrollOffsetToFlooredVector2d( |
| 612 property_trees->scroll_tree.current_scroll_offset( |
| 613 scroll_ancestor->owning_layer_id)); |
| 614 sticky_box_offset += gfx::ToFlooredVector2d( |
| 615 draw_property_utils::CalculateTotalStickyOffsetToScroller( |
| 616 parent(), scroll_ancestor->owning_layer_id)); |
| 617 } |
| 596 sticky_data->main_thread_offset = | 618 sticky_data->main_thread_offset = |
| 597 position.OffsetFromOrigin() - | 619 position.OffsetFromOrigin() - sticky_box_offset.OffsetFromOrigin(); |
| 598 sticky_data->constraints.parent_relative_sticky_box_offset | 620 if (Layer* layer = |
| 599 .OffsetFromOrigin(); | 621 sticky_data->constraints.nearest_layer_shifting_sticky_box) { |
| 622 sticky_data->nearest_node_shifting_sticky_box = |
| 623 layer->transform_tree_index(); |
| 624 } |
| 625 if (Layer* layer = sticky_data->constraints |
| 626 .nearest_layer_shifting_containing_block) { |
| 627 sticky_data->nearest_node_shifting_containing_block = |
| 628 layer->transform_tree_index(); |
| 629 } |
| 600 } | 630 } |
| 601 transform_node->needs_local_transform_update = true; | 631 transform_node->needs_local_transform_update = true; |
| 602 transform_node->transform_changed = true; | 632 transform_node->transform_changed = true; |
| 603 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 633 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
| 604 SetNeedsCommitNoRebuild(); | 634 SetNeedsCommitNoRebuild(); |
| 605 return; | 635 return; |
| 606 } | 636 } |
| 607 | 637 |
| 608 SetNeedsCommit(); | 638 SetNeedsCommit(); |
| 609 } | 639 } |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1579 ->num_copy_requests_in_subtree; | 1609 ->num_copy_requests_in_subtree; |
| 1580 } | 1610 } |
| 1581 | 1611 |
| 1582 gfx::Transform Layer::screen_space_transform() const { | 1612 gfx::Transform Layer::screen_space_transform() const { |
| 1583 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1613 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
| 1584 return draw_property_utils::ScreenSpaceTransform( | 1614 return draw_property_utils::ScreenSpaceTransform( |
| 1585 this, layer_tree_host_->property_trees()->transform_tree); | 1615 this, layer_tree_host_->property_trees()->transform_tree); |
| 1586 } | 1616 } |
| 1587 | 1617 |
| 1588 } // namespace cc | 1618 } // namespace cc |
| OLD | NEW |