Bug 1338347 - Record frame throughput ratio for APZ animations r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 20 Mar 2017 11:41:05 -0400
changeset 552138 02b734210c9c14c91ccd324074786a0ce68bd30a
parent 552137 6bb6ad363f65d95247fc6930f188b265792d5064
child 552139 5f585d37cdb86f16152e1cd9716fc3e62a0e960b
push id51252
push userhikezoe@mozilla.com
push dateTue, 28 Mar 2017 02:10:27 +0000
reviewersbotond
bugs1338347
milestone55.0a1
Bug 1338347 - Record frame throughput ratio for APZ animations r=botond MozReview-Commit-ID: 7Ljaya9RFeo
gfx/layers/composite/AnimationMetricsTracker.cpp
gfx/layers/composite/AnimationMetricsTracker.h
gfx/layers/composite/AsyncCompositionManager.cpp
--- a/gfx/layers/composite/AnimationMetricsTracker.cpp
+++ b/gfx/layers/composite/AnimationMetricsTracker.cpp
@@ -14,16 +14,17 @@
 
 namespace mozilla {
 namespace layers {
 
 AnimationMetricsTracker::AnimationMetricsTracker()
   : mMaxLayerAreaAnimated(0)
   , mChromeAnimationFrameCount(0)
   , mContentAnimationFrameCount(0)
+  , mApzAnimationFrameCount(0)
 {
 }
 
 AnimationMetricsTracker::~AnimationMetricsTracker()
 {
 }
 
 void
@@ -57,16 +58,28 @@ AnimationMetricsTracker::UpdateAnimation
                             (aActive & AnimationProcessTypes::eContent) != AnimationProcessTypes::eNone,
                             mContentAnimationStart,
                             mContentAnimationFrameCount,
                             aVsyncInterval,
                             Telemetry::COMPOSITOR_ANIMATION_THROUGHPUT_CONTENT);
 }
 
 void
+AnimationMetricsTracker::UpdateApzAnimationInProgress(bool aInProgress,
+                                                      TimeDuration aVsyncInterval)
+{
+  UpdateAnimationThroughput("apz",
+                            aInProgress,
+                            mApzAnimationStart,
+                            mApzAnimationFrameCount,
+                            aVsyncInterval,
+                            Telemetry::COMPOSITOR_ANIMATION_THROUGHPUT_APZ);
+}
+
+void
 AnimationMetricsTracker::AnimationStarted()
 {
 }
 
 void
 AnimationMetricsTracker::AnimationEnded()
 {
   MOZ_ASSERT(mCurrentAnimationStart);
--- a/gfx/layers/composite/AnimationMetricsTracker.h
+++ b/gfx/layers/composite/AnimationMetricsTracker.h
@@ -33,16 +33,22 @@ public:
    * This function should be called per composite, to inform the metrics
    * tracker which processes have active animations. If there is are animations
    * in progress, the sum of their areas should also be provided, along with
    * the vsync interval.
    */
   void UpdateAnimationInProgress(AnimationProcessTypes aActive, uint64_t aLayerArea,
                                  TimeDuration aVsyncInterval);
 
+  /**
+   * Similar to UpdateAnimationInProgress, but this is for APZ animations. Again,
+   * this should be called per composite.
+   */
+  void UpdateApzAnimationInProgress(bool aInProgress, TimeDuration aVsyncInterval);
+
 private:
   void AnimationStarted();
   void AnimationEnded();
   void UpdateAnimationThroughput(const char* aLabel,
                                  bool aInProgress,
                                  TimeStamp& aStartTime,
                                  uint32_t& aFrameCount,
                                  TimeDuration aVsyncInterval,
@@ -59,14 +65,18 @@ private:
   // The start time of the current chrome-process animation.
   TimeStamp mChromeAnimationStart;
   // The number of frames composited for the current chrome-process animation.
   uint32_t mChromeAnimationFrameCount;
   // The start time of the current content-process animation.
   TimeStamp mContentAnimationStart;
   // The number of frames composited for the current content-process animation.
   uint32_t mContentAnimationFrameCount;
+  // The start time of the current APZ animation.
+  TimeStamp mApzAnimationStart;
+  // The number of frames composited for the current APZ animation.
+  uint32_t mApzAnimationFrameCount;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif // mozilla_layers_AnimationMetricsTracker_h
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -1406,17 +1406,19 @@ AsyncCompositionManager::TransformShadow
     // get it.
     TimeStamp nextFrame = aCurrentFrame;
 
     MOZ_ASSERT(aVsyncRate != TimeDuration::Forever());
     if (aVsyncRate != TimeDuration::Forever()) {
       nextFrame += aVsyncRate;
     }
 
-    wantNextFrame |= SampleAPZAnimations(LayerMetricsWrapper(root), nextFrame);
+    bool apzAnimating = SampleAPZAnimations(LayerMetricsWrapper(root), nextFrame);
+    mAnimationMetricsTracker.UpdateApzAnimationInProgress(apzAnimating, aVsyncRate);
+    wantNextFrame |= apzAnimating;
   }
 
   HostLayer* rootComposite = root->AsHostLayer();
 
   gfx::Matrix4x4 trans = rootComposite->GetShadowBaseTransform();
   trans *= gfx::Matrix4x4::From2D(mWorldTransform);
   rootComposite->SetShadowBaseTransform(trans);