#ifndef WEBPImageDecoder_h
#define WEBPImageDecoder_h
#include "platform/image-decoders/ImageDecoder.h"
#include "webp/decode.h"
#include "webp/demux.h"
namespace WebCore {
class PLATFORM_EXPORT WEBPImageDecoder : public ImageDecoder {
public:
WEBPImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption, size_t maxDecodedBytes);
virtual ~WEBPImageDecoder();
virtual String filenameExtension() const OVERRIDE { return "webp"; }
virtual bool isSizeAvailable() OVERRIDE;
virtual size_t frameCount() OVERRIDE;
virtual ImageFrame* frameBufferAtIndex(size_t) OVERRIDE;
virtual void setData(SharedBuffer* data, bool allDataReceived) OVERRIDE;
virtual int repetitionCount() const OVERRIDE;
virtual bool frameIsCompleteAtIndex(size_t) const OVERRIDE;
virtual float frameDurationAtIndex(size_t) const OVERRIDE;
virtual size_t clearCacheExceptFrame(size_t) OVERRIDE;
private:
bool decode(const uint8_t* dataBytes, size_t dataSize, bool onlySize, size_t frameIndex);
WebPIDecoder* m_decoder;
WebPDecBuffer m_decoderBuffer;
int m_formatFlags;
bool m_frameBackgroundHasAlpha;
#if USE(QCMSLIB)
qcms_transform* colorTransform() const { return m_transform; }
void createColorTransform(const char* data, size_t);
void readColorProfile();
bool m_haveReadProfile;
qcms_transform* m_transform;
#endif
bool updateDemuxer();
bool initFrameBuffer(size_t frameIndex);
void applyPostProcessing(size_t frameIndex);
virtual void clearFrameBuffer(size_t frameIndex) OVERRIDE;
WebPDemuxer* m_demux;
WebPDemuxState m_demuxState;
bool m_haveAlreadyParsedThisData;
bool m_haveReadAnimationParameters;
int m_repetitionCount;
int m_decodedHeight;
void clear();
void clearDecoder();
};
}
#endif