| 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return; // Already in front. | 128 return; // Already in front. |
| 129 StackAbove(child, children_.back()); | 129 StackAbove(child, children_.back()); |
| 130 | 130 |
| 131 SetNeedsToRecomputeHole(); | 131 SetNeedsToRecomputeHole(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void Layer::StackAbove(Layer* child, Layer* other) { | 134 void Layer::StackAbove(Layer* child, Layer* other) { |
| 135 DCHECK_NE(child, other); | 135 DCHECK_NE(child, other); |
| 136 DCHECK_EQ(this, child->parent()); | 136 DCHECK_EQ(this, child->parent()); |
| 137 DCHECK_EQ(this, other->parent()); | 137 DCHECK_EQ(this, other->parent()); |
| 138 size_t child_i = | 138 |
| 139 const size_t child_i = |
| 139 std::find(children_.begin(), children_.end(), child) - children_.begin(); | 140 std::find(children_.begin(), children_.end(), child) - children_.begin(); |
| 140 size_t other_i = | 141 const size_t other_i = |
| 141 std::find(children_.begin(), children_.end(), other) - children_.begin(); | 142 std::find(children_.begin(), children_.end(), other) - children_.begin(); |
| 142 if (child_i > other_i) | 143 if (child_i == other_i + 1) |
| 143 return; // Already in front of |other|. | 144 return; |
| 144 | 145 |
| 145 // Reorder children. | 146 const size_t dest_i = child_i < other_i ? other_i : other_i + 1; |
| 146 children_.erase(children_.begin() + child_i); | 147 children_.erase(children_.begin() + child_i); |
| 147 children_.insert(children_.begin() + other_i, child); | 148 children_.insert(children_.begin() + dest_i, child); |
| 148 | 149 |
| 149 SetNeedsToRecomputeHole(); | 150 SetNeedsToRecomputeHole(); |
| 150 | 151 |
| 151 #if defined(USE_WEBKIT_COMPOSITOR) | 152 #if defined(USE_WEBKIT_COMPOSITOR) |
| 152 child->web_layer_.removeFromParent(); | 153 child->web_layer_.removeFromParent(); |
| 153 web_layer_.insertChild(child->web_layer_, other_i); | 154 web_layer_.insertChild(child->web_layer_, dest_i); |
| 154 #endif | 155 #endif |
| 155 } | 156 } |
| 156 | 157 |
| 157 bool Layer::Contains(const Layer* other) const { | 158 bool Layer::Contains(const Layer* other) const { |
| 158 for (const Layer* parent = other; parent; parent = parent->parent()) { | 159 for (const Layer* parent = other; parent; parent = parent->parent()) { |
| 159 if (parent == this) | 160 if (parent == this) |
| 160 return true; | 161 return true; |
| 161 } | 162 } |
| 162 return false; | 163 return false; |
| 163 } | 164 } |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 0, | 734 0, |
| 734 static_cast<float>(size.width())/texture_cc->size().width(), | 735 static_cast<float>(size.width())/texture_cc->size().width(), |
| 735 static_cast<float>(size.height())/texture_cc->size().height()); | 736 static_cast<float>(size.height())/texture_cc->size().height()); |
| 736 texture_layer.setUVRect(rect); | 737 texture_layer.setUVRect(rect); |
| 737 web_layer_.setBounds(size); | 738 web_layer_.setBounds(size); |
| 738 } | 739 } |
| 739 } | 740 } |
| 740 #endif | 741 #endif |
| 741 | 742 |
| 742 } // namespace ui | 743 } // namespace ui |
| OLD | NEW |