LCOV - code coverage report
Current view: top level - gfx/layers/composite - ImageComposite.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 9 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; 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_GFX_IMAGECOMPOSITE_H
       7             : #define MOZILLA_GFX_IMAGECOMPOSITE_H
       8             : 
       9             : #include "CompositableHost.h"           // for CompositableTextureHostRef
      10             : #include "mozilla/gfx/2D.h"
      11             : #include "mozilla/TimeStamp.h"          // for TimeStamp
      12             : #include "nsTArray.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace layers {
      16             : 
      17             : /**
      18             :  * Implements Image selection logic.
      19             :  */
      20             : class ImageComposite
      21             : {
      22             : public:
      23             :   static const float BIAS_TIME_MS;
      24             : 
      25             :   explicit ImageComposite();
      26             :   ~ImageComposite();
      27             : 
      28           0 :   int32_t GetFrameID()
      29             :   {
      30           0 :     const TimedImage* img = ChooseImage();
      31           0 :     return img ? img->mFrameID : -1;
      32             :   }
      33             : 
      34           0 :   int32_t GetProducerID()
      35             :   {
      36           0 :     const TimedImage* img = ChooseImage();
      37           0 :     return img ? img->mProducerID : -1;
      38             :   }
      39             : 
      40           0 :   int32_t GetLastFrameID() const { return mLastFrameID; }
      41           0 :   int32_t GetLastProducerID() const { return mLastProducerID; }
      42             : 
      43             :   enum Bias {
      44             :     // Don't apply bias to frame times
      45             :     BIAS_NONE,
      46             :     // Apply a negative bias to frame times to keep them before the vsync time
      47             :     BIAS_NEGATIVE,
      48             :     // Apply a positive bias to frame times to keep them after the vsync time
      49             :     BIAS_POSITIVE,
      50             :   };
      51             : 
      52             :   static TimeStamp GetBiasedTime(const TimeStamp& aInput, ImageComposite::Bias aBias);
      53             : 
      54             : protected:
      55             :   static Bias UpdateBias(const TimeStamp& aCompositionTime,
      56             :                          const TimeStamp& aCompositedImageTime,
      57             :                          const TimeStamp& aNextImageTime, // may be null
      58             :                          ImageComposite::Bias aBias);
      59             : 
      60             :   virtual TimeStamp GetCompositionTime() const = 0;
      61             : 
      62           0 :   struct TimedImage {
      63             :     CompositableTextureHostRef mTextureHost;
      64             :     TimeStamp mTimeStamp;
      65             :     gfx::IntRect mPictureRect;
      66             :     int32_t mFrameID;
      67             :     int32_t mProducerID;
      68             :   };
      69             : 
      70             :   /**
      71             :    * ChooseImage is guaranteed to return the same TimedImage every time it's
      72             :    * called during the same composition, up to the end of Composite() ---
      73             :    * it depends only on mImages, mCompositor->GetCompositionTime(), and mBias.
      74             :    * mBias is updated at the end of Composite().
      75             :    */
      76             :   const TimedImage* ChooseImage() const;
      77             :   TimedImage* ChooseImage();
      78             :   int ChooseImageIndex() const;
      79             : 
      80             :   nsTArray<TimedImage> mImages;
      81             :   int32_t mLastFrameID;
      82             :   int32_t mLastProducerID;
      83             :   /**
      84             :    * Bias to apply to the next frame.
      85             :    */
      86             :   Bias mBias;
      87             : };
      88             : 
      89             : } // namespace layers
      90             : } // namespace mozilla
      91             : 
      92             : #endif // MOZILLA_GFX_IMAGECOMPOSITE_H

Generated by: LCOV version 1.13