This source file includes following definitions.
- reset
- init
- setData
- isFailed
- isSizeAvailable
- size
- frameCount
- isFrameCompleteAtIndex
- getFrameAtIndex
#include "config.h"
#include "WebImageDecoder.h"
#include "platform/SharedBuffer.h"
#include "platform/image-decoders/bmp/BMPImageDecoder.h"
#include "platform/image-decoders/ico/ICOImageDecoder.h"
#include "public/platform/Platform.h"
#include "public/platform/WebData.h"
#include "public/platform/WebImage.h"
#include "public/platform/WebSize.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/PassRefPtr.h"
using namespace WebCore;
namespace blink {
void WebImageDecoder::reset()
{
delete m_private;
}
void WebImageDecoder::init(Type type)
{
size_t maxDecodedBytes = blink::Platform::current()->maxDecodedImageBytes();
switch (type) {
case TypeBMP:
m_private = new BMPImageDecoder(ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied, maxDecodedBytes);
break;
case TypeICO:
m_private = new ICOImageDecoder(ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied, maxDecodedBytes);
break;
}
}
void WebImageDecoder::setData(const WebData& data, bool allDataReceived)
{
ASSERT(m_private);
m_private->setData(PassRefPtr<SharedBuffer>(data).get(), allDataReceived);
}
bool WebImageDecoder::isFailed() const
{
ASSERT(m_private);
return m_private->failed();
}
bool WebImageDecoder::isSizeAvailable() const
{
ASSERT(m_private);
return m_private->isSizeAvailable();
}
WebSize WebImageDecoder::size() const
{
ASSERT(m_private);
return m_private->size();
}
size_t WebImageDecoder::frameCount() const
{
ASSERT(m_private);
return m_private->frameCount();
}
bool WebImageDecoder::isFrameCompleteAtIndex(int index) const
{
ASSERT(m_private);
ImageFrame* const frameBuffer = m_private->frameBufferAtIndex(index);
if (!frameBuffer)
return false;
return frameBuffer->status() == ImageFrame::FrameComplete;
}
WebImage WebImageDecoder::getFrameAtIndex(int index = 0) const
{
ASSERT(m_private);
ImageFrame* const frameBuffer = m_private->frameBufferAtIndex(index);
if (!frameBuffer)
return WebImage();
RefPtr<NativeImageSkia> image = frameBuffer->asNewNativeImage();
return WebImage(image->bitmap());
}
}