Off-screen rendering in iOS performance optimization

Source: Internet
Author: User

GPU screen rendering is available in the following two ways:

    • On-Screen Rendering
      means the current screen rendering, which refers to the rendering operation of the GPU in the screen buffer currently used for display.

    • Off-screen Rendering
      Off-screen rendering, refers to the GPU in the current screen buffer to open a new buffer for rendering operations.
special off-screen rendering:If rendering in the current screen buffer that is not in the GPU is called off-screen rendering, there is another special "off-screen rendering" method:CPU Rendering. If we rewrite the DrawRect method and draw using any of the core graphics techniques, CPU rendering is involved. The entire rendering process is done synchronously by the CPU in the app, and the rendered bitmap is finally used by the GPU for display. (CPU rendering->GPU display) when to invoke off-screen rendering:When using fillets, shadows, and masks, the blend of layer properties is specified to not be drawn directly to the screen before being pre-synthesized, so an off-screen rendering is required. why off-screen rendering can cause performance costs:Out-of-screen rendering does not imply software drawing, but it means that the layer must be displayed in arendered (either CPU or GPU) in the offscreen context. Therefore, when using off-screen rendering, it is very easy to cause performance consumption, because in OpenGL, the off-screen rendering willan out-of-screen buffer is created and rendered separately in memory, and the off-screen buffer is very performance-intensive with the current screen buffer context switch.   use instruments to monitor off-screen renderingInstruments'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 off-screen are highlighted in yellow, which means there may be a performance problem with the yellow layer.

    • Color Hits Green and Misses Red
      If Shouldrasterize is set to Yes, the corresponding render result is cached, if the layer is green, the cache is reused, and if it is red, the cache is created repeatedly, indicating that there is a performance problem.

optimizations on the iOS versionUiimageview with UIButton before IOS 9.0 will trigger off-screen rendering. IOS 9.0 UIButton Setting the fillet will trigger off-screen rendering, while the PNG picture in Uiimageview does not trigger off-screen rendering, and if you set other shadow effects, it will trigger off-screen rendering. It may be that Apple also realizes that off-screen rendering can produce performance problems, so it doesn't have to be rendered off-screen when Apple doesn't produce off-screen rendering.

Off-screen rendering in iOS performance optimization

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.