离屏渲染 Offscreen rendering

Instruments

1、打开方式

离屏渲染 Offscreen rendering_第1张图片
打开Instruments.png

离屏渲染 Offscreen rendering_第2张图片
图片.png

离屏渲染 Offscreen rendering_第3张图片
图片.png

2 触发方式

The biggest bottlenecks to graphics performance is offscreen rendering and blending – they can happen for every frame of the animation and can cause choppy scrolling.

Offscreen rendering (software rendering) happens when it is necessary to do the drawing in software (offscreen) before it can be handed over to the GPU. Hardware does not handles text rendering and advanced compositions with masks and shadows.

The following will trigger offscreen rendering:

  • Any layer with a mask (layer.mask)

  • Any layer with layer.masksToBounds / view.clipsToBounds being true

  • Any layer with layer.allowsGroupOpacity set to YES and layer.opacity is less than 1.0
    When does a view (or layer) require offscreen rendering?

  • Any layer with a drop shadow (layer.shadow*).
    Tips on how to fix: https://markpospesel.wordpress.com/tag/performance/

  • Any layer with layer.shouldRasterize being true

  • Any layer with layer.cornerRadius, layer.edgeAntialiasingMask, layer.allowsEdgeAntialiasing

  • Any layer with layer.borderWith and layer.borderColor?
    Missing reference / proof

  • Text (any kind, including UILabel, CATextLayer, Core Text, etc).

  • Most of the drawing you do with CGContext in drawRect:. Even an empty implementation will be rendered offscreen.

  • 阴影开启shadowPath wwdc 2014 session 419里有相应介绍

3 优缺点

离屏渲染优缺点

4 文档下载

WWDC 2014 - Session 419 - iOS

你可能感兴趣的:(离屏渲染 Offscreen rendering)