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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 bool Layer::ShouldDraw() const { | 209 bool Layer::ShouldDraw() const { |
210 return type_ == LAYER_HAS_TEXTURE && GetCombinedOpacity() > 0.0f && | 210 return type_ == LAYER_HAS_TEXTURE && GetCombinedOpacity() > 0.0f && |
211 !hole_rect_.Contains(gfx::Rect(gfx::Point(0, 0), bounds_.size())); | 211 !hole_rect_.Contains(gfx::Rect(gfx::Point(0, 0), bounds_.size())); |
212 } | 212 } |
213 | 213 |
214 // static | 214 // static |
215 void Layer::ConvertPointToLayer(const Layer* source, | 215 void Layer::ConvertPointToLayer(const Layer* source, |
216 const Layer* target, | 216 const Layer* target, |
217 gfx::Point* point) { | 217 gfx::Point* point) { |
218 const Layer* inner = NULL; | 218 if (source == target) |
219 const Layer* outer = NULL; | 219 return; |
220 if (source->Contains(target)) { | 220 |
221 inner = target; | 221 const Layer* root_layer = source->compositor()->root_layer(); |
222 outer = source; | 222 CHECK_EQ(root_layer, target->compositor()->root_layer()); |
223 inner->ConvertPointFromAncestor(outer, point); | 223 |
224 } else if (target->Contains(source)) { | 224 if (source != root_layer) |
225 inner = source; | 225 source->ConvertPointForAncestor(root_layer, point); |
226 outer = target; | 226 if (target != root_layer) |
227 inner->ConvertPointForAncestor(outer, point); | 227 target->ConvertPointFromAncestor(root_layer, point); |
228 } else { | |
229 NOTREACHED(); // |source| and |target| are in unrelated hierarchies. | |
230 } | |
231 } | 228 } |
232 | 229 |
233 void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { | 230 void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { |
234 if (fills_bounds_opaquely_ == fills_bounds_opaquely) | 231 if (fills_bounds_opaquely_ == fills_bounds_opaquely) |
235 return; | 232 return; |
236 | 233 |
237 fills_bounds_opaquely_ = fills_bounds_opaquely; | 234 fills_bounds_opaquely_ = fills_bounds_opaquely; |
238 | 235 |
239 SetNeedsToRecomputeHole(); | 236 SetNeedsToRecomputeHole(); |
240 #if defined(USE_WEBKIT_COMPOSITOR) | 237 #if defined(USE_WEBKIT_COMPOSITOR) |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 #else | 686 #else |
690 unsigned int texture_id = 0; | 687 unsigned int texture_id = 0; |
691 #endif | 688 #endif |
692 web_layer_.to<WebKit::WebExternalTextureLayer>().setTextureId( | 689 web_layer_.to<WebKit::WebExternalTextureLayer>().setTextureId( |
693 should_draw ? texture_id : 0); | 690 should_draw ? texture_id : 0); |
694 } | 691 } |
695 } | 692 } |
696 #endif | 693 #endif |
697 | 694 |
698 } // namespace ui | 695 } // namespace ui |
OLD | NEW |