mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 05:51:42 +00:00
lottie: pass matteSource and bitmap to layer's render function
matteSource layer has to be handled in other way. For now, matteSource layer does not be applied to layers. But, matteSource layer will be invisible. In some test cases, it helps to check other layers which are overlayed by a wrongly drawn matteSource layer. Anyway, the matte feature will be implemented soon. Change-Id: Ib1e47e7ce9012b73a1729341d130defa561061c6
This commit is contained in:
parent
308d8cf4ba
commit
ff13f55ad4
@ -119,7 +119,7 @@ bool LOTCompItem::render(const LOTBuffer &buffer)
|
||||
|
||||
VPainter painter(&bitmap);
|
||||
VRle mask;
|
||||
mRootLayer->render(&painter, mask);
|
||||
mRootLayer->render(&painter, mask, nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -156,8 +156,16 @@ VRle LOTMaskItem::rle()
|
||||
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;
|
||||
@ -170,12 +178,17 @@ void LOTLayerItem::render(VPainter *painter, const VRle &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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,8 +339,17 @@ void LOTCompLayerItem::updateStaticProperty()
|
||||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
@ -337,9 +359,21 @@ void LOTCompLayerItem::render(VPainter *painter, const VRle &inheritMask)
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +64,9 @@ public:
|
||||
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;}
|
||||
@ -96,7 +98,7 @@ public:
|
||||
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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user