#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/image-decoders/webp/webp_image_decoder.h"
#include <string.h>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkData.h"
#if defined(ARCH_CPU_BIG_ENDIAN)
#error Blink assumes a little-endian target.
#endif
namespace {
inline void findBlendRangeAtRow(const gfx::Rect& src,
const gfx::Rect& dst,
int canvasY,
int& left1,
int& width1,
int& left2,
int& width2) { … }
void alphaBlendPremultiplied(blink::ImageFrame& src,
blink::ImageFrame& dst,
int canvasY,
int left,
int width) { … }
void alphaBlendNonPremultiplied(blink::ImageFrame& src,
blink::ImageFrame& dst,
int canvasY,
int left,
int width) { … }
enum class WebPFileFormat { … };
bool IsSimpleLossyWebPImage(const sk_sp<SkData>& blob) { … }
void UpdateWebPFileFormatUMA(const sk_sp<SkData>& blob) { … }
}
namespace blink {
WEBPImageDecoder::WEBPImageDecoder(AlphaOption alpha_option,
ColorBehavior color_behavior,
wtf_size_t max_decoded_bytes)
: … { … }
WEBPImageDecoder::~WEBPImageDecoder() { … }
String WEBPImageDecoder::FilenameExtension() const { … }
const AtomicString& WEBPImageDecoder::MimeType() const { … }
void WEBPImageDecoder::Clear() { … }
void WEBPImageDecoder::ClearDecoder() { … }
WEBP_CSP_MODE WEBPImageDecoder::RGBOutputMode() { … }
bool WEBPImageDecoder::CanAllowYUVDecodingForWebP() const { … }
void WEBPImageDecoder::OnSetData(scoped_refptr<SegmentReader> data) { … }
int WEBPImageDecoder::RepetitionCount() const { … }
bool WEBPImageDecoder::FrameIsReceivedAtIndex(wtf_size_t index) const { … }
base::TimeDelta WEBPImageDecoder::FrameDurationAtIndex(wtf_size_t index) const { … }
bool WEBPImageDecoder::UpdateDemuxer() { … }
void WEBPImageDecoder::OnInitFrameBuffer(wtf_size_t frame_index) { … }
void WEBPImageDecoder::DecodeToYUV() { … }
gfx::Size WEBPImageDecoder::DecodedYUVSize(cc::YUVIndex index) const { … }
wtf_size_t WEBPImageDecoder::DecodedYUVWidthBytes(cc::YUVIndex index) const { … }
SkYUVColorSpace WEBPImageDecoder::GetYUVColorSpace() const { … }
cc::YUVSubsampling WEBPImageDecoder::GetYUVSubsampling() const { … }
bool WEBPImageDecoder::CanReusePreviousFrameBuffer(
wtf_size_t frame_index) const { … }
void WEBPImageDecoder::ClearFrameBuffer(wtf_size_t frame_index) { … }
void WEBPImageDecoder::ReadColorProfile() { … }
void WEBPImageDecoder::ApplyPostProcessing(wtf_size_t frame_index) { … }
void WEBPImageDecoder::DecodeSize() { … }
wtf_size_t WEBPImageDecoder::DecodeFrameCount() { … }
void WEBPImageDecoder::InitializeNewFrame(wtf_size_t index) { … }
void WEBPImageDecoder::Decode(wtf_size_t index) { … }
bool WEBPImageDecoder::DecodeSingleFrameToYUV(const uint8_t* data_bytes,
wtf_size_t data_size) { … }
bool WEBPImageDecoder::DecodeSingleFrame(const uint8_t* data_bytes,
wtf_size_t data_size,
wtf_size_t frame_index) { … }
cc::ImageHeaderMetadata WEBPImageDecoder::MakeMetadataForDecodeAcceleration()
const { … }
bool WEBPImageDecoder::FrameStatusSufficientForSuccessors(wtf_size_t index) { … }
}