Software drawing (efficient drawing 13.1), software drawing 13.1
Software drawing
TermsPlottingSoftware plotting is usually indicated in the context of Core Animation (that is, drawing not assisted by GPU ). In iOS, software plotting is usually completed by the Core Graphics framework. However, in some cases, compared with Core Animation and OpenGL, Core Graphics is much slower.
Software plotting is not only inefficient, but also consumes considerable memory.CALayer
You only need some memory related to yourself: only its host graph consumes a certain amount of memory space. Even ifContents
You do not need to increase the size of an image. If the same image is replaced by multiple layersContents
Attribute, they will share the same block of memory instead of copying the block.
But once you implementCALayerDelegate
Protocol-DrawLayer: inContext:
Method orUIView
In-DrawRect:
Method (in fact, the packaging method of the former), the layer creates a drawing context, the size of memory required for this context can be obtained from this formula: Layer WidthLayer Height4 bytes. The unit of width and height is pixel. For a full screen layer on the Retina iPad, the memory size is 2048.15264 bytes, equivalent to 12 MB memory, each layer needs to re-erase the memory and re-allocate each time it is re-painted.
Software plotting is expensive. unless absolutely necessary, you should avoid redrawing your view. The secret to improving the rendering performance is to avoid plotting as much as possible.