OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer.h" | 7 #include "cc/layer.h" |
8 | 8 |
9 #include "CCActiveAnimation.h" | 9 #include "CCActiveAnimation.h" |
10 #include "CCAnimationEvents.h" | 10 #include "CCAnimationEvents.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 if (m_layerId < 0) { | 70 if (m_layerId < 0) { |
71 s_nextLayerId = 1; | 71 s_nextLayerId = 1; |
72 m_layerId = s_nextLayerId++; | 72 m_layerId = s_nextLayerId++; |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 LayerChromium::~LayerChromium() | 76 LayerChromium::~LayerChromium() |
77 { | 77 { |
78 // Our parent should be holding a reference to us so there should be no | 78 // Our parent should be holding a reference to us so there should be no |
79 // way for us to be destroyed while we still have a parent. | 79 // way for us to be destroyed while we still have a parent. |
80 ASSERT(!parent()); | 80 DCHECK(!parent()); |
81 | 81 |
82 // Remove the parent reference from all children. | 82 // Remove the parent reference from all children. |
83 removeAllChildren(); | 83 removeAllChildren(); |
84 } | 84 } |
85 | 85 |
86 void LayerChromium::setUseLCDText(bool useLCDText) | 86 void LayerChromium::setUseLCDText(bool useLCDText) |
87 { | 87 { |
88 m_useLCDText = useLCDText; | 88 m_useLCDText = useLCDText; |
89 } | 89 } |
90 | 90 |
(...skipping 27 matching lines...) Expand all Loading... |
118 { | 118 { |
119 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi
dth(); | 119 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi
dth(); |
120 float heightScale = static_cast<float>(contentBounds().height()) / bounds().
height(); | 120 float heightScale = static_cast<float>(contentBounds().height()) / bounds().
height(); |
121 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h
eight); | 121 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h
eight); |
122 contentRect.scale(widthScale, heightScale); | 122 contentRect.scale(widthScale, heightScale); |
123 return enclosingIntRect(contentRect); | 123 return enclosingIntRect(contentRect); |
124 } | 124 } |
125 | 125 |
126 void LayerChromium::setParent(LayerChromium* layer) | 126 void LayerChromium::setParent(LayerChromium* layer) |
127 { | 127 { |
128 ASSERT(!layer || !layer->hasAncestor(this)); | 128 DCHECK(!layer || !layer->hasAncestor(this)); |
129 m_parent = layer; | 129 m_parent = layer; |
130 setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0); | 130 setLayerTreeHost(m_parent ? m_parent->layerTreeHost() : 0); |
131 } | 131 } |
132 | 132 |
133 bool LayerChromium::hasAncestor(LayerChromium* ancestor) const | 133 bool LayerChromium::hasAncestor(LayerChromium* ancestor) const |
134 { | 134 { |
135 for (LayerChromium* layer = parent(); layer; layer = layer->parent()) { | 135 for (LayerChromium* layer = parent(); layer; layer = layer->parent()) { |
136 if (layer == ancestor) | 136 if (layer == ancestor) |
137 return true; | 137 return true; |
138 } | 138 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 void LayerChromium::replaceChild(LayerChromium* reference, scoped_refptr<LayerCh
romium> newLayer) | 179 void LayerChromium::replaceChild(LayerChromium* reference, scoped_refptr<LayerCh
romium> newLayer) |
180 { | 180 { |
181 ASSERT_ARG(reference, reference); | 181 ASSERT_ARG(reference, reference); |
182 ASSERT_ARG(reference, reference->parent() == this); | 182 ASSERT_ARG(reference, reference->parent() == this); |
183 | 183 |
184 if (reference == newLayer) | 184 if (reference == newLayer) |
185 return; | 185 return; |
186 | 186 |
187 int referenceIndex = indexOfChild(reference); | 187 int referenceIndex = indexOfChild(reference); |
188 if (referenceIndex == -1) { | 188 if (referenceIndex == -1) { |
189 ASSERT_NOT_REACHED(); | 189 NOTREACHED(); |
190 return; | 190 return; |
191 } | 191 } |
192 | 192 |
193 reference->removeFromParent(); | 193 reference->removeFromParent(); |
194 | 194 |
195 if (newLayer) { | 195 if (newLayer) { |
196 newLayer->removeFromParent(); | 196 newLayer->removeFromParent(); |
197 insertChild(newLayer, referenceIndex); | 197 insertChild(newLayer, referenceIndex); |
198 } | 198 } |
199 } | 199 } |
(...skipping 27 matching lines...) Expand all Loading... |
227 LayerChromium* layer = this; | 227 LayerChromium* layer = this; |
228 while (layer->parent()) | 228 while (layer->parent()) |
229 layer = layer->parent(); | 229 layer = layer->parent(); |
230 return layer; | 230 return layer; |
231 } | 231 } |
232 | 232 |
233 void LayerChromium::removeAllChildren() | 233 void LayerChromium::removeAllChildren() |
234 { | 234 { |
235 while (m_children.size()) { | 235 while (m_children.size()) { |
236 LayerChromium* layer = m_children[0].get(); | 236 LayerChromium* layer = m_children[0].get(); |
237 ASSERT(layer->parent()); | 237 DCHECK(layer->parent()); |
238 layer->removeFromParent(); | 238 layer->removeFromParent(); |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 void LayerChromium::setChildren(const LayerList& children) | 242 void LayerChromium::setChildren(const LayerList& children) |
243 { | 243 { |
244 if (children == m_children) | 244 if (children == m_children) |
245 return; | 245 return; |
246 | 246 |
247 removeAllChildren(); | 247 removeAllChildren(); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 647 |
648 if (boundsContainPageScale == m_boundsContainPageScale) | 648 if (boundsContainPageScale == m_boundsContainPageScale) |
649 return; | 649 return; |
650 | 650 |
651 m_boundsContainPageScale = boundsContainPageScale; | 651 m_boundsContainPageScale = boundsContainPageScale; |
652 setNeedsDisplay(); | 652 setNeedsDisplay(); |
653 } | 653 } |
654 | 654 |
655 void LayerChromium::createRenderSurface() | 655 void LayerChromium::createRenderSurface() |
656 { | 656 { |
657 ASSERT(!m_renderSurface); | 657 DCHECK(!m_renderSurface); |
658 m_renderSurface = make_scoped_ptr(new RenderSurfaceChromium(this)); | 658 m_renderSurface = make_scoped_ptr(new RenderSurfaceChromium(this)); |
659 setRenderTarget(this); | 659 setRenderTarget(this); |
660 } | 660 } |
661 | 661 |
662 bool LayerChromium::descendantDrawsContent() | 662 bool LayerChromium::descendantDrawsContent() |
663 { | 663 { |
664 for (size_t i = 0; i < m_children.size(); ++i) { | 664 for (size_t i = 0; i < m_children.size(); ++i) { |
665 if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsConte
nt()) | 665 if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsConte
nt()) |
666 return true; | 666 return true; |
667 } | 667 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 { | 788 { |
789 return 0; | 789 return 0; |
790 } | 790 } |
791 | 791 |
792 void sortLayers(std::vector<scoped_refptr<LayerChromium> >::iterator, std::vecto
r<scoped_refptr<LayerChromium> >::iterator, void*) | 792 void sortLayers(std::vector<scoped_refptr<LayerChromium> >::iterator, std::vecto
r<scoped_refptr<LayerChromium> >::iterator, void*) |
793 { | 793 { |
794 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort LayerChromiums. | 794 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort LayerChromiums. |
795 } | 795 } |
796 | 796 |
797 } | 797 } |
OLD | NEW |