Relative performance of native C++ to Flash for pixel-pushing – Education Career Blog

I was trying to get a ballpark idea of how much slower Flash is at pure pixel-pushing 2D graphics than doing the same thing in SDL or other native library. For instance if I have a Flash/Flex app on a modern PC which each frame does a 2D loop and directly reads/sets every pixel, what equivalent PC would give the same performance for a native C++ app? Maybe a classic Pentium, a PII, PIII? I know it’s probably not quite a linear relationship but it must be possible to get some kind of idea.


Recent Flash versions talk directly to the video driver, so the difference is a lot less than you’d think.


It would be very, very slow for a generic 2d rewrite using getPixel()/setPixel() on every frame. You basically can’t push pixels and expect real time performance.

However, it always depends on what you’re trying to do. Many of the most common animation techniques can instead be done by using native (player-accelerated) features and that’s faster in Flash. For example, if you wanted a rectangle moving around the screen, you wouldn’t push it on a BitmapData instance, you could just have a native box moving; if you want to transform a video to blur it, you could use the native BlurFilter filter; if you want to change overall color of an image, you can use a color matrix instead; if you want to apply some 3d transformation to something, you can use the native 3d transformers; and so on and so forth.

For serious, lower-level pixel pushing, you can also use Pixel Bender, Flash’s pixel shader language. It can do much faster pixel pushing (C-level speeds) but it’s limited. It works great if you want to, say, build your own filters/shaders or blending modes, but it’s not for SDL-level stuff. People have created proof-of-concept demos like low-res raycasting demos, but that’s about the top of what you can do.

If you want real C performance and you’re thinking of SDL or something similar, you may be better off by actually doing your stuff in C and using Alchemy to compile. There’s a port of SDL to Flash, for example, or even complete ports of id Software’s DOOM/Hexen/Heretic – all using native code, with some tweaks for UI.

Leave a Comment