Online Book Reader

Home Category

Developing Android Applications with Adobe AIR [86]

By Root 2493 0
method.

This technique is developed in detail in Chapter 18.

Interactivity


Setting cacheAsBitmapMatrix to true does not affect the object’s interactivity. It still functions as it would in the traditional rendering model both for events and for function calls.

Multiple Rendering Techniques


On Android devices, you could use traditional rendering along with cacheAsBitmap and/or cacheAsBitmapMatrix. Another technique is to convert your vector assets as bitmaps, in which case no caching is needed. The technique you use may vary from one application to the next.

Remember that caching is meant to be a solution for demanding rendering. It is helpful for games and certain types of animations (not for traditional timeline animation). If there is no display list conflict, as described earlier, caching all assets makes sense. There is no need to use caching for screen-based applications with fairly static UIs.

At the time of this writing, there seems to be a bug using filters on a noncached object while the GPU mode is set in the application descriptor (as in the example below). It should be fixed in a later release:

var sprite:Sprite = new Sprite();

sprite.graphics.beginFill(0xFF6600, 1);

sprite.graphics.drawRect(0, 0, 200, 100);

sprite.graphics.endFill();

sprite.filters = [new DropShadowFilter(2, 45, 0x000000, 0.5, 6, 6, 1, 3)];

addChild(sprite);

NOTE

If you are not using caching, do not leave renderMode set to GPU in your application descriptor. Doing so may cause unexpected behavior similar to that described in the text.

Maximum Texture Memory and Texture Size


The maximum texture size supported is 1,024×1,024 (it is 2,048×2,048 for iPhone and iPad). This dimension represents the size after transformation. The maximum memory is not part of the memory consumed by the application, and therefore is not accessible. We will discuss memory consumption in Chapter 19.

2.5D Objects


A 2.5D object is an object with an additional z property that allows for different types of transformation.

If an object has cacheAsBitmapMatrix on and a z property is added, the caching is lost.

A 2.5D shape does not need cacheAsBitmapMatrix because it is always cached for motion, scaling, and rotation without any additional coding. But if its visibility is changed to false, it will no longer be cached.

How to Test the Efficiency of GPU Rendering


There are various ways to test application performance beyond the human eye and perception. Testing your frame rate is your best benchmark. Please refer to Chapter 19 for more information.

Matrices

Being familiar with matrices will help you better understand rendering and hardware acceleration. Matrices were first introduced with Flash 8 to give developers more control over manipulation of display objects.

Every display object has an underlying matrix representation, even if it does not have graphics. It is used to determine where, at what scale, and at what orientation an object should be drawn.

A 3×3 matrix is made of rows and columns. Its elements are labeled a, b, c, d, tx, ty, u, v, and w. They are organized as follows:

[ a b tx ]

[ c d ty ]

[ u v w ]

Each element represents a specific property. The u, v, and w elements provide extra capabilities that are not used. Their values are constant, and are 0, 0, and 1, respectively:

[ x scale y skew x position ]

[ x skew y scale y position ]

[ 0 0 1 ]

There is no property for rotation. Scaling and skewing together can distort coordinates to provide what you see as rotation.

The values are used to calculate and determine a new position based on the transformation. The formula is:

x' = x*a + y*c + tx

y' = x*b + y*d + ty

where x' and y' (that is, x prime and y prime) represent the new positions based on the transformation.

Identity Matrix


When a matrix without transformation is applied, it is called an identity matrix. This is what we used in our cacheAsBitmapMatrix example earlier:

[ 1 0 0 ]

[ 0 1 0 ]

[ 0 0 1 ]

Scale is 1 (or full scale) and no skewing is applied. Using the transformation formula,

Return Main Page Previous Page Next Page

®Online Book Reader