Developing Android Applications with Adobe AIR [82]
An SObject is the displayObject equivalent in binary code, and is not accessible via ActionScript. It is made of layers with closed paths, with edges and colors. Edges are defined as quadratic Bezier curves and are used to prevent two closed paths from intersecting. Abutment is used to seam them together. More edges mean more calculation. Color applies to solids and gradients, but also bitmaps, video, and masks (combined color values of all display objects to determine a final color).
Enhanced Caching/GPU Model
No calculation is needed for cached items. They may be rotated, scaled, and skewed using their bitmap representation.
Rasterization
Traditional Model
This step is the most demanding in terms of memory. It uses multithreading for better performance. The screen is divided into dynamically allocated horizontal chunks. Taking one dirty rectangle at a time, lines are scanned from left to right to sort the edges and render a span, which is a horizontal row of pixels. Hidden objects, the alpha channel of a bitmap, and subpixel edges are all part of the calculation.
Enhanced Caching/GPU Model
Transformation cached rendering, also called processing, is used. It converts each vector graphic as a bitmap and keeps it in an off-screen buffer to be reused over time. Once that process it done, scene compositing takes all the bitmaps and rearranges them as needed.
Presentation
Traditional Model
Blitting, or pixel blit, is the transfer of the back buffer to the screen. Only the dirty rectangles are transferred.
Enhanced Caching/GPU Model
The process is similar to the traditional model, but the GPU is much faster at moving pixels.
GPU Rendering on Android
The rendering mode used for Android is called GPU Vector. Both the creation of individual pixel buffers and scene compositing are done by the GPU. The GPU is particularly useful in this performance-constrained environment.
The GPU rendering technique only benefits vector art. It reduces the time needed to rasterize vector graphics, especially complex ones, to a bitmap. A bitmap is already a pixel buffer, also called a texture. There is no need to duplicate it. In fact, doing so would waste precious memory.
To perform GPU rendering in Android using Flash Professional, go to File→AIR Android settings. Select the General tab, and under Render Mode, select GPU.
In Flash Builder, set the renderMode node of the initialWindow node of your application descriptor to gpu:
... If the user has a device that does not perform hardware acceleration, or if it does not work reliably with its drivers, AIR ignores the setting. No message is dispatched. The cacheAsBitmap Property When the cacheAsBitmap property is set to true, the display object rendered as a bitmap is cached in memory for reuse, as shown in Figure 14-1. Figure 14-1. Taking vector graphics and rendering them as one bitmap via the cacheAsBitmap property Because vector graphics use subpixels and bitmaps don’t, objects snap to the full pixel and may look different from what you intended. To avoid this, apply the vector image on a full whole-number pixel. You can set the cacheAsBitmap property in Flash Professional under Properties→Cache As Bitmap. You can only apply it to symbols. The art will then be converted to a bitmap at runtime, but it will not be modified in the IDE. You can also set the property in code: var myVector:Sprite = new Sprite(); myVector.cacheAsBitmap = true; An object is only cached when it has its visible property set to true. Additionally, if its visibility is turned off, its bitmap representation is discarded. The following example puts 100 circles on the stage. They animate frantically. Try the code on your device. Click on the stage to toggle the cacheAsBitmap property to true or false
The cacheAsBitmap property was added in Flash 8 with the Surface Renderer. Its purpose is to optimize the animation of vector graphics along the x- and y-axes, a process called translation.