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