2012-12-20 16:49:25 +00: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-15 03:52:05 +00:00
|
|
|
#ifndef mozilla_image_ImageMetadata_h
|
|
|
|
#define mozilla_image_ImageMetadata_h
|
2013-11-19 06:03:36 +00:00
|
|
|
|
2013-07-30 14:25:31 +00:00
|
|
|
#include <stdint.h>
|
2013-08-27 22:10:28 +00:00
|
|
|
#include "mozilla/Maybe.h"
|
2013-02-27 19:23:08 +00:00
|
|
|
#include "nsSize.h"
|
2013-08-25 07:19:42 +00:00
|
|
|
#include "Orientation.h"
|
2012-12-20 16:49:25 +00: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 18:29:00 +00:00
|
|
|
{ }
|
2012-12-20 16:49:25 +00:00
|
|
|
|
|
|
|
// Set the metadata this object represents on an image.
|
|
|
|
void SetOnImage(RasterImage* image);
|
|
|
|
|
|
|
|
void SetHotspot(uint16_t hotspotx, uint16_t hotspoty)
|
|
|
|
{
|
|
|
|
mHotspotX = hotspotx;
|
|
|
|
mHotspotY = hotspoty;
|
|
|
|
}
|
|
|
|
void SetLoopCount(int32_t loopcount)
|
|
|
|
{
|
|
|
|
mLoopCount = loopcount;
|
|
|
|
}
|
|
|
|
|
2013-08-25 07:19:42 +00:00
|
|
|
void SetSize(int32_t width, int32_t height, Orientation orientation)
|
2013-02-27 19:23:08 +00:00
|
|
|
{
|
2015-01-08 08:01:25 +00:00
|
|
|
if (!HasSize()) {
|
|
|
|
mSize.emplace(nsIntSize(width, height));
|
|
|
|
mOrientation.emplace(orientation);
|
|
|
|
}
|
2013-02-27 19:23:08 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 22:39:41 +00:00
|
|
|
bool HasSize() const { return mSize.isSome(); }
|
|
|
|
bool HasOrientation() const { return mOrientation.isSome(); }
|
2013-02-27 19:23:08 +00:00
|
|
|
|
2014-08-13 22:39:41 +00:00
|
|
|
int32_t GetWidth() const { return mSize->width; }
|
|
|
|
int32_t GetHeight() const { return mSize->height; }
|
2015-01-18 22:02:13 +00:00
|
|
|
nsIntSize GetSize() const { return *mSize; }
|
2014-08-13 22:39:41 +00:00
|
|
|
Orientation GetOrientation() const { return *mOrientation; }
|
2013-02-27 19:23:08 +00:00
|
|
|
|
2012-12-20 16:49:25 +00: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 19:23:08 +00:00
|
|
|
Maybe<nsIntSize> mSize;
|
2014-11-26 21:22:10 +00:00
|
|
|
Maybe<Orientation> mOrientation;
|
2012-12-20 16:49:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
2013-11-19 06:03:36 +00:00
|
|
|
|
2015-05-15 03:52:05 +00:00
|
|
|
#endif // mozilla_image_ImageMetadata_h
|