Unclear support for some Win2D effects with Composition APIs
See original GitHub issueHello, I’m working with the Composition APIs and some Win2D effects and I’ve read the list of the available Win2D effects that are currently supported with the Composition APIs here.
From the list in that page (as well as this page) I can see that the GaussianBlurEffect
is marked with the [NoComposition]
attribute, so it shouldn’t be supported. Yet I can use this method without any problems (and I’m not sure why):
public static SpriteVisual GetAttachedBlur<T>(
[NotNull] this T element, float blur, int ms) where T : FrameworkElement
{
// Get the visual and the compositor
Visual visual = element.GetVisual();
Compositor compositor = visual.Compositor;
// Create the blur effect and the effect factory
GaussianBlurEffect blurEffect = new GaussianBlurEffect
{
Name = "Blur",
BlurAmount = blur,
BorderMode = EffectBorderMode.Hard,
Optimization = EffectOptimization.Balanced,
Source = new CompositionEffectSourceParameter("source")
};
CompositionEffectFactory effectFactory = compositor.CreateEffectFactory(blurEffect);
// Setup the rest of the effect
CompositionEffectBrush effectBrush = effectFactory.CreateBrush();
effectBrush.SetSourceParameter("source", compositor.CreateBackdropBrush());
// Assign the effect to a brush and display it
SpriteVisual sprite = compositor.CreateSpriteVisual();
sprite.Brush = effectBrush;
sprite.Size = new Vector2((float)element.ActualWidth, (float)element.ActualHeight);
ElementCompositionPreview.SetElementChildVisual(element, sprite);
return sprite;
}
I mean, looking at the documentation, I would expect the code to fail, since the GaussianBlurEffect
doesn’t seem to be supported.
Then, I tried another effect (the DirectionalBlurEffect
, which is also marked as not supported by the Composition APIs) and that failed (the CreateEffectFactory
threw an exception.
So my questions are:
- If both those effects are marked as
[NoComposition]
, why does theGaussianBlurEffect
actually work with the Composition APIs, and theDirectionalBlurEffect
doesn’t? Is there another way to use those other effects, or is there a plan to support them as well in future Windows 10 releases?
Thanks for your help!
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (7 by maintainers)
Top GitHub Comments
Here’s a list of effects that are currently tagged as NoComposition but are supported as of today:
You should see updates to the Win2D documentation over the next few days.
You (and others) have a direct say in which effects we support next: please feel free to submit feedback (and upvote) about the specific Win2D effects you’d like to see in the Composition APIs.
This is a documentation bug on the Win2D page: GaussianBlurEffect is supported in Composition.
Thanks for your feedback; we will update the Win2D effect descriptions.