#ifndef ImageSource_h
#define ImageSource_h
#include "ImageOrientation.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
#if PLATFORM(WX)
class wxBitmap;
class wxGraphicsBitmap;
#elif USE(CG)
typedef struct CGImageSource* CGImageSourceRef;
typedef struct CGImage* CGImageRef;
typedef const struct __CFData* CFDataRef;
#elif PLATFORM(QT)
#include <qglobal.h>
QT_BEGIN_NAMESPACE
class QPixmap;
QT_END_NAMESPACE
#elif USE(CAIRO)
#include "NativeImageCairo.h"
#elif USE(SKIA)
namespace WebCore {
class NativeImageSkia;
}
#elif OS(WINCE)
#include "SharedBitmap.h"
#endif
namespace WebCore {
class ImageOrientation;
class IntPoint;
class IntSize;
class SharedBuffer;
#if USE(CG)
#if USE(WEBKIT_IMAGE_DECODERS)
class ImageDecoder;
typedef ImageDecoder* NativeImageSourcePtr;
#else
typedef CGImageSourceRef NativeImageSourcePtr;
#endif
typedef CGImageRef NativeImagePtr;
#elif PLATFORM(OPENVG)
class ImageDecoder;
class TiledImageOpenVG;
typedef ImageDecoder* NativeImageSourcePtr;
typedef TiledImageOpenVG* NativeImagePtr;
#elif PLATFORM(QT)
class ImageDecoderQt;
typedef ImageDecoderQt* NativeImageSourcePtr;
typedef QPixmap* NativeImagePtr;
#else
class ImageDecoder;
typedef ImageDecoder* NativeImageSourcePtr;
#if PLATFORM(WX)
#if USE(WXGC)
typedef wxGraphicsBitmap* NativeImagePtr;
#else
typedef wxBitmap* NativeImagePtr;
#endif
#elif USE(CAIRO)
typedef WebCore::NativeImageCairo* NativeImagePtr;
#elif USE(SKIA)
typedef WebCore::NativeImageSkia* NativeImagePtr;
#elif OS(WINCE)
typedef RefPtr<SharedBitmap> NativeImagePtr;
#elif PLATFORM(BLACKBERRY)
class ImageDecoder;
typedef ImageDecoder* NativeImageSourcePtr;
typedef void* NativeImagePtr;
#endif
#endif
const int cAnimationLoopOnce = 0;
const int cAnimationLoopInfinite = -1;
const int cAnimationNone = -2;
class ImageSource {
WTF_MAKE_NONCOPYABLE(ImageSource);
public:
enum AlphaOption {
AlphaPremultiplied,
AlphaNotPremultiplied
};
enum GammaAndColorProfileOption {
GammaAndColorProfileApplied,
GammaAndColorProfileIgnored
};
#if USE(CG)
enum ShouldSkipMetadata {
DoNotSkipMetadata,
SkipMetadata
};
#endif
ImageSource(AlphaOption alphaOption = AlphaPremultiplied, GammaAndColorProfileOption gammaAndColorProfileOption = GammaAndColorProfileApplied);
~ImageSource();
void clear(bool destroyAll,
size_t clearBeforeFrame = 0,
SharedBuffer* data = NULL,
bool allDataReceived = false);
bool initialized() const;
void setData(SharedBuffer* data, bool allDataReceived);
String filenameExtension() const;
bool isSizeAvailable();
IntSize size(RespectImageOrientationEnum = DoNotRespectImageOrientation) const;
IntSize frameSizeAtIndex(size_t, RespectImageOrientationEnum = DoNotRespectImageOrientation) const;
IntSize originalSize(RespectImageOrientationEnum = DoNotRespectImageOrientation) const;
bool getHotSpot(IntPoint&) const;
size_t bytesDecodedToDetermineProperties() const;
int repetitionCount();
size_t frameCount() const;
NativeImagePtr createFrameAtIndex(size_t, float scaleHint, float* actualScaleOut, ssize_t* bytesOut);
bool isSubsampled() const { return m_baseSubsampling; }
float frameDurationAtIndex(size_t);
bool frameHasAlphaAtIndex(size_t); bool frameIsCompleteAtIndex(size_t); ImageOrientation orientationAtIndex(size_t) const;
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
static unsigned maxPixelsPerDecodedImage() { return s_maxPixelsPerDecodedImage; }
static void setMaxPixelsPerDecodedImage(unsigned maxPixels) { s_maxPixelsPerDecodedImage = maxPixels; }
#endif
bool shouldSubsampleImageWithSize(unsigned size) const;
static unsigned maximumImageSizeBeforeSubsampling();
static void setMaximumImageSizeBeforeSubsampling(unsigned maximum);
static bool acceleratedImageDecodingEnabled() { return s_acceleratedImageDecoding; }
static void setAcceleratedImageDecodingEnabled(bool flag) { s_acceleratedImageDecoding = flag; }
private:
NativeImageSourcePtr m_decoder;
AlphaOption m_alphaOption;
GammaAndColorProfileOption m_gammaAndColorProfileOption;
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
static unsigned s_maxPixelsPerDecodedImage;
#endif
mutable int m_baseSubsampling;
mutable bool m_isProgressive;
CFDictionaryRef imageSourceOptions(ShouldSkipMetadata, int subsampling = 0) const;
static bool s_acceleratedImageDecoding;
};
}
#endif