@@ -512,6 +512,7 @@ CompositionObject GetCompositionObject(CompositionObject obj) =>
512512 CompositionObjectType . Vector2KeyFrameAnimation => GetVector2KeyFrameAnimation ( ( Vector2KeyFrameAnimation ) obj ) ,
513513 CompositionObjectType . Vector3KeyFrameAnimation => GetVector3KeyFrameAnimation ( ( Vector3KeyFrameAnimation ) obj ) ,
514514 CompositionObjectType . Vector4KeyFrameAnimation => GetVector4KeyFrameAnimation ( ( Vector4KeyFrameAnimation ) obj ) ,
515+ CompositionObjectType . CompositionEffectFactory => GetCompositionEffectFactory ( ( CompositionEffectFactory ) obj ) ,
515516 _ => throw new InvalidOperationException ( ) ,
516517 } ;
517518
@@ -984,63 +985,32 @@ LoadedImageSurface GetLoadedImageSurface(LoadedImageSurface obj)
984985 return result ;
985986 }
986987
987- CompositionEffectBrush GetCompositionEffectBrush ( CompositionEffectBrush obj )
988+ CompositionEffectFactory GetCompositionEffectFactory ( CompositionEffectFactory obj )
988989 {
989990 if ( GetExisting ( obj , out var result ) )
990991 {
991992 return result ;
992993 }
993994
994- IEnumerable < CompositionEffectSourceParameter > sources ;
995- GraphicsEffectBase newEffect ;
996-
997- var effectBase = obj . GetEffect ( ) ;
998- switch ( effectBase . Type )
999- {
1000- case GraphicsEffectType . CompositeEffect :
1001- {
1002- var effect = ( CompositeEffect ) effectBase ;
1003-
1004- var newCompositeEffect = new CompositeEffect
1005- {
1006- Mode = effect . Mode ,
1007- } ;
1008-
1009- foreach ( var source in effect . Sources )
1010- {
1011- newCompositeEffect . Sources . Add ( source ) ;
1012- }
1013-
1014- newEffect = newCompositeEffect ;
1015- sources = effect . Sources ;
1016- }
1017-
1018- break ;
1019- case GraphicsEffectType . GaussianBlurEffect :
1020- {
1021- var effect = ( GaussianBlurEffect ) effectBase ;
1022-
1023- newEffect = new GaussianBlurEffect
1024- {
1025- BlurAmount = effect . BlurAmount ,
1026- Source = effect . Source ,
1027- } ;
995+ result = CacheAndInitializeCompositionObject ( obj , _c . CreateEffectFactory ( obj . Effect ) ) ;
1028996
1029- sources = effect . Source is null
1030- ? Array . Empty < CompositionEffectSourceParameter > ( )
1031- : new [ ] { effect . Source } ;
1032- }
997+ return result ;
998+ }
1033999
1034- break ;
1035- default :
1036- throw new InvalidOperationException ( ) ;
1000+ CompositionEffectBrush GetCompositionEffectBrush ( CompositionEffectBrush obj )
1001+ {
1002+ if ( GetExisting ( obj , out var result ) )
1003+ {
1004+ return result ;
10371005 }
10381006
1039- var effectBrush = _c . CreateEffectFactory ( newEffect ) . CreateBrush ( ) ;
1007+ var effectFactory = GetCompositionEffectFactory ( obj . GetEffectFactory ( ) ) ;
1008+ var effectBrush = effectFactory . CreateBrush ( ) ;
1009+
10401010 result = CacheAndInitializeCompositionObject ( obj , effectBrush ) ;
10411011
10421012 // Set the sources.
1043- foreach ( var source in sources )
1013+ foreach ( var source in effectFactory . Effect . Sources )
10441014 {
10451015 result . SetSourceParameter ( source . Name , GetCompositionBrush ( obj . GetSourceParameter ( source . Name ) ) ) ;
10461016 }
0 commit comments