#pragma once
#include "DecodingOptions.h"
#include "ImageOrientation.h"
#include "ImageTypes.h"
#include "IntPoint.h"
#include "IntSize.h"
#include "NativeImage.h"
#include <wtf/Optional.h>
#include <wtf/ThreadSafeRefCounted.h>
namespace WebCore {
class SharedBuffer;
class ImageDecoder : public ThreadSafeRefCounted<ImageDecoder> {
WTF_MAKE_FAST_ALLOCATED;
public:
ImageDecoder(SharedBuffer& data, AlphaOption, GammaAndColorProfileOption);
static Ref<ImageDecoder> create(SharedBuffer& data, AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption)
{
return adoptRef(*new ImageDecoder(data, alphaOption, gammaAndColorProfileOption));
}
static size_t bytesDecodedToDetermineProperties();
EncodedDataStatus encodedDataStatus() const;
bool isSizeAvailable() { return encodedDataStatus() >= EncodedDataStatus::SizeAvailable; }
size_t frameCount() const;
RepetitionCount repetitionCount() const;
String uti() const;
String filenameExtension() const;
std::optional<IntPoint> hotSpot() const;
IntSize frameSizeAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const;
bool frameIsCompleteAtIndex(size_t) const;
ImageOrientation frameOrientationAtIndex(size_t) const;
float frameDurationAtIndex(size_t) const;
bool frameHasAlphaAtIndex(size_t) const;
bool frameAllowSubsamplingAtIndex(size_t) const;
unsigned frameBytesAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default) const;
NativeImagePtr createFrameImageAtIndex(size_t, SubsamplingLevel = SubsamplingLevel::Default, const DecodingOptions& = DecodingMode::Synchronous) const;
void setData(SharedBuffer&, bool allDataReceived);
bool isAllDataReceived() const { return m_isAllDataReceived; }
void clearFrameBufferCache(size_t) { }
protected:
bool m_isAllDataReceived { false };
RetainPtr<CGImageSourceRef> m_nativeDecoder;
};
}