image/src/ImageMetadata.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     7 #ifndef ImageMetadata_h___
     8 #define ImageMetadata_h___
    10 #include <stdint.h>
    11 #include "mozilla/Maybe.h"
    12 #include "nsSize.h"
    13 #include "Orientation.h"
    15 namespace mozilla {
    16 namespace image {
    18 class RasterImage;
    20 // The metadata about an image that decoders accumulate as they decode.
    21 class ImageMetadata
    22 {
    23 public:
    24   ImageMetadata()
    25     : mHotspotX(-1)
    26     , mHotspotY(-1)
    27     , mLoopCount(-1)
    28     , mIsNonPremultiplied(false)
    29   {}
    31   // Set the metadata this object represents on an image.
    32   void SetOnImage(RasterImage* image);
    34   void SetHotspot(uint16_t hotspotx, uint16_t hotspoty)
    35   {
    36     mHotspotX = hotspotx;
    37     mHotspotY = hotspoty;
    38   }
    39   void SetLoopCount(int32_t loopcount)
    40   {
    41     mLoopCount = loopcount;
    42   }
    44   void SetIsNonPremultiplied(bool nonPremult)
    45   {
    46     mIsNonPremultiplied = nonPremult;
    47   }
    49   void SetSize(int32_t width, int32_t height, Orientation orientation)
    50   {
    51     mSize.construct(nsIntSize(width, height));
    52     mOrientation.construct(orientation);
    53   }
    55   bool HasSize() const { return !mSize.empty(); }
    56   bool HasOrientation() const { return !mOrientation.empty(); }
    58   int32_t GetWidth() const { return mSize.ref().width; }
    59   int32_t GetHeight() const { return mSize.ref().height; }
    60   Orientation GetOrientation() const { return mOrientation.ref(); }
    62 private:
    63   // The hotspot found on cursors, or -1 if none was found.
    64   int32_t mHotspotX;
    65   int32_t mHotspotY;
    67   // The loop count for animated images, or -1 for infinite loop.
    68   int32_t mLoopCount;
    70   Maybe<nsIntSize> mSize;
    71   Maybe<Orientation>  mOrientation;
    73   bool mIsNonPremultiplied;
    74 };
    76 } // namespace image
    77 } // namespace mozilla
    79 #endif // ImageMetadata_h___

mercurial