| 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/debug_border_draw_quad.h" | 11 #include "cc/debug_border_draw_quad.h" |
| 11 #include "cc/debug_colors.h" | 12 #include "cc/debug_colors.h" |
| 12 #include "cc/layer_tree_debug_state.h" | 13 #include "cc/layer_tree_debug_state.h" |
| 13 #include "cc/layer_tree_impl.h" | 14 #include "cc/layer_tree_impl.h" |
| 14 #include "cc/layer_tree_settings.h" | 15 #include "cc/layer_tree_settings.h" |
| 15 #include "cc/math_util.h" | 16 #include "cc/math_util.h" |
| 16 #include "cc/proxy.h" | 17 #include "cc/proxy.h" |
| 17 #include "cc/quad_sink.h" | 18 #include "cc/quad_sink.h" |
| 18 #include "cc/scrollbar_animation_controller.h" | 19 #include "cc/scrollbar_animation_controller.h" |
| 19 #include "ui/gfx/point_conversions.h" | 20 #include "ui/gfx/point_conversions.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 43 , m_useParentBackfaceVisibility(false) | 44 , m_useParentBackfaceVisibility(false) |
| 44 , m_drawCheckerboardForMissingTiles(false) | 45 , m_drawCheckerboardForMissingTiles(false) |
| 45 , m_drawsContent(false) | 46 , m_drawsContent(false) |
| 46 , m_forceRenderSurface(false) | 47 , m_forceRenderSurface(false) |
| 47 , m_isContainerForFixedPositionLayers(false) | 48 , m_isContainerForFixedPositionLayers(false) |
| 48 , m_fixedToContainerLayer(false) | 49 , m_fixedToContainerLayer(false) |
| 49 , m_drawDepth(0) | 50 , m_drawDepth(0) |
| 50 #ifndef NDEBUG | 51 #ifndef NDEBUG |
| 51 , m_betweenWillDrawAndDidDraw(false) | 52 , m_betweenWillDrawAndDidDraw(false) |
| 52 #endif | 53 #endif |
| 53 , m_layerAnimationController(LayerAnimationController::create(this)) | |
| 54 { | 54 { |
| 55 DCHECK(m_layerId > 0); | 55 DCHECK(m_layerId > 0); |
| 56 DCHECK(m_layerTreeImpl); | 56 DCHECK(m_layerTreeImpl); |
| 57 m_layerTreeImpl->RegisterLayer(this); | 57 m_layerTreeImpl->RegisterLayer(this); |
| 58 AnimationRegistrar* registrar = m_layerTreeImpl->animationRegistrar(); |
| 59 m_layerAnimationController = registrar->GetAnimationControllerForId(m_layerI
d); |
| 60 m_layerAnimationController->addObserver(this); |
| 58 } | 61 } |
| 59 | 62 |
| 60 LayerImpl::~LayerImpl() | 63 LayerImpl::~LayerImpl() |
| 61 { | 64 { |
| 62 #ifndef NDEBUG | 65 #ifndef NDEBUG |
| 63 DCHECK(!m_betweenWillDrawAndDidDraw); | 66 DCHECK(!m_betweenWillDrawAndDidDraw); |
| 64 #endif | 67 #endif |
| 65 m_layerTreeImpl->UnregisterLayer(this); | 68 m_layerTreeImpl->UnregisterLayer(this); |
| 69 m_layerAnimationController->removeObserver(this); |
| 66 } | 70 } |
| 67 | 71 |
| 68 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) | 72 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) |
| 69 { | 73 { |
| 70 child->setParent(this); | 74 child->setParent(this); |
| 71 DCHECK_EQ(layerTreeImpl(), child->layerTreeImpl()); | 75 DCHECK_EQ(layerTreeImpl(), child->layerTreeImpl()); |
| 72 m_children.append(child.Pass()); | 76 m_children.append(child.Pass()); |
| 73 layerTreeImpl()->SetNeedsUpdateDrawProperties(); | 77 layerTreeImpl()->SetNeedsUpdateDrawProperties(); |
| 74 } | 78 } |
| 75 | 79 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 bool LayerImpl::layerIsAlwaysDamaged() const | 456 bool LayerImpl::layerIsAlwaysDamaged() const |
| 453 { | 457 { |
| 454 return false; | 458 return false; |
| 455 } | 459 } |
| 456 | 460 |
| 457 int LayerImpl::id() const | 461 int LayerImpl::id() const |
| 458 { | 462 { |
| 459 return m_layerId; | 463 return m_layerId; |
| 460 } | 464 } |
| 461 | 465 |
| 462 float LayerImpl::opacity() const | 466 void LayerImpl::OnOpacityAnimated(float opacity) |
| 463 { | |
| 464 return m_opacity; | |
| 465 } | |
| 466 | |
| 467 void LayerImpl::setOpacityFromAnimation(float opacity) | |
| 468 { | 467 { |
| 469 setOpacity(opacity); | 468 setOpacity(opacity); |
| 470 } | 469 } |
| 471 | 470 |
| 472 const gfx::Transform& LayerImpl::transform() const | 471 void LayerImpl::OnTransformAnimated(const gfx::Transform& transform) |
| 473 { | |
| 474 return m_transform; | |
| 475 } | |
| 476 | |
| 477 void LayerImpl::setTransformFromAnimation(const gfx::Transform& transform) | |
| 478 { | 472 { |
| 479 setTransform(transform); | 473 setTransform(transform); |
| 480 } | 474 } |
| 481 | 475 |
| 482 void LayerImpl::setBounds(const gfx::Size& bounds) | 476 void LayerImpl::setBounds(const gfx::Size& bounds) |
| 483 { | 477 { |
| 484 if (m_bounds == bounds) | 478 if (m_bounds == bounds) |
| 485 return; | 479 return; |
| 486 | 480 |
| 487 m_bounds = bounds; | 481 m_bounds = bounds; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 | 613 |
| 620 void LayerImpl::setOpacity(float opacity) | 614 void LayerImpl::setOpacity(float opacity) |
| 621 { | 615 { |
| 622 if (m_opacity == opacity) | 616 if (m_opacity == opacity) |
| 623 return; | 617 return; |
| 624 | 618 |
| 625 m_opacity = opacity; | 619 m_opacity = opacity; |
| 626 noteLayerSurfacePropertyChanged(); | 620 noteLayerSurfacePropertyChanged(); |
| 627 } | 621 } |
| 628 | 622 |
| 623 float LayerImpl::opacity() const |
| 624 { |
| 625 return m_opacity; |
| 626 } |
| 627 |
| 629 bool LayerImpl::opacityIsAnimating() const | 628 bool LayerImpl::opacityIsAnimating() const |
| 630 { | 629 { |
| 631 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); | 630 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); |
| 632 } | 631 } |
| 633 | 632 |
| 634 void LayerImpl::setPosition(const gfx::PointF& position) | 633 void LayerImpl::setPosition(const gfx::PointF& position) |
| 635 { | 634 { |
| 636 if (m_position == position) | 635 if (m_position == position) |
| 637 return; | 636 return; |
| 638 | 637 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 661 | 660 |
| 662 void LayerImpl::setTransform(const gfx::Transform& transform) | 661 void LayerImpl::setTransform(const gfx::Transform& transform) |
| 663 { | 662 { |
| 664 if (m_transform == transform) | 663 if (m_transform == transform) |
| 665 return; | 664 return; |
| 666 | 665 |
| 667 m_transform = transform; | 666 m_transform = transform; |
| 668 noteLayerSurfacePropertyChanged(); | 667 noteLayerSurfacePropertyChanged(); |
| 669 } | 668 } |
| 670 | 669 |
| 670 const gfx::Transform& LayerImpl::transform() const |
| 671 { |
| 672 return m_transform; |
| 673 } |
| 674 |
| 671 bool LayerImpl::transformIsAnimating() const | 675 bool LayerImpl::transformIsAnimating() const |
| 672 { | 676 { |
| 673 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran
sform); | 677 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran
sform); |
| 674 } | 678 } |
| 675 | 679 |
| 676 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) | 680 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) |
| 677 { | 681 { |
| 678 if (this->contentBounds() == contentBounds) | 682 if (this->contentBounds() == contentBounds) |
| 679 return; | 683 return; |
| 680 | 684 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 | 786 |
| 783 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 787 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
| 784 { | 788 { |
| 785 if (!m_scrollbarAnimationController) | 789 if (!m_scrollbarAnimationController) |
| 786 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 790 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
| 787 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 791 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
| 788 m_scrollbarAnimationController->updateScrollOffset(this); | 792 m_scrollbarAnimationController->updateScrollOffset(this); |
| 789 } | 793 } |
| 790 | 794 |
| 791 } // namespace cc | 795 } // namespace cc |
| OLD | NEW |