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

Unified Diff: ui/gfx/compositor/layer.cc

Issue 8136005: Makes visbility inherited. That is, in order for a window to be (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to trunk Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/compositor/layer.h ('k') | ui/gfx/compositor/layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/compositor/layer.cc
diff --git a/ui/gfx/compositor/layer.cc b/ui/gfx/compositor/layer.cc
index fc1db003602f3e5315c6f53303f9133cc701a801..e0a3a3a72a1e75c9734a204519fe25104ca2d3a5 100644
--- a/ui/gfx/compositor/layer.cc
+++ b/ui/gfx/compositor/layer.cc
@@ -134,13 +134,28 @@ void Layer::SetOpacity(float opacity) {
}
void Layer::SetVisible(bool visible) {
+ if (visible_ == visible)
+ return;
+
+ bool was_drawn = IsDrawn();
visible_ = visible;
- if (!visible_)
+ bool is_drawn = IsDrawn();
+ if (was_drawn == is_drawn)
+ return;
+
+ if (!is_drawn)
DropTextures();
if (parent_)
parent_->RecomputeHole();
}
+bool Layer::IsDrawn() const {
+ const Layer* layer = this;
+ while (layer && layer->visible_)
+ layer = layer->parent_;
+ return layer == NULL;
+}
+
bool Layer::ShouldDraw() {
return type_ == LAYER_HAS_TEXTURE && GetCombinedOpacity() > 0.0f &&
!hole_rect_.Contains(gfx::Rect(gfx::Point(0, 0), bounds_.size()));
@@ -290,14 +305,14 @@ void Layer::RecomputeHole() {
// 1) We cannot do any hole punching if any child has a transform.
for (size_t i = 0; i < children_.size(); ++i) {
- if (children_[i]->transform().HasChange() && children_[i]->visible())
+ if (children_[i]->transform().HasChange() && children_[i]->visible_)
return;
}
// 2) Find the largest hole.
for (size_t i = 0; i < children_.size(); ++i) {
// Ignore non-opaque and hidden children.
- if (!children_[i]->IsCompletelyOpaque() || !children_[i]->visible())
+ if (!children_[i]->IsCompletelyOpaque() || !children_[i]->visible_)
continue;
if (children_[i]->bounds().size().GetArea() > hole_rect_.size().GetArea()) {
@@ -308,7 +323,7 @@ void Layer::RecomputeHole() {
// 3) Make sure hole does not intersect with non-opaque children.
for (size_t i = 0; i < children_.size(); ++i) {
// Ignore opaque and hidden children.
- if (children_[i]->IsCompletelyOpaque() || !children_[i]->visible())
+ if (children_[i]->IsCompletelyOpaque() || !children_[i]->visible_)
continue;
// Ignore non-intersecting children.
« no previous file with comments | « ui/gfx/compositor/layer.h ('k') | ui/gfx/compositor/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698