LCOV - code coverage report
Current view: top level - gfx/layers/composite - AnimationMetricsTracker.h (source / functions) Hit Total Coverage
Test: output.info Lines: 4 4 100.0 %
Date: 2017-07-14 16:53:18 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef mozilla_layers_AnimationMetricsTracker_h
       7             : #define mozilla_layers_AnimationMetricsTracker_h
       8             : 
       9             : #include "mozilla/Telemetry.h"
      10             : #include "mozilla/TimeStamp.h"
      11             : #include "mozilla/TypedEnumBits.h"
      12             : 
      13             : namespace mozilla {
      14             : namespace layers {
      15             : 
      16             : enum class AnimationProcessTypes {
      17             :   eNone = 0x0,
      18             :   eContent = 0x1,
      19             :   eChrome = 0x2
      20             : };
      21             : 
      22          58 : MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AnimationProcessTypes)
      23             : 
      24             : /**
      25             :  * Tracks the start and end of compositor animations.
      26             :  */
      27             : class AnimationMetricsTracker {
      28             : public:
      29             :   AnimationMetricsTracker();
      30             :   ~AnimationMetricsTracker();
      31             : 
      32             :   /**
      33             :    * This function should be called per composite, to inform the metrics
      34             :    * tracker which processes have active animations. If there is are animations
      35             :    * in progress, the sum of their areas should also be provided, along with
      36             :    * the vsync interval.
      37             :    */
      38             :   void UpdateAnimationInProgress(AnimationProcessTypes aActive, uint64_t aLayerArea,
      39             :                                  TimeDuration aVsyncInterval);
      40             : 
      41             :   /**
      42             :    * Similar to UpdateAnimationInProgress, but this is for APZ animations. Again,
      43             :    * this should be called per composite.
      44             :    */
      45             :   void UpdateApzAnimationInProgress(bool aInProgress, TimeDuration aVsyncInterval);
      46             : 
      47             : private:
      48             :   // A struct to group data that we need for each type of compositor animation.
      49             :   struct AnimationData {
      50             :     // The start time of the current animation.
      51             :     TimeStamp mStart;
      52             :     // The timestamp of the most recent animation frame.
      53             :     TimeStamp mLastFrameTime;
      54             :     // The longest animation frame length encountered so far.
      55             :     TimeDuration mLongestFrame;
      56             :     // The number of frames composited for the current animation.
      57             :     uint32_t mFrameCount;
      58             : 
      59           3 :     AnimationData()
      60           3 :       : mFrameCount(0)
      61             :     {
      62           3 :     }
      63             :   };
      64             : 
      65             :   void AnimationStarted();
      66             :   void AnimationEnded();
      67             :   void UpdateAnimationThroughput(const char* aLabel,
      68             :                                  bool aInProgress,
      69             :                                  AnimationData& aAnimationData,
      70             :                                  TimeDuration aVsyncInterval,
      71             :                                  Telemetry::HistogramID aThroughputHistogram,
      72             :                                  Telemetry::HistogramID aMaxDropsHistogram);
      73             : 
      74             :   // The start time of the current compositor animation. This just tracks
      75             :   // whether the compositor is running an animation, without regard to which
      76             :   // process the animation is coming from.
      77             :   TimeStamp mCurrentAnimationStart;
      78             :   // The max area (in layer pixels) that the current compositor animation
      79             :   // has touched on any given animation frame.
      80             :   uint64_t mMaxLayerAreaAnimated;
      81             : 
      82             :   // We keep an instance of the struct for each type of compositor animation.
      83             :   AnimationData mChromeAnimation;
      84             :   AnimationData mContentAnimation;
      85             :   AnimationData mApzAnimation;
      86             : };
      87             : 
      88             : } // namespace layers
      89             : } // namespace mozilla
      90             : 
      91             : #endif // mozilla_layers_AnimationMetricsTracker_h

Generated by: LCOV version 1.13