在HTML5画布外部渲染图像会影响性能吗? [英] Will rendering images outside an HTML5 canvas hurt performance?

查看:45
本文介绍了在HTML5画布外部渲染图像会影响性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建2D平台游戏,并且屏幕上会有很多关卡.渲染这些会损害性能,还是我应该开发某种形式的2D遮挡剔除以避免渲染呢?此外,这会导致多少性能下降?

I'm building a 2D platformer game and I'll have a bunch of the level off the screen. Will it hurt performance to render these, or should I develop some form of 2D occlusion culling to avoid rendering this? Furthermore, how much of a performance hit would this cause?

推荐答案

渲染引擎应该抛出对画布外部区域的渲染调用,但是我仍然建议不要尝试从这些区域开始绘制,只是为了减少执行不必要的逻辑的总体开销.就是说,主要的费用将是如果触发重新绘制,那么在这种情况下就不太可能发生.

The rendering engine should throw out render calls to areas outside the canvas, but I would still recommend not trying to draw to those areas to begin with just to reduce the overall overhead of performing unnecessary logic. That said, the major cost would be if repaints were triggered, which in this case would not likely happen.

这是2010年的WebKit错误报告(已修复),解决了浏览器意外在画布外绘制内容的问题:

Here is a WebKit bug report (FIXED) from 2010 that addresses an issue where the browser was accidentally drawing things outside the canvas:

https://bugs.webkit.org/show_bug.cgi?id=45792

这篇关于在HTML5画布外部渲染图像会影响性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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