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 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 } | 643 } |
644 | 644 |
645 void Layer::UpdateNinePatchLayerAperture(const gfx::Rect& aperture_in_dip) { | 645 void Layer::UpdateNinePatchLayerAperture(const gfx::Rect& aperture_in_dip) { |
646 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); | 646 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); |
647 nine_patch_layer_aperture_ = aperture_in_dip; | 647 nine_patch_layer_aperture_ = aperture_in_dip; |
648 gfx::Rect aperture_in_pixel = ConvertRectToPixel(this, aperture_in_dip); | 648 gfx::Rect aperture_in_pixel = ConvertRectToPixel(this, aperture_in_dip); |
649 nine_patch_layer_->SetAperture(aperture_in_pixel); | 649 nine_patch_layer_->SetAperture(aperture_in_pixel); |
650 } | 650 } |
651 | 651 |
652 void Layer::UpdateNinePatchLayerBorder(const gfx::Rect& border) { | 652 void Layer::UpdateNinePatchLayerBorder(const gfx::Rect& border) { |
| 653 DCHECK_EQ(type_, LAYER_NINE_PATCH); |
| 654 DCHECK(nine_patch_layer_.get()); |
| 655 nine_patch_layer_->SetBorder(border); |
| 656 } |
| 657 |
| 658 void Layer::UpdateNinePatchOcclusion(const gfx::Rect& occlusion) { |
653 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); | 659 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); |
654 nine_patch_layer_->SetBorder(border); | 660 nine_patch_layer_->SetLayerOcclusion(occlusion); |
655 } | 661 } |
656 | 662 |
657 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } | 663 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } |
658 | 664 |
659 SkColor Layer::GetTargetColor() { | 665 SkColor Layer::GetTargetColor() { |
660 if (GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR)) | 666 if (GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR)) |
661 return GetAnimator()->GetTargetColor(); | 667 return GetAnimator()->GetTargetColor(); |
662 return cc_layer_->background_color(); | 668 return cc_layer_->background_color(); |
663 } | 669 } |
664 | 670 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 std::find(children_.begin(), children_.end(), child) - children_.begin(); | 841 std::find(children_.begin(), children_.end(), child) - children_.begin(); |
836 const size_t other_i = | 842 const size_t other_i = |
837 std::find(children_.begin(), children_.end(), other) - children_.begin(); | 843 std::find(children_.begin(), children_.end(), other) - children_.begin(); |
838 if ((above && child_i == other_i + 1) || (!above && child_i + 1 == other_i)) | 844 if ((above && child_i == other_i + 1) || (!above && child_i + 1 == other_i)) |
839 return; | 845 return; |
840 | 846 |
841 const size_t dest_i = | 847 const size_t dest_i = |
842 above ? | 848 above ? |
843 (child_i < other_i ? other_i : other_i + 1) : | 849 (child_i < other_i ? other_i : other_i + 1) : |
844 (child_i < other_i ? other_i - 1 : other_i); | 850 (child_i < other_i ? other_i - 1 : other_i); |
| 851 |
845 children_.erase(children_.begin() + child_i); | 852 children_.erase(children_.begin() + child_i); |
846 children_.insert(children_.begin() + dest_i, child); | 853 children_.insert(children_.begin() + dest_i, child); |
847 | 854 |
848 child->cc_layer_->RemoveFromParent(); | 855 child->cc_layer_->RemoveFromParent(); |
849 cc_layer_->InsertChild(child->cc_layer_, dest_i); | 856 cc_layer_->InsertChild(child->cc_layer_, dest_i); |
850 } | 857 } |
851 | 858 |
852 bool Layer::ConvertPointForAncestor(const Layer* ancestor, | 859 bool Layer::ConvertPointForAncestor(const Layer* ancestor, |
853 gfx::Point* point) const { | 860 gfx::Point* point) const { |
854 gfx::Transform transform; | 861 gfx::Transform transform; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 if (animator_) { | 1067 if (animator_) { |
1061 animator_->ResetCompositor(compositor); | 1068 animator_->ResetCompositor(compositor); |
1062 animator_->RemoveFromCollection(collection); | 1069 animator_->RemoveFromCollection(collection); |
1063 } | 1070 } |
1064 | 1071 |
1065 for (auto* child : children_) | 1072 for (auto* child : children_) |
1066 child->ResetCompositorForAnimatorsInTree(compositor); | 1073 child->ResetCompositorForAnimatorsInTree(compositor); |
1067 } | 1074 } |
1068 | 1075 |
1069 } // namespace ui | 1076 } // namespace ui |
OLD | NEW |