| 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 "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "cc/animation_registrar.h" | 10 #include "cc/animation_registrar.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 , m_betweenWillDrawAndDidDraw(false) | 56 , m_betweenWillDrawAndDidDraw(false) |
| 57 #endif | 57 #endif |
| 58 , m_horizontalScrollbarLayer(0) | 58 , m_horizontalScrollbarLayer(0) |
| 59 , m_verticalScrollbarLayer(0) | 59 , m_verticalScrollbarLayer(0) |
| 60 { | 60 { |
| 61 DCHECK(m_layerId > 0); | 61 DCHECK(m_layerId > 0); |
| 62 DCHECK(m_layerTreeImpl); | 62 DCHECK(m_layerTreeImpl); |
| 63 m_layerTreeImpl->RegisterLayer(this); | 63 m_layerTreeImpl->RegisterLayer(this); |
| 64 AnimationRegistrar* registrar = m_layerTreeImpl->animationRegistrar(); | 64 AnimationRegistrar* registrar = m_layerTreeImpl->animationRegistrar(); |
| 65 m_layerAnimationController = registrar->GetAnimationControllerForId(m_layerI
d); | 65 m_layerAnimationController = registrar->GetAnimationControllerForId(m_layerI
d); |
| 66 m_layerAnimationController->addObserver(this); | 66 m_layerAnimationController->AddObserver(this); |
| 67 } | 67 } |
| 68 | 68 |
| 69 LayerImpl::~LayerImpl() | 69 LayerImpl::~LayerImpl() |
| 70 { | 70 { |
| 71 #ifndef NDEBUG | 71 #ifndef NDEBUG |
| 72 DCHECK(!m_betweenWillDrawAndDidDraw); | 72 DCHECK(!m_betweenWillDrawAndDidDraw); |
| 73 #endif | 73 #endif |
| 74 m_layerTreeImpl->UnregisterLayer(this); | 74 m_layerTreeImpl->UnregisterLayer(this); |
| 75 m_layerAnimationController->removeObserver(this); | 75 m_layerAnimationController->RemoveObserver(this); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) | 78 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) |
| 79 { | 79 { |
| 80 child->setParent(this); | 80 child->setParent(this); |
| 81 DCHECK_EQ(layerTreeImpl(), child->layerTreeImpl()); | 81 DCHECK_EQ(layerTreeImpl(), child->layerTreeImpl()); |
| 82 m_children.push_back(child.Pass()); | 82 m_children.push_back(child.Pass()); |
| 83 layerTreeImpl()->set_needs_update_draw_properties(); | 83 layerTreeImpl()->set_needs_update_draw_properties(); |
| 84 } | 84 } |
| 85 | 85 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // will become incorrect if we simply clobber the updateRect here. The Layer
Impl's updateRect needs to | 358 // will become incorrect if we simply clobber the updateRect here. The Layer
Impl's updateRect needs to |
| 359 // accumulate (i.e. union) any update changes that have occurred on the main
thread. | 359 // accumulate (i.e. union) any update changes that have occurred on the main
thread. |
| 360 m_updateRect.Union(layer->updateRect()); | 360 m_updateRect.Union(layer->updateRect()); |
| 361 layer->setUpdateRect(m_updateRect); | 361 layer->setUpdateRect(m_updateRect); |
| 362 | 362 |
| 363 layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta()); | 363 layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta()); |
| 364 layer->setSentScrollDelta(gfx::Vector2d()); | 364 layer->setSentScrollDelta(gfx::Vector2d()); |
| 365 | 365 |
| 366 layer->setStackingOrderChanged(m_stackingOrderChanged); | 366 layer->setStackingOrderChanged(m_stackingOrderChanged); |
| 367 | 367 |
| 368 m_layerAnimationController->pushAnimationUpdatesTo(layer->layerAnimationCont
roller()); | 368 m_layerAnimationController->PushAnimationUpdatesTo(layer->layerAnimationCont
roller()); |
| 369 | 369 |
| 370 // Reset any state that should be cleared for the next update. | 370 // Reset any state that should be cleared for the next update. |
| 371 m_stackingOrderChanged = false; | 371 m_stackingOrderChanged = false; |
| 372 m_updateRect = gfx::RectF(); | 372 m_updateRect = gfx::RectF(); |
| 373 } | 373 } |
| 374 | 374 |
| 375 std::string LayerImpl::indentString(int indent) | 375 std::string LayerImpl::indentString(int indent) |
| 376 { | 376 { |
| 377 std::string str; | 377 std::string str; |
| 378 for (int i = 0; i != indent; ++i) | 378 for (int i = 0; i != indent; ++i) |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 noteLayerSurfacePropertyChanged(); | 732 noteLayerSurfacePropertyChanged(); |
| 733 } | 733 } |
| 734 | 734 |
| 735 float LayerImpl::opacity() const | 735 float LayerImpl::opacity() const |
| 736 { | 736 { |
| 737 return m_opacity; | 737 return m_opacity; |
| 738 } | 738 } |
| 739 | 739 |
| 740 bool LayerImpl::opacityIsAnimating() const | 740 bool LayerImpl::opacityIsAnimating() const |
| 741 { | 741 { |
| 742 return m_layerAnimationController->isAnimatingProperty(Animation::Opacity); | 742 return m_layerAnimationController->IsAnimatingProperty(Animation::Opacity); |
| 743 } | 743 } |
| 744 | 744 |
| 745 void LayerImpl::setPosition(const gfx::PointF& position) | 745 void LayerImpl::setPosition(const gfx::PointF& position) |
| 746 { | 746 { |
| 747 if (m_position == position) | 747 if (m_position == position) |
| 748 return; | 748 return; |
| 749 | 749 |
| 750 m_position = position; | 750 m_position = position; |
| 751 noteLayerPropertyChangedForSubtree(); | 751 noteLayerPropertyChangedForSubtree(); |
| 752 } | 752 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 779 noteLayerSurfacePropertyChanged(); | 779 noteLayerSurfacePropertyChanged(); |
| 780 } | 780 } |
| 781 | 781 |
| 782 const gfx::Transform& LayerImpl::transform() const | 782 const gfx::Transform& LayerImpl::transform() const |
| 783 { | 783 { |
| 784 return m_transform; | 784 return m_transform; |
| 785 } | 785 } |
| 786 | 786 |
| 787 bool LayerImpl::transformIsAnimating() const | 787 bool LayerImpl::transformIsAnimating() const |
| 788 { | 788 { |
| 789 return m_layerAnimationController->isAnimatingProperty(Animation::Transform)
; | 789 return m_layerAnimationController->IsAnimatingProperty(Animation::Transform)
; |
| 790 } | 790 } |
| 791 | 791 |
| 792 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) | 792 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) |
| 793 { | 793 { |
| 794 if (this->contentBounds() == contentBounds) | 794 if (this->contentBounds() == contentBounds) |
| 795 return; | 795 return; |
| 796 | 796 |
| 797 m_drawProperties.content_bounds = contentBounds; | 797 m_drawProperties.content_bounds = contentBounds; |
| 798 noteLayerPropertyChanged(); | 798 noteLayerPropertyChanged(); |
| 799 } | 799 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 } | 985 } |
| 986 | 986 |
| 987 scoped_ptr<base::Value> LayerImpl::AsValue() const | 987 scoped_ptr<base::Value> LayerImpl::AsValue() const |
| 988 { | 988 { |
| 989 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 989 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 990 AsValueInto(state.get()); | 990 AsValueInto(state.get()); |
| 991 return state.PassAs<base::Value>(); | 991 return state.PassAs<base::Value>(); |
| 992 } | 992 } |
| 993 | 993 |
| 994 } // namespace cc | 994 } // namespace cc |
| OLD | NEW |