| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 399 |
| 400 const Layer* root_layer = GetRoot(source); | 400 const Layer* root_layer = GetRoot(source); |
| 401 CHECK_EQ(root_layer, GetRoot(target)); | 401 CHECK_EQ(root_layer, GetRoot(target)); |
| 402 | 402 |
| 403 if (source != root_layer) | 403 if (source != root_layer) |
| 404 source->ConvertPointForAncestor(root_layer, point); | 404 source->ConvertPointForAncestor(root_layer, point); |
| 405 if (target != root_layer) | 405 if (target != root_layer) |
| 406 target->ConvertPointFromAncestor(root_layer, point); | 406 target->ConvertPointFromAncestor(root_layer, point); |
| 407 } | 407 } |
| 408 | 408 |
| 409 bool Layer::GetTargetTransformRelativeTo(const Layer* ancestor, |
| 410 gfx::Transform* transform) const { |
| 411 const Layer* p = this; |
| 412 for (; p && p != ancestor; p = p->parent()) { |
| 413 gfx::Transform translation; |
| 414 translation.Translate(static_cast<float>(p->bounds().x()), |
| 415 static_cast<float>(p->bounds().y())); |
| 416 // Use target transform so that result will be correct once animation is |
| 417 // finished. |
| 418 if (!p->GetTargetTransform().IsIdentity()) |
| 419 transform->ConcatTransform(p->GetTargetTransform()); |
| 420 transform->ConcatTransform(translation); |
| 421 } |
| 422 return p == ancestor; |
| 423 } |
| 424 |
| 409 // static | 425 // static |
| 410 gfx::Transform Layer::ConvertTransformToCCTransform( | 426 gfx::Transform Layer::ConvertTransformToCCTransform( |
| 411 const gfx::Transform& transform, | 427 const gfx::Transform& transform, |
| 412 const gfx::Rect& bounds, | 428 const gfx::Rect& bounds, |
| 413 float device_scale_factor) { | 429 float device_scale_factor) { |
| 414 gfx::Transform cc_transform; | 430 gfx::Transform cc_transform; |
| 415 cc_transform.Scale(device_scale_factor, device_scale_factor); | 431 cc_transform.Scale(device_scale_factor, device_scale_factor); |
| 416 cc_transform.Translate(bounds.x(), bounds.y()); | 432 cc_transform.Translate(bounds.x(), bounds.y()); |
| 417 cc_transform.PreconcatTransform(transform); | 433 cc_transform.PreconcatTransform(transform); |
| 418 cc_transform.Scale(1.0f / device_scale_factor, 1.0f / device_scale_factor); | 434 cc_transform.Scale(1.0f / device_scale_factor, 1.0f / device_scale_factor); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 bool Layer::ConvertPointFromAncestor(const Layer* ancestor, | 689 bool Layer::ConvertPointFromAncestor(const Layer* ancestor, |
| 674 gfx::Point* point) const { | 690 gfx::Point* point) const { |
| 675 gfx::Transform transform; | 691 gfx::Transform transform; |
| 676 bool result = GetTargetTransformRelativeTo(ancestor, &transform); | 692 bool result = GetTargetTransformRelativeTo(ancestor, &transform); |
| 677 gfx::Point3F p(*point); | 693 gfx::Point3F p(*point); |
| 678 transform.TransformPointReverse(p); | 694 transform.TransformPointReverse(p); |
| 679 *point = gfx::ToFlooredPoint(p.AsPointF()); | 695 *point = gfx::ToFlooredPoint(p.AsPointF()); |
| 680 return result; | 696 return result; |
| 681 } | 697 } |
| 682 | 698 |
| 683 bool Layer::GetTargetTransformRelativeTo(const Layer* ancestor, | |
| 684 gfx::Transform* transform) const { | |
| 685 const Layer* p = this; | |
| 686 for (; p && p != ancestor; p = p->parent()) { | |
| 687 gfx::Transform translation; | |
| 688 translation.Translate(static_cast<float>(p->bounds().x()), | |
| 689 static_cast<float>(p->bounds().y())); | |
| 690 // Use target transform so that result will be correct once animation is | |
| 691 // finished. | |
| 692 if (!p->GetTargetTransform().IsIdentity()) | |
| 693 transform->ConcatTransform(p->GetTargetTransform()); | |
| 694 transform->ConcatTransform(translation); | |
| 695 } | |
| 696 return p == ancestor; | |
| 697 } | |
| 698 | |
| 699 void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { | 699 void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { |
| 700 if (bounds == bounds_) | 700 if (bounds == bounds_) |
| 701 return; | 701 return; |
| 702 | 702 |
| 703 base::Closure closure; | 703 base::Closure closure; |
| 704 if (delegate_) | 704 if (delegate_) |
| 705 closure = delegate_->PrepareForLayerBoundsChange(); | 705 closure = delegate_->PrepareForLayerBoundsChange(); |
| 706 bool was_move = bounds_.size() == bounds.size(); | 706 bool was_move = bounds_.size() == bounds.size(); |
| 707 gfx::Transform transform = this->transform(); | 707 gfx::Transform transform = this->transform(); |
| 708 bounds_ = bounds; | 708 bounds_ = bounds; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 texture_layer_->SetUV(uv_top_left, uv_bottom_right); | 926 texture_layer_->SetUV(uv_top_left, uv_bottom_right); |
| 927 } else if (delegated_renderer_layer_.get()) { | 927 } else if (delegated_renderer_layer_.get()) { |
| 928 delegated_renderer_layer_->SetDisplaySize( | 928 delegated_renderer_layer_->SetDisplaySize( |
| 929 ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); | 929 ConvertSizeToPixel(this, delegated_frame_size_in_dip_)); |
| 930 size.ClampToMax(delegated_frame_size_in_dip_); | 930 size.ClampToMax(delegated_frame_size_in_dip_); |
| 931 } | 931 } |
| 932 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); | 932 cc_layer_->SetBounds(ConvertSizeToPixel(this, size)); |
| 933 } | 933 } |
| 934 | 934 |
| 935 } // namespace ui | 935 } // namespace ui |
| OLD | NEW |