LCOV - code coverage report
Current view: top level - image - ImageMetadata.h (source / functions) Hit Total Coverage
Test: output.info Lines: 32 39 82.1 %
Date: 2017-07-14 16:53:18 Functions: 23 27 85.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  *
       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_image_ImageMetadata_h
       8             : #define mozilla_image_ImageMetadata_h
       9             : 
      10             : #include <stdint.h>
      11             : #include "mozilla/Maybe.h"
      12             : #include "nsSize.h"
      13             : #include "Orientation.h"
      14             : #include "FrameTimeout.h"
      15             : 
      16             : namespace mozilla {
      17             : namespace image {
      18             : 
      19             : // The metadata about an image that decoders accumulate as they decode.
      20         231 : class ImageMetadata
      21             : {
      22             : public:
      23          33 :   ImageMetadata()
      24          33 :     : mLoopCount(-1)
      25             :     , mFirstFrameTimeout(FrameTimeout::Forever())
      26          33 :     , mHasAnimation(false)
      27          33 :   { }
      28             : 
      29           0 :   void SetHotspot(uint16_t aHotspotX, uint16_t aHotspotY)
      30             :   {
      31           0 :     mHotspot = Some(gfx::IntPoint(aHotspotX, aHotspotY));
      32           0 :   }
      33           0 :   gfx::IntPoint GetHotspot() const { return *mHotspot; }
      34          33 :   bool HasHotspot() const { return mHotspot.isSome(); }
      35             : 
      36          14 :   void SetLoopCount(int32_t loopcount)
      37             :   {
      38          14 :     mLoopCount = loopcount;
      39          14 :   }
      40           4 :   int32_t GetLoopCount() const { return mLoopCount; }
      41             : 
      42           2 :   void SetLoopLength(FrameTimeout aLength) { mLoopLength = Some(aLength); }
      43           2 :   FrameTimeout GetLoopLength() const { return *mLoopLength; }
      44           4 :   bool HasLoopLength() const { return mLoopLength.isSome(); }
      45             : 
      46           4 :   void SetFirstFrameTimeout(FrameTimeout aTimeout) { mFirstFrameTimeout = aTimeout; }
      47           4 :   FrameTimeout GetFirstFrameTimeout() const { return mFirstFrameTimeout; }
      48             : 
      49           2 :   void SetFirstFrameRefreshArea(const gfx::IntRect& aRefreshArea)
      50             :   {
      51           2 :     mFirstFrameRefreshArea = Some(aRefreshArea);
      52           2 :   }
      53           2 :   gfx::IntRect GetFirstFrameRefreshArea() const { return *mFirstFrameRefreshArea; }
      54           4 :   bool HasFirstFrameRefreshArea() const { return mFirstFrameRefreshArea.isSome(); }
      55             : 
      56          33 :   void SetSize(int32_t width, int32_t height, Orientation orientation)
      57             :   {
      58          33 :     if (!HasSize()) {
      59          33 :       mSize.emplace(nsIntSize(width, height));
      60          33 :       mOrientation.emplace(orientation);
      61             :     }
      62          33 :   }
      63         229 :   nsIntSize GetSize() const { return *mSize; }
      64         560 :   bool HasSize() const { return mSize.isSome(); }
      65             : 
      66           0 :   void AddNativeSize(const nsIntSize& aSize)
      67             :   {
      68           0 :     mNativeSizes.AppendElement(aSize);
      69           0 :   }
      70             : 
      71          33 :   const nsTArray<nsIntSize>& GetNativeSizes() const { return mNativeSizes; }
      72             : 
      73          33 :   Orientation GetOrientation() const { return *mOrientation; }
      74          33 :   bool HasOrientation() const { return mOrientation.isSome(); }
      75             : 
      76           4 :   void SetHasAnimation() { mHasAnimation = true; }
      77          81 :   bool HasAnimation() const { return mHasAnimation; }
      78             : 
      79             : private:
      80             :   /// The hotspot found on cursors, if present.
      81             :   Maybe<gfx::IntPoint> mHotspot;
      82             : 
      83             :   /// The loop count for animated images, or -1 for infinite loop.
      84             :   int32_t mLoopCount;
      85             : 
      86             :   // The total length of a single loop through an animated image.
      87             :   Maybe<FrameTimeout> mLoopLength;
      88             : 
      89             :   /// The timeout of an animated image's first frame.
      90             :   FrameTimeout mFirstFrameTimeout;
      91             : 
      92             :   // The area of the image that needs to be invalidated when the animation
      93             :   // loops.
      94             :   Maybe<gfx::IntRect> mFirstFrameRefreshArea;
      95             : 
      96             :   Maybe<nsIntSize> mSize;
      97             :   Maybe<Orientation> mOrientation;
      98             : 
      99             :   // Sizes the image can natively decode to.
     100             :   nsTArray<nsIntSize> mNativeSizes;
     101             : 
     102             :   bool mHasAnimation : 1;
     103             : };
     104             : 
     105             : } // namespace image
     106             : } // namespace mozilla
     107             : 
     108             : #endif // mozilla_image_ImageMetadata_h

Generated by: LCOV version 1.13