Lottie optimization

This commit is contained in:
Isaac 2024-05-14 23:05:11 +04:00
parent 920de21020
commit ea4a203285
3 changed files with 15 additions and 78 deletions

View File

@ -38,55 +38,27 @@ static void processRenderTree(std::shared_ptr<RenderTreeNode> const &node, Vecto
double alpha = node->alpha();
/*if (node->_contentItem) {
if (node->_contentItem) {
RenderTreeNodeContentItem *contentItem = node->_contentItem.get();
for (const auto &shadingVariant : contentItem->shadings) {
CGRect shapeBounds = bezierPathsBoundingBoxParallel(bezierPathsBoundingBoxContext, shadingVariant->explicitPath.value());
if (shadingVariant->stroke) {
CGRect shapeBounds = bezierPathsBoundingBoxParallel(bezierPathsBoundingBoxContext, shadingVariant->explicitPath.value());
shapeBounds = shapeBounds.insetBy(-shadingVariant->stroke->lineWidth / 2.0, -shadingVariant->stroke->lineWidth / 2.0);
effectiveLocalBounds = shapeBounds;
switch (shadingVariant->stroke->shading->type()) {
case RenderTreeNodeContent::ShadingType::Solid: {
RenderTreeNodeContent::SolidShading *solidShading = (RenderTreeNodeContent::SolidShading *)shadingVariant->stroke->shading.get();
alpha *= solidShading->opacity;
break;
}
case RenderTreeNodeContent::ShadingType::Gradient: {
break;
}
default:
break;
if (effectiveLocalBounds) {
effectiveLocalBounds = effectiveLocalBounds->unionWith(shapeBounds);
} else {
effectiveLocalBounds = shapeBounds;
}
} else if (shadingVariant->fill) {
CGRect shapeBounds = bezierPathsBoundingBoxParallel(bezierPathsBoundingBoxContext, shadingVariant->explicitPath.value());
effectiveLocalBounds = shapeBounds;
switch (shadingVariant->fill->shading->type()) {
case RenderTreeNodeContent::ShadingType::Solid: {
RenderTreeNodeContent::SolidShading *solidShading = (RenderTreeNodeContent::SolidShading *)shadingVariant->fill->shading.get();
alpha *= solidShading->opacity;
break;
}
case RenderTreeNodeContent::ShadingType::Gradient: {
RenderTreeNodeContent::GradientShading *gradientShading = (RenderTreeNodeContent::GradientShading *)shadingVariant->fill->shading.get();
alpha *= gradientShading->opacity;
break;
}
default:
break;
if (effectiveLocalBounds) {
effectiveLocalBounds = effectiveLocalBounds->unionWith(shapeBounds);
} else {
effectiveLocalBounds = shapeBounds;
}
}
}
}*/
if (node->content()) {
}
/*if (node->content()) {
RenderTreeNodeContent *shapeContent = node->content().get();
CGRect shapeBounds = bezierPathsBoundingBoxParallel(bezierPathsBoundingBoxContext, shapeContent->paths);
@ -94,45 +66,10 @@ static void processRenderTree(std::shared_ptr<RenderTreeNode> const &node, Vecto
if (shapeContent->stroke) {
shapeBounds = shapeBounds.insetBy(-shapeContent->stroke->lineWidth / 2.0, -shapeContent->stroke->lineWidth / 2.0);
effectiveLocalBounds = shapeBounds;
/*switch (shapeContent->stroke->shading->type()) {
case RenderTreeNodeContent::ShadingType::Solid: {
RenderTreeNodeContent::SolidShading *solidShading = (RenderTreeNodeContent::SolidShading *)shapeContent->stroke->shading.get();
alpha *= solidShading->opacity;
break;
}
case RenderTreeNodeContent::ShadingType::Gradient: {
break;
}
default:
break;
}*/
} else if (shapeContent->fill) {
effectiveLocalBounds = shapeBounds;
/*switch (shapeContent->fill->shading->type()) {
case RenderTreeNodeContent::ShadingType::Solid: {
RenderTreeNodeContent::SolidShading *solidShading = (RenderTreeNodeContent::SolidShading *)shapeContent->fill->shading.get();
alpha *= solidShading->opacity;
break;
}
case RenderTreeNodeContent::ShadingType::Gradient: {
RenderTreeNodeContent::GradientShading *gradientShading = (RenderTreeNodeContent::GradientShading *)shapeContent->fill->shading.get();
alpha *= gradientShading->opacity;
break;
}
default:
break;
}*/
}
}
}*/
bool isInvertedMatte = isInvertedMask;
if (isInvertedMatte) {

View File

@ -78,7 +78,7 @@ private final class ReferenceCompareTest {
}
var continueFromName: String?
//continueFromName = "35707580709863498.json"
//continueFromName = "778160933443732778.json"
let _ = await processAnimationFolderAsync(basePath: bundlePath, path: "", stopOnFailure: true, process: { path, name, alwaysDraw in
if let continueFromNameValue = continueFromName {

View File

@ -1011,7 +1011,7 @@ public:
false
);
shadingVariant.renderTree = shadingRenderTree;
_renderTree->_subnodes.push_back(shadingRenderTree);
//_renderTree->_subnodes.push_back(shadingRenderTree);
auto itemShadingVariant = std::make_shared<RenderTreeNodeContentShadingVariant>();
if (shadingVariant.fill) {