45cd20004c
"Artboards" are top-level Rive containers (similar to AE compositions), holding the scene graphics and related animations. Artboard properties: - name - width/height (size) - translation (position) - origin (anchor point for transforms?) - (background) color - clip contents flag Plumb artboard parsing + background rendering, and hook into viewer. TBR= Change-Id: Ib188245ce41a76197cf9e0937689adf8243826d6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295244 Reviewed-by: Florin Malita <fmalita@google.com> Commit-Queue: Florin Malita <fmalita@google.com>
64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
/*
|
|
* Copyright 2020 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkRive_DEFINED
|
|
#define SkRive_DEFINED
|
|
|
|
#include "include/core/SkM44.h"
|
|
#include "include/core/SkRefCnt.h"
|
|
#include "include/core/SkString.h"
|
|
#include "modules/sksg/include/SkSGRenderNode.h"
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
class SkStreamAsset;
|
|
|
|
namespace skrive {
|
|
|
|
class Artboard final : public sksg::RenderNode {
|
|
public:
|
|
SG_ATTRIBUTE(Name , SkString , fName ) // TODO: non-invalidating attributes?
|
|
SG_ATTRIBUTE(Color , SkColor4f, fColor )
|
|
SG_ATTRIBUTE(Size , SkV2 , fSize )
|
|
SG_ATTRIBUTE(Origin , SkV2 , fOrigin )
|
|
SG_ATTRIBUTE(Translation , SkV2 , fTranslation )
|
|
SG_ATTRIBUTE(ClipContents, bool , fClipContents)
|
|
|
|
private:
|
|
SkRect onRevalidate(sksg::InvalidationController*, const SkMatrix&) override;
|
|
void onRender(SkCanvas*, const RenderContext*) const override;
|
|
const RenderNode* onNodeAt(const SkPoint&) const override;
|
|
|
|
SkString fName;
|
|
SkColor4f fColor = {0, 0, 0, 1};
|
|
SkV2 fSize = {0, 0},
|
|
fOrigin = {0, 0},
|
|
fTranslation = {0, 0};
|
|
bool fClipContents = false;
|
|
|
|
using INHERITED = RenderNode;
|
|
};
|
|
|
|
class SK_API SkRive final : public SkNVRefCnt<SkRive> {
|
|
public:
|
|
class Builder final {
|
|
public:
|
|
sk_sp<SkRive> make(std::unique_ptr<SkStreamAsset>);
|
|
};
|
|
|
|
const std::vector<sk_sp<Artboard>>& artboards() const { return fArtboards; }
|
|
std::vector<sk_sp<Artboard>>& artboards() { return fArtboards; }
|
|
|
|
private:
|
|
std::vector<sk_sp<Artboard>> fArtboards;
|
|
};
|
|
|
|
} // skrive
|
|
|
|
#endif // SkRive_DEFINED
|