| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/layer_impl.h" | 5 #include "cc/layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 8 |
| 7 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 8 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 9 #include "cc/debug_border_draw_quad.h" | 11 #include "cc/debug_border_draw_quad.h" |
| 10 #include "cc/debug_colors.h" | 12 #include "cc/debug_colors.h" |
| 11 #include "cc/layer_sorter.h" | 13 #include "cc/layer_sorter.h" |
| 12 #include "cc/layer_tree_host_impl.h" | 14 #include "cc/layer_tree_host_impl.h" |
| 13 #include "cc/math_util.h" | 15 #include "cc/math_util.h" |
| 14 #include "cc/proxy.h" | 16 #include "cc/proxy.h" |
| 15 #include "cc/quad_sink.h" | 17 #include "cc/quad_sink.h" |
| 16 #include "cc/scrollbar_animation_controller.h" | 18 #include "cc/scrollbar_animation_controller.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 { | 71 { |
| 70 #ifndef NDEBUG | 72 #ifndef NDEBUG |
| 71 DCHECK(!m_betweenWillDrawAndDidDraw); | 73 DCHECK(!m_betweenWillDrawAndDidDraw); |
| 72 #endif | 74 #endif |
| 73 SkSafeUnref(m_filter); | 75 SkSafeUnref(m_filter); |
| 74 } | 76 } |
| 75 | 77 |
| 76 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) | 78 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) |
| 77 { | 79 { |
| 78 child->setParent(this); | 80 child->setParent(this); |
| 79 m_children.append(child.Pass()); | 81 m_children.push_back(child.Pass()); |
| 80 } | 82 } |
| 81 | 83 |
| 82 void LayerImpl::removeFromParent() | 84 void LayerImpl::removeFromParent() |
| 83 { | 85 { |
| 84 if (!m_parent) | 86 if (!m_parent) |
| 85 return; | 87 return; |
| 86 | 88 |
| 87 LayerImpl* parent = m_parent; | 89 LayerImpl* parent = m_parent; |
| 88 m_parent = 0; | 90 m_parent = 0; |
| 89 | 91 |
| 90 for (size_t i = 0; i < parent->m_children.size(); ++i) { | 92 parent->m_children.erase(std::find(parent->m_children.begin(), parent->m_chi
ldren.end(), this)); |
| 91 if (parent->m_children[i] == this) { | |
| 92 parent->m_children.remove(i); | |
| 93 return; | |
| 94 } | |
| 95 } | |
| 96 } | 93 } |
| 97 | 94 |
| 98 void LayerImpl::removeAllChildren() | 95 void LayerImpl::removeAllChildren() |
| 99 { | 96 { |
| 100 while (m_children.size()) | 97 while (m_children.size()) |
| 101 m_children[0]->removeFromParent(); | 98 m_children.front()->removeFromParent(); |
| 102 } | 99 } |
| 103 | 100 |
| 104 void LayerImpl::clearChildList() | 101 void LayerImpl::clearChildList() |
| 105 { | 102 { |
| 106 m_children.clear(); | 103 m_children.clear(); |
| 107 } | 104 } |
| 108 | 105 |
| 109 void LayerImpl::createRenderSurface() | 106 void LayerImpl::createRenderSurface() |
| 110 { | 107 { |
| 111 DCHECK(!m_renderSurface); | 108 DCHECK(!m_renderSurface); |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 | 708 |
| 712 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 709 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
| 713 { | 710 { |
| 714 if (!m_scrollbarAnimationController) | 711 if (!m_scrollbarAnimationController) |
| 715 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 712 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
| 716 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 713 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
| 717 m_scrollbarAnimationController->updateScrollOffset(this); | 714 m_scrollbarAnimationController->updateScrollOffset(this); |
| 718 } | 715 } |
| 719 | 716 |
| 720 } // namespace cc | 717 } // namespace cc |
| OLD | NEW |