Backed out changeset 177eae915693 (bug 1206581) for bustage
[gecko.git] / image / OrientedImage.h
blob5db5d70f41156810f632e541645b031262f5034f
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
26 typedef gfx::SourceSurface SourceSurface;
28 public:
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,
39 uint32_t aWhichFrame,
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,
49 uint32_t aWhichFrame,
50 gfx::Filter aFilter,
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,
56 uint32_t aWhichFrame,
57 gfx::Filter aFilter,
58 uint32_t aFlags) override;
60 protected:
61 OrientedImage(Image* aImage, Orientation aOrientation)
62 : ImageWrapper(aImage)
63 , mOrientation(aOrientation)
64 { }
66 virtual ~OrientedImage() { }
68 gfxMatrix OrientationMatrix(const nsIntSize& aSize, bool aInvert = false);
70 private:
71 Orientation mOrientation;
73 friend class ImageOps;
76 } // namespace image
77 } // namespace mozilla
79 #endif // mozilla_image_OrientedImage_h