Graphics Reference
In-Depth Information
Limit the Use of Filters and Shadows
Filters and shadows take quite a bit of time to calculate and render within Core
Animation. Therefore, it is recommended that you keep these to a minimum and that
you avoid animating either one if possible. Here are some helpful tips:
.
Especially in the case of filters, it is possible to render a static, temporary image,
with the filter applied. This static image can then be used in place of the layer (with
filters applied) during an animation to speed up rendering. When the animation is
complete, the filtered-layer can then be swapped back in. Although this might not
apply in all situations, it can yield significant performance advantages. This can be
accomplished by asking the topmost layer to -drawInContext: that creates the static
image that can be swapped in.
.
Shadows are expensive. Because they are a partially transparent layer, they require
large calculations to determine each pixel (because each pixel needs to be calculated
on each layer until an opaque layer is hit). If shadows end up overlapping this
increases the cost dramatically. Consider limiting shadows to only the outer layers
and allow the inner layers to generate without any effects. See “Minimize Alpha
Blending” later in this chapter.
Use Transition Effects Wisely
Transition effects offer great ways to give visual clues to the users that their view of the
data or application is changing and how it is changing. From views sliding in and out of
the window to layers curling away, the intention is obvious to the users. However, transi-
tions such as filters and shadows (mentioned in the previous section), can be expensive
with regard to performance.
Therefore, when designing your applications you should consider how many transitions
you are applying to the visible application at one time or how quickly they are being
applied.
Avoid Nested Transforms
As part of the power of Core Animation, it is possible to transform multiple layers that
reside within each other. For example, you can have layers within layers all of which are
transformed on their z- axis. However, it should be noted that these transforms are applied
in real time and are not cached. Therefore when you move or animate a layer that has
multiple levels of transforms, each transform needs to be recalculated for each frame of
the animation.
To increase performance, avoid using multiple levels of transforms while your
animations run.
Search WWH ::




Custom Search