GPU Rendering in Adobe AIR for Android

I recently started playing around with GPU rendering in AIR for Android, and I decided to do a quick video demonstrating the differences between CPU and GPU rendering modes.


The code for this example is available here on GitHub.

As you can see from the example application, the key to offloading rendering to the GPU is to do three things:

1. Set rendering mode to GPU in your application descriptor like this:

<initialWindow>
    <content>[...]</content>
    <resizable>true</resizable>
    <autoOrients>false</autoOrients>
    <fullScreen>false</fullScreen>
    <visible>true</visible>
    <renderMode>gpu</renderMode>
</initialWindow>

2. Make sure cacheAsBitmap is set to true on your DisplayObject like this:

square.cacheAsBitmap = true;

3. Make sure to assign a Matrix to the cacheAsBitmapMatrix property on your DisplayObject like this:

square.cacheAsBitmapMatrix = new Matrix();

That’s all you have to do to offload your rending to the GPU and to free your CPU up for more important tasks.