1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/image/src/OrientedImage.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_ 1.10 +#define MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_ 1.11 + 1.12 +#include "ImageWrapper.h" 1.13 +#include "mozilla/gfx/2D.h" 1.14 +#include "mozilla/RefPtr.h" 1.15 +#include "Orientation.h" 1.16 + 1.17 +namespace mozilla { 1.18 +namespace image { 1.19 + 1.20 +/** 1.21 + * An Image wrapper that rotates and/or flips an image according to a specified 1.22 + * Orientation. 1.23 + * 1.24 + * XXX(seth): There a known (performance, not correctness) issue with 1.25 + * GetImageContainer. See the comments for that method for more information. 1.26 + */ 1.27 +class OrientedImage : public ImageWrapper 1.28 +{ 1.29 + typedef mozilla::gfx::SourceSurface SourceSurface; 1.30 + 1.31 +public: 1.32 + NS_DECL_ISUPPORTS 1.33 + 1.34 + virtual ~OrientedImage() { } 1.35 + 1.36 + virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; 1.37 + 1.38 + NS_IMETHOD GetWidth(int32_t* aWidth) MOZ_OVERRIDE; 1.39 + NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE; 1.40 + NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE; 1.41 + NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE; 1.42 + NS_IMETHOD_(mozilla::TemporaryRef<SourceSurface>) 1.43 + GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE; 1.44 + NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager, 1.45 + mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE; 1.46 + NS_IMETHOD Draw(gfxContext* aContext, 1.47 + GraphicsFilter aFilter, 1.48 + const gfxMatrix& aUserSpaceToImageSpace, 1.49 + const gfxRect& aFill, 1.50 + const nsIntRect& aSubimage, 1.51 + const nsIntSize& aViewportSize, 1.52 + const SVGImageContext* aSVGContext, 1.53 + uint32_t aWhichFrame, 1.54 + uint32_t aFlags) MOZ_OVERRIDE; 1.55 + 1.56 +protected: 1.57 + OrientedImage(Image* aImage, Orientation aOrientation) 1.58 + : ImageWrapper(aImage) 1.59 + , mOrientation(aOrientation) 1.60 + { } 1.61 + 1.62 + gfxMatrix OrientationMatrix(const nsIntSize& aViewportSize); 1.63 + 1.64 +private: 1.65 + Orientation mOrientation; 1.66 + 1.67 + friend class ImageOps; 1.68 +}; 1.69 + 1.70 +} // namespace image 1.71 +} // namespace mozilla 1.72 + 1.73 +#endif // MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_