Chromium Code Reviews| 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 "cc/layer.h" | 5 #include "cc/layer.h" |
| 6 | 6 |
| 7 #include "cc/active_animation.h" | 7 #include "cc/active_animation.h" |
| 8 #include "cc/animation_events.h" | 8 #include "cc/animation_events.h" |
| 9 #include "cc/layer_animation_controller.h" | 9 #include "cc/layer_animation_controller.h" |
| 10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 if (host && m_layerAnimationController->hasActiveAnimation()) | 109 if (host && m_layerAnimationController->hasActiveAnimation()) |
| 110 host->didAddAnimation(); | 110 host->didAddAnimation(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void Layer::setNeedsCommit() | 113 void Layer::setNeedsCommit() |
| 114 { | 114 { |
| 115 if (m_layerTreeHost) | 115 if (m_layerTreeHost) |
| 116 m_layerTreeHost->setNeedsCommit(); | 116 m_layerTreeHost->setNeedsCommit(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void Layer::setNeedsFullTreeSync() | |
| 120 { | |
| 121 if (m_layerTreeHost) | |
| 122 m_layerTreeHost->setNeedsFullTreeSync(); | |
| 123 } | |
| 124 | |
| 119 gfx::Rect Layer::layerRectToContentRect(const gfx::RectF& layerRect) const | 125 gfx::Rect Layer::layerRectToContentRect(const gfx::RectF& layerRect) const |
| 120 { | 126 { |
| 121 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content sScaleY()); | 127 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content sScaleY()); |
| 122 // Intersect with content rect to avoid the extra pixel because for some | 128 // Intersect with content rect to avoid the extra pixel because for some |
| 123 // values x and y, ceil((x / y) * y) may be x + 1. | 129 // values x and y, ceil((x / y) * y) may be x + 1. |
| 124 contentRect.Intersect(gfx::Rect(gfx::Point(), contentBounds())); | 130 contentRect.Intersect(gfx::Rect(gfx::Point(), contentBounds())); |
| 125 return gfx::ToEnclosingRect(contentRect); | 131 return gfx::ToEnclosingRect(contentRect); |
| 126 } | 132 } |
| 127 | 133 |
| 128 void Layer::setParent(Layer* layer) | 134 void Layer::setParent(Layer* layer) |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 150 | 156 |
| 151 void Layer::insertChild(scoped_refptr<Layer> child, size_t index) | 157 void Layer::insertChild(scoped_refptr<Layer> child, size_t index) |
| 152 { | 158 { |
| 153 child->removeFromParent(); | 159 child->removeFromParent(); |
| 154 child->setParent(this); | 160 child->setParent(this); |
| 155 child->m_stackingOrderChanged = true; | 161 child->m_stackingOrderChanged = true; |
| 156 | 162 |
| 157 index = min(index, m_children.size()); | 163 index = min(index, m_children.size()); |
| 158 LayerList::iterator iter = m_children.begin(); | 164 LayerList::iterator iter = m_children.begin(); |
| 159 m_children.insert(iter + index, child); | 165 m_children.insert(iter + index, child); |
| 160 setNeedsCommit(); | 166 setNeedsFullTreeSync(); |
| 161 } | 167 } |
| 162 | 168 |
| 163 void Layer::removeFromParent() | 169 void Layer::removeFromParent() |
| 164 { | 170 { |
| 165 if (m_parent) | 171 if (m_parent) |
| 166 m_parent->removeChild(this); | 172 m_parent->removeChild(this); |
| 167 } | 173 } |
| 168 | 174 |
| 169 void Layer::removeChild(Layer* child) | 175 void Layer::removeChild(Layer* child) |
| 170 { | 176 { |
| 171 for (LayerList::iterator iter = m_children.begin(); iter != m_children.end() ; ++iter) | 177 for (LayerList::iterator iter = m_children.begin(); iter != m_children.end() ; ++iter) |
| 172 { | 178 { |
| 173 if (*iter != child) | 179 if (*iter != child) |
| 174 continue; | 180 continue; |
| 175 | 181 |
| 176 child->setParent(0); | 182 child->setParent(0); |
| 177 m_children.erase(iter); | 183 m_children.erase(iter); |
| 178 setNeedsCommit(); | 184 setNeedsFullTreeSync(); |
| 179 return; | 185 return; |
| 180 } | 186 } |
| 181 } | 187 } |
| 182 | 188 |
| 183 void Layer::replaceChild(Layer* reference, scoped_refptr<Layer> newLayer) | 189 void Layer::replaceChild(Layer* reference, scoped_refptr<Layer> newLayer) |
| 184 { | 190 { |
| 185 DCHECK(reference); | 191 DCHECK(reference); |
| 186 DCHECK_EQ(reference->parent(), this); | 192 DCHECK_EQ(reference->parent(), this); |
| 187 | 193 |
| 188 if (reference == newLayer) | 194 if (reference == newLayer) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 { | 301 { |
| 296 if (m_maskLayer == maskLayer) | 302 if (m_maskLayer == maskLayer) |
| 297 return; | 303 return; |
| 298 if (m_maskLayer) | 304 if (m_maskLayer) |
| 299 m_maskLayer->setLayerTreeHost(0); | 305 m_maskLayer->setLayerTreeHost(0); |
| 300 m_maskLayer = maskLayer; | 306 m_maskLayer = maskLayer; |
| 301 if (m_maskLayer) { | 307 if (m_maskLayer) { |
| 302 m_maskLayer->setLayerTreeHost(m_layerTreeHost); | 308 m_maskLayer->setLayerTreeHost(m_layerTreeHost); |
| 303 m_maskLayer->setIsMask(true); | 309 m_maskLayer->setIsMask(true); |
| 304 } | 310 } |
| 305 setNeedsCommit(); | 311 setNeedsFullTreeSync(); |
| 306 } | 312 } |
| 307 | 313 |
| 308 void Layer::setReplicaLayer(Layer* layer) | 314 void Layer::setReplicaLayer(Layer* layer) |
| 309 { | 315 { |
| 310 if (m_replicaLayer == layer) | 316 if (m_replicaLayer == layer) |
| 311 return; | 317 return; |
| 312 if (m_replicaLayer) | 318 if (m_replicaLayer) |
| 313 m_replicaLayer->setLayerTreeHost(0); | 319 m_replicaLayer->setLayerTreeHost(0); |
| 314 m_replicaLayer = layer; | 320 m_replicaLayer = layer; |
| 315 if (m_replicaLayer) | 321 if (m_replicaLayer) |
| 316 m_replicaLayer->setLayerTreeHost(m_layerTreeHost); | 322 m_replicaLayer->setLayerTreeHost(m_layerTreeHost); |
| 317 setNeedsCommit(); | 323 setNeedsFullTreeSync(); |
| 318 } | 324 } |
| 319 | 325 |
| 320 void Layer::setFilters(const WebKit::WebFilterOperations& filters) | 326 void Layer::setFilters(const WebKit::WebFilterOperations& filters) |
| 321 { | 327 { |
| 322 if (m_filters == filters) | 328 if (m_filters == filters) |
| 323 return; | 329 return; |
| 324 DCHECK(!m_filter); | 330 DCHECK(!m_filter); |
| 325 m_filters = filters; | 331 m_filters = filters; |
| 326 setNeedsCommit(); | 332 setNeedsCommit(); |
| 327 if (!filters.isEmpty()) | 333 if (!filters.isEmpty()) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform); | 410 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform); |
| 405 } | 411 } |
| 406 | 412 |
| 407 void Layer::setScrollOffset(gfx::Vector2d scrollOffset) | 413 void Layer::setScrollOffset(gfx::Vector2d scrollOffset) |
| 408 { | 414 { |
| 409 if (m_scrollOffset == scrollOffset) | 415 if (m_scrollOffset == scrollOffset) |
| 410 return; | 416 return; |
| 411 m_scrollOffset = scrollOffset; | 417 m_scrollOffset = scrollOffset; |
| 412 if (m_layerScrollClient) | 418 if (m_layerScrollClient) |
| 413 m_layerScrollClient->didScroll(); | 419 m_layerScrollClient->didScroll(); |
| 414 setNeedsCommit(); | 420 setNeedsFullTreeSync(); |
|
danakj
2012/12/03 18:46:25
How come a scrollOffset needs a full sync?
| |
| 415 } | 421 } |
| 416 | 422 |
| 417 void Layer::setMaxScrollOffset(gfx::Vector2d maxScrollOffset) | 423 void Layer::setMaxScrollOffset(gfx::Vector2d maxScrollOffset) |
| 418 { | 424 { |
| 419 if (m_maxScrollOffset == maxScrollOffset) | 425 if (m_maxScrollOffset == maxScrollOffset) |
| 420 return; | 426 return; |
| 421 m_maxScrollOffset = maxScrollOffset; | 427 m_maxScrollOffset = maxScrollOffset; |
| 422 setNeedsCommit(); | 428 setNeedsCommit(); |
| 423 } | 429 } |
| 424 | 430 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 838 { | 844 { |
| 839 return 0; | 845 return 0; |
| 840 } | 846 } |
| 841 | 847 |
| 842 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*) | 848 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*) |
| 843 { | 849 { |
| 844 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers. | 850 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers. |
| 845 } | 851 } |
| 846 | 852 |
| 847 } // namespace cc | 853 } // namespace cc |
| OLD | NEW |