Jump to content

Which of these canvas approaches do you think is quicker?


rich
 Share

Recommended Posts

I would use a different solution, with 2 non-hidden canvases. That is, instead of having a single visible canvas that covers the whole screen, actually show two smaller canvases side by side on the screen and draw to them directly.

 

That'd be the best of both worlds in my opinion: you don't need context.clip() and you don't need the extra memory for the hidden canvases.

 

Also, if you draw to a canvas with no transform, and then transform the whole thing afterwards, you end up drawing more pixels than you actually see on the screen (your hidden canvas will have to be larger than the visible area, if when it's transformed it's going to be scaled down for example). Since fill rate is the most common bottleneck on mobiles, I would imagine that this could be potentially quite a lot slower, depending on the extent of the scaling and rotation.

Link to comment
Share on other sites

Yeah my worry with that approach is that I focus on mobile first, always, and there are several phones where GPU acceleration really screws up if you start overlapping canvases. For a side-by-side it would be fine, but for a camera-in-camera you've got overlap, or a rotation where one may touch the other. I've seen Samsung phones screw the whole rendering doing this, you get really psychedelic results (like when the palette and textures gets corrupted in GPU memory), or large black regions around the overlapping areas. I suspect on desktop it would be flawless though, but 90% of my work is on mobile :(

Link to comment
Share on other sites

As far as I know, the problem you mention with Samsung mobiles only happens in the stock Android browser in Android 4.x with the Mali400 GPU and, most importantly, only when you clear and redraw a part of your layered canvases.

 

If you clear and redraw the whole canvas every frame, that should never happen.

 

Of course I haven't tried every single Samsung device, but that's what I've found so far. If you noticed that this happens in other circumstances too, I'd really like to know that, as I've been relying on layered canvases for quite a few things :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...