I want to know why setting the Brush.Opacity
value of element rather than setting the element's Opacity
property is better for performance.
From MSDN: Modifying an element's Opacity
property can cause WPF to create a temporary surface.
But I can't understand what is temporary surface
Can any one explain?
Thanks.
If a temporary surface is created, it means a new bitmap is created for the element, the element's contents are rendered to it, and then it is composited onto the parent element's surface using the opacity provided.
Otherwise, if you just set the opacity of the brush, it can bypass this step and just draw directly to the parent element's surface.
Creating a new bitmap and compositing it is more expensive than just drawing directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With