Replies: 1 comment
-
|
Created Issue here: #4410 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
DWM can struggle to clip visuals using rounded rectangle geometry, which leads to reduced framerates on lower end devices when lots of elements with
CornerRadiusset rendered are on screen at once. ClippingAttachedCardShadowwithCompositionGeometricClipcan double this performance burden, where you have aControlwithCornerRadiusset, and then a shadow on top with its corners being rounded and clipped in a similar manner.To improve performance in this area, I've started working on a feature to mask shadows with
CompositionMaskBrush, instead of clipping them withCompositionGeometricClip, via the following steps:ShapeVisualwith rounded rectangle geometry that has a thick outline and no fill (similar to the geometry we currently use to clip shadows)CompositionVisualSurface+CompositionSurfaceBrushfrom theShapeVisualcreated in the previous stepCompositionVisualSurface+CompositionSurfaceBrushfrom theSpriteVisualthat hosts theDropShadowCompositionMaskBrushMaskto theCompositionSurfaceBrushmade from theShapeVisualSourceto theCompositionSurfaceBrushmade from theSpriteVisualthat hosts theDropShadowSpriteVisualand set itsBrushto theCompositionMaskBrushfrom the previous stepSpriteVisualfrom the previous step as the child of theUIElementtheAttachedCardShadowis being attached toFollowing these steps, the inner content of the
AttachedCardShadowwill be masked out with a texture rather than clipped out with geometry, while maintaining a similar visual effect. While there is still geometry involved, the geometry is part of a visual, rather than part of a clip, so DWM handles it better performance-wise (for some reason).One drawback of using this method is that the corners of the shadow will appear more aliased, this is mostly unnoticeable on a low opacity shadow, but may be more apparent when the shadow's opacity is higher. So I'm including an API to choose clipping/masking methods, between
CompositionGeometricClipandCompositionMaskBrush.Please chip in if you have any ideas or suggestions to add :D
Beta Was this translation helpful? Give feedback.
All reactions