Bug 1078122 part 2 - Encapsulate mIsRunningOnCompositor in AnimationPlayer; r=dholbert
authorBrian Birtles <birtles@gmail.com>
Mon, 20 Oct 2014 13:55:46 +0900
changeset 211176 8f7dfd335493a888690487b643e7b496ab24a56b
parent 211175 fe98ceaaafa7964c5eefd8ff13dbb87df04f5071
child 211177 d54306da529f6918f79a9e43c5e0a61883cee453
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdholbert
bugs1078122
milestone36.0a1
Bug 1078122 part 2 - Encapsulate mIsRunningOnCompositor in AnimationPlayer; r=dholbert
dom/animation/AnimationPlayer.h
layout/base/nsDisplayList.cpp
layout/style/nsAnimationManager.cpp
layout/style/nsTransitionManager.cpp
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -30,19 +30,19 @@ namespace dom {
 
 class AnimationPlayer : public nsWrapperCache
 {
 protected:
   virtual ~AnimationPlayer() { }
 
 public:
   explicit AnimationPlayer(AnimationTimeline* aTimeline)
-    : mIsRunningOnCompositor(false)
-    , mTimeline(aTimeline)
+    : mTimeline(aTimeline)
     , mIsPaused(false)
+    , mIsRunningOnCompositor(false)
   {
   }
 
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationPlayer)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AnimationPlayer)
 
   AnimationTimeline* GetParentObject() const { return mTimeline; }
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
@@ -87,35 +87,38 @@ public:
 
   bool HasCurrentSource() const {
     return GetSource() && GetSource()->IsCurrent();
   }
   bool HasInEffectSource() const {
     return GetSource() && GetSource()->IsInEffect();
   }
 
+  void SetIsRunningOnCompositor() { mIsRunningOnCompositor = true; }
+  void ClearIsRunningOnCompositor() { mIsRunningOnCompositor = false; }
+
   // Returns true if this animation does not currently need to update
   // style on the main thread (e.g. because it is empty, or is
   // running on the compositor).
   bool CanThrottle() const;
 
   // The beginning of the delay period.
   Nullable<TimeDuration> mStartTime; // Timeline timescale
-  bool mIsRunningOnCompositor;
 
   nsRefPtr<AnimationTimeline> mTimeline;
   nsRefPtr<Animation> mSource;
 
 protected:
   void FlushStyle() const;
   void MaybePostRestyle() const;
   StickyTimeDuration SourceContentEnd() const;
 
   Nullable<TimeDuration> mHoldTime;  // Player timescale
   bool mIsPaused;
+  bool mIsRunningOnCompositor;
 };
 
 } // namespace dom
 
 class CSSAnimationPlayer MOZ_FINAL : public dom::AnimationPlayer
 {
 public:
  explicit CSSAnimationPlayer(dom::AnimationTimeline* aTimeline)
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -407,17 +407,17 @@ AddAnimationsForProperty(nsIFrame* aFram
   for (size_t playerIdx = 0; playerIdx < aPlayers.Length(); playerIdx++) {
     AnimationPlayer* player = aPlayers[playerIdx];
     dom::Animation* anim = player->GetSource();
     if (!(anim && anim->HasAnimationOfProperty(aProperty) &&
           player->IsRunning())) {
       continue;
     }
     AddAnimationForProperty(aFrame, aProperty, player, aLayer, aData, aPending);
-    player->mIsRunningOnCompositor = true;
+    player->SetIsRunningOnCompositor();
   }
 }
 
 /* static */ void
 nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
                                                          nsDisplayListBuilder* aBuilder,
                                                          nsDisplayItem* aItem,
                                                          nsIFrame* aFrame,
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -306,17 +306,17 @@ nsAnimationManager::CheckAnimationRule(n
           if (oldPlayer->GetSource() && newPlayer->GetSource()) {
             Animation* oldAnim = oldPlayer->GetSource();
             Animation* newAnim = newPlayer->GetSource();
             oldAnim->Timing() = newAnim->Timing();
             oldAnim->Properties() = newAnim->Properties();
           }
 
           // Reset compositor state so animation will be re-synchronized.
-          oldPlayer->mIsRunningOnCompositor = false;
+          oldPlayer->ClearIsRunningOnCompositor();
 
           // Handle changes in play state.
           // CSSAnimationPlayer takes care of override behavior so that,
           // for example, if the author has called pause(), that will
           // override the animation-play-state.
           // (We should check newPlayer->IsStylePaused() but that requires
           //  downcasting to CSSAnimationPlayer and we happen to know that
           //  newPlayer will only ever be paused by calling PauseFromStyle
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -829,17 +829,17 @@ nsTransitionManager::FlushTransitions(Fl
             // to know not to start a new transition for the transition
             // from the almost-completed value to the final value.
             player->GetSource()->SetIsFinishedTransition();
             collection->UpdateAnimationGeneration(mPresContext);
             transitionStartedOrEnded = true;
           } else if ((computedTiming.mPhase ==
                       ComputedTiming::AnimationPhase_Active) &&
                      canThrottleTick &&
-                    !player->mIsRunningOnCompositor) {
+                     !player->IsRunningOnCompositor()) {
             // Start a transition with a delay where we should start the
             // transition proper.
             collection->UpdateAnimationGeneration(mPresContext);
             transitionStartedOrEnded = true;
           }
         }
       } while (i != 0);