2012-12-20 08:49:25 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-05-14 20:52:05 -07:00
|
|
|
#ifndef mozilla_image_ImageMetadata_h
|
|
|
|
#define mozilla_image_ImageMetadata_h
|
2013-11-18 22:03:36 -08:00
|
|
|
|
2013-07-30 07:25:31 -07:00
|
|
|
#include <stdint.h>
|
2013-08-27 15:10:28 -07:00
|
|
|
#include "mozilla/Maybe.h"
|
2013-02-27 11:23:08 -08:00
|
|
|
#include "nsSize.h"
|
2013-08-25 00:19:42 -07:00
|
|
|
#include "Orientation.h"
|
2012-12-20 08:49:25 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace image {
|
|
|
|
|
|
|
|
class RasterImage;
|
|
|
|
|
|
|
|
// The metadata about an image that decoders accumulate as they decode.
|
|
|
|
class ImageMetadata
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ImageMetadata()
|
|
|
|
: mHotspotX(-1)
|
|
|
|
, mHotspotY(-1)
|
|
|
|
, mLoopCount(-1)
|
2015-01-19 10:29:00 -08:00
|
|
|
{ }
|
2012-12-20 08:49:25 -08:00
|
|
|
|
|
|
|
// Set the metadata this object represents on an image.
|
2015-07-31 07:29:12 -07:00
|
|
|
nsresult SetOnImage(RasterImage* aImage);
|
2012-12-20 08:49:25 -08:00
|
|
|
|
|
|
|
void SetHotspot(uint16_t hotspotx, uint16_t hotspoty)
|
|
|
|
{
|
|
|
|
mHotspotX = hotspotx;
|
|
|
|
mHotspotY = hotspoty;
|
|
|
|
}
|
|
|
|
void SetLoopCount(int32_t loopcount)
|
|
|
|
{
|
|
|
|
mLoopCount = loopcount;
|
|
|
|
}
|
|
|
|
|
2013-08-25 00:19:42 -07:00
|
|
|
void SetSize(int32_t width, int32_t height, Orientation orientation)
|
2013-02-27 11:23:08 -08:00
|
|
|
{
|
2015-01-08 00:01:25 -08:00
|
|
|
if (!HasSize()) {
|
|
|
|
mSize.emplace(nsIntSize(width, height));
|
|
|
|
mOrientation.emplace(orientation);
|
|
|
|
}
|
2013-02-27 11:23:08 -08:00
|
|
|
}
|
|
|
|
|
2014-08-13 15:39:41 -07:00
|
|
|
bool HasSize() const { return mSize.isSome(); }
|
|
|
|
bool HasOrientation() const { return mOrientation.isSome(); }
|
2013-02-27 11:23:08 -08:00
|
|
|
|
2014-08-13 15:39:41 -07:00
|
|
|
int32_t GetWidth() const { return mSize->width; }
|
|
|
|
int32_t GetHeight() const { return mSize->height; }
|
2015-01-18 14:02:13 -08:00
|
|
|
nsIntSize GetSize() const { return *mSize; }
|
2014-08-13 15:39:41 -07:00
|
|
|
Orientation GetOrientation() const { return *mOrientation; }
|
2013-02-27 11:23:08 -08:00
|
|
|
|
2012-12-20 08:49:25 -08:00
|
|
|
private:
|
|
|
|
// The hotspot found on cursors, or -1 if none was found.
|
|
|
|
int32_t mHotspotX;
|
|
|
|
int32_t mHotspotY;
|
|
|
|
|
|
|
|
// The loop count for animated images, or -1 for infinite loop.
|
|
|
|
int32_t mLoopCount;
|
|
|
|
|
2013-02-27 11:23:08 -08:00
|
|
|
Maybe<nsIntSize> mSize;
|
2014-11-26 13:22:10 -08:00
|
|
|
Maybe<Orientation> mOrientation;
|
2012-12-20 08:49:25 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
2013-11-18 22:03:36 -08:00
|
|
|
|
2015-05-14 20:52:05 -07:00
|
|
|
#endif // mozilla_image_ImageMetadata_h
|