ImageDecoderSkia.cpp [plain text]
#include "config.h"
#include "ImageDecoder.h"
#include "NotImplemented.h"
namespace WebCore {
ImageFrame::ImageFrame()
: m_status(FrameEmpty)
, m_duration(0)
, m_disposalMethod(DisposeNotSpecified)
, m_premultiplyAlpha(true)
{
}
ImageFrame& ImageFrame::operator=(const ImageFrame& other)
{
if (this == &other)
return *this;
m_bitmap = other.m_bitmap;
m_bitmap.lockPixels();
setOriginalFrameRect(other.originalFrameRect());
setStatus(other.status());
setDuration(other.duration());
setDisposalMethod(other.disposalMethod());
setPremultiplyAlpha(other.premultiplyAlpha());
return *this;
}
void ImageFrame::clearPixelData()
{
m_bitmap.reset();
m_status = FrameEmpty;
}
void ImageFrame::zeroFillPixelData()
{
m_bitmap.eraseARGB(0, 0, 0, 0);
}
bool ImageFrame::copyBitmapData(const ImageFrame& other)
{
if (this == &other)
return true;
m_bitmap.reset();
const NativeImageSkia& otherBitmap = other.m_bitmap;
return otherBitmap.copyTo(&m_bitmap, otherBitmap.config());
}
bool ImageFrame::setSize(int newWidth, int newHeight)
{
ASSERT(width() == 0 && height() == 0);
m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, newWidth, newHeight);
if (!m_bitmap.allocPixels())
return false;
zeroFillPixelData();
return true;
}
NativeImagePtr ImageFrame::asNewNativeImage() const
{
return new NativeImageSkia(m_bitmap);
}
bool ImageFrame::hasAlpha() const
{
return !m_bitmap.isOpaque();
}
void ImageFrame::setHasAlpha(bool alpha)
{
m_bitmap.setIsOpaque(!alpha);
}
void ImageFrame::setColorProfile(const ColorProfile& colorProfile)
{
notImplemented();
}
void ImageFrame::setStatus(FrameStatus status)
{
m_status = status;
if (m_status == FrameComplete)
m_bitmap.setDataComplete(); }
int ImageFrame::width() const
{
return m_bitmap.width();
}
int ImageFrame::height() const
{
return m_bitmap.height();
}
}