Line data Source code
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_DECL_ISUPPORTS_INHERITED
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_(DrawResult) Draw(gfxContext* aContext,
48 : const nsIntSize& aSize,
49 : const ImageRegion& aRegion,
50 : uint32_t aWhichFrame,
51 : gfx::SamplingFilter aSamplingFilter,
52 : const Maybe<SVGImageContext>& aSVGContext,
53 : uint32_t aFlags,
54 : float aOpacity) override;
55 : NS_IMETHOD_(nsIntRect) GetImageSpaceInvalidationRect(
56 : const nsIntRect& aRect) override;
57 : nsIntSize OptimalImageSizeForDest(const gfxSize& aDest,
58 : uint32_t aWhichFrame,
59 : gfx::SamplingFilter aSamplingFilter,
60 : uint32_t aFlags) override;
61 :
62 : protected:
63 0 : OrientedImage(Image* aImage, Orientation aOrientation)
64 0 : : ImageWrapper(aImage)
65 0 : , mOrientation(aOrientation)
66 0 : { }
67 :
68 0 : virtual ~OrientedImage() { }
69 :
70 : gfxMatrix OrientationMatrix(const nsIntSize& aSize, bool aInvert = false);
71 :
72 : private:
73 : Orientation mOrientation;
74 :
75 : friend class ImageOps;
76 : };
77 :
78 : } // namespace image
79 : } // namespace mozilla
80 :
81 : #endif // mozilla_image_OrientedImage_h
|