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