bc098ef6d4
Bug: skia:10914 SkAnimCodecPlayer: - Properly handle orientation, whether the image is still or not - Mark const methods as const - Fix seek() so that if you seek to the duration of frame 0, it will show frame 1 - Fix the SkImageInfo so if the first frame is opaque, but following frames are not, those frames can still be decoded resources: - Rename "webp-animated.webp" to "stoplight.webp", which better describes the animation - Update test files accordingly - Add "stoplight_h.webp", which is the same animation with an EXIF that converts it to a horizontal stoplight AnimCodecPlayer test: - Test the new image files - Verify SkAnimCodecPlayer::dimensions behaves as expected - Remove extra debugging line - Provide better error messages AnimCodecPlayerExifGM: - Add a new GM that shows all frames of the new animation with an EXIF orientation - Add a new GM that shows all frames of an animation with an opaque first frame followed by frames with alpha Change-Id: I43cf91c16d52aa1901eef8e13e1e644eea6058b3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332753 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
/*
|
|
* Copyright 2018 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkAnimCodecPlayer_DEFINED
|
|
#define SkAnimCodecPlayer_DEFINED
|
|
|
|
#include "include/codec/SkCodec.h"
|
|
|
|
class SkImage;
|
|
|
|
class SkAnimCodecPlayer {
|
|
public:
|
|
SkAnimCodecPlayer(std::unique_ptr<SkCodec> codec);
|
|
~SkAnimCodecPlayer();
|
|
|
|
/**
|
|
* Returns the current frame of the animation. This defaults to the first frame for
|
|
* animated codecs (i.e. msec = 0). Calling this multiple times (without calling seek())
|
|
* will always return the same image object (or null if there was an error).
|
|
*/
|
|
sk_sp<SkImage> getFrame();
|
|
|
|
/**
|
|
* Return the size of the image(s) that will be returned by getFrame().
|
|
*/
|
|
SkISize dimensions() const;
|
|
|
|
/**
|
|
* Returns the total duration of the animation in milliseconds. Returns 0 for a single-frame
|
|
* image.
|
|
*/
|
|
uint32_t duration() const { return fTotalDuration; }
|
|
|
|
/**
|
|
* Finds the closest frame associated with the time code (in milliseconds) and sets that
|
|
* to be the current frame (call getFrame() to retrieve that image).
|
|
* Returns true iff this call to seek() changed the "current frame" for the animation.
|
|
* Thus if seek() returns false, then getFrame() will return the same image as it did
|
|
* before this call to seek().
|
|
*/
|
|
bool seek(uint32_t msec);
|
|
|
|
|
|
private:
|
|
std::unique_ptr<SkCodec> fCodec;
|
|
SkImageInfo fImageInfo;
|
|
std::vector<SkCodec::FrameInfo> fFrameInfos;
|
|
std::vector<sk_sp<SkImage> > fImages;
|
|
int fCurrIndex = 0;
|
|
uint32_t fTotalDuration;
|
|
|
|
sk_sp<SkImage> getFrameAt(int index);
|
|
};
|
|
|
|
#endif
|
|
|