chromium/third_party/blink/renderer/platform/image-decoders/webp/webp_image_decoder.cc

// Copyright 2010 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#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 {

// Returns two point ranges (<left, width> pairs) at row |canvasY| which belong
// to |src| but not |dst|. A range is empty if its width is 0.
inline void findBlendRangeAtRow(const gfx::Rect& src,
                                const gfx::Rect& dst,
                                int canvasY,
                                int& left1,
                                int& width1,
                                int& left2,
                                int& width2) {}

// alphaBlendPremultiplied and alphaBlendNonPremultiplied are separate methods,
// even though they only differ by one line. This is done so that the compiler
// can inline BlendSrcOverDstPremultiplied() and BlensSrcOverDstRaw() calls.
// For GIF images, this optimization reduces decoding time by 15% for 3MB
// images.
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) {}

// Do not rename entries nor reuse numeric values. See the following link for
// descriptions: https://developers.google.com/speed/webp/docs/riff_container.
enum class WebPFileFormat {};

// Validates that |blob| is a simple lossy WebP image. Note that this explicitly
// checks "WEBPVP8 " to exclude extended lossy WebPs that don't actually use any
// extended features.
//
// TODO(crbug.com/1009237): consider combining this with the logic to detect
// WebPs that can be decoded to YUV.
bool IsSimpleLossyWebPImage(const sk_sp<SkData>& blob) {}

// This method parses |blob|'s header and emits a UMA with the file format, as
// defined by WebP, see WebPFileFormat.
void UpdateWebPFileFormatUMA(const sk_sp<SkData>& blob) {}

}  // namespace

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) {}

}  // namespace blink