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 "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 num_dependents_need_push_properties_ = 0; | 602 num_dependents_need_push_properties_ = 0; |
603 } | 603 } |
604 | 604 |
605 gfx::Vector2dF LayerImpl::FixedContainerSizeDelta() const { | 605 gfx::Vector2dF LayerImpl::FixedContainerSizeDelta() const { |
606 if (!scroll_clip_layer_) | 606 if (!scroll_clip_layer_) |
607 return gfx::Vector2dF(); | 607 return gfx::Vector2dF(); |
608 | 608 |
609 float scale_delta = layer_tree_impl()->page_scale_delta(); | 609 float scale_delta = layer_tree_impl()->page_scale_delta(); |
610 float scale = layer_tree_impl()->page_scale_factor(); | 610 float scale = layer_tree_impl()->page_scale_factor(); |
611 | 611 |
612 gfx::Vector2dF delta_from_scroll = scroll_clip_layer_->BoundsDelta(); | 612 gfx::Vector2dF delta_from_scroll = scroll_clip_layer_->bounds_delta(); |
613 delta_from_scroll.Scale(1.f / scale); | 613 delta_from_scroll.Scale(1.f / scale); |
614 | 614 |
615 // The delta-from-pinch component requires some explanation: A viewport of | 615 // The delta-from-pinch component requires some explanation: A viewport of |
616 // size (w,h) will appear to be size (w/s,h/s) under scale s in the content | 616 // size (w,h) will appear to be size (w/s,h/s) under scale s in the content |
617 // space. If s -> s' on the impl thread, where s' = s * ds, then the apparent | 617 // space. If s -> s' on the impl thread, where s' = s * ds, then the apparent |
618 // viewport size change in the content space due to ds is: | 618 // viewport size change in the content space due to ds is: |
619 // | 619 // |
620 // (w/s',h/s') - (w/s,h/s) = (w,h)(1/s' - 1/s) = (w,h)(1 - ds)/(s ds) | 620 // (w/s',h/s') - (w/s,h/s) = (w,h)(1/s' - 1/s) = (w,h)(1 - ds)/(s ds) |
621 // | 621 // |
622 gfx::Vector2dF delta_from_pinch = | 622 gfx::Vector2dF delta_from_pinch = |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 | 762 |
763 layer_tree_impl_->DidAnimateScrollOffset(); | 763 layer_tree_impl_->DidAnimateScrollOffset(); |
764 } | 764 } |
765 | 765 |
766 void LayerImpl::OnAnimationWaitingForDeletion() {} | 766 void LayerImpl::OnAnimationWaitingForDeletion() {} |
767 | 767 |
768 bool LayerImpl::IsActive() const { | 768 bool LayerImpl::IsActive() const { |
769 return layer_tree_impl_->IsActiveTree(); | 769 return layer_tree_impl_->IsActiveTree(); |
770 } | 770 } |
771 | 771 |
772 // TODO(wjmaclean) Convert so that bounds returns SizeF. | 772 // TODO(aelias): Convert so that bounds returns SizeF. |
773 gfx::Size LayerImpl::bounds() const { | 773 gfx::Size LayerImpl::bounds() const { |
774 return ToCeiledSize(temporary_impl_bounds_); | 774 return gfx::ToCeiledSize(gfx::SizeF(bounds_.width() + bounds_delta_.x(), |
| 775 bounds_.height() + bounds_delta_.y())); |
775 } | 776 } |
776 | 777 |
777 void LayerImpl::SetBounds(const gfx::Size& bounds) { | 778 void LayerImpl::SetBounds(const gfx::Size& bounds) { |
778 if (bounds_ == bounds) | 779 if (bounds_ == bounds) |
779 return; | 780 return; |
780 | 781 |
781 bounds_ = bounds; | 782 bounds_ = bounds; |
782 temporary_impl_bounds_ = bounds; | |
783 | 783 |
784 ScrollbarParametersDidChange(); | 784 ScrollbarParametersDidChange(); |
785 if (masks_to_bounds()) | 785 if (masks_to_bounds()) |
786 NoteLayerPropertyChangedForSubtree(); | 786 NoteLayerPropertyChangedForSubtree(); |
787 else | 787 else |
788 NoteLayerPropertyChanged(); | 788 NoteLayerPropertyChanged(); |
789 } | 789 } |
790 | 790 |
791 void LayerImpl::SetTemporaryImplBounds(const gfx::SizeF& bounds) { | 791 void LayerImpl::SetBoundsDelta(const gfx::Vector2dF& bounds_delta) { |
792 if (temporary_impl_bounds_ == bounds) | 792 if (bounds_delta_ == bounds_delta) |
793 return; | 793 return; |
794 | 794 |
795 temporary_impl_bounds_ = bounds; | 795 bounds_delta_ = bounds_delta; |
796 | 796 |
797 ScrollbarParametersDidChange(); | 797 ScrollbarParametersDidChange(); |
798 if (masks_to_bounds()) | 798 if (masks_to_bounds()) |
799 NoteLayerPropertyChangedForSubtree(); | 799 NoteLayerPropertyChangedForSubtree(); |
800 else | 800 else |
801 NoteLayerPropertyChanged(); | 801 NoteLayerPropertyChanged(); |
802 } | 802 } |
803 | 803 |
804 void LayerImpl::SetMaskLayer(scoped_ptr<LayerImpl> mask_layer) { | 804 void LayerImpl::SetMaskLayer(scoped_ptr<LayerImpl> mask_layer) { |
805 int new_layer_id = mask_layer ? mask_layer->id() : -1; | 805 int new_layer_id = mask_layer ? mask_layer->id() : -1; |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 } | 1267 } |
1268 // TODO(wjmaclean) Once we move to a model where the two-viewport model is | 1268 // TODO(wjmaclean) Once we move to a model where the two-viewport model is |
1269 // turned on in all builds, remove the next two lines. For now however, the | 1269 // turned on in all builds, remove the next two lines. For now however, the |
1270 // page scale layer may coincide with the clip layer, and so this is | 1270 // page scale layer may coincide with the clip layer, and so this is |
1271 // necessary. | 1271 // necessary. |
1272 if (page_scale_layer == scrollbar_clip_layer) { | 1272 if (page_scale_layer == scrollbar_clip_layer) { |
1273 scroll_rect.Scale(layer_tree_impl()->total_page_scale_factor()); | 1273 scroll_rect.Scale(layer_tree_impl()->total_page_scale_factor()); |
1274 current_offset.Scale(layer_tree_impl()->total_page_scale_factor()); | 1274 current_offset.Scale(layer_tree_impl()->total_page_scale_factor()); |
1275 } | 1275 } |
1276 | 1276 |
1277 scrollbar_layer->SetVerticalAdjust( | 1277 scrollbar_layer->SetVerticalAdjust(scrollbar_clip_layer->bounds_delta().y()); |
1278 layer_tree_impl()->VerticalAdjust(scrollbar_clip_layer->id())); | |
1279 if (scrollbar_layer->orientation() == HORIZONTAL) { | 1278 if (scrollbar_layer->orientation() == HORIZONTAL) { |
1280 float visible_ratio = clip_rect.width() / scroll_rect.width(); | 1279 float visible_ratio = clip_rect.width() / scroll_rect.width(); |
1281 scrollbar_layer->SetCurrentPos(current_offset.x()); | 1280 scrollbar_layer->SetCurrentPos(current_offset.x()); |
1282 scrollbar_layer->SetMaximum(scroll_rect.width() - clip_rect.width()); | 1281 scrollbar_layer->SetMaximum(scroll_rect.width() - clip_rect.width()); |
1283 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | 1282 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); |
1284 } else { | 1283 } else { |
1285 float visible_ratio = clip_rect.height() / scroll_rect.height(); | 1284 float visible_ratio = clip_rect.height() / scroll_rect.height(); |
1286 scrollbar_layer->SetCurrentPos(current_offset.y()); | 1285 scrollbar_layer->SetCurrentPos(current_offset.y()); |
1287 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height()); | 1286 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height()); |
1288 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | 1287 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 } | 1534 } |
1536 | 1535 |
1537 void LayerImpl::NotifyAnimationFinished( | 1536 void LayerImpl::NotifyAnimationFinished( |
1538 base::TimeTicks monotonic_time, | 1537 base::TimeTicks monotonic_time, |
1539 Animation::TargetProperty target_property) { | 1538 Animation::TargetProperty target_property) { |
1540 if (target_property == Animation::ScrollOffset) | 1539 if (target_property == Animation::ScrollOffset) |
1541 layer_tree_impl_->InputScrollAnimationFinished(); | 1540 layer_tree_impl_->InputScrollAnimationFinished(); |
1542 } | 1541 } |
1543 | 1542 |
1544 } // namespace cc | 1543 } // namespace cc |
OLD | NEW |