2013-08-25 00:19:43 -07: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/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_
|
|
|
|
#define MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_
|
|
|
|
|
|
|
|
#include "ImageWrapper.h"
|
2014-04-15 11:02:23 -07:00
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
2013-08-25 00:19:43 -07:00
|
|
|
#include "Orientation.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace image {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An Image wrapper that rotates and/or flips an image according to a specified
|
|
|
|
* Orientation.
|
|
|
|
*
|
|
|
|
* XXX(seth): There a known (performance, not correctness) issue with
|
|
|
|
* GetImageContainer. See the comments for that method for more information.
|
|
|
|
*/
|
|
|
|
class OrientedImage : public ImageWrapper
|
|
|
|
{
|
2014-07-10 08:00:31 -07:00
|
|
|
typedef gfx::SourceSurface SourceSurface;
|
2014-04-15 11:02:23 -07:00
|
|
|
|
2013-08-25 00:19:43 -07:00
|
|
|
public:
|
2014-07-14 12:21:34 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-08-25 00:19:43 -07:00
|
|
|
|
|
|
|
NS_IMETHOD GetWidth(int32_t* aWidth) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE;
|
2014-07-10 08:00:31 -07:00
|
|
|
NS_IMETHOD_(TemporaryRef<SourceSurface>)
|
2014-04-15 11:02:23 -07:00
|
|
|
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
|
2014-07-10 08:00:31 -07:00
|
|
|
NS_IMETHOD GetImageContainer(layers::LayerManager* aManager,
|
|
|
|
layers::ImageContainer** _retval) MOZ_OVERRIDE;
|
2013-08-25 00:19:43 -07:00
|
|
|
NS_IMETHOD Draw(gfxContext* aContext,
|
2014-08-22 13:12:38 -07:00
|
|
|
const nsIntSize& aSize,
|
|
|
|
const ImageRegion& aRegion,
|
2013-08-25 00:19:43 -07:00
|
|
|
uint32_t aWhichFrame,
|
2014-08-22 13:12:38 -07:00
|
|
|
GraphicsFilter aFilter,
|
|
|
|
const Maybe<SVGImageContext>& aSVGContext,
|
2013-08-25 00:19:43 -07:00
|
|
|
uint32_t aFlags) MOZ_OVERRIDE;
|
2014-12-05 15:58:00 -08:00
|
|
|
NS_IMETHOD_(nsIntRect) GetImageSpaceInvalidationRect(
|
|
|
|
const nsIntRect& aRect) MOZ_OVERRIDE;
|
2014-07-28 14:27:40 -07:00
|
|
|
nsIntSize OptimalImageSizeForDest(const gfxSize& aDest,
|
|
|
|
uint32_t aWhichFrame,
|
|
|
|
GraphicsFilter aFilter,
|
|
|
|
uint32_t aFlags) MOZ_OVERRIDE;
|
2014-12-05 15:58:00 -08:00
|
|
|
|
2013-08-25 00:19:43 -07:00
|
|
|
protected:
|
|
|
|
OrientedImage(Image* aImage, Orientation aOrientation)
|
|
|
|
: ImageWrapper(aImage)
|
|
|
|
, mOrientation(aOrientation)
|
|
|
|
{ }
|
|
|
|
|
2014-06-23 11:49:08 -07:00
|
|
|
virtual ~OrientedImage() { }
|
|
|
|
|
2014-08-22 13:12:38 -07:00
|
|
|
gfxMatrix OrientationMatrix(const nsIntSize& aSize, bool aInvert = false);
|
2013-08-25 00:19:43 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
Orientation mOrientation;
|
|
|
|
|
|
|
|
friend class ImageOps;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_
|