LCOV - code coverage report
Current view: top level - dom/base - ImageTracker.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 2 2 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 ts=8 sts=2 et sw=2 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             : /* table of images used in a document, for batch locking/unlocking and
       8             :  * animating */
       9             : 
      10             : #ifndef mozilla_dom_ImageTracker
      11             : #define mozilla_dom_ImageTracker
      12             : 
      13             : #include "nsDataHashtable.h"
      14             : #include "nsHashKeys.h"
      15             : 
      16             : class imgIRequest;
      17             : 
      18             : namespace mozilla {
      19             : namespace dom {
      20             : 
      21             : /*
      22             :  * Image Tracking
      23             :  *
      24             :  * Style and content images register their imgIRequests with their document's
      25             :  * image tracker, so that we can efficiently tell all descendant images when
      26             :  * they are and are not visible. When an image is on-screen, we want to call
      27             :  * LockImage() on it so that it doesn't do things like discarding frame data
      28             :  * to save memory. The PresShell informs its document's image tracker whether
      29             :  * its images should be locked or not via SetLockingState().
      30             :  *
      31             :  * See bug 512260.
      32             :  */
      33             : class ImageTracker
      34             : {
      35             : public:
      36             :   ImageTracker();
      37             :   ImageTracker(const ImageTracker&) = delete;
      38             :   ImageTracker& operator=(const ImageTracker&) = delete;
      39             : 
      40          66 :   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageTracker)
      41             : 
      42             :   nsresult Add(imgIRequest* aImage);
      43             : 
      44             :   enum { REQUEST_DISCARD = 0x1 };
      45             :   nsresult Remove(imgIRequest* aImage, uint32_t aFlags = 0);
      46             : 
      47             :   // Makes the images on this document locked/unlocked. By default, the locking
      48             :   // state is unlocked/false.
      49             :   nsresult SetLockingState(bool aLocked);
      50             : 
      51             :   // Makes the images on this document capable of having their animation
      52             :   // active or suspended. An Image will animate as long as at least one of its
      53             :   // owning Documents needs it to animate; otherwise it can suspend.
      54             :   void SetAnimatingState(bool aAnimating);
      55             : 
      56             :   void RequestDiscardAll();
      57             : 
      58             : private:
      59             :   ~ImageTracker();
      60             : 
      61             :   nsDataHashtable<nsPtrHashKey<imgIRequest>, uint32_t> mImages;
      62             :   bool mLocking;
      63             :   bool mAnimating;
      64             : };
      65             : 
      66             : } // namespace dom
      67             : } // namespace mozilla
      68             : 
      69             : #endif // mozilla_dom_ImageTracker

Generated by: LCOV version 1.13