skia2/include/codec/SkCodecAnimation.h
Leon Scroggins III 469d67e7d9 Expose more info in SkCodec::FrameInfo
Bug: b/160984428

Add more fields to SkCodec::FrameInfo, which describes the properties of
an individual frame in an animated image. This allows a client that
wishes to seek to determine frame dependencies so that they can decode
an arbitrary frame, which in turn will allow SkCodec to remove
SkCodec::FrameInfo::fRequiredFrame. Currently, SkCodec seeks through the
stream to determine frame dependencies, but this is unnecessary work
(and storage) for a client that does not want to seek.

These fields also support the proposed APIs in go/animated-ndk.

Move SkCodecAnimation::Blend from SkCodecAnimationPriv (and delete that
file) into SkCodecAnimation.h. Rename its values to be more clear.

Merge common code for populating SkCodec::FrameInfo.

Add a test for a GIF with offsets outside the range of the image. Note
that libwebp rejects such an image.

Update libgifcodec.

Change-Id: Ie27e0531e7d62eaae153eccb3105bf2121b5aac4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339857
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Nigel Tao <nigeltao@google.com>
2020-12-02 22:37:20 +00:00

62 lines
1.6 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkCodecAnimation_DEFINED
#define SkCodecAnimation_DEFINED
namespace SkCodecAnimation {
/**
* This specifies how the next frame is based on this frame.
*
* Names are based on the GIF 89a spec.
*
* The numbers correspond to values in a GIF.
*/
enum class DisposalMethod {
/**
* The next frame should be drawn on top of this one.
*
* In a GIF, a value of 0 (not specified) is also treated as Keep.
*/
kKeep = 1,
/**
* Similar to Keep, except the area inside this frame's rectangle
* should be cleared to the BackGround color (transparent) before
* drawing the next frame.
*/
kRestoreBGColor = 2,
/**
* The next frame should be drawn on top of the previous frame - i.e.
* disregarding this one.
*
* In a GIF, a value of 4 is also treated as RestorePrevious.
*/
kRestorePrevious = 3,
};
/**
* How to blend the current frame.
*/
enum class Blend {
/**
* Blend with the prior frame as if using SkBlendMode::kSrcOver.
*/
kSrcOver,
/**
* Blend with the prior frame as if using SkBlendMode::kSrc.
*
* This frame's pixels replace the destination pixels.
*/
kSrc,
};
} // namespace SkCodecAnimation
#endif // SkCodecAnimation_DEFINED