Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: ui/compositor/layer.cc

Issue 1889153002: cc: nine patch: add occlusion support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Daniel's nits Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 nine_patch_layer_->SetBitmap(bitmap_copy); 622 nine_patch_layer_->SetBitmap(bitmap_copy);
623 } 623 }
624 624
625 void Layer::UpdateNinePatchLayerAperture(const gfx::Rect& aperture_in_dip) { 625 void Layer::UpdateNinePatchLayerAperture(const gfx::Rect& aperture_in_dip) {
626 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); 626 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get());
627 nine_patch_layer_aperture_ = aperture_in_dip; 627 nine_patch_layer_aperture_ = aperture_in_dip;
628 gfx::Rect aperture_in_pixel = ConvertRectToPixel(this, aperture_in_dip); 628 gfx::Rect aperture_in_pixel = ConvertRectToPixel(this, aperture_in_dip);
629 nine_patch_layer_->SetAperture(aperture_in_pixel); 629 nine_patch_layer_->SetAperture(aperture_in_pixel);
630 } 630 }
631 631
632 void Layer::UpdateNinePatchLayerBorder(const gfx::Rect& border) { 632 void Layer::UpdateNinePatchOcclusion(const gfx::Rect& rect) {
633 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get()); 633 DCHECK(type_ == LAYER_NINE_PATCH && nine_patch_layer_.get());
634 nine_patch_layer_->SetBorder(border); 634 nine_patch_layer_->SetLayerOcclusion(rect);
635 } 635 }
636 636
637 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } 637 void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); }
638 638
639 SkColor Layer::GetTargetColor() { 639 SkColor Layer::GetTargetColor() {
640 if (GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR)) 640 if (GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR))
641 return GetAnimator()->GetTargetColor(); 641 return GetAnimator()->GetTargetColor();
642 return cc_layer_->background_color(); 642 return cc_layer_->background_color();
643 } 643 }
644 644
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 std::find(children_.begin(), children_.end(), child) - children_.begin(); 813 std::find(children_.begin(), children_.end(), child) - children_.begin();
814 const size_t other_i = 814 const size_t other_i =
815 std::find(children_.begin(), children_.end(), other) - children_.begin(); 815 std::find(children_.begin(), children_.end(), other) - children_.begin();
816 if ((above && child_i == other_i + 1) || (!above && child_i + 1 == other_i)) 816 if ((above && child_i == other_i + 1) || (!above && child_i + 1 == other_i))
817 return; 817 return;
818 818
819 const size_t dest_i = 819 const size_t dest_i =
820 above ? 820 above ?
821 (child_i < other_i ? other_i : other_i + 1) : 821 (child_i < other_i ? other_i : other_i + 1) :
822 (child_i < other_i ? other_i - 1 : other_i); 822 (child_i < other_i ? other_i - 1 : other_i);
823
823 children_.erase(children_.begin() + child_i); 824 children_.erase(children_.begin() + child_i);
824 children_.insert(children_.begin() + dest_i, child); 825 children_.insert(children_.begin() + dest_i, child);
825 826
826 child->cc_layer_->RemoveFromParent(); 827 child->cc_layer_->RemoveFromParent();
827 cc_layer_->InsertChild(child->cc_layer_, dest_i); 828 cc_layer_->InsertChild(child->cc_layer_, dest_i);
828 } 829 }
829 830
830 bool Layer::ConvertPointForAncestor(const Layer* ancestor, 831 bool Layer::ConvertPointForAncestor(const Layer* ancestor,
831 gfx::Point* point) const { 832 gfx::Point* point) const {
832 gfx::Transform transform; 833 gfx::Transform transform;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 if (animator_) { 1026 if (animator_) {
1026 animator_->ResetCompositor(compositor); 1027 animator_->ResetCompositor(compositor);
1027 animator_->RemoveFromCollection(collection); 1028 animator_->RemoveFromCollection(collection);
1028 } 1029 }
1029 1030
1030 for (auto* child : children_) 1031 for (auto* child : children_)
1031 child->ResetCompositorForAnimatorsInTree(compositor); 1032 child->ResetCompositorForAnimatorsInTree(compositor);
1032 } 1033 }
1033 1034
1034 } // namespace ui 1035 } // namespace ui
OLDNEW
« ui/compositor/layer.h ('K') | « ui/compositor/layer.h ('k') | ui/wm/core/shadow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698