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 {
|
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) {
|
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) {
|
if (node->isHidden() || node->alpha() == 0.0f) {
|
||||||
node->renderData.isValid = false;
|
node->renderData.isValid = false;
|
||||||
@ -39,24 +63,7 @@ static void processRenderTree(std::shared_ptr<RenderTreeNode> const &node, Vecto
|
|||||||
double alpha = node->alpha();
|
double alpha = node->alpha();
|
||||||
|
|
||||||
if (node->_contentItem) {
|
if (node->_contentItem) {
|
||||||
RenderTreeNodeContentItem *contentItem = node->_contentItem.get();
|
processRenderContentItem(node->_contentItem, effectiveLocalBounds, 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInvertedMatte = isInvertedMask;
|
bool isInvertedMatte = isInvertedMask;
|
||||||
@ -189,10 +196,6 @@ static void processRenderTree(std::shared_ptr<RenderTreeNode> const &node, Vecto
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static void drawLottieContentItem(std::shared_ptr<lottieRendering::Canvas> context, std::shared_ptr<lottie::RenderTreeNodeContentItem> item) {
|
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) {
|
for (const auto &shading : item->shadings) {
|
||||||
if (shading->explicitPath->empty()) {
|
if (shading->explicitPath->empty()) {
|
||||||
continue;
|
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) {
|
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--) {
|
for (int i = (int)subItems.size() - 1; i >= 0; i--) {
|
||||||
subItems[i]->initializeRenderChildren();
|
subItems[i]->initializeRenderChildren();
|
||||||
subItemNodes.push_back(subItems[i]->_renderTree);
|
subItemNodes.push_back(subItems[i]->_renderTree);
|
||||||
|
//_renderTree->_contentItem->subItems.push_back(subItems[i]->_renderTree->_contentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!subItemNodes.empty()) {
|
if (!subItemNodes.empty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user