|
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_IMAGELIB_ORIENTEDIMAGE_H_ |
|
7 #define MOZILLA_IMAGELIB_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 mozilla::gfx::SourceSurface SourceSurface; |
|
27 |
|
28 public: |
|
29 NS_DECL_ISUPPORTS |
|
30 |
|
31 virtual ~OrientedImage() { } |
|
32 |
|
33 virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; |
|
34 |
|
35 NS_IMETHOD GetWidth(int32_t* aWidth) MOZ_OVERRIDE; |
|
36 NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE; |
|
37 NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE; |
|
38 NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE; |
|
39 NS_IMETHOD_(mozilla::TemporaryRef<SourceSurface>) |
|
40 GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE; |
|
41 NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager, |
|
42 mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE; |
|
43 NS_IMETHOD Draw(gfxContext* aContext, |
|
44 GraphicsFilter aFilter, |
|
45 const gfxMatrix& aUserSpaceToImageSpace, |
|
46 const gfxRect& aFill, |
|
47 const nsIntRect& aSubimage, |
|
48 const nsIntSize& aViewportSize, |
|
49 const SVGImageContext* aSVGContext, |
|
50 uint32_t aWhichFrame, |
|
51 uint32_t aFlags) MOZ_OVERRIDE; |
|
52 |
|
53 protected: |
|
54 OrientedImage(Image* aImage, Orientation aOrientation) |
|
55 : ImageWrapper(aImage) |
|
56 , mOrientation(aOrientation) |
|
57 { } |
|
58 |
|
59 gfxMatrix OrientationMatrix(const nsIntSize& aViewportSize); |
|
60 |
|
61 private: |
|
62 Orientation mOrientation; |
|
63 |
|
64 friend class ImageOps; |
|
65 }; |
|
66 |
|
67 } // namespace image |
|
68 } // namespace mozilla |
|
69 |
|
70 #endif // MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_ |