@@ -512,6 +512,7 @@ CompositionObject GetCompositionObject(CompositionObject obj) =>
512
512
CompositionObjectType . Vector2KeyFrameAnimation => GetVector2KeyFrameAnimation ( ( Vector2KeyFrameAnimation ) obj ) ,
513
513
CompositionObjectType . Vector3KeyFrameAnimation => GetVector3KeyFrameAnimation ( ( Vector3KeyFrameAnimation ) obj ) ,
514
514
CompositionObjectType . Vector4KeyFrameAnimation => GetVector4KeyFrameAnimation ( ( Vector4KeyFrameAnimation ) obj ) ,
515
+ CompositionObjectType . CompositionEffectFactory => GetCompositionEffectFactory ( ( CompositionEffectFactory ) obj ) ,
515
516
_ => throw new InvalidOperationException ( ) ,
516
517
} ;
517
518
@@ -984,63 +985,32 @@ LoadedImageSurface GetLoadedImageSurface(LoadedImageSurface obj)
984
985
return result ;
985
986
}
986
987
987
- CompositionEffectBrush GetCompositionEffectBrush ( CompositionEffectBrush obj )
988
+ CompositionEffectFactory GetCompositionEffectFactory ( CompositionEffectFactory obj )
988
989
{
989
990
if ( GetExisting ( obj , out var result ) )
990
991
{
991
992
return result ;
992
993
}
993
994
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 ) ) ;
1028
996
1029
- sources = effect . Source is null
1030
- ? Array . Empty < CompositionEffectSourceParameter > ( )
1031
- : new [ ] { effect . Source } ;
1032
- }
997
+ return result ;
998
+ }
1033
999
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 ;
1037
1005
}
1038
1006
1039
- var effectBrush = _c . CreateEffectFactory ( newEffect ) . CreateBrush ( ) ;
1007
+ var effectFactory = GetCompositionEffectFactory ( obj . GetEffectFactory ( ) ) ;
1008
+ var effectBrush = effectFactory . CreateBrush ( ) ;
1009
+
1040
1010
result = CacheAndInitializeCompositionObject ( obj , effectBrush ) ;
1041
1011
1042
1012
// Set the sources.
1043
- foreach ( var source in sources )
1013
+ foreach ( var source in effectFactory . Effect . Sources )
1044
1014
{
1045
1015
result . SetSourceParameter ( source . Name , GetCompositionBrush ( obj . GetSourceParameter ( source . Name ) ) ) ;
1046
1016
}
0 commit comments