Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: cc/layer.cc

Issue 12517003: cc: Chromify the Animation and LayerAnimationController classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer.h ('k') | cc/layer_animation_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/animation.h" 7 #include "cc/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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 , m_automaticallyComputeRasterScale(false) 54 , m_automaticallyComputeRasterScale(false)
55 , m_boundsContainPageScale(false) 55 , m_boundsContainPageScale(false)
56 , m_layerAnimationDelegate(0) 56 , m_layerAnimationDelegate(0)
57 , m_layerScrollClient(0) 57 , m_layerScrollClient(0)
58 { 58 {
59 if (m_layerId < 0) { 59 if (m_layerId < 0) {
60 s_nextLayerId = 1; 60 s_nextLayerId = 1;
61 m_layerId = s_nextLayerId++; 61 m_layerId = s_nextLayerId++;
62 } 62 }
63 63
64 m_layerAnimationController = LayerAnimationController::create(m_layerId); 64 m_layerAnimationController = LayerAnimationController::Create(m_layerId);
65 m_layerAnimationController->addObserver(this); 65 m_layerAnimationController->AddObserver(this);
66 addLayerAnimationEventObserver(m_layerAnimationController.get()); 66 addLayerAnimationEventObserver(m_layerAnimationController.get());
67 } 67 }
68 68
69 Layer::~Layer() 69 Layer::~Layer()
70 { 70 {
71 // Our parent should be holding a reference to us so there should be no 71 // Our parent should be holding a reference to us so there should be no
72 // way for us to be destroyed while we still have a parent. 72 // way for us to be destroyed while we still have a parent.
73 DCHECK(!parent()); 73 DCHECK(!parent());
74 74
75 m_layerAnimationController->removeObserver(this); 75 m_layerAnimationController->RemoveObserver(this);
76 76
77 // Remove the parent reference from all children and dependents. 77 // Remove the parent reference from all children and dependents.
78 removeAllChildren(); 78 removeAllChildren();
79 if (m_maskLayer) { 79 if (m_maskLayer) {
80 DCHECK_EQ(this, m_maskLayer->parent()); 80 DCHECK_EQ(this, m_maskLayer->parent());
81 m_maskLayer->removeFromParent(); 81 m_maskLayer->removeFromParent();
82 } 82 }
83 if (m_replicaLayer) { 83 if (m_replicaLayer) {
84 DCHECK_EQ(this, m_replicaLayer->parent()); 84 DCHECK_EQ(this, m_replicaLayer->parent());
85 m_replicaLayer->removeFromParent(); 85 m_replicaLayer->removeFromParent();
86 } 86 }
87 } 87 }
88 88
89 void Layer::setLayerTreeHost(LayerTreeHost* host) 89 void Layer::setLayerTreeHost(LayerTreeHost* host)
90 { 90 {
91 if (m_layerTreeHost == host) 91 if (m_layerTreeHost == host)
92 return; 92 return;
93 93
94 m_layerTreeHost = host; 94 m_layerTreeHost = host;
95 95
96 for (size_t i = 0; i < m_children.size(); ++i) 96 for (size_t i = 0; i < m_children.size(); ++i)
97 m_children[i]->setLayerTreeHost(host); 97 m_children[i]->setLayerTreeHost(host);
98 98
99 if (m_maskLayer) 99 if (m_maskLayer)
100 m_maskLayer->setLayerTreeHost(host); 100 m_maskLayer->setLayerTreeHost(host);
101 if (m_replicaLayer) 101 if (m_replicaLayer)
102 m_replicaLayer->setLayerTreeHost(host); 102 m_replicaLayer->setLayerTreeHost(host);
103 103
104 m_layerAnimationController->setAnimationRegistrar(host ? host->animationRegi strar() : 0); 104 m_layerAnimationController->SetAnimationRegistrar(host ? host->animationRegi strar() : 0);
105 105
106 if (host && m_layerAnimationController->hasAnyAnimation()) 106 if (host && m_layerAnimationController->has_any_animation())
107 host->setNeedsCommit(); 107 host->setNeedsCommit();
108 if (host && (!m_filters.isEmpty() || !m_backgroundFilters.isEmpty() || m_fil ter)) 108 if (host && (!m_filters.isEmpty() || !m_backgroundFilters.isEmpty() || m_fil ter))
109 m_layerTreeHost->setNeedsFilterContext(); 109 m_layerTreeHost->setNeedsFilterContext();
110 110
111 } 111 }
112 112
113 void Layer::setNeedsCommit() 113 void Layer::setNeedsCommit()
114 { 114 {
115 if (m_ignoreSetNeedsCommit) 115 if (m_ignoreSetNeedsCommit)
116 return; 116 return;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 setNeedsCommit(); 428 setNeedsCommit();
429 } 429 }
430 430
431 float Layer::opacity() const 431 float Layer::opacity() const
432 { 432 {
433 return m_opacity; 433 return m_opacity;
434 } 434 }
435 435
436 bool Layer::opacityIsAnimating() const 436 bool Layer::opacityIsAnimating() const
437 { 437 {
438 return m_layerAnimationController->isAnimatingProperty(Animation::Opacity); 438 return m_layerAnimationController->IsAnimatingProperty(Animation::Opacity);
439 } 439 }
440 440
441 void Layer::setContentsOpaque(bool opaque) 441 void Layer::setContentsOpaque(bool opaque)
442 { 442 {
443 if (m_contentsOpaque == opaque) 443 if (m_contentsOpaque == opaque)
444 return; 444 return;
445 m_contentsOpaque = opaque; 445 m_contentsOpaque = opaque;
446 setNeedsCommit(); 446 setNeedsCommit();
447 } 447 }
448 448
(...skipping 21 matching lines...) Expand all
470 setNeedsCommit(); 470 setNeedsCommit();
471 } 471 }
472 472
473 const gfx::Transform& Layer::transform() const 473 const gfx::Transform& Layer::transform() const
474 { 474 {
475 return m_transform; 475 return m_transform;
476 } 476 }
477 477
478 bool Layer::transformIsAnimating() const 478 bool Layer::transformIsAnimating() const
479 { 479 {
480 return m_layerAnimationController->isAnimatingProperty(Animation::Transform) ; 480 return m_layerAnimationController->IsAnimatingProperty(Animation::Transform) ;
481 } 481 }
482 482
483 void Layer::setScrollOffset(gfx::Vector2d scrollOffset) 483 void Layer::setScrollOffset(gfx::Vector2d scrollOffset)
484 { 484 {
485 if (m_scrollOffset == scrollOffset) 485 if (m_scrollOffset == scrollOffset)
486 return; 486 return;
487 m_scrollOffset = scrollOffset; 487 m_scrollOffset = scrollOffset;
488 if (m_layerScrollClient) 488 if (m_layerScrollClient)
489 m_layerScrollClient->didScroll(); 489 m_layerScrollClient->didScroll();
490 setNeedsCommit(); 490 setNeedsCommit();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 DCHECK(layer->sentScrollDelta().IsZero()); 674 DCHECK(layer->sentScrollDelta().IsZero());
675 layer->setScrollDelta(active_twin->scrollDelta() - active_twin->sent ScrollDelta()); 675 layer->setScrollDelta(active_twin->scrollDelta() - active_twin->sent ScrollDelta());
676 } 676 }
677 } else { 677 } else {
678 layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta()); 678 layer->setScrollDelta(layer->scrollDelta() - layer->sentScrollDelta());
679 layer->setSentScrollDelta(gfx::Vector2d()); 679 layer->setSentScrollDelta(gfx::Vector2d());
680 } 680 }
681 681
682 layer->setStackingOrderChanged(m_stackingOrderChanged); 682 layer->setStackingOrderChanged(m_stackingOrderChanged);
683 683
684 m_layerAnimationController->pushAnimationUpdatesTo(layer->layerAnimationCont roller()); 684 m_layerAnimationController->PushAnimationUpdatesTo(layer->layerAnimationCont roller());
685 685
686 // Reset any state that should be cleared for the next update. 686 // Reset any state that should be cleared for the next update.
687 m_stackingOrderChanged = false; 687 m_stackingOrderChanged = false;
688 m_updateRect = gfx::RectF(); 688 m_updateRect = gfx::RectF();
689 } 689 }
690 690
691 scoped_ptr<LayerImpl> Layer::createLayerImpl(LayerTreeImpl* treeImpl) 691 scoped_ptr<LayerImpl> Layer::createLayerImpl(LayerTreeImpl* treeImpl)
692 { 692 {
693 return LayerImpl::create(treeImpl, m_layerId); 693 return LayerImpl::create(treeImpl, m_layerId);
694 } 694 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 // also being run on the impl thread, there is no need to request a commit t o push 781 // also being run on the impl thread, there is no need to request a commit t o push
782 // this value over, so set this value directly rather than calling setTransf orm. 782 // this value over, so set this value directly rather than calling setTransf orm.
783 m_transform = transform; 783 m_transform = transform;
784 } 784 }
785 785
786 bool Layer::IsActive() const 786 bool Layer::IsActive() const
787 { 787 {
788 return true; 788 return true;
789 } 789 }
790 790
791 bool Layer::addAnimation(scoped_ptr <Animation> animation) 791 bool Layer::AddAnimation(scoped_ptr <Animation> animation)
792 { 792 {
793 if (!m_layerAnimationController->animationRegistrar()) 793 if (!m_layerAnimationController->animation_registrar())
794 return false; 794 return false;
795 795
796 m_layerAnimationController->addAnimation(animation.Pass()); 796 m_layerAnimationController->AddAnimation(animation.Pass());
797 setNeedsCommit(); 797 setNeedsCommit();
798 return true; 798 return true;
799 } 799 }
800 800
801 void Layer::pauseAnimation(int animationId, double timeOffset) 801 void Layer::PauseAnimation(int animationId, double timeOffset)
802 { 802 {
803 m_layerAnimationController->pauseAnimation(animationId, timeOffset); 803 m_layerAnimationController->PauseAnimation(animationId, timeOffset);
804 setNeedsCommit(); 804 setNeedsCommit();
805 } 805 }
806 806
807 void Layer::removeAnimation(int animationId) 807 void Layer::RemoveAnimation(int animationId)
808 { 808 {
809 m_layerAnimationController->removeAnimation(animationId); 809 m_layerAnimationController->RemoveAnimation(animationId);
810 setNeedsCommit(); 810 setNeedsCommit();
811 } 811 }
812 812
813 void Layer::suspendAnimations(double monotonicTime) 813 void Layer::suspendAnimations(double monotonicTime)
814 { 814 {
815 m_layerAnimationController->suspendAnimations(monotonicTime); 815 m_layerAnimationController->SuspendAnimations(monotonicTime);
816 setNeedsCommit(); 816 setNeedsCommit();
817 } 817 }
818 818
819 void Layer::resumeAnimations(double monotonicTime) 819 void Layer::resumeAnimations(double monotonicTime)
820 { 820 {
821 m_layerAnimationController->resumeAnimations(monotonicTime); 821 m_layerAnimationController->ResumeAnimations(monotonicTime);
822 setNeedsCommit(); 822 setNeedsCommit();
823 } 823 }
824 824
825 void Layer::setLayerAnimationController(scoped_refptr<LayerAnimationController> layerAnimationController) 825 void Layer::setLayerAnimationController(scoped_refptr<LayerAnimationController> layerAnimationController)
826 { 826 {
827 removeLayerAnimationEventObserver(m_layerAnimationController.get()); 827 removeLayerAnimationEventObserver(m_layerAnimationController.get());
828 m_layerAnimationController->removeObserver(this); 828 m_layerAnimationController->RemoveObserver(this);
829 m_layerAnimationController = layerAnimationController; 829 m_layerAnimationController = layerAnimationController;
830 m_layerAnimationController->setForceSync(); 830 m_layerAnimationController->set_force_sync();
831 m_layerAnimationController->addObserver(this); 831 m_layerAnimationController->AddObserver(this);
832 addLayerAnimationEventObserver(m_layerAnimationController.get()); 832 addLayerAnimationEventObserver(m_layerAnimationController.get());
833 setNeedsCommit(); 833 setNeedsCommit();
834 } 834 }
835 835
836 scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController() 836 scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController()
837 { 837 {
838 m_layerAnimationController->removeObserver(this); 838 m_layerAnimationController->RemoveObserver(this);
839 scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationControlle r; 839 scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationControlle r;
840 m_layerAnimationController = LayerAnimationController::create(id()); 840 m_layerAnimationController = LayerAnimationController::Create(id());
841 m_layerAnimationController->addObserver(this); 841 m_layerAnimationController->AddObserver(this);
842 m_layerAnimationController->setAnimationRegistrar(toReturn->animationRegistr ar()); 842 m_layerAnimationController->SetAnimationRegistrar(toReturn->animation_regist rar());
843 return toReturn; 843 return toReturn;
844 } 844 }
845 845
846 bool Layer::hasActiveAnimation() const 846 bool Layer::hasActiveAnimation() const
847 { 847 {
848 return m_layerAnimationController->hasActiveAnimation(); 848 return m_layerAnimationController->HasActiveAnimation();
849 } 849 }
850 850
851 void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClock Time) 851 void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClock Time)
852 { 852 {
853 FOR_EACH_OBSERVER(LayerAnimationEventObserver, m_layerAnimationObservers, 853 FOR_EACH_OBSERVER(LayerAnimationEventObserver, m_layerAnimationObservers,
854 OnAnimationStarted(event)); 854 OnAnimationStarted(event));
855 if (m_layerAnimationDelegate) 855 if (m_layerAnimationDelegate)
856 m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime); 856 m_layerAnimationDelegate->notifyAnimationStarted(wallClockTime);
857 } 857 }
858 858
859 void Layer::notifyAnimationFinished(double wallClockTime) 859 void Layer::notifyAnimationFinished(double wallClockTime)
860 { 860 {
861 if (m_layerAnimationDelegate) 861 if (m_layerAnimationDelegate)
862 m_layerAnimationDelegate->notifyAnimationFinished(wallClockTime); 862 m_layerAnimationDelegate->notifyAnimationFinished(wallClockTime);
863 } 863 }
864 864
865 void Layer::notifyAnimationPropertyUpdate(const AnimationEvent& event) 865 void Layer::notifyAnimationPropertyUpdate(const AnimationEvent& event)
866 { 866 {
867 if (event.targetProperty == Animation::Opacity) 867 if (event.target_property == Animation::Opacity)
868 setOpacity(event.opacity); 868 setOpacity(event.opacity);
869 else 869 else
870 setTransform(event.transform); 870 setTransform(event.transform);
871 } 871 }
872 872
873 void Layer::addLayerAnimationEventObserver(LayerAnimationEventObserver* animatio nObserver) 873 void Layer::addLayerAnimationEventObserver(LayerAnimationEventObserver* animatio nObserver)
874 { 874 {
875 if (!m_layerAnimationObservers.HasObserver(animationObserver)) 875 if (!m_layerAnimationObservers.HasObserver(animationObserver))
876 m_layerAnimationObservers.AddObserver(animationObserver); 876 m_layerAnimationObservers.AddObserver(animationObserver);
877 } 877 }
(...skipping 14 matching lines...) Expand all
892 { 892 {
893 return 0; 893 return 0;
894 } 894 }
895 895
896 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*) 896 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*)
897 { 897 {
898 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers. 898 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers.
899 } 899 }
900 900
901 } // namespace cc 901 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer.h ('k') | cc/layer_animation_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698