Bug 1516095 [wpt PR 14643] - Update wpt metadata, a=testonly
[gecko.git] / image / OrientedImage.h
blobe662ea1e8651eeb9d94db4cf7a56aae846865911
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"
14 namespace mozilla {
15 namespace image {
17 /**
18 * An Image wrapper that rotates and/or flips an image according to a specified
19 * Orientation.
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;
27 public:
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;
40 NS_IMETHOD_(bool)
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;
45 NS_IMETHOD_(bool)
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,
53 uint32_t aFlags,
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;
66 protected:
67 OrientedImage(Image* aImage, Orientation aOrientation)
68 : ImageWrapper(aImage), mOrientation(aOrientation) {}
70 virtual ~OrientedImage() {}
72 gfxMatrix OrientationMatrix(const nsIntSize& aSize, bool aInvert = false);
74 private:
75 Orientation mOrientation;
77 friend class ImageOps;
80 } // namespace image
81 } // namespace mozilla
83 #endif // mozilla_image_OrientedImage_h