简体   繁体   English

ActionScript-位图缓存与图像资产性能

[英]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. 我创建了一个全光谱色轮Sprite对象,该对象由1440个矢量三角形或切片组成(如果需要)。

since i want to animate the color wheel, i've activated the display object's cacheAsBitmap property. 由于我想为色轮设置动画,因此我激活了显示对象的cacheAsBitmap属性。 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. 通过无损压缩将色轮的PNG屏幕快照导入到库中,将其转换为Sprite,然后旋转此新图像资源在动画过程中表现出色。

why does an uncompressed PNG image asset import out perform the same vector image with cacheAsBitmap property set to true? 为什么未压缩的PNG图像资产导入会在cacheAsBitmap属性设置为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; cacheAsBitmap仅适用于正在翻译而不是旋转的对象; 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. cacheAsBitmap属性最适合与大多数具有静态内容且不经常缩放和旋转的影片剪辑一起使用。 With such movie clips, cacheAsBitmap can lead to performance increases when the movie clip is translated (when its x and y position is changed). 使用此类影片剪辑,在平移影片剪辑时(更改其x和y位置时),cacheAsBitmap可以提高性能。

This is because the cached bitmap is copied pixel-by-pixel directly to the display surface (for speed -- this is called blitting ). 这是因为将缓存的位图逐像素直接复制到显示表面(为了提高速度,这称为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. 仅当应用了转换时才重新计算位图是一项设计决策,在最常见的情况下(转换不经常进行转换),可以提高性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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