| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 const Layer* root_layer = GetRoot(source); | 402 const Layer* root_layer = GetRoot(source); |
| 403 CHECK_EQ(root_layer, GetRoot(target)); | 403 CHECK_EQ(root_layer, GetRoot(target)); |
| 404 | 404 |
| 405 if (source != root_layer) | 405 if (source != root_layer) |
| 406 source->ConvertPointForAncestor(root_layer, point); | 406 source->ConvertPointForAncestor(root_layer, point); |
| 407 if (target != root_layer) | 407 if (target != root_layer) |
| 408 target->ConvertPointFromAncestor(root_layer, point); | 408 target->ConvertPointFromAncestor(root_layer, point); |
| 409 } | 409 } |
| 410 | 410 |
| 411 bool Layer::GetTargetTransformRelativeTo(const Layer* ancestor, |
| 412 gfx::Transform* transform) const { |
| 413 const Layer* p = this; |
| 414 for (; p && p != ancestor; p = p->parent()) { |
| 415 gfx::Transform translation; |
| 416 translation.Translate(static_cast<float>(p->bounds().x()), |
| 417 static_cast<float>(p->bounds().y())); |
| 418 // Use target transform so that result will be correct once animation is |
| 419 // finished. |
| 420 if (!p->GetTargetTransform().IsIdentity()) |
| 421 transform->ConcatTransform(p->GetTargetTransform()); |
| 422 transform->ConcatTransform(translation); |
| 423 } |
| 424 return p == ancestor; |
| 425 } |
| 426 |
| 411 // static | 427 // static |
| 412 gfx::Transform Layer::ConvertTransformToCCTransform( | 428 gfx::Transform Layer::ConvertTransformToCCTransform( |
| 413 const gfx::Transform& transform, | 429 const gfx::Transform& transform, |
| 414 const gfx::Rect& bounds, | 430 const gfx::Rect& bounds, |
| 415 float device_scale_factor) { | 431 float device_scale_factor) { |
| 416 gfx::Transform cc_transform; | 432 gfx::Transform cc_transform; |
| 417 cc_transform.Scale(device_scale_factor, device_scale_factor); | 433 cc_transform.Scale(device_scale_factor, device_scale_factor); |
| 418 cc_transform.Translate(bounds.x(), bounds.y()); | 434 cc_transform.Translate(bounds.x(), bounds.y()); |
| 419 cc_transform.PreconcatTransform(transform); | 435 cc_transform.PreconcatTransform(transform); |
| 420 cc_transform.Scale(1.0f / device_scale_factor, 1.0f / device_scale_factor); | 436 cc_transform.Scale(1.0f / device_scale_factor, 1.0f / device_scale_factor); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 bool Layer::ConvertPointFromAncestor(const Layer* ancestor, | 679 bool Layer::ConvertPointFromAncestor(const Layer* ancestor, |
| 664 gfx::Point* point) const { | 680 gfx::Point* point) const { |
| 665 gfx::Transform transform; | 681 gfx::Transform transform; |
| 666 bool result = GetTargetTransformRelativeTo(ancestor, &transform); | 682 bool result = GetTargetTransformRelativeTo(ancestor, &transform); |
| 667 gfx::Point3F p(*point); | 683 gfx::Point3F p(*point); |
| 668 transform.TransformPointReverse(p); | 684 transform.TransformPointReverse(p); |
| 669 *point = gfx::ToFlooredPoint(p.AsPointF()); | 685 *point = gfx::ToFlooredPoint(p.AsPointF()); |
| 670 return result; | 686 return result; |
| 671 } | 687 } |
| 672 | 688 |
| 673 bool Layer::GetTargetTransformRelativeTo(const Layer* ancestor, | |
| 674 gfx::Transform* transform) const { | |
| 675 const Layer* p = this; | |
| 676 for (; p && p != ancestor; p = p->parent()) { | |
| 677 gfx::Transform translation; | |
| 678 translation.Translate(static_cast<float>(p->bounds().x()), | |
| 679 static_cast<float>(p->bounds().y())); | |
| 680 // Use target transform so that result will be correct once animation is | |
| 681 // finished. | |
| 682 if (!p->GetTargetTransform().IsIdentity()) | |
| 683 transform->ConcatTransform(p->GetTargetTransform()); | |
| 684 transform->ConcatTransform(translation); | |
| 685 } | |
| 686 return p == ancestor; | |
| 687 } | |
| 688 | |
| 689 void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { | 689 void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { |
| 690 if (bounds == bounds_) | 690 if (bounds == bounds_) |
| 691 return; | 691 return; |
| 692 | 692 |
| 693 base::Closure closure; | 693 base::Closure closure; |
| 694 if (delegate_) | 694 if (delegate_) |
| 695 closure = delegate_->PrepareForLayerBoundsChange(); | 695 closure = delegate_->PrepareForLayerBoundsChange(); |
| 696 bool was_move = bounds_.size() == bounds.size(); | 696 bool was_move = bounds_.size() == bounds.size(); |
| 697 gfx::Transform transform = this->transform(); | 697 gfx::Transform transform = this->transform(); |
| 698 bounds_ = bounds; | 698 bounds_ = bounds; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 texture_layer_->SetUV(uv_top_left, uv_bottom_right); | 916 texture_layer_->SetUV(uv_top_left, uv_bottom_right); |
| 917 } else if (delegated_renderer_layer_.get()) { | 917 } else if (delegated_renderer_layer_.get()) { |
| 918 delegated_renderer_layer_->SetDisplaySize( | 918 delegated_renderer_layer_->SetDisplaySize( |
| 919 ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); | 919 ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); |
| 920 size.ClampToMax(delegated_frame_size_in_dip_); | 920 size.ClampToMax(delegated_frame_size_in_dip_); |
| 921 } | 921 } |
| 922 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 922 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |
| 923 } | 923 } |
| 924 | 924 |
| 925 } // namespace ui | 925 } // namespace ui |
| OLD | NEW |