LCOV - code coverage report
Current view: top level - gfx/layers/ipc - CompositorVsyncScheduler.h (source / functions) Hit Total Coverage
Test: output.info Lines: 3 3 100.0 %
Date: 2017-07-14 16:53:18 Functions: 3 3 100.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             : /* vim: set sw=4 ts=8 et tw=80 : */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_layers_CompositorVsyncScheduler_h
       8             : #define mozilla_layers_CompositorVsyncScheduler_h
       9             : 
      10             : #include <stdint.h>                     // for uint64_t
      11             : 
      12             : #include "mozilla/Attributes.h"         // for override
      13             : #include "mozilla/Monitor.h"            // for Monitor
      14             : #include "mozilla/RefPtr.h"             // for RefPtr
      15             : #include "mozilla/TimeStamp.h"          // for TimeStamp
      16             : #include "mozilla/gfx/Point.h"          // for IntSize
      17             : #include "mozilla/VsyncDispatcher.h"
      18             : #include "mozilla/widget/CompositorWidget.h"
      19             : #include "nsISupportsImpl.h"
      20             : 
      21             : 
      22             : class MessageLoop;
      23             : class nsIWidget;
      24             : 
      25             : namespace mozilla {
      26             : 
      27             : class CancelableRunnable;
      28             : 
      29             : namespace gfx {
      30             : class DrawTarget;
      31             : } // namespace gfx
      32             : 
      33             : namespace layers {
      34             : 
      35             : class CompositorVsyncSchedulerOwner;
      36             : 
      37             : /**
      38             :  * Manages the vsync (de)registration and tracking on behalf of the
      39             :  * compositor when it need to paint.
      40             :  * Turns vsync notifications into scheduled composites.
      41             :  **/
      42             : class CompositorVsyncScheduler
      43             : {
      44         303 :   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorVsyncScheduler)
      45             : 
      46             : public:
      47             :   explicit CompositorVsyncScheduler(CompositorVsyncSchedulerOwner* aVsyncSchedulerOwner,
      48             :                                     widget::CompositorWidget* aWidget);
      49             : 
      50             :   bool NotifyVsync(TimeStamp aVsyncTimestamp);
      51             :   void SetNeedsComposite();
      52             :   void OnForceComposeToTarget();
      53             : 
      54             :   void ScheduleTask(already_AddRefed<CancelableRunnable>, int);
      55             :   void ResumeComposition();
      56             :   void ComposeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect = nullptr);
      57             :   void PostCompositeTask(TimeStamp aCompositeTimestamp);
      58             :   void Destroy();
      59             :   void ScheduleComposition();
      60             :   void CancelCurrentCompositeTask();
      61             :   bool NeedsComposite();
      62             :   void Composite(TimeStamp aVsyncTimestamp);
      63             :   void ForceComposeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect);
      64             : 
      65          29 :   const TimeStamp& GetLastComposeTime()
      66             :   {
      67          29 :     return mLastCompose;
      68             :   }
      69             : 
      70             : #ifdef COMPOSITOR_PERFORMANCE_WARNING
      71             :   const TimeStamp& GetExpectedComposeStartTime()
      72             :   {
      73             :     return mExpectedComposeStartTime;
      74             :   }
      75             : #endif
      76             : 
      77             : private:
      78             :   virtual ~CompositorVsyncScheduler();
      79             : 
      80             :   void NotifyCompositeTaskExecuted();
      81             :   void ObserveVsync();
      82             :   void UnobserveVsync();
      83             :   void DispatchTouchEvents(TimeStamp aVsyncTimestamp);
      84             :   void DispatchVREvents(TimeStamp aVsyncTimestamp);
      85             :   void CancelCurrentSetNeedsCompositeTask();
      86             : 
      87             :   class Observer final : public VsyncObserver
      88             :   {
      89             :   public:
      90             :     explicit Observer(CompositorVsyncScheduler* aOwner);
      91             :     virtual bool NotifyVsync(TimeStamp aVsyncTimestamp) override;
      92             :     void Destroy();
      93             :   private:
      94             :     virtual ~Observer();
      95             : 
      96             :     Mutex mMutex;
      97             :     // Hold raw pointer to avoid mutual reference.
      98             :     CompositorVsyncScheduler* mOwner;
      99             :   };
     100             : 
     101             :   CompositorVsyncSchedulerOwner* mVsyncSchedulerOwner;
     102             :   TimeStamp mLastCompose;
     103             : 
     104             : #ifdef COMPOSITOR_PERFORMANCE_WARNING
     105             :   TimeStamp mExpectedComposeStartTime;
     106             : #endif
     107             : 
     108             :   bool mAsapScheduling;
     109             :   bool mIsObservingVsync;
     110             :   uint32_t mNeedsComposite;
     111             :   int32_t mVsyncNotificationsSkipped;
     112             :   widget::CompositorWidget* mWidget;
     113             :   RefPtr<CompositorVsyncScheduler::Observer> mVsyncObserver;
     114             : 
     115             :   mozilla::Monitor mCurrentCompositeTaskMonitor;
     116             :   RefPtr<CancelableRunnable> mCurrentCompositeTask;
     117             : 
     118             :   mozilla::Monitor mSetNeedsCompositeMonitor;
     119             :   RefPtr<CancelableRunnable> mSetNeedsCompositeTask;
     120             : };
     121             : 
     122             : } // namespace layers
     123             : } // namespace mozilla
     124             : 
     125             : #endif // mozilla_layers_CompositorVsyncScheduler_h

Generated by: LCOV version 1.13