VPainter painter(&bitmap);
VRle mask;
- mRootLayer->render(&painter, mask);
+ mRootLayer->render(&painter, mask, nullptr);
return true;
}
return mRle;
}
-void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask)
+void LOTLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLayerItem *matteSource)
{
+ VRle matteRle;
+ if (matteSource) {
+ std::vector<VDrawable *> matteList;
+ matteSource->renderList(matteList);
+ for (auto &i : matteList) {
+ matteRle = matteRle + i->rle();
+ }
+ }
std::vector<VDrawable *> list;
renderList(list);
VRle mask = inheritMask;
for (auto &i : list) {
painter->setBrush(i->mBrush);
- if (!mask.isEmpty()) {
- VRle rle = i->rle() & mask;
- painter->drawRle(VPoint(), rle);
- } else {
- painter->drawRle(VPoint(), i->rle());
+ VRle rle = i->rle();
+ if (!mask.isEmpty()) rle = i->rle() & mask;
+
+ if (!matteRle.isEmpty()) {
+ if (mLayerData->mMatteType == MatteType::AlphaInv) {
+ rle = rle - matteRle;
+ } else {
+ rle = rle & matteRle;
+ }
}
+ painter->drawRle(VPoint(), rle);
}
}
}
}
-void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask)
+void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask, LOTLayerItem *matteSource)
{
+ VRle matteRle;
+ if (matteSource) {
+ std::vector<VDrawable *> matteList;
+ matteSource->renderList(matteList);
+ for (auto &i : matteList) {
+ matteRle = matteRle + i->rle();
+ }
+ }
+
VRle mask = inheritMask;
if (hasMask()) {
mask = mask & inheritMask;
}
+ LOTLayerItem *matteLayer = nullptr;
for (auto i = mLayers.rbegin(); i != mLayers.rend(); ++i) {
LOTLayerItem *layer = *i;
- layer->render(painter, mask);
+
+ if (!matteLayer && layer->hasMatte()) {
+ matteLayer = layer;
+ continue;
+ }
+
+ if (matteLayer) {
+ matteLayer->render(painter, mask, layer);
+ matteLayer = nullptr;
+ } else {
+ layer->render(painter, mask, nullptr);
+ }
}
}
VMatrix matrix(int frameNo) const;
virtual void renderList(std::vector<VDrawable *> &list){}
virtual void updateStaticProperty();
- virtual void render(VPainter *painter, const VRle &mask);
+ virtual void render(VPainter *painter, const VRle &mask, LOTLayerItem *matteSource);
+ bool hasMatte() { if (mLayerData->mMatteType == MatteType::None) return false; return true; }
+
protected:
virtual void updateContent() = 0;
inline VMatrix combinedMatrix() const {return mCombinedMatrix;}
LOTCompLayerItem(LOTLayerData *layerData);
void renderList(std::vector<VDrawable *> &list)final;
void updateStaticProperty() final;
- void render(VPainter *painter, const VRle &mask) final;
+ void render(VPainter *painter, const VRle &mask, LOTLayerItem *matteSource) final;
protected:
void updateContent() final;
private: