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; }
|
|
|
|
|
2018-01-22 17:57:06 +00:00
|
|
|
namespace sksg { class Scene; }
|
2017-12-30 17:27:00 +00:00
|
|
|
|
2018-01-16 22:04:30 +00:00
|
|
|
namespace skottie {
|
2017-12-30 17:27:00 +00:00
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2018-02-23 16:10:22 +00:00
|
|
|
class Animation : public SkRefCnt {
|
2017-12-30 17:27:00 +00:00
|
|
|
public:
|
2018-02-23 16:10:22 +00:00
|
|
|
static sk_sp<Animation> Make(SkStream*, const ResourceProvider&);
|
|
|
|
static sk_sp<Animation> MakeFromFile(const char path[], const ResourceProvider* = nullptr);
|
2017-12-30 17:27:00 +00:00
|
|
|
|
2018-02-23 16:10:22 +00:00
|
|
|
~Animation() override;
|
2017-12-30 17:27:00 +00:00
|
|
|
|
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
|
|
|
|
2018-01-22 17:57:06 +00:00
|
|
|
void setShowInval(bool show);
|
2017-12-30 17:27:00 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2018-01-22 17:57:06 +00:00
|
|
|
SkString fVersion;
|
|
|
|
SkSize fSize;
|
|
|
|
SkScalar fFrameRate,
|
|
|
|
fInPoint,
|
|
|
|
fOutPoint;
|
2017-12-30 17:27:00 +00:00
|
|
|
|
2018-01-22 17:57:06 +00:00
|
|
|
std::unique_ptr<sksg::Scene> fScene;
|
2017-12-30 17:27:00 +00:00
|
|
|
|
2018-02-23 16:10:22 +00:00
|
|
|
typedef SkRefCnt INHERITED;
|
2017-12-30 17:27:00 +00:00
|
|
|
};
|
|
|
|
|
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
|