void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask,
const VRle &matteRle)
{
- mDrawableList.clear();
- renderList(mDrawableList);
+ auto renderlist = renderList();
+
+ if (renderlist.empty()) return;
VRle mask;
if (mLayerMask) {
mask = inheritMask;
}
- for (auto &i : mDrawableList) {
+ for (auto &i : renderlist) {
painter->setBrush(i->mBrush);
VRle rle = i->rle();
if (matteRle.empty()) {
}
}
}
-void LOTCompLayerItem::renderList(std::vector<VDrawable *> &list)
-{
- if (skipRendering()) return;
-
- LOTLayerItem *matte = nullptr;
- for (const auto &layer : mLayers) {
- if (layer->hasMatte()) {
- matte = layer.get();
- } else {
- if (layer->visible()) {
- if (matte) {
- if (matte->visible()) {
- layer->renderList(list);
- matte->renderList(list);
- }
- } else {
- layer->renderList(list);
- }
- }
- matte = nullptr;
- }
- }
-}
LOTSolidLayerItem::LOTSolidLayerItem(LOTLayerData *layerData)
: LOTLayerItem(layerData)
{
+ mDrawableList = &mRenderNode;
}
void LOTSolidLayerItem::updateContent()
mRenderNode.preprocess(clip);
}
-void LOTSolidLayerItem::renderList(std::vector<VDrawable *> &list)
+DrawableList LOTSolidLayerItem::renderList()
{
- if (skipRendering()) return;
+ if (skipRendering()) return {};
- list.push_back(&mRenderNode);
+ return {&mDrawableList , 1};
}
LOTImageLayerItem::LOTImageLayerItem(LOTLayerData *layerData)
: LOTLayerItem(layerData)
{
+ mDrawableList = &mRenderNode;
+
if (!mLayerData->asset()) return;
mTexture.mBitmap = mLayerData->asset()->bitmap();
mRenderNode.preprocess(clip);
}
-void LOTImageLayerItem::renderList(std::vector<VDrawable *> &list)
+DrawableList LOTImageLayerItem::renderList()
{
- if (skipRendering()) return;
+ if (skipRendering()) return {};
- list.push_back(&mRenderNode);
+ return {&mDrawableList , 1};
}
LOTNullLayerItem::LOTNullLayerItem(LOTLayerData *layerData)
}
-void LOTShapeLayerItem::renderList(std::vector<VDrawable *> &list)
+DrawableList LOTShapeLayerItem::renderList()
{
- if (skipRendering()) return;
- mRoot->renderList(list);
+ if (skipRendering()) return {};
+
+ mDrawableList.clear();
+ mRoot->renderList(mDrawableList);
+
+ if (mDrawableList.empty()) return {};
+
+ return {mDrawableList.data() , mDrawableList.size()};
}
bool LOTContentGroupItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth,
VSize mViewSize;
LOTCompositionData *mCompData;
std::unique_ptr<LOTLayerItem> mRootLayer;
- bool mKeepAspectRatio{true};
int mCurFrameNo;
- std::vector<LOTNode *> mRenderList;
- std::vector<VDrawable *> mDrawableList;
+ bool mKeepAspectRatio{true};
};
class LOTLayerMaskItem;
std::vector<LOTNode *> mCNodeList;
};
+template< class T>
+class VSpan
+{
+public:
+ using reference = T &;
+ using pointer = T *;
+ using const_pointer = T const *;
+ using const_reference = T const &;
+ using index_type = size_t;
+
+ using iterator = pointer;
+ using const_iterator = const_pointer;
+
+ VSpan() = default;
+ VSpan(pointer data, index_type size):_data(data), _size(size){}
+
+ constexpr pointer data() const noexcept {return _data; }
+ constexpr index_type size() const noexcept {return _size; }
+ constexpr bool empty() const noexcept { return size() == 0 ;}
+ constexpr iterator begin() const noexcept { return data(); }
+ constexpr iterator end() const noexcept {return data() + size() ;}
+ constexpr const_iterator cbegin() const noexcept {return data();}
+ constexpr const_iterator cend() const noexcept { return data() + size();}
+ constexpr reference operator[]( index_type idx ) const { return *( data() + idx );}
+
+private:
+ pointer _data{nullptr};
+ index_type _size{0};
+};
+
+using DrawableList = VSpan<VDrawable *>;
+
class LOTLayerItem
{
public:
virtual void update(int frameNo, const VMatrix &parentMatrix, float parentAlpha);
VMatrix matrix(int frameNo) const;
void preprocess(const VRect& clip);
- virtual void renderList(std::vector<VDrawable *> &){}
+ virtual DrawableList renderList(){ return {};}
virtual void render(VPainter *painter, const VRle &mask, const VRle &matteRle);
bool hasMatte() { if (mLayerData->mMatteType == MatteType::None) return false; return true; }
MatteType matteType() const { return mLayerData->mMatteType;}
inline DirtyFlag flag() const {return mDirtyFlag;}
bool skipRendering() const {return (!visible() || vIsZero(combinedAlpha()));}
protected:
- std::vector<VDrawable *> mDrawableList;
std::unique_ptr<LOTLayerMaskItem> mLayerMask;
LOTLayerData *mLayerData{nullptr};
LOTLayerItem *mParentLayer{nullptr};
public:
explicit LOTCompLayerItem(LOTLayerData *layerData);
- void renderList(std::vector<VDrawable *> &list)final;
void render(VPainter *painter, const VRle &mask, const VRle &matteRle) final;
void buildLayerNode() final;
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value) override;
public:
explicit LOTSolidLayerItem(LOTLayerData *layerData);
void buildLayerNode() final;
+ DrawableList renderList() final;
protected:
void preprocessStage(const VRect& clip) final;
void updateContent() final;
- void renderList(std::vector<VDrawable *> &list) final;
private:
LOTDrawable mRenderNode;
+ VDrawable *mDrawableList{nullptr}; //to work with the Span api
};
class LOTContentItem;
public:
explicit LOTShapeLayerItem(LOTLayerData *layerData);
static std::unique_ptr<LOTContentItem> createContentItem(LOTData *contentData);
- void renderList(std::vector<VDrawable *> &list)final;
+ DrawableList renderList() final;
void buildLayerNode() final;
bool resolveKeyPath(LOTKeyPath &keyPath, uint depth, LOTVariant &value) override;
protected:
void preprocessStage(const VRect& clip) final;
void updateContent() final;
+ std::vector<VDrawable *> mDrawableList;
std::unique_ptr<LOTContentGroupItem> mRoot;
};
public:
explicit LOTImageLayerItem(LOTLayerData *layerData);
void buildLayerNode() final;
+ DrawableList renderList() final;
protected:
void preprocessStage(const VRect& clip) final;
void updateContent() final;
- void renderList(std::vector<VDrawable *> &list) final;
private:
LOTDrawable mRenderNode;
VTexture mTexture;
+ VDrawable *mDrawableList{nullptr}; //to work with the Span api
};
class LOTMaskItem
{
LOTLayerItem::buildLayerNode();
- mDrawableList.clear();
- renderList(mDrawableList);
+ auto renderlist = renderList();
cnodes().clear();
- for (auto &i : mDrawableList) {
+ for (auto &i : renderlist) {
auto lotDrawable = static_cast<LOTDrawable *>(i);
lotDrawable->sync();
cnodes().push_back(lotDrawable->mCNode.get());
{
LOTLayerItem::buildLayerNode();
- mDrawableList.clear();
- renderList(mDrawableList);
+ auto renderlist = renderList();
cnodes().clear();
- for (auto &i : mDrawableList) {
+ for (auto &i : renderlist) {
auto lotDrawable = static_cast<LOTDrawable *>(i);
lotDrawable->sync();
cnodes().push_back(lotDrawable->mCNode.get());
{
LOTLayerItem::buildLayerNode();
- mDrawableList.clear();
- renderList(mDrawableList);
+ auto renderlist = renderList();
cnodes().clear();
- for (auto &i : mDrawableList) {
+ for (auto &i : renderlist) {
auto lotDrawable = static_cast<LOTDrawable *>(i);
lotDrawable->sync();