應用LayoutTransform與RenderTransform的性能影響?

[英]Performance impact of applying either LayoutTransform vs RenderTransform?


I have had dealt with both LayoutTransform and RenderTransform and I know that each one is suited for a specific scenario which I had found a use for in previous projects.

我已經處理過LayoutTransform和RenderTransform,我知道每個都適合我在以前的項目中使用過的特定場景。

Yet, from a performance perspective and while using a WPF profiling tool, for an instance, Which one has a lesser impact on the UI performance ?

但是,從性能角度和使用WPF分析工具時,對於一個實例,哪一個對UI性能的影響較小?

2 个解决方案

#1


10  

As specified by MSDN:

由MSDN指定:

To apply transformations to a FrameworkElement, create a Transform and apply it to one of the two properties that the FrameworkElement class provides: LayoutTransform – A transform that is applied before the layout pass. After the transform is applied, the layout system processes the transformed size and position of the element. RenderTransform – A transform that modifies the appearance of the element but is applied after the layout pass is complete. By using the RenderTransform property instead of the LayoutTransform property, you can obtain performance benefits. Which property should you use? Because of the performance benefits that it provides, use the RenderTransform property whenever possible, especially when you use animated Transform objects. Use the LayoutTransform property when scaling, rotating, or skewing and you need the parent of the element to adjust to the transformed size of the element. Note that, when they are used with the LayoutTransform property, TranslateTransform objects appear to have no effect on elements. That is because the layout system returns the translated element to its original position as part of its processing.

要將轉換應用於FrameworkElement,請創建一個Transform並將其應用於FrameworkElement類提供的兩個屬性之一:LayoutTransform - 在布局傳遞之前應用的轉換。應用變換后,布局系統處理元素的變換大小和位置。 RenderTransform - 一種修改元素外觀的變換,但在布局傳遞完成后應用。通過使用RenderTransform屬性而不是LayoutTransform屬性,可以獲得性能優勢。你應該使用哪個屬性?由於它提供的性能優勢,請盡可能使用RenderTransform屬性,尤其是在使用動畫Transform對象時。縮放,旋轉或傾斜時使用LayoutTransform屬性,您需要元素的父級調整為元素的變換大小。請注意,當它們與LayoutTransform屬性一起使用時,TranslateTransform對象似乎對元素沒有影響。這是因為布局系統將翻譯后的元素作為其處理的一部分返回到其原始位置。

And Also:

並且:

LayoutTransform can lead to poor application performance if you invoke it in a scenario that does not require a full pass by the layout system. When you apply a LayoutTransform to the Children collection of the Panel, it triggers a new pass by the layout system and forces all on-screen objects to be remeasured and rearranged. If you are updating the complete application user interface (UI), this functionality might be exactly what you need. However, if you do not need a full layout pass, use the RenderTransform property, which does not invoke the layout system, and therefore, is typically a better choice for this scenario.

如果在不需要布局系統完全通過的場景中調用LayoutTransform,則會導致應用程序性能下降。將LayoutTransform應用於Panel的Children集合時,它會觸發布局系統的新傳遞,並強制重新測量和重新排列所有屏幕上的對象。如果要更新完整的應用程序用戶界面(UI),則此功能可能正是您所需要的。但是,如果您不需要完整的布局傳遞,請使用RenderTransform屬性,該屬性不會調用布局系統,因此,通常是此方案的更好選擇。

#2


12  

To add to gliderkite's answer, RenderTransforms will also be processed by the GPU when capable, whereas LayoutTransforms are done on the CPU.

要添加到gliderkite的答案,RenderTransforms還將在有能力時由GPU處理,而LayoutTransforms在CPU上完成。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/04/26/729e93e452c0ffae98708cc5165bc1d2.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com