Can I use ROPs in Canvas? (I care for performance reasons only)

179 views Asked by At

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

1

There are 1 answers

3
Simon Sarris On BEST ANSWER

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.