OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/compositor/layer.h" | 5 #include "ui/gfx/compositor/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 SetOpacityImmediately(opacity); | 180 SetOpacityImmediately(opacity); |
181 } | 181 } |
182 | 182 |
183 void Layer::SetVisible(bool visible) { | 183 void Layer::SetVisible(bool visible) { |
184 if (visible_ == visible) | 184 if (visible_ == visible) |
185 return; | 185 return; |
186 | 186 |
187 bool was_drawn = IsDrawn(); | 187 bool was_drawn = IsDrawn(); |
188 visible_ = visible; | 188 visible_ = visible; |
| 189 #if defined(USE_WEBKIT_COMPOSITOR) |
| 190 // TODO(piman): Expose a visibility flag on WebLayer. |
| 191 web_layer_.setOpacity(visible_ ? opacity_ : 0.f); |
| 192 #endif |
189 bool is_drawn = IsDrawn(); | 193 bool is_drawn = IsDrawn(); |
190 if (was_drawn == is_drawn) | 194 if (was_drawn == is_drawn) |
191 return; | 195 return; |
192 | 196 |
193 if (!is_drawn) | 197 if (!is_drawn) |
194 DropTextures(); | 198 DropTextures(); |
195 SetNeedsToRecomputeHole(); | 199 SetNeedsToRecomputeHole(); |
196 #if defined(USE_WEBKIT_COMPOSITOR) | |
197 // TODO(piman): Expose a visibility flag on WebLayer. | |
198 web_layer_.setOpacity(visible_ ? opacity_ : 0.f); | |
199 #endif | |
200 } | 200 } |
201 | 201 |
202 bool Layer::IsDrawn() const { | 202 bool Layer::IsDrawn() const { |
203 const Layer* layer = this; | 203 const Layer* layer = this; |
204 while (layer && layer->visible_) | 204 while (layer && layer->visible_) |
205 layer = layer->parent_; | 205 layer = layer->parent_; |
206 return layer == NULL; | 206 return layer == NULL; |
207 } | 207 } |
208 | 208 |
209 bool Layer::ShouldDraw() const { | 209 bool Layer::ShouldDraw() const { |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 #else | 689 #else |
690 unsigned int texture_id = 0; | 690 unsigned int texture_id = 0; |
691 #endif | 691 #endif |
692 web_layer_.to<WebKit::WebExternalTextureLayer>().setTextureId( | 692 web_layer_.to<WebKit::WebExternalTextureLayer>().setTextureId( |
693 should_draw ? texture_id : 0); | 693 should_draw ? texture_id : 0); |
694 } | 694 } |
695 } | 695 } |
696 #endif | 696 #endif |
697 | 697 |
698 } // namespace ui | 698 } // namespace ui |
OLD | NEW |