2013-04-05 21:14:34 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-05-15 03:52:05 +00:00
|
|
|
#ifndef mozilla_image_ImageOps_h
|
|
|
|
#define mozilla_image_ImageOps_h
|
2013-04-05 21:14:34 +00:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2015-04-21 15:04:57 +00:00
|
|
|
#include "nsRect.h"
|
2013-04-05 21:14:34 +00:00
|
|
|
|
2014-07-22 00:59:22 +00:00
|
|
|
class gfxDrawable;
|
2013-04-05 21:14:34 +00:00
|
|
|
class imgIContainer;
|
2015-08-01 01:10:31 +00:00
|
|
|
class nsIInputStream;
|
2013-04-05 21:14:34 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2015-08-01 01:10:31 +00:00
|
|
|
|
|
|
|
namespace gfx {
|
|
|
|
class SourceSurface;
|
|
|
|
}
|
|
|
|
|
2013-04-05 21:14:34 +00:00
|
|
|
namespace image {
|
|
|
|
|
|
|
|
class Image;
|
2014-06-19 00:57:51 +00:00
|
|
|
struct Orientation;
|
2013-04-05 21:14:34 +00:00
|
|
|
|
|
|
|
class ImageOps
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates a version of an existing image which does not animate and is frozen
|
|
|
|
* at the first frame.
|
|
|
|
*
|
|
|
|
* @param aImage The existing image.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<Image> Freeze(Image* aImage);
|
|
|
|
static already_AddRefed<imgIContainer> Freeze(imgIContainer* aImage);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a clipped version of an existing image. Animation is unaffected.
|
|
|
|
*
|
|
|
|
* @param aImage The existing image.
|
|
|
|
* @param aClip The rectangle to clip the image against.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<Image> Clip(Image* aImage, nsIntRect aClip);
|
2014-12-04 19:43:00 +00:00
|
|
|
static already_AddRefed<imgIContainer> Clip(imgIContainer* aImage,
|
|
|
|
nsIntRect aClip);
|
2013-04-05 21:14:34 +00:00
|
|
|
|
2013-08-25 07:19:43 +00:00
|
|
|
/**
|
|
|
|
* Creates a version of an existing image which is rotated and/or flipped to
|
|
|
|
* the specified orientation.
|
|
|
|
*
|
|
|
|
* @param aImage The existing image.
|
|
|
|
* @param aOrientation The desired orientation.
|
|
|
|
*/
|
2014-12-04 19:43:00 +00:00
|
|
|
static already_AddRefed<Image> Orient(Image* aImage,
|
|
|
|
Orientation aOrientation);
|
|
|
|
static already_AddRefed<imgIContainer> Orient(imgIContainer* aImage,
|
|
|
|
Orientation aOrientation);
|
2013-08-25 07:19:43 +00:00
|
|
|
|
2014-07-22 00:59:22 +00:00
|
|
|
/**
|
|
|
|
* Creates an image from a gfxDrawable.
|
|
|
|
*
|
|
|
|
* @param aDrawable The gfxDrawable.
|
|
|
|
*/
|
2014-12-04 19:43:00 +00:00
|
|
|
static already_AddRefed<imgIContainer>
|
|
|
|
CreateFromDrawable(gfxDrawable* aDrawable);
|
2014-07-22 00:59:22 +00:00
|
|
|
|
2015-08-01 01:10:31 +00:00
|
|
|
/**
|
|
|
|
* Decodes an image from an nsIInputStream directly into a SourceSurface,
|
|
|
|
* without ever creating an Image or imgIContainer (which are mostly
|
|
|
|
* main-thread-only). That means that this function may be called
|
|
|
|
* off-main-thread.
|
|
|
|
*
|
|
|
|
* @param aInputStream An input stream containing an encoded image.
|
|
|
|
* @param aMimeType The MIME type of the image.
|
|
|
|
* @param aFlags Flags of the imgIContainer::FLAG_DECODE_* variety.
|
|
|
|
* @return A SourceSurface containing the first frame of the image at its
|
|
|
|
* intrinsic size, or nullptr if the image cannot be decoded.
|
|
|
|
*/
|
2015-08-01 01:10:34 +00:00
|
|
|
static already_AddRefed<gfx::SourceSurface>
|
2015-08-01 01:10:31 +00:00
|
|
|
DecodeToSurface(nsIInputStream* aInputStream,
|
|
|
|
const nsACString& aMimeType,
|
|
|
|
uint32_t aFlags);
|
|
|
|
|
2013-04-05 21:14:34 +00:00
|
|
|
private:
|
|
|
|
// This is a static utility class, so disallow instantiation.
|
|
|
|
virtual ~ImageOps() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-05-15 03:52:05 +00:00
|
|
|
#endif // mozilla_image_ImageOps_h
|