Commit a92dd682 authored by Wan-Teh Chang's avatar Wan-Teh Chang Committed by Commit Bot

Improve comment ImageDecoder::InitializeNewFrame

Also remove unneeded ImageFrame setter calls in
AVIFImageDecoder::InitializeNewFrame. By analyzing all the overrides of
the InitializeNewFrame method, I found that the following ImageFrame
setters can only be called during InitializeNewFrame:
  * SetDuration
  * SetDisposalMethod
  * SetAlphaBlendSource
  * SetRequiredPreviousFrameIndex
Since AVIF frames don't require any previous frames, we don't need to
call the last three setters in AVIFImageDecoder::InitializeNewFrame.

Change-Id: I554c1a28a4dc008cd5e19946297b82fa0061f97c
Bug: 1071221
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2164108
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783760}
parent 0bba6e4d
......@@ -450,23 +450,13 @@ void AVIFImageDecoder::InitializeNewFrame(size_t index) {
if (decode_to_half_float_)
buffer.SetPixelFormat(ImageFrame::PixelFormat::kRGBA_F16);
// For AVIFs, the frame always fills the entire image.
buffer.SetOriginalFrameRect(IntRect(IntPoint(), Size()));
avifImageTiming timing;
auto ret = avifDecoderNthImageTiming(decoder_.get(), index, &timing);
DCHECK_EQ(ret, AVIF_RESULT_OK);
buffer.SetDuration(base::TimeDelta::FromSecondsD(timing.duration));
// The AVIF file format does not contain information equivalent to the
// disposal method or alpha blend source. Since the AVIF decoder handles frame
// dependence internally, set options that best correspond to "each frame is
// independent".
buffer.SetDisposalMethod(ImageFrame::kDisposeNotSpecified);
buffer.SetAlphaBlendSource(ImageFrame::kBlendAtopBgcolor);
// Leave all frames as being independent (the default) because we require all
// frames be the same size.
DCHECK_EQ(buffer.RequiredPreviousFrameIndex(), kNotFound);
}
void AVIFImageDecoder::Decode(size_t index) {
......
......@@ -444,8 +444,8 @@ class PLATFORM_EXPORT ImageDecoder {
// call.
bool InitFrameBuffer(size_t);
// Performs any additional setup of the requested frame after it has been
// initially created, e.g. setting a duration or disposal method.
// Performs any decoder-specific setup of the requested frame after it has
// been newly created, e.g. setting the frame's duration or disposal method.
virtual void InitializeNewFrame(size_t) {}
// Decodes the requested frame.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment