Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_ |
michael@0 | 7 | #define MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "ImageWrapper.h" |
michael@0 | 10 | #include "mozilla/gfx/2D.h" |
michael@0 | 11 | #include "mozilla/RefPtr.h" |
michael@0 | 12 | #include "Orientation.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace image { |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * An Image wrapper that rotates and/or flips an image according to a specified |
michael@0 | 19 | * Orientation. |
michael@0 | 20 | * |
michael@0 | 21 | * XXX(seth): There a known (performance, not correctness) issue with |
michael@0 | 22 | * GetImageContainer. See the comments for that method for more information. |
michael@0 | 23 | */ |
michael@0 | 24 | class OrientedImage : public ImageWrapper |
michael@0 | 25 | { |
michael@0 | 26 | typedef mozilla::gfx::SourceSurface SourceSurface; |
michael@0 | 27 | |
michael@0 | 28 | public: |
michael@0 | 29 | NS_DECL_ISUPPORTS |
michael@0 | 30 | |
michael@0 | 31 | virtual ~OrientedImage() { } |
michael@0 | 32 | |
michael@0 | 33 | virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; |
michael@0 | 34 | |
michael@0 | 35 | NS_IMETHOD GetWidth(int32_t* aWidth) MOZ_OVERRIDE; |
michael@0 | 36 | NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE; |
michael@0 | 37 | NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE; |
michael@0 | 38 | NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE; |
michael@0 | 39 | NS_IMETHOD_(mozilla::TemporaryRef<SourceSurface>) |
michael@0 | 40 | GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE; |
michael@0 | 41 | NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager, |
michael@0 | 42 | mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE; |
michael@0 | 43 | NS_IMETHOD Draw(gfxContext* aContext, |
michael@0 | 44 | GraphicsFilter aFilter, |
michael@0 | 45 | const gfxMatrix& aUserSpaceToImageSpace, |
michael@0 | 46 | const gfxRect& aFill, |
michael@0 | 47 | const nsIntRect& aSubimage, |
michael@0 | 48 | const nsIntSize& aViewportSize, |
michael@0 | 49 | const SVGImageContext* aSVGContext, |
michael@0 | 50 | uint32_t aWhichFrame, |
michael@0 | 51 | uint32_t aFlags) MOZ_OVERRIDE; |
michael@0 | 52 | |
michael@0 | 53 | protected: |
michael@0 | 54 | OrientedImage(Image* aImage, Orientation aOrientation) |
michael@0 | 55 | : ImageWrapper(aImage) |
michael@0 | 56 | , mOrientation(aOrientation) |
michael@0 | 57 | { } |
michael@0 | 58 | |
michael@0 | 59 | gfxMatrix OrientationMatrix(const nsIntSize& aViewportSize); |
michael@0 | 60 | |
michael@0 | 61 | private: |
michael@0 | 62 | Orientation mOrientation; |
michael@0 | 63 | |
michael@0 | 64 | friend class ImageOps; |
michael@0 | 65 | }; |
michael@0 | 66 | |
michael@0 | 67 | } // namespace image |
michael@0 | 68 | } // namespace mozilla |
michael@0 | 69 | |
michael@0 | 70 | #endif // MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_ |