KDrawSprite: Get GPU power without cacheAsBitmapMatrix on AIR for iOS

KDrawSprite is an ActionScript library for mobile AIR applications using Packager for iPhone, AIR for iOS and AIR for Android to get more power of GPU. My iPhone app Korean Alphabet 1.2.2 is using this to get more than 30 fps on older devices, ex. iPod Touch 1st gen. A4 chip powered latest devices, such as iPad and iPhone 4, will performs 100 fps over with KDrawSprite.

Source on github:
https://github.com/kawanet/as3kawalib/raw/master/src/net/kawa/display/KDrawSprite.as
Document:
http://www.kawa.net/works/as/as3kawalib/docs/net/kawa/display/KDrawSprite.html


KDrawSprite draws your vector image onto a bitmap image. You don't need to manipulate cacheAsBitmapMatrix and cacheAsBitmap properties. These are powerful, however, sometimes make our app crashed erratically. You need take more care for iPad which has larger screen but has less memory.

How To Use This

Simply call KDrawSprite.getSprite() instead of setting cacheAsBitmapMatrix and cacheAsBitmap properties.
var sprite:Sprite = new Sprite();
sprite.graphics.beginFill(0x336699);
sprite.graphics.drawCircle(50, 50, 50);

// sprite.cacheAsBitmapMatrix = new Matrix(); // BEFORE
// sprite.cacheAsBitmap = true;


sprite = KDrawSprite.getSprite(sprite);       // AFTER

addChild(sprite);
sprite.x = 100;
sprite.y = 100;
sprite.scaleX = 0.5;
sprite.height = 50;
sprite.rotation = 1;
Bitmap operations such as moving, scaling and rotation will be GPU enabled.
KDrawSprite will also free memory of image rendered when it comes out of the Stage.

You need call getSprite() or draw() method whenever you make changes on the vector source image. This also means any other needless re-rendering will not be invoked. Learn more on document.

Super Sampling Anti-Aliasing (2x SSAA)

KDrawSprite supports 2x SSAA, super sampling anti-aliasing, in addition to NoAA per default.

Note

To get better performance and rendering quality, you MUST set stage.quality as StageQuality.LOW. Also use 2x SSAA when needed.
stage.quality = StageQuality.LOW; // must

* Japanese version of this post is here.