WPF 中的 StackPanel 性能不佳

发布于 2024-12-13 06:55:45 字数 239 浏览 0 评论 0原文

我有一个在高分辨率显示器(1920x1080)上全屏运行的应用程序。 大约 25% 的屏幕是 StackPanel,用于在屏幕上滚动图像。 (X 位置使用双动画进行动画处理)

滚动非常滞后和跳跃,并且有明显的撕裂。 它运行在一台全新的高端游戏笔记本电脑上,运行 Win7 64 位。

我不明白为什么性能这么差。我做错了什么吗?这种动画是在CPU上运行还是在GPU上运行?有没有更智能的方法在屏幕上滚动图像?

I have an application which runs fullscreen on a high resolution display (1920x1080).
About 25% of the screen is a StackPanel that scrolls images across the screen.
(the X position is animated with double animation)

The scroll is very laggy and jumpy, and with visible tearing.
This is running on a brand new high-end gaming laptop, running Win7 64bit.

I don't understand why the performance is so poor. Am I doing something wrong? Does this kind of animation run on the CPU or GPU? Is there a smarter way to scroll images across the screen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜空下最亮的亮点 2024-12-20 06:55:45

WPF 可以进行硬件加速,但仅限于较新的显卡驱动程序。一些板载的开箱即用驱动程序将默认返回软件渲染,这可能会让人感觉非常缓慢和笨重。至于撕裂,这是正常的显卡设置,称为垂直同步。我会尝试将显卡驱动程序更新为专有驱动程序(nVidia、AMD 等),并在卡上启用垂直同步。

您可以使用解释的方法检查它是否属于软件渲染或硬件渲染此处

如果这不能解决问题,我能想到的唯一其他可能性是您的动画/渲染未同步到 GUI。

请参阅 msdn 文章了解更多详细信息。

WPF can be hardware-accelerated, but only on newer video card drivers. Some of the onboard, out of box drivers, will default back to software rendering, which can feel really slow and clunky. As for the tearing, that's a normal video card setting, called V-Sync. I would try updating the video card drivers to a proprietary driver (nVidia, AMD, etc.), and enabling vertical sync on the card.

You can check to see if it falls into software, or hardware rendering using the methods explained here.

If that doesn't resolve the issue, the only other possibility I can think of is your animation/rendering is not synced to the GUI.

See this msdn article for more details.

柒夜笙歌凉 2024-12-20 06:55:45

我见过的一个可以解决这个问题的技巧是在页面上放置一个 3D 对象,从侧面查看它并旋转它,例如 4 个图像有一个立方体,每侧都有一个图像。
是的,旋转仍然需要 GPU 和处理器时间,但它是由 WPF 动画在内部处理的,因此一旦设置滚动,不需要与后面的代码进行交互。

A trick that I've seen that can get around this issue is to place a 3D object on your page, view it side on and rotate it e.g. for 4 images have a cube with an image set to each side.
Yes the rotation still requires GPU and processor time but it is taken care of internally by the WPF animation and so doesn't require interaction with code behind once set rolling.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文