2013-08-25 07:19:43 +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_OrientedImage_h
|
|
|
|
#define mozilla_image_OrientedImage_h
|
2013-08-25 07:19:43 +00:00
|
|
|
|
|
|
|
#include "ImageWrapper.h"
|
2014-04-15 18:02:23 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-08-25 07:19:43 +00: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 15:00:31 +00:00
|
|
|
typedef gfx::SourceSurface SourceSurface;
|
2014-04-15 18:02:23 +00:00
|
|
|
|
2013-08-25 07:19:43 +00:00
|
|
|
public:
|
2014-07-14 19:21:34 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-08-25 07:19:43 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetWidth(int32_t* aWidth) override;
|
|
|
|
NS_IMETHOD GetHeight(int32_t* aHeight) override;
|
|
|
|
NS_IMETHOD GetIntrinsicSize(nsSize* aSize) override;
|
|
|
|
NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) override;
|
2015-06-17 14:00:52 +00:00
|
|
|
NS_IMETHOD_(already_AddRefed<SourceSurface>)
|
2015-03-21 16:28:04 +00:00
|
|
|
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) override;
|
2015-09-19 20:34:09 +00:00
|
|
|
NS_IMETHOD_(already_AddRefed<SourceSurface>)
|
|
|
|
GetFrameAtSize(const gfx::IntSize& aSize,
|
|
|
|
uint32_t aWhichFrame,
|
|
|
|
uint32_t aFlags) override;
|
2015-05-13 07:23:44 +00:00
|
|
|
NS_IMETHOD_(bool) IsImageContainerAvailable(layers::LayerManager* aManager,
|
|
|
|
uint32_t aFlags) override;
|
2015-03-18 02:40:16 +00:00
|
|
|
NS_IMETHOD_(already_AddRefed<layers::ImageContainer>)
|
|
|
|
GetImageContainer(layers::LayerManager* aManager,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t aFlags) override;
|
2015-02-04 21:50:56 +00:00
|
|
|
NS_IMETHOD_(DrawResult) Draw(gfxContext* aContext,
|
|
|
|
const nsIntSize& aSize,
|
|
|
|
const ImageRegion& aRegion,
|
|
|
|
uint32_t aWhichFrame,
|
2016-05-25 16:01:18 +00:00
|
|
|
gfx::SamplingFilter aSamplingFilter,
|
2015-02-04 21:50:56 +00:00
|
|
|
const Maybe<SVGImageContext>& aSVGContext,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t aFlags) override;
|
2014-12-05 23:58:00 +00:00
|
|
|
NS_IMETHOD_(nsIntRect) GetImageSpaceInvalidationRect(
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsIntRect& aRect) override;
|
2014-07-28 21:27:40 +00:00
|
|
|
nsIntSize OptimalImageSizeForDest(const gfxSize& aDest,
|
|
|
|
uint32_t aWhichFrame,
|
2016-05-25 16:01:18 +00:00
|
|
|
gfx::SamplingFilter aSamplingFilter,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t aFlags) override;
|
2014-12-05 23:58:00 +00:00
|
|
|
|
2013-08-25 07:19:43 +00:00
|
|
|
protected:
|
|
|
|
OrientedImage(Image* aImage, Orientation aOrientation)
|
|
|
|
: ImageWrapper(aImage)
|
|
|
|
, mOrientation(aOrientation)
|
|
|
|
{ }
|
|
|
|
|
2014-06-23 18:49:08 +00:00
|
|
|
virtual ~OrientedImage() { }
|
|
|
|
|
2014-08-22 20:12:38 +00:00
|
|
|
gfxMatrix OrientationMatrix(const nsIntSize& aSize, bool aInvert = false);
|
2013-08-25 07:19:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Orientation mOrientation;
|
|
|
|
|
|
|
|
friend class ImageOps;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-05-15 03:52:05 +00:00
|
|
|
#endif // mozilla_image_OrientedImage_h
|