简体   繁体   中英

ActionScript - Bitmap Cacheing vs. Image Asset Performance

i've created a full spectrum color wheel Sprite object that is composed of 1440 vector triangles, or slices if you will.

since i want to animate the color wheel, i've activated the display object's cacheAsBitmap property. however, caching the vector as a bitmap does not increase performance during animation – it remains slow, jumpy.

importing a PNG screenshot of the color wheel into the library with lossless compression, converting it to a Sprite, and rotating this new image asset performs great during animation.

why does an uncompressed PNG image asset import out perform the same vector image with cacheAsBitmap property set to true?

Because each time you rotate the object, it has to recalculate a new bitmap.

cacheAsBitmap is only intended for objects that are being translated, not rotated; from the docs :

The cacheAsBitmap property is best used with movie clips that have mostly static content and that do not scale and rotate frequently. With such movie clips, cacheAsBitmap can lead to performance increases when the movie clip is translated (when its x and y position is changed).

This is because the cached bitmap is copied pixel-by-pixel directly to the display surface (for speed -- this is called blitting ). Applying transformations to the bitmap every time it is rendered would be silly for objects that are rotated only once in a while. Recalculating the bitmap only when transformations are applied is a design decision which increases performance in the most common case, where transformations other than translation are infrequent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM