mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
[WIP] Lottie
This commit is contained in:
parent
bf292c0066
commit
2d06c977ed
@ -8,6 +8,30 @@
|
||||
|
||||
namespace lottie {
|
||||
|
||||
static void processRenderContentItem(std::shared_ptr<RenderTreeNodeContentItem> const &contentItem, std::optional<CGRect> &effectiveLocalBounds, BezierPathsBoundingBoxContext &bezierPathsBoundingBoxContext) {
|
||||
for (const auto &shadingVariant : contentItem->shadings) {
|
||||
CGRect shapeBounds = bezierPathsBoundingBoxParallel(bezierPathsBoundingBoxContext, shadingVariant->explicitPath.value());
|
||||
if (shadingVariant->stroke) {
|
||||
shapeBounds = shapeBounds.insetBy(-shadingVariant->stroke->lineWidth / 2.0, -shadingVariant->stroke->lineWidth / 2.0);
|
||||
if (effectiveLocalBounds) {
|
||||
effectiveLocalBounds = effectiveLocalBounds->unionWith(shapeBounds);
|
||||
} else {
|
||||
effectiveLocalBounds = shapeBounds;
|
||||
}
|
||||
} else if (shadingVariant->fill) {
|
||||
if (effectiveLocalBounds) {
|
||||
effectiveLocalBounds = effectiveLocalBounds->unionWith(shapeBounds);
|
||||
} else {
|
||||
effectiveLocalBounds = shapeBounds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &subItem : contentItem->subItems) {
|
||||
processRenderContentItem(subItem, effectiveLocalBounds, bezierPathsBoundingBoxContext);
|
||||
}
|
||||
}
|
||||
|
||||
static void processRenderTree(std::shared_ptr<RenderTreeNode> const &node, Vector2D const &globalSize, CATransform3D const &parentTransform, bool isInvertedMask, BezierPathsBoundingBoxContext &bezierPathsBoundingBoxContext) {
|
||||
if (node->isHidden() || node->alpha() == 0.0f) {
|
||||
node->renderData.isValid = false;
|
||||
@ -39,24 +63,7 @@ static void processRenderTree(std::shared_ptr<RenderTreeNode> const &node, Vecto
|
||||
double alpha = node->alpha();
|
||||
|
||||
if (node->_contentItem) {
|
||||
RenderTreeNodeContentItem *contentItem = node->_contentItem.get();
|
||||
for (const auto &shadingVariant : contentItem->shadings) {
|
||||
CGRect shapeBounds = bezierPathsBoundingBoxParallel(bezierPathsBoundingBoxContext, shadingVariant->explicitPath.value());
|
||||
if (shadingVariant->stroke) {
|
||||
shapeBounds = shapeBounds.insetBy(-shadingVariant->stroke->lineWidth / 2.0, -shadingVariant->stroke->lineWidth / 2.0);
|
||||
if (effectiveLocalBounds) {
|
||||
effectiveLocalBounds = effectiveLocalBounds->unionWith(shapeBounds);
|
||||
} else {
|
||||
effectiveLocalBounds = shapeBounds;
|
||||
}
|
||||
} else if (shadingVariant->fill) {
|
||||
if (effectiveLocalBounds) {
|
||||
effectiveLocalBounds = effectiveLocalBounds->unionWith(shapeBounds);
|
||||
} else {
|
||||
effectiveLocalBounds = shapeBounds;
|
||||
}
|
||||
}
|
||||
}
|
||||
processRenderContentItem(node->_contentItem, effectiveLocalBounds, bezierPathsBoundingBoxContext);
|
||||
}
|
||||
|
||||
bool isInvertedMatte = isInvertedMask;
|
||||
@ -189,10 +196,6 @@ static void processRenderTree(std::shared_ptr<RenderTreeNode> const &node, Vecto
|
||||
namespace {
|
||||
|
||||
static void drawLottieContentItem(std::shared_ptr<lottieRendering::Canvas> context, std::shared_ptr<lottie::RenderTreeNodeContentItem> item) {
|
||||
if (item->shadings.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &shading : item->shadings) {
|
||||
if (shading->explicitPath->empty()) {
|
||||
continue;
|
||||
@ -359,6 +362,10 @@ static void drawLottieContentItem(std::shared_ptr<lottieRendering::Canvas> conte
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &subItem : item->subItems) {
|
||||
drawLottieContentItem(context, subItem);
|
||||
}
|
||||
}
|
||||
|
||||
static void renderLottieRenderNode(std::shared_ptr<lottie::RenderTreeNode> node, std::shared_ptr<lottieRendering::Canvas> parentContext, lottie::Vector2D const &globalSize, double parentAlpha) {
|
||||
|
@ -1034,6 +1034,7 @@ public:
|
||||
for (int i = (int)subItems.size() - 1; i >= 0; i--) {
|
||||
subItems[i]->initializeRenderChildren();
|
||||
subItemNodes.push_back(subItems[i]->_renderTree);
|
||||
//_renderTree->_contentItem->subItems.push_back(subItems[i]->_renderTree->_contentItem);
|
||||
}
|
||||
|
||||
if (!subItemNodes.empty()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user