This source file includes following definitions.
- m_gammaAndColorProfileOption
- clearCacheExceptFrame
- initialized
- setData
- filenameExtension
- isSizeAvailable
- size
- frameSizeAtIndex
- getHotSpot
- repetitionCount
- frameCount
- createFrameAtIndex
- frameDurationAtIndex
- orientationAtIndex
- frameHasAlphaAtIndex
- frameIsCompleteAtIndex
- frameBytesAtIndex
#include "config.h"
#include "platform/graphics/ImageSource.h"
#include "platform/graphics/DeferredImageDecoder.h"
#include "platform/image-decoders/ImageDecoder.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/PassRefPtr.h"
namespace WebCore {
ImageSource::ImageSource(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption)
: m_alphaOption(alphaOption)
, m_gammaAndColorProfileOption(gammaAndColorProfileOption)
{
}
ImageSource::~ImageSource()
{
}
size_t ImageSource::clearCacheExceptFrame(size_t clearExceptFrame)
{
return m_decoder ? m_decoder->clearCacheExceptFrame(clearExceptFrame) : 0;
}
bool ImageSource::initialized() const
{
return m_decoder;
}
void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
{
if (!m_decoder)
m_decoder = DeferredImageDecoder::create(*data, m_alphaOption, m_gammaAndColorProfileOption);
if (m_decoder)
m_decoder->setData(data, allDataReceived);
}
String ImageSource::filenameExtension() const
{
return m_decoder ? m_decoder->filenameExtension() : String();
}
bool ImageSource::isSizeAvailable()
{
return m_decoder && m_decoder->isSizeAvailable();
}
IntSize ImageSource::size(RespectImageOrientationEnum shouldRespectOrientation) const
{
return frameSizeAtIndex(0, shouldRespectOrientation);
}
IntSize ImageSource::frameSizeAtIndex(size_t index, RespectImageOrientationEnum shouldRespectOrientation) const
{
if (!m_decoder)
return IntSize();
IntSize size = m_decoder->frameSizeAtIndex(index);
if ((shouldRespectOrientation == RespectImageOrientation) && m_decoder->orientation().usesWidthAsHeight())
return IntSize(size.height(), size.width());
return size;
}
bool ImageSource::getHotSpot(IntPoint& hotSpot) const
{
return m_decoder ? m_decoder->hotSpot(hotSpot) : false;
}
int ImageSource::repetitionCount()
{
return m_decoder ? m_decoder->repetitionCount() : cAnimationNone;
}
size_t ImageSource::frameCount() const
{
return m_decoder ? m_decoder->frameCount() : 0;
}
PassRefPtr<NativeImageSkia> ImageSource::createFrameAtIndex(size_t index)
{
if (!m_decoder)
return nullptr;
ImageFrame* buffer = m_decoder->frameBufferAtIndex(index);
if (!buffer || buffer->status() == ImageFrame::FrameEmpty)
return nullptr;
if (size().isEmpty())
return nullptr;
return buffer->asNewNativeImage();
}
float ImageSource::frameDurationAtIndex(size_t index) const
{
if (!m_decoder)
return 0;
const float duration = m_decoder->frameDurationAtIndex(index) / 1000.0f;
if (duration < 0.011f)
return 0.100f;
return duration;
}
ImageOrientation ImageSource::orientationAtIndex(size_t) const
{
return m_decoder ? m_decoder->orientation() : DefaultImageOrientation;
}
bool ImageSource::frameHasAlphaAtIndex(size_t index) const
{
return !m_decoder || m_decoder->frameHasAlphaAtIndex(index);
}
bool ImageSource::frameIsCompleteAtIndex(size_t index) const
{
return m_decoder && m_decoder->frameIsCompleteAtIndex(index);
}
unsigned ImageSource::frameBytesAtIndex(size_t index) const
{
if (!m_decoder)
return 0;
return m_decoder->frameBytesAtIndex(index);
}
}