简体   繁体   English

调整大小时 BitmapCache 性能不佳

[英]BitmapCache poor performance while resizing

I have a ListView with different complex ListViewItem containers consisting of images, shadow effects, blur effects.. etc. Rendering these containers in large amounts heavily reduces performance, especially since i'm using a blur overlay frame on top of the ListView .我有一个ListView其中包含不同的复杂ListViewItem容器,包括图像、阴影效果、模糊效果等。大量渲染这些容器会严重降低性能,尤其是因为我在ListView顶部使用了模糊覆盖框架。 Which is why in this case i'm setting CacheMode to BitmapCache (improves performance by up to 15x the fps).这就是为什么在这种情况下我将CacheMode设置为BitmapCache (将性能提高高达 15 倍的 fps)。

<Border.CacheMode>
    <BitmapCache />
</Border.CacheMode>

The problem is that i use a WrapPanel and a ValueConverter to dynamically resize and fit these containers into the WrapPanel so that they completely fill the space in either horizontal or tile views.问题是我使用WrapPanelValueConverter来动态调整这些容器的大小并将其放入WrapPanel以便它们完全填充水平或平铺视图中的空间。 Apparently, that doesn't work well with caching and it produces severe lags/stalls (frame drops to 0).显然,这不适用于缓存,并且会产生严重的滞后/停顿(帧下降到 0)。

Currently my 3 options are:目前我的 3 个选项是:

  • Disable caching (and live with almost 15fps)禁用缓存(并以近 15fps 的速度运行)
  • Disable resizing (looks unacceptable)禁用调整大小(看起来不可接受)
  • Disable caching and resizing only when resizing window (still performs bad but it's the best option i have)仅在调整窗口大小时禁用缓存和调整大小(仍然表现不佳,但这是我拥有的最佳选择)

My questions:我的问题:

  • Why do i get these huge drops in performance while resizing with caching vs without caching?为什么在使用缓存和不使用缓存调整大小时,性能会大幅下降?
  • Am i misusing caching or doing it wrong?我是滥用缓存还是做错了?
  • Is there a better way of fixing this mess without compromises?有没有更好的方法来解决这个烂摊子而不妥协?

Ok.好的。 After a lot of reading and experimenting, i figured two things:经过大量的阅读和实验,我想到了两件事:

  • First, Caching should not be used on elements that resize frequently, especially if they're too many (couldn't find out why).首先, Caching不应该用于经常调整大小的元素,特别是如果它们太多(找不到原因)。 So, i basically cached fixed size child elements instead.所以,我基本上缓存了固定大小的子元素。

  • And that reminded me of Virtualization which was exactly what i was missing but didn't know was supported in WPF Lists .这让我想起了Virtualization ,这正是我所缺少的,但不知道WPF Lists支持。

With some more optimizations, now, i can resize the window buttery smooth.通过更多优化,现在我可以平滑地调整窗口的大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM