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