diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm index 8a63baf5a7..a4903b4bb6 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm @@ -8,6 +8,30 @@ namespace lottie { +static void processRenderContentItem(std::shared_ptr const &contentItem, std::optional &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 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 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 const &node, Vecto namespace { static void drawLottieContentItem(std::shared_ptr context, std::shared_ptr 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 conte } } } + + for (const auto &subItem : item->subItems) { + drawLottieContentItem(context, subItem); + } } static void renderLottieRenderNode(std::shared_ptr node, std::shared_ptr parentContext, lottie::Vector2D const &globalSize, double parentAlpha) { diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.cpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.cpp index 096d140b12..1ffaff84f8 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.cpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.cpp @@ -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()) {