Skip to content

Commit

Permalink
Translate shape as a separate visual with child if it has animated op…
Browse files Browse the repository at this point in the history
…acity (#459)
  • Loading branch information
aborziak-ms authored Aug 16, 2021
1 parent e0a2b5a commit f5a5e97
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion source/LottieToWinComp/Shapes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,17 @@ internal ShapeLayerTranslator(ShapeLayerContext context)
_context = context;
}

// Indicates if we can translate shape layer as a single composition shape (GetShapeRoot).
// Otherwise we should use extra parent Visual (GetVisualRoot).
//
// Note: We can apply Masks and effects only to Visual node.
// Also we can reduce number of expression animations if we apply opacity directly to visual node
// instead of pushing it down to color fill that will produce color expression animation.
internal override bool IsShape =>
!_context.Layer.Masks.Any() &&
_context.Effects.DropShadowEffect is null &&
_context.Effects.GaussianBlurEffect is null;
_context.Effects.GaussianBlurEffect is null &&
_context.Layer.Transform.Opacity.IsAlways(Opacity.Opaque);

internal override CompositionShape? GetShapeRoot(TranslationContext context)
{
Expand All @@ -668,6 +675,9 @@ _context.Effects.DropShadowEffect is null &&

// Update the opacity from the transform. This is necessary to push the opacity
// to the leaves (because CompositionShape does not support opacity).
// Note: this is no longer used because we will not call GetShapeRoot if layer transform has
// animated opacity, instead we will call GetVisualRoot. But let's keep it here
// just in case we will change the logic of IsShape flag.
shapeContext.UpdateOpacityFromTransform(_context, _context.Layer.Transform);
contentsNode.Shapes.Add(TranslateShapeLayerContents(shapeContext, _context.Layer.Contents));

Expand Down

0 comments on commit f5a5e97

Please sign in to comment.