Off-screen rendering _ios in IOS performance optimization

Source: Internet
Author: User

GPU Screen rendering has the following two ways:

On-Screen Rendering

The current screen rendering means that the rendering of the GPU is performed in the screen buffer currently used for display.

Off-screen Rendering

Off-screen rendering means that the GPU is opening a new buffer for rendering operations outside the current screen buffer.

Special off-screen rendering:

If rendering in the current screen buffer on the GPU is called off screen rendering, there is another special "off screen rendering" approach: CPU rendering.
If we rewrite the DrawRect method and use any of the core graphics techniques for drawing operations, it involves CPU rendering. The entire rendering process is synchronized by the CPU in the app

Finished, the rendered bitmap is finally handed over to the GPU for display. (CPU rendering->GPU display)

When will evoke off-screen rendering:

When using rounded corners, shadows, and masks, the mixture of layer properties is specified to not be drawn directly on the screen until it is synthesized, so that the on-screen rendering is required.

Why off-screen rendering can result in performance consumption:

Off-screen rendering does not mean that the software is drawn, but it means that the layer must be rendered in a screen context before it is displayed (whether the CPU or the GPU).
So when using off-screen rendering is very easy to cause performance consumption, because in OpenGL, off-screen rendering will create a separate screen buffer in memory and render, while the screen outer buffer with the current screen buffer context switch is very performance.

Use instruments to monitor off-screen rendering

Instruments's core animation tool has several check options related to OFF screen rendering:
Color offscreen-rendered Yellow

When turned on, the layers that need to be rendered out of the screen are highlighted in yellow, which means that there may be a performance problem with the yellow layer.

Color Hits Green and misses Red

If the shouldrasterize is set to Yes, the corresponding render result is cached, if the layer is green, it means that the cache is reused, and if it is red it means that the cache is created repeatedly, which means there is a performance problem.

Optimizations on the iOS version

Uiimageview with UIButton before IOS 9.0 will trigger off-screen rendering.

After IOS 9.0 UIButton set rounded corners will trigger off-screen rendering, and uiimageview PNG image set rounded corner will not trigger off the screen rendering, if you set other shadow effects such as or will trigger off screen rendering.

It may be that Apple also realizes that off-screen rendering can be a performance problem, so it doesn't have to be rendered out of the screen without leaving the screen to render it.

Through this article, I hope to help everyone, thank you for your support to this site!

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.