Software drawing (efficient drawing 13.1), software drawing 13.1

Source: Internet
Author: User

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.CALayerYou only need some memory related to yourself: only its host graph consumes a certain amount of memory space. Even ifContentsYou do not need to increase the size of an image. If the same image is replaced by multiple layersContentsAttribute, they will share the same block of memory instead of copying the block.

But once you implementCALayerDelegateProtocol-DrawLayer: inContext:Method orUIViewIn-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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.