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:
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