Keavon
Keavon

Reputation: 7493

Will rendering images outside an HTML5 canvas hurt performance?

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?

Upvotes: 0

Views: 184

Answers (1)

chaps
chaps

Reputation: 73

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.

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

Upvotes: 2

Related Questions