2017-12-30 17:27:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2018-01-16 22:04:30 +00:00
|
|
|
#ifndef Skottie_DEFINED
|
|
|
|
#define Skottie_DEFINED
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "SkSize.h"
|
|
|
|
#include "SkString.h"
|
|
|
|
#include "SkTArray.h"
|
|
|
|
#include "SkTHash.h"
|
|
|
|
#include "SkTypes.h"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class SkCanvas;
|
2018-01-08 13:25:27 +00:00
|
|
|
struct SkRect;
|
2017-12-30 17:27:00 +00:00
|
|
|
class SkStream;
|
|
|
|
|
|
|
|
namespace Json { class Value; }
|
|
|
|
|
|
|
|
namespace sksg { class RenderNode; }
|
|
|
|
|
2018-01-16 22:04:30 +00:00
|
|
|
namespace skottie {
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
class AnimatorBase;
|
|
|
|
|
2018-01-08 17:51:12 +00:00
|
|
|
class ResourceProvider : public SkNoncopyable {
|
|
|
|
public:
|
|
|
|
virtual ~ResourceProvider() = default;
|
|
|
|
|
|
|
|
virtual std::unique_ptr<SkStream> openStream(const char resource[]) const = 0;
|
|
|
|
};
|
|
|
|
|
2017-12-30 17:27:00 +00:00
|
|
|
class Animation : public SkNoncopyable {
|
|
|
|
public:
|
2018-01-08 17:51:12 +00:00
|
|
|
static std::unique_ptr<Animation> Make(SkStream*, const ResourceProvider&);
|
|
|
|
static std::unique_ptr<Animation> MakeFromFile(const char path[],
|
|
|
|
const ResourceProvider* = nullptr);
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
~Animation();
|
|
|
|
|
2018-01-08 13:25:27 +00:00
|
|
|
void render(SkCanvas*, const SkRect* dst = nullptr) const;
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
void animationTick(SkMSec);
|
|
|
|
|
2017-12-31 16:08:42 +00:00
|
|
|
const SkString& version() const { return fVersion; }
|
|
|
|
const SkSize& size() const { return fSize; }
|
|
|
|
SkScalar frameRate() const { return fFrameRate; }
|
|
|
|
SkScalar inPoint() const { return fInPoint; }
|
|
|
|
SkScalar outPoint() const { return fOutPoint; }
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
void setShowInval(bool show) { fShowInval = show; }
|
|
|
|
|
|
|
|
private:
|
2018-01-08 17:51:12 +00:00
|
|
|
Animation(const ResourceProvider&,
|
|
|
|
SkString ver, const SkSize& size, SkScalar fps,
|
|
|
|
const Json::Value&);
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
SkString fVersion;
|
|
|
|
SkSize fSize;
|
|
|
|
SkScalar fFrameRate,
|
|
|
|
fInPoint,
|
|
|
|
fOutPoint;
|
|
|
|
|
|
|
|
sk_sp<sksg::RenderNode> fDom;
|
|
|
|
SkTArray<std::unique_ptr<AnimatorBase>> fAnimators;
|
|
|
|
|
|
|
|
bool fShowInval = false;
|
|
|
|
|
|
|
|
typedef SkNoncopyable INHERITED;
|
|
|
|
};
|
|
|
|
|
2018-01-16 22:04:30 +00:00
|
|
|
} // namespace skottie
|
2017-12-30 17:27:00 +00:00
|
|
|
|
2018-01-16 22:04:30 +00:00
|
|
|
#endif // Skottie_DEFINED
|