1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_image_OrientedImage_h
7 #define mozilla_image_OrientedImage_h
9 #include "ImageWrapper.h"
10 #include "mozilla/gfx/2D.h"
11 #include "mozilla/RefPtr.h"
12 #include "Orientation.h"
18 * An Image wrapper that rotates and/or flips an image according to a specified
21 * XXX(seth): There a known (performance, not correctness) issue with
22 * GetImageContainer. See the comments for that method for more information.
24 class OrientedImage
: public ImageWrapper
{
25 typedef gfx::SourceSurface SourceSurface
;
28 NS_INLINE_DECL_REFCOUNTING_INHERITED(OrientedImage
, ImageWrapper
)
30 NS_IMETHOD
GetWidth(int32_t* aWidth
) override
;
31 NS_IMETHOD
GetHeight(int32_t* aHeight
) override
;
32 nsresult
GetNativeSizes(nsTArray
<gfx::IntSize
>& aNativeSizes
) const override
;
33 NS_IMETHOD
GetIntrinsicSize(nsSize
* aSize
) override
;
34 NS_IMETHOD
GetIntrinsicRatio(nsSize
* aRatio
) override
;
35 NS_IMETHOD_(already_AddRefed
<SourceSurface
>)
36 GetFrame(uint32_t aWhichFrame
, uint32_t aFlags
) override
;
37 NS_IMETHOD_(already_AddRefed
<SourceSurface
>)
38 GetFrameAtSize(const gfx::IntSize
& aSize
, uint32_t aWhichFrame
,
39 uint32_t aFlags
) override
;
41 IsImageContainerAvailable(layers::LayerManager
* aManager
,
42 uint32_t aFlags
) override
;
43 NS_IMETHOD_(already_AddRefed
<layers::ImageContainer
>)
44 GetImageContainer(layers::LayerManager
* aManager
, uint32_t aFlags
) override
;
46 IsImageContainerAvailableAtSize(layers::LayerManager
* aManager
,
47 const gfx::IntSize
& aSize
,
48 uint32_t aFlags
) override
;
49 NS_IMETHOD_(ImgDrawResult
)
50 GetImageContainerAtSize(layers::LayerManager
* aManager
,
51 const gfx::IntSize
& aSize
,
52 const Maybe
<SVGImageContext
>& aSVGContext
,
54 layers::ImageContainer
** aOutContainer
) override
;
55 NS_IMETHOD_(ImgDrawResult
)
56 Draw(gfxContext
* aContext
, const nsIntSize
& aSize
, const ImageRegion
& aRegion
,
57 uint32_t aWhichFrame
, gfx::SamplingFilter aSamplingFilter
,
58 const Maybe
<SVGImageContext
>& aSVGContext
, uint32_t aFlags
,
59 float aOpacity
) override
;
60 NS_IMETHOD_(nsIntRect
)
61 GetImageSpaceInvalidationRect(const nsIntRect
& aRect
) override
;
62 nsIntSize
OptimalImageSizeForDest(const gfxSize
& aDest
, uint32_t aWhichFrame
,
63 gfx::SamplingFilter aSamplingFilter
,
64 uint32_t aFlags
) override
;
67 OrientedImage(Image
* aImage
, Orientation aOrientation
)
68 : ImageWrapper(aImage
), mOrientation(aOrientation
) {}
70 virtual ~OrientedImage() {}
72 gfxMatrix
OrientationMatrix(const nsIntSize
& aSize
, bool aInvert
= false);
75 Orientation mOrientation
;
77 friend class ImageOps
;
81 } // namespace mozilla
83 #endif // mozilla_image_OrientedImage_h