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
26 typedef gfx::SourceSurface SourceSurface
;
29 NS_DECL_ISUPPORTS_INHERITED
31 NS_IMETHOD
GetWidth(int32_t* aWidth
) override
;
32 NS_IMETHOD
GetHeight(int32_t* aHeight
) 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
,
40 uint32_t aFlags
) override
;
41 NS_IMETHOD_(bool) IsImageContainerAvailable(layers::LayerManager
* aManager
,
42 uint32_t aFlags
) override
;
43 NS_IMETHOD_(already_AddRefed
<layers::ImageContainer
>)
44 GetImageContainer(layers::LayerManager
* aManager
,
45 uint32_t aFlags
) override
;
46 NS_IMETHOD_(DrawResult
) Draw(gfxContext
* aContext
,
47 const nsIntSize
& aSize
,
48 const ImageRegion
& aRegion
,
51 const Maybe
<SVGImageContext
>& aSVGContext
,
52 uint32_t aFlags
) override
;
53 NS_IMETHOD_(nsIntRect
) GetImageSpaceInvalidationRect(
54 const nsIntRect
& aRect
) override
;
55 nsIntSize
OptimalImageSizeForDest(const gfxSize
& aDest
,
58 uint32_t aFlags
) override
;
61 OrientedImage(Image
* aImage
, Orientation aOrientation
)
62 : ImageWrapper(aImage
)
63 , mOrientation(aOrientation
)
66 virtual ~OrientedImage() { }
68 gfxMatrix
OrientationMatrix(const nsIntSize
& aSize
, bool aInvert
= false);
71 Orientation mOrientation
;
73 friend class ImageOps
;
77 } // namespace mozilla
79 #endif // mozilla_image_OrientedImage_h