| 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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 delta_from_scroll.Scale(1.f / scale); | 615 delta_from_scroll.Scale(1.f / scale); |
| 616 | 616 |
| 617 // The delta-from-pinch component requires some explanation: A viewport of | 617 // The delta-from-pinch component requires some explanation: A viewport of |
| 618 // size (w,h) will appear to be size (w/s,h/s) under scale s in the content | 618 // size (w,h) will appear to be size (w/s,h/s) under scale s in the content |
| 619 // space. If s -> s' on the impl thread, where s' = s * ds, then the apparent | 619 // space. If s -> s' on the impl thread, where s' = s * ds, then the apparent |
| 620 // viewport size change in the content space due to ds is: | 620 // viewport size change in the content space due to ds is: |
| 621 // | 621 // |
| 622 // (w/s',h/s') - (w/s,h/s) = (w,h)(1/s' - 1/s) = (w,h)(1 - ds)/(s ds) | 622 // (w/s',h/s') - (w/s,h/s) = (w,h)(1/s' - 1/s) = (w,h)(1 - ds)/(s ds) |
| 623 // | 623 // |
| 624 gfx::Vector2dF delta_from_pinch = | 624 gfx::Vector2dF delta_from_pinch = |
| 625 gfx::Rect(scroll_clip_layer_->bounds()).bottom_right() - gfx::PointF(); | 625 gfx::RectF(scroll_clip_layer_->bounds()).bottom_right() - gfx::PointF(); |
| 626 delta_from_pinch.Scale((1.f - scale_delta) / (scale * scale_delta)); | 626 delta_from_pinch.Scale((1.f - scale_delta) / (scale * scale_delta)); |
| 627 | 627 |
| 628 return delta_from_scroll + delta_from_pinch; | 628 return delta_from_scroll + delta_from_pinch; |
| 629 } | 629 } |
| 630 | 630 |
| 631 base::DictionaryValue* LayerImpl::LayerTreeAsJson() const { | 631 base::DictionaryValue* LayerImpl::LayerTreeAsJson() const { |
| 632 base::DictionaryValue* result = new base::DictionaryValue; | 632 base::DictionaryValue* result = new base::DictionaryValue; |
| 633 result->SetString("LayerType", LayerTypeAsString()); | 633 result->SetString("LayerType", LayerTypeAsString()); |
| 634 | 634 |
| 635 base::ListValue* list = new base::ListValue; | 635 base::ListValue* list = new base::ListValue; |
| 636 list->AppendInteger(bounds().width()); | 636 list->AppendDouble(bounds().width()); |
| 637 list->AppendInteger(bounds().height()); | 637 list->AppendDouble(bounds().height()); |
| 638 result->Set("Bounds", list); | 638 result->Set("Bounds", list); |
| 639 | 639 |
| 640 list = new base::ListValue; | 640 list = new base::ListValue; |
| 641 list->AppendDouble(position_.x()); | 641 list->AppendDouble(position_.x()); |
| 642 list->AppendDouble(position_.y()); | 642 list->AppendDouble(position_.y()); |
| 643 result->Set("Position", list); | 643 result->Set("Position", list); |
| 644 | 644 |
| 645 const gfx::Transform& gfx_transform = draw_properties_.target_space_transform; | 645 const gfx::Transform& gfx_transform = draw_properties_.target_space_transform; |
| 646 double transform[16]; | 646 double transform[16]; |
| 647 gfx_transform.matrix().asColMajord(transform); | 647 gfx_transform.matrix().asColMajord(transform); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 | 764 |
| 765 layer_tree_impl_->DidAnimateScrollOffset(); | 765 layer_tree_impl_->DidAnimateScrollOffset(); |
| 766 } | 766 } |
| 767 | 767 |
| 768 void LayerImpl::OnAnimationWaitingForDeletion() {} | 768 void LayerImpl::OnAnimationWaitingForDeletion() {} |
| 769 | 769 |
| 770 bool LayerImpl::IsActive() const { | 770 bool LayerImpl::IsActive() const { |
| 771 return layer_tree_impl_->IsActiveTree(); | 771 return layer_tree_impl_->IsActiveTree(); |
| 772 } | 772 } |
| 773 | 773 |
| 774 // TODO(aelias): Convert so that bounds returns SizeF. | 774 gfx::SizeF LayerImpl::bounds() const { |
| 775 gfx::Size LayerImpl::bounds() const { | |
| 776 return gfx::ToCeiledSize(gfx::SizeF(bounds_.width() + bounds_delta_.x(), | 775 return gfx::ToCeiledSize(gfx::SizeF(bounds_.width() + bounds_delta_.x(), |
| 777 bounds_.height() + bounds_delta_.y())); | 776 bounds_.height() + bounds_delta_.y())); |
| 778 } | 777 } |
| 779 | 778 |
| 780 void LayerImpl::SetBounds(const gfx::Size& bounds) { | 779 void LayerImpl::SetBounds(const gfx::Size& bounds) { |
| 781 if (bounds_ == bounds) | 780 if (bounds_ == bounds) |
| 782 return; | 781 return; |
| 783 | 782 |
| 784 bounds_ = bounds; | 783 bounds_ = bounds; |
| 785 | 784 |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 } | 1551 } |
| 1553 | 1552 |
| 1554 void LayerImpl::NotifyAnimationFinished( | 1553 void LayerImpl::NotifyAnimationFinished( |
| 1555 base::TimeTicks monotonic_time, | 1554 base::TimeTicks monotonic_time, |
| 1556 Animation::TargetProperty target_property) { | 1555 Animation::TargetProperty target_property) { |
| 1557 if (target_property == Animation::ScrollOffset) | 1556 if (target_property == Animation::ScrollOffset) |
| 1558 layer_tree_impl_->InputScrollAnimationFinished(); | 1557 layer_tree_impl_->InputScrollAnimationFinished(); |
| 1559 } | 1558 } |
| 1560 | 1559 |
| 1561 } // namespace cc | 1560 } // namespace cc |
| OLD | NEW |