不透明度=0 时的绘图视觉性能 [英] DrawingVisual performance with Opacity=0

查看:23
本文介绍了不透明度=0 时的绘图视觉性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在 WPF 中有一个 DrawingVisual 且 Opacity=0,是否足以不绘制它?我们在 Canvas 上有数百个 DrawingVisual,并且目前正在将不显示的视觉对象设置为 Opacity=0,我想确保渲染具有 Opacity=0 的 DrawingVisual 不会影响渲染性能.

If I have a DrawingVisual in WPF with Opacity=0, is that enough for it not to be drawn? We have hundreds of DrawingVisuals on a Canvas, and are currently setting Opacity=0 on the visuals that are not to be displayed, and I wanted to make sure there is no rendering performance hit for rendering a DrawingVisual with Opacity=0.

更新:我通过测试发现当 Opacity=0 时存在开销,但是由于 DrawingVisual 没有 Visibility 属性,我不知道你还有什么办法告诉它不显示,除非你真的删除它来自视觉树,所以欢迎提出任何建议.

UPDATE: I have discovered through testing that there IS overhead when Opacity=0, but since DrawingVisual doesn't have a Visibility property, I don't know how else you would tell it to not be displayed unless you actualy remove it from the visual tree, so any suggestions are welcome.

推荐答案

最有效的似乎是在我的测试中设置不透明度.另一种简单的方法是重绘受影响的视觉效果.

The most efficient seems to be setting the opacity in my tests. Another simple approach is to redraw the visuals that are affected.

using (DrawingContext dc = RenderOpen()) {} //Hide this visual

然后在它们再次可见时重新绘制.

And then redraw when they become visible again.

渲染一个空白的绘图上下文似乎非常快.但是,如果您有复杂的视觉效果,则在它们变得可见时重新渲染它们可能需要时间.

Rendering a blank drawingcontext seems to be very quick. But if you have complicated visuals it could take time to rerender them when they become visible.

这篇关于不透明度=0 时的绘图视觉性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆