user291701
user291701

Reputation: 39681

Canvas performance - better to draw to an offscreen canvas first?

As the question states - will canvas performance be faster if we do all our drawing in an off-screen buffer, then draw that buffer to the on-screen canvas, or does it not matter?

I'm drawing a lot of rectangles + small images on each draw loop. It works extremely well on ios, but on android phones it's pretty horrible. But maybe the browser implementation is doing this for us under the covers already.

Thanks

Upvotes: 1

Views: 1675

Answers (1)

Nikola Radosavljević
Nikola Radosavljević

Reputation: 6911

It will help if you do this in order to cache part of the image. If you just draw everything to it and then copy to on-screen canvas, then it's not worth the effort.

  • use multiple canvases one over another to draw parts of the image separately (use one for rarely updated drawing, and another only for parts which change often)
  • use off-screen canvas for shapes which don't change, but move around in main canvas.

Upvotes: 1

Related Questions