This source file includes following definitions.
- m_generationId
- refEncodedData
- getInfo
- getPixels
#include "config.h"
#include "platform/graphics/DecodingImageGenerator.h"
#include "SkData.h"
#include "SkImageInfo.h"
#include "platform/PlatformInstrumentation.h"
#include "platform/SharedBuffer.h"
#include "platform/TraceEvent.h"
#include "platform/graphics/ImageFrameGenerator.h"
namespace WebCore {
DecodingImageGenerator::DecodingImageGenerator(PassRefPtr<ImageFrameGenerator> frameGenerator, const SkImageInfo& info, size_t index)
: m_frameGenerator(frameGenerator)
, m_imageInfo(info)
, m_frameIndex(index)
, m_generationId(0)
{
}
DecodingImageGenerator::~DecodingImageGenerator()
{
}
SkData* DecodingImageGenerator::refEncodedData()
{
RefPtr<SharedBuffer> buffer = nullptr;
bool allDataReceived = false;
m_frameGenerator->copyData(&buffer, &allDataReceived);
if (buffer && allDataReceived) {
return SkData::NewWithCopy(buffer->data(), buffer->size());
}
return 0;
}
bool DecodingImageGenerator::getInfo(SkImageInfo* info)
{
*info = m_imageInfo;
return true;
}
bool DecodingImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes)
{
TRACE_EVENT1("webkit", "DecodingImageGenerator::getPixels", "index", static_cast<int>(m_frameIndex));
ASSERT(info.fWidth == m_imageInfo.fWidth);
ASSERT(info.fHeight == m_imageInfo.fHeight);
ASSERT(info.fColorType == m_imageInfo.fColorType);
ASSERT(info.fAlphaType == m_imageInfo.fAlphaType);
PlatformInstrumentation::willDecodeLazyPixelRef(m_generationId);
bool decoded = m_frameGenerator->decodeAndScale(m_imageInfo, m_frameIndex, pixels, rowBytes);
PlatformInstrumentation::didDecodeLazyPixelRef(m_generationId);
return decoded;
}
}