diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-29 20:36:29 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-29 20:36:29 +0000 |
commit | 6fb3c2719180afa6f2d64377b4e4c158e56637d6 (patch) | |
tree | 591418d951443528dc217b277aff113819df08b5 /ui | |
parent | ae53df1368dbfb4d36b2bb6d1797e4a937b764d2 (diff) | |
download | chromium_src-6fb3c2719180afa6f2d64377b4e4c158e56637d6.zip chromium_src-6fb3c2719180afa6f2d64377b4e4c158e56637d6.tar.gz chromium_src-6fb3c2719180afa6f2d64377b4e4c158e56637d6.tar.bz2 |
Construct a View's layer immediately when SetPaintToLayer(true) is called or when a transform is set.This eliminates the need for LayerHelper since it basically just served as a middle-man for caching layer state when a layer did not exist (which occurred when a view was invisible or not part of a view hierarchy).Also includes a fix to reorder layer children properly without crashing due to dropped textures.BUG=noneTEST=existing unittests
Review URL: http://codereview.chromium.org/8054023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/window.cc | 4 | ||||
-rw-r--r-- | ui/gfx/compositor/layer.cc | 10 | ||||
-rw-r--r-- | ui/gfx/compositor/layer.h | 3 |
3 files changed, 14 insertions, 3 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc index 86e1dda..b738a5b 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -139,9 +139,7 @@ void Window::MoveChildToFront(Window* child) { children_.insert(children_.begin() + children_.size(), child); SchedulePaintInRect(gfx::Rect()); - ui::Layer* parent_layer = child->layer()->parent(); - parent_layer->Remove(child->layer()); - parent_layer->Add(child->layer()); + child->layer()->parent()->MoveToFront(child->layer()); } void Window::AddChild(Window* child) { diff --git a/ui/gfx/compositor/layer.cc b/ui/gfx/compositor/layer.cc index 448158c..622f0a2 100644 --- a/ui/gfx/compositor/layer.cc +++ b/ui/gfx/compositor/layer.cc @@ -78,6 +78,14 @@ void Layer::Remove(Layer* child) { child->DropTextures(); } +void Layer::MoveToFront(Layer* child) { + std::vector<Layer*>::iterator i = + std::find(children_.begin(), children_.end(), child); + DCHECK(i != children_.end()); + children_.erase(i); + children_.push_back(child); +} + bool Layer::Contains(const Layer* other) const { for (const Layer* parent = other; parent; parent = parent->parent()) { if (parent == this) @@ -129,6 +137,8 @@ void Layer::SetVisible(bool visible) { visible_ = visible; if (!visible_) DropTextures(); + if (fills_bounds_opaquely_ && parent_) + parent_->RecomputeHole(); } bool Layer::ShouldDraw() { diff --git a/ui/gfx/compositor/layer.h b/ui/gfx/compositor/layer.h index 625067a..1d06035 100644 --- a/ui/gfx/compositor/layer.h +++ b/ui/gfx/compositor/layer.h @@ -65,6 +65,9 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimatorDelegate { // Removes a Layer from this Layer. void Remove(Layer* child); + // Moves a child to the end of the child list. + void MoveToFront(Layer* child); + // Returns the child Layers. const std::vector<Layer*>& children() { return children_; } |