michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_ michael@0: #define MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_ michael@0: michael@0: #include "ImageWrapper.h" michael@0: #include "mozilla/gfx/2D.h" michael@0: #include "mozilla/RefPtr.h" michael@0: #include "Orientation.h" michael@0: michael@0: namespace mozilla { michael@0: namespace image { michael@0: michael@0: /** michael@0: * An Image wrapper that rotates and/or flips an image according to a specified michael@0: * Orientation. michael@0: * michael@0: * XXX(seth): There a known (performance, not correctness) issue with michael@0: * GetImageContainer. See the comments for that method for more information. michael@0: */ michael@0: class OrientedImage : public ImageWrapper michael@0: { michael@0: typedef mozilla::gfx::SourceSurface SourceSurface; michael@0: michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: virtual ~OrientedImage() { } michael@0: michael@0: virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; michael@0: michael@0: NS_IMETHOD GetWidth(int32_t* aWidth) MOZ_OVERRIDE; michael@0: NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE; michael@0: NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE; michael@0: NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE; michael@0: NS_IMETHOD_(mozilla::TemporaryRef) michael@0: GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE; michael@0: NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager, michael@0: mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE; michael@0: NS_IMETHOD Draw(gfxContext* aContext, michael@0: GraphicsFilter aFilter, michael@0: const gfxMatrix& aUserSpaceToImageSpace, michael@0: const gfxRect& aFill, michael@0: const nsIntRect& aSubimage, michael@0: const nsIntSize& aViewportSize, michael@0: const SVGImageContext* aSVGContext, michael@0: uint32_t aWhichFrame, michael@0: uint32_t aFlags) MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: OrientedImage(Image* aImage, Orientation aOrientation) michael@0: : ImageWrapper(aImage) michael@0: , mOrientation(aOrientation) michael@0: { } michael@0: michael@0: gfxMatrix OrientationMatrix(const nsIntSize& aViewportSize); michael@0: michael@0: private: michael@0: Orientation mOrientation; michael@0: michael@0: friend class ImageOps; michael@0: }; michael@0: michael@0: } // namespace image michael@0: } // namespace mozilla michael@0: michael@0: #endif // MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_