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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 } | 642 } |
643 | 643 |
644 void Layer::UpdateNinePatchLayerAperture(const gfx::Rect& aperture_in_dip) { | 644 void Layer::UpdateNinePatchLayerAperture(const gfx::Rect& aperture_in_dip) { |
645 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); | 645 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); |
646 nine_patch_layer_aperture_ = aperture_in_dip; | 646 nine_patch_layer_aperture_ = aperture_in_dip; |
647 gfx::Rect aperture_in_pixel = ConvertRectToPixel(this, aperture_in_dip); | 647 gfx::Rect aperture_in_pixel = ConvertRectToPixel(this, aperture_in_dip); |
648 nine_patch_layer_->SetAperture(aperture_in_pixel); | 648 nine_patch_layer_->SetAperture(aperture_in_pixel); |
649 } | 649 } |
650 | 650 |
651 void Layer::UpdateNinePatchLayerBorder(const gfx::Rect& border) { | 651 void Layer::UpdateNinePatchLayerBorder(const gfx::Rect& border) { |
| 652 DCHECK_EQ(type_, LAYER_NINE_PATCH); |
| 653 DCHECK(nine_patch_layer_.get()); |
| 654 nine_patch_layer_->SetBorder(border); |
| 655 } |
| 656 |
| 657 void Layer::UpdateNinePatchOcclusion(const gfx::Rect& occlusion) { |
652 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); | 658 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); |
653 nine_patch_layer_->SetBorder(border); | 659 nine_patch_layer_->SetLayerOcclusion(occlusion); |
654 } | 660 } |
655 | 661 |
656 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } | 662 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } |
657 | 663 |
658 SkColor Layer::GetTargetColor() { | 664 SkColor Layer::GetTargetColor() { |
659 if (GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR)) | 665 if (GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR)) |
660 return GetAnimator()->GetTargetColor(); | 666 return GetAnimator()->GetTargetColor(); |
661 return cc_layer_->background_color(); | 667 return cc_layer_->background_color(); |
662 } | 668 } |
663 | 669 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 std::find(children_.begin(), children_.end(), child) - children_.begin(); | 831 std::find(children_.begin(), children_.end(), child) - children_.begin(); |
826 const size_t other_i = | 832 const size_t other_i = |
827 std::find(children_.begin(), children_.end(), other) - children_.begin(); | 833 std::find(children_.begin(), children_.end(), other) - children_.begin(); |
828 if ((above && child_i == other_i + 1) || (!above && child_i + 1 == other_i)) | 834 if ((above && child_i == other_i + 1) || (!above && child_i + 1 == other_i)) |
829 return; | 835 return; |
830 | 836 |
831 const size_t dest_i = | 837 const size_t dest_i = |
832 above ? | 838 above ? |
833 (child_i < other_i ? other_i : other_i + 1) : | 839 (child_i < other_i ? other_i : other_i + 1) : |
834 (child_i < other_i ? other_i - 1 : other_i); | 840 (child_i < other_i ? other_i - 1 : other_i); |
| 841 |
835 children_.erase(children_.begin() + child_i); | 842 children_.erase(children_.begin() + child_i); |
836 children_.insert(children_.begin() + dest_i, child); | 843 children_.insert(children_.begin() + dest_i, child); |
837 | 844 |
838 child->cc_layer_->RemoveFromParent(); | 845 child->cc_layer_->RemoveFromParent(); |
839 cc_layer_->InsertChild(child->cc_layer_, dest_i); | 846 cc_layer_->InsertChild(child->cc_layer_, dest_i); |
840 } | 847 } |
841 | 848 |
842 bool Layer::ConvertPointForAncestor(const Layer* ancestor, | 849 bool Layer::ConvertPointForAncestor(const Layer* ancestor, |
843 gfx::Point* point) const { | 850 gfx::Point* point) const { |
844 gfx::Transform transform; | 851 gfx::Transform transform; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 if (animator_) { | 1056 if (animator_) { |
1050 animator_->ResetCompositor(compositor); | 1057 animator_->ResetCompositor(compositor); |
1051 animator_->RemoveFromCollection(collection); | 1058 animator_->RemoveFromCollection(collection); |
1052 } | 1059 } |
1053 | 1060 |
1054 for (auto* child : children_) | 1061 for (auto* child : children_) |
1055 child->ResetCompositorForAnimatorsInTree(compositor); | 1062 child->ResetCompositorForAnimatorsInTree(compositor); |
1056 } | 1063 } |
1057 | 1064 |
1058 } // namespace ui | 1065 } // namespace ui |
OLD | NEW |