This source file includes following definitions.
- m_requiredPreviousFrameIndexValid
- clearPixelData
- zeroFillPixelData
- copyBitmapData
- setSize
- asNewNativeImage
- hasAlpha
- setHasAlpha
- setStatus
- zeroFillFrameRect
#include "config.h"
#include "platform/image-decoders/ImageDecoder.h"
namespace WebCore {
ImageFrame::ImageFrame()
: m_allocator(0)
, m_hasAlpha(false)
, m_status(FrameEmpty)
, m_duration(0)
, m_disposalMethod(DisposeNotSpecified)
, m_alphaBlendSource(BlendAtopPreviousFrame)
, m_premultiplyAlpha(true)
, m_pixelsChanged(false)
, m_requiredPreviousFrameIndex(kNotFound)
#if !ASSERT_DISABLED
, m_requiredPreviousFrameIndexValid(false)
#endif
{
}
ImageFrame& ImageFrame::operator=(const ImageFrame& other)
{
if (this == &other)
return *this;
m_bitmap = other.m_bitmap;
m_bitmap.lockPixels();
m_pixelsChanged = other.m_pixelsChanged;
setMemoryAllocator(other.allocator());
setOriginalFrameRect(other.originalFrameRect());
setStatus(other.status());
setDuration(other.duration());
setDisposalMethod(other.disposalMethod());
setAlphaBlendSource(other.alphaBlendSource());
setPremultiplyAlpha(other.premultiplyAlpha());
setHasAlpha(other.hasAlpha());
m_requiredPreviousFrameIndex = other.m_requiredPreviousFrameIndex;
#if !ASSERT_DISABLED
m_requiredPreviousFrameIndexValid = other.m_requiredPreviousFrameIndexValid;
#endif
return *this;
}
void ImageFrame::clearPixelData()
{
m_bitmap.reset();
m_status = FrameEmpty;
}
void ImageFrame::zeroFillPixelData()
{
m_bitmap.eraseARGB(0, 0, 0, 0);
m_hasAlpha = true;
}
bool ImageFrame::copyBitmapData(const ImageFrame& other)
{
if (this == &other)
return true;
m_hasAlpha = other.m_hasAlpha;
m_bitmap.reset();
return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType());
}
bool ImageFrame::setSize(int newWidth, int newHeight)
{
ASSERT(!width() && !height());
m_bitmap.setConfig(SkImageInfo::MakeN32Premul(newWidth, newHeight));
if (!m_bitmap.allocPixels(m_allocator, 0))
return false;
zeroFillPixelData();
return true;
}
PassRefPtr<NativeImageSkia> ImageFrame::asNewNativeImage() const
{
return NativeImageSkia::create(m_bitmap);
}
bool ImageFrame::hasAlpha() const
{
return m_hasAlpha;
}
void ImageFrame::setHasAlpha(bool alpha)
{
m_hasAlpha = alpha;
if (m_status != FrameComplete)
alpha = true;
m_bitmap.setAlphaType(alpha ? kPremul_SkAlphaType : kOpaque_SkAlphaType);
}
void ImageFrame::setStatus(Status status)
{
m_status = status;
if (m_status == FrameComplete) {
m_bitmap.setAlphaType(m_hasAlpha ? kPremul_SkAlphaType : kOpaque_SkAlphaType);
notifyBitmapIfPixelsChanged();
m_bitmap.setImmutable();
}
}
void ImageFrame::zeroFillFrameRect(const IntRect& rect)
{
if (rect.isEmpty())
return;
m_bitmap.eraseArea(rect, SkColorSetARGB(0, 0, 0, 0));
setHasAlpha(true);
}
}