/src/mozilla-central/image/OrientedImage.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
5 | | |
6 | | #ifndef mozilla_image_OrientedImage_h |
7 | | #define mozilla_image_OrientedImage_h |
8 | | |
9 | | #include "ImageWrapper.h" |
10 | | #include "mozilla/gfx/2D.h" |
11 | | #include "mozilla/RefPtr.h" |
12 | | #include "Orientation.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace image { |
16 | | |
17 | | /** |
18 | | * An Image wrapper that rotates and/or flips an image according to a specified |
19 | | * Orientation. |
20 | | * |
21 | | * XXX(seth): There a known (performance, not correctness) issue with |
22 | | * GetImageContainer. See the comments for that method for more information. |
23 | | */ |
24 | | class OrientedImage : public ImageWrapper |
25 | | { |
26 | | typedef gfx::SourceSurface SourceSurface; |
27 | | |
28 | | public: |
29 | | NS_INLINE_DECL_REFCOUNTING_INHERITED(OrientedImage, ImageWrapper) |
30 | | |
31 | | NS_IMETHOD GetWidth(int32_t* aWidth) override; |
32 | | NS_IMETHOD GetHeight(int32_t* aHeight) override; |
33 | | nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) const override; |
34 | | NS_IMETHOD GetIntrinsicSize(nsSize* aSize) override; |
35 | | NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) override; |
36 | | NS_IMETHOD_(already_AddRefed<SourceSurface>) |
37 | | GetFrame(uint32_t aWhichFrame, uint32_t aFlags) override; |
38 | | NS_IMETHOD_(already_AddRefed<SourceSurface>) |
39 | | GetFrameAtSize(const gfx::IntSize& aSize, |
40 | | uint32_t aWhichFrame, |
41 | | uint32_t aFlags) override; |
42 | | NS_IMETHOD_(bool) IsImageContainerAvailable(layers::LayerManager* aManager, |
43 | | uint32_t aFlags) override; |
44 | | NS_IMETHOD_(already_AddRefed<layers::ImageContainer>) |
45 | | GetImageContainer(layers::LayerManager* aManager, |
46 | | uint32_t aFlags) override; |
47 | | NS_IMETHOD_(bool) |
48 | | IsImageContainerAvailableAtSize(layers::LayerManager* aManager, |
49 | | const gfx::IntSize& aSize, |
50 | | uint32_t aFlags) override; |
51 | | NS_IMETHOD_(ImgDrawResult) |
52 | | GetImageContainerAtSize(layers::LayerManager* aManager, |
53 | | const gfx::IntSize& aSize, |
54 | | const Maybe<SVGImageContext>& aSVGContext, |
55 | | uint32_t aFlags, |
56 | | layers::ImageContainer** aOutContainer) override; |
57 | | NS_IMETHOD_(ImgDrawResult) Draw(gfxContext* aContext, |
58 | | const nsIntSize& aSize, |
59 | | const ImageRegion& aRegion, |
60 | | uint32_t aWhichFrame, |
61 | | gfx::SamplingFilter aSamplingFilter, |
62 | | const Maybe<SVGImageContext>& aSVGContext, |
63 | | uint32_t aFlags, |
64 | | float aOpacity) override; |
65 | | NS_IMETHOD_(nsIntRect) GetImageSpaceInvalidationRect( |
66 | | const nsIntRect& aRect) override; |
67 | | nsIntSize OptimalImageSizeForDest(const gfxSize& aDest, |
68 | | uint32_t aWhichFrame, |
69 | | gfx::SamplingFilter aSamplingFilter, |
70 | | uint32_t aFlags) override; |
71 | | |
72 | | protected: |
73 | | OrientedImage(Image* aImage, Orientation aOrientation) |
74 | | : ImageWrapper(aImage) |
75 | | , mOrientation(aOrientation) |
76 | 0 | { } |
77 | | |
78 | 0 | virtual ~OrientedImage() { } |
79 | | |
80 | | gfxMatrix OrientationMatrix(const nsIntSize& aSize, bool aInvert = false); |
81 | | |
82 | | private: |
83 | | Orientation mOrientation; |
84 | | |
85 | | friend class ImageOps; |
86 | | }; |
87 | | |
88 | | } // namespace image |
89 | | } // namespace mozilla |
90 | | |
91 | | #endif // mozilla_image_OrientedImage_h |