2

So... In the good old days of making games, when you were drawing sprites to the screen, you'd use ROPs to draw only the "non-transparent" part of your sprite. (Yes, I haven't done any game coding in a loooong time)

(In case you have no idea what I'm talking about, check this out. It was a beautiful hack)

I'm now trying to do some "HTML5 games", and I'm experimenting with different ways of doing things and measuring their performance, and I noticed that there seem to be no ROPs in Canvas. When you draw something, that "something" has a full alpha channel, and actually drawing semi-transparent things is exactly as fast as drawing "opaque" things.

Now, this is great if you're drawing semi-transparent stuff, but for 99.999% of what you're doing, this sounds incredibly wasteful, and it feels like if we did have ROPs, we could probably draw 10 times as fast using the old mask trick.

Am I missing something here?
Is there already a way with Canvas to "turn off alpha" to make it draw faster?
Am I completely crazy, and this doesn't matter because, really, I can actually already draw 1000 sprites in 3ms (300 FPS), plus the video card is probably doing it directly, or will soon, so what do I care?
What do you think?

Thank you!
Daniel

Daniel Magliola
  • 30,898
  • 61
  • 164
  • 243

1 Answers1

1

Am I missing something here?

Nay

Is there already a way with Canvas to "turn off alpha" to make it draw faster?

Nay, sorry. Alpha is simply in the element no matter what, as a fact of HTMLElement conventions to date I imagine. In fact the default state of canvas is 100% black pixels with full transparency.

Simon Sarris
  • 62,212
  • 13
  • 141
  • 171
  • Right... The question is... Am I bitching for nothing? Isn't this a *huge* amount of needlessly wasted performance that HTML5 game devs could take advantage of if they wanted to go to the trouble of making their masks and using ROPs, instead of the easy and slower path of letting the browser handle that for you slowly? Wouldn't it be a good idea to have this? (I get that it complicates the API, but there's no *need* to use it...) – Daniel Magliola Nov 28 '11 at 19:51
  • 1
    Although I'm a fiend for canvas performance, I wouldn't call this particular optimization huge in this day and age. – Simon Sarris Nov 28 '11 at 20:16
  • Ok, that was the question. 10 years ago the difference was HUGE, I wasn't sure whether this was still relevant. Thanks! – Daniel Magliola Nov 28 '11 at 20:20