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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 LayerAnimationElement::TRANSFORM)) { | 236 LayerAnimationElement::TRANSFORM)) { |
237 return animator_->GetTargetTransform(); | 237 return animator_->GetTargetTransform(); |
238 } | 238 } |
239 return transform(); | 239 return transform(); |
240 } | 240 } |
241 | 241 |
242 void Layer::SetBounds(const gfx::Rect& bounds) { | 242 void Layer::SetBounds(const gfx::Rect& bounds) { |
243 GetAnimator()->SetBounds(bounds); | 243 GetAnimator()->SetBounds(bounds); |
244 } | 244 } |
245 | 245 |
| 246 void Layer::SetSubpixelPositionOffset(const gfx::Vector2dF offset) { |
| 247 subpixel_position_offset_ = offset; |
| 248 RecomputePosition(); |
| 249 } |
| 250 |
246 gfx::Rect Layer::GetTargetBounds() const { | 251 gfx::Rect Layer::GetTargetBounds() const { |
247 if (animator_.get() && animator_->IsAnimatingProperty( | 252 if (animator_.get() && animator_->IsAnimatingProperty( |
248 LayerAnimationElement::BOUNDS)) { | 253 LayerAnimationElement::BOUNDS)) { |
249 return animator_->GetTargetBounds(); | 254 return animator_->GetTargetBounds(); |
250 } | 255 } |
251 return bounds_; | 256 return bounds_; |
252 } | 257 } |
253 | 258 |
254 void Layer::SetMasksToBounds(bool masks_to_bounds) { | 259 void Layer::SetMasksToBounds(bool masks_to_bounds) { |
255 cc_layer_->SetMasksToBounds(masks_to_bounds); | 260 cc_layer_->SetMasksToBounds(masks_to_bounds); |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 static_cast<float>(size.height()) / frame_size_in_dip_.height()); | 957 static_cast<float>(size.height()) / frame_size_in_dip_.height()); |
953 texture_layer_->SetUV(uv_top_left, uv_bottom_right); | 958 texture_layer_->SetUV(uv_top_left, uv_bottom_right); |
954 } else if (delegated_renderer_layer_.get()) { | 959 } else if (delegated_renderer_layer_.get()) { |
955 size.SetToMin(frame_size_in_dip_); | 960 size.SetToMin(frame_size_in_dip_); |
956 delegated_renderer_layer_->SetDisplaySize(frame_size_in_dip_); | 961 delegated_renderer_layer_->SetDisplaySize(frame_size_in_dip_); |
957 } | 962 } |
958 cc_layer_->SetBounds(size); | 963 cc_layer_->SetBounds(size); |
959 } | 964 } |
960 | 965 |
961 void Layer::RecomputePosition() { | 966 void Layer::RecomputePosition() { |
962 cc_layer_->SetPosition(gfx::PointF(bounds_.x(), bounds_.y())); | 967 cc_layer_->SetPosition(bounds_.origin() + subpixel_position_offset_); |
963 } | 968 } |
964 | 969 |
965 void Layer::AddAnimatorsInTreeToCollection( | 970 void Layer::AddAnimatorsInTreeToCollection( |
966 LayerAnimatorCollection* collection) { | 971 LayerAnimatorCollection* collection) { |
967 DCHECK(collection); | 972 DCHECK(collection); |
968 if (IsAnimating()) | 973 if (IsAnimating()) |
969 animator_->AddToCollection(collection); | 974 animator_->AddToCollection(collection); |
970 std::for_each( | 975 std::for_each( |
971 children_.begin(), | 976 children_.begin(), |
972 children_.end(), | 977 children_.end(), |
(...skipping 11 matching lines...) Expand all Loading... |
984 children_.end(), | 989 children_.end(), |
985 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), | 990 std::bind2nd(std::mem_fun(&Layer::RemoveAnimatorsInTreeFromCollection), |
986 collection)); | 991 collection)); |
987 } | 992 } |
988 | 993 |
989 bool Layer::IsAnimating() const { | 994 bool Layer::IsAnimating() const { |
990 return animator_ && animator_->is_animating(); | 995 return animator_ && animator_->is_animating(); |
991 } | 996 } |
992 | 997 |
993 } // namespace ui | 998 } // namespace ui |
OLD | NEW |