@@ -709,79 +709,6 @@ from n in graph.CompositionObjectNodes
709709 }
710710 }
711711
712- static VisibilityDescription ComposeVisibilities ( in VisibilityDescription a , in VisibilityDescription b )
713- {
714- if ( a . Sequence . Length == 0 )
715- {
716- return b ;
717- }
718-
719- if ( b . Sequence . Length == 0 )
720- {
721- return a ;
722- }
723-
724- if ( a . Duration != b . Duration )
725- {
726- throw new InvalidOperationException ( ) ;
727- }
728-
729- if ( a . Sequence . SequenceEqual ( b . Sequence ) )
730- {
731- // They're identical.
732- return a ;
733- }
734-
735- // Combine and optimize the 2 sequences.
736- var composedSequence = ComposeVisibilitySequences ( a . Sequence , b . Sequence ) . ToArray ( ) ;
737-
738- return new VisibilityDescription ( a . Duration , composedSequence ) ;
739- }
740-
741- // Composes 2 visibility sequence.
742- static IEnumerable < ( bool isVisible , float progress ) > ComposeVisibilitySequences (
743- ( bool isVisible , float progress ) [ ] a ,
744- ( bool isVisible , float progress ) [ ] b )
745- {
746- var currentVisibility = false ;
747- var currentProgress = 0F ;
748-
749- var ai = 0 ;
750- var bi = 0 ;
751-
752- while ( ai < a . Length || bi < b . Length )
753- {
754- var cura = ai < a . Length ? a [ ai ] : ( a [ a . Length - 1 ] . isVisible , progress : float . MaxValue ) ;
755- var curb = bi < b . Length ? b [ bi ] : ( b [ b . Length - 1 ] . isVisible , progress : float . MaxValue ) ;
756-
757- // Is the visibility changing?
758- if ( ( cura . isVisible & curb . isVisible ) != currentVisibility )
759- {
760- yield return ( currentVisibility , currentProgress ) ;
761- currentVisibility = ! currentVisibility ;
762- }
763-
764- if ( cura . progress == curb . progress )
765- {
766- currentProgress = cura . progress ;
767- ai ++ ;
768- bi ++ ;
769- }
770- else if ( cura . progress < curb . progress )
771- {
772- currentProgress = cura . progress ;
773- ai ++ ;
774- }
775- else
776- {
777- currentProgress = curb . progress ;
778- bi ++ ;
779- }
780- }
781-
782- yield return ( currentVisibility , currentProgress ) ;
783- }
784-
785712 // Find ContainerVisuals that have a single ShapeVisual child with orthongonal properties and
786713 // push the properties down to the ShapeVisual.
787714 static void PushPropertiesDownToShapeVisual ( ObjectGraph < Node > graph )
@@ -875,18 +802,18 @@ void ApplyVisibility(Visual to, VisibilityDescription fromVisibility, Compositio
875802 {
876803 var toVisibility = GetVisiblityAnimationDescription ( to ) ;
877804
878- var compositeVisibility = ComposeVisibilities ( fromVisibility , toVisibility ) ;
805+ var compositeVisibility = VisibilityDescription . Compose ( fromVisibility , toVisibility ) ;
879806
880807 if ( compositeVisibility . Sequence . Length > 0 )
881808 {
882809 _madeProgress = true ;
883810 var c = new Compositor ( ) ;
884811 var animation = c . CreateBooleanKeyFrameAnimation ( ) ;
885812 animation . Duration = compositeVisibility . Duration ;
886- if ( compositeVisibility . Sequence [ 0 ] . progress == 0 )
813+ if ( compositeVisibility . Sequence [ 0 ] . Progress == 0 )
887814 {
888815 // Set the initial visiblity.
889- to . IsVisible = compositeVisibility . Sequence [ 0 ] . isVisible ;
816+ to . IsVisible = compositeVisibility . Sequence [ 0 ] . IsVisible ;
890817 }
891818
892819 foreach ( var ( isVisible , progress ) in compositeVisibility . Sequence )
@@ -919,14 +846,14 @@ static VisibilityDescription GetVisiblityAnimationDescription(Visual visual)
919846
920847 if ( animator is null )
921848 {
922- return new VisibilityDescription ( TimeSpan . Zero , Array . Empty < ( bool , float ) > ( ) ) ;
849+ return new VisibilityDescription ( TimeSpan . Zero , Array . Empty < VisibilityAtProgress > ( ) ) ;
923850 }
924851
925852 var visibilityAnimation = ( BooleanKeyFrameAnimation ) animator . Animation ;
926853
927854 return new VisibilityDescription ( visibilityAnimation . Duration , GetDescription ( ) . ToArray ( ) ) ;
928855
929- IEnumerable < ( bool isVisible , float progress ) > GetDescription ( )
856+ IEnumerable < VisibilityAtProgress > GetDescription ( )
930857 {
931858 if ( animator is null )
932859 {
@@ -947,11 +874,11 @@ static VisibilityDescription GetVisiblityAnimationDescription(Visual visual)
947874 if ( kf . Progress != 0 && visual . IsVisible == false )
948875 {
949876 // Output an initial keyframe.
950- yield return ( false , 0 ) ;
877+ yield return new VisibilityAtProgress ( false , 0 ) ;
951878 }
952879 }
953880
954- yield return ( kf . Value , kf . Progress ) ;
881+ yield return new VisibilityAtProgress ( kf . Value , kf . Progress ) ;
955882 }
956883 }
957884 }
@@ -980,7 +907,7 @@ static VisibilityDescription GetVisiblityAnimationDescription(CompositionShape s
980907
981908 return new VisibilityDescription ( scaleAnimation . Duration , GetDescription ( ) . ToArray ( ) ) ;
982909
983- IEnumerable < ( bool isVisible , float progress ) > GetDescription ( )
910+ IEnumerable < VisibilityAtProgress > GetDescription ( )
984911 {
985912 foreach ( KeyFrameAnimation < Vector2 , Expr . Vector2 > . ValueKeyFrame kf in scaleAnimation . KeyFrames )
986913 {
@@ -1004,11 +931,11 @@ static VisibilityDescription GetVisiblityAnimationDescription(CompositionShape s
1004931 // add a non-visible state at 0.
1005932 if ( kf . Progress != 0 && shape . Scale == Vector2 . Zero )
1006933 {
1007- yield return ( false , 0 ) ;
934+ yield return new VisibilityAtProgress ( false , 0 ) ;
1008935 }
1009936 }
1010937
1011- yield return ( kf . Value == Vector2 . One , kf . Progress ) ;
938+ yield return new VisibilityAtProgress ( kf . Value == Vector2 . One , kf . Progress ) ;
1012939 }
1013940 }
1014941 }
@@ -1513,16 +1440,6 @@ void CopyDescriptions(IDescribable from, IDescribable to)
15131440 static CompositionObject . Animator ? TryGetAnimatorByPropertyName ( CompositionObject obj , string name ) =>
15141441 obj . Animators . Where ( anim => anim . AnimatedProperty == name ) . FirstOrDefault ( ) ;
15151442
1516- readonly struct VisibilityDescription
1517- {
1518- internal VisibilityDescription ( TimeSpan duration , ( bool isVisible , float progress ) [ ] sequence )
1519- => ( Duration , Sequence ) = ( duration , sequence ) ;
1520-
1521- internal TimeSpan Duration { get ; }
1522-
1523- internal ( bool isVisible , float progress ) [ ] Sequence { get ; }
1524- }
1525-
15261443 sealed class Node : Graph . Node < Node >
15271444 {
15281445 internal CompositionObject ? Parent { get ; set ; }
0 commit comments