When does a view (or layer) require offscreen rendering?

后端 未结 3 1869
轮回少年
轮回少年 2020-12-12 08:45

Hello
this weekend I started to watch the 2011 WWDC videos. I\'ve found really interesting topics about iOS. My favorites were about performance and graphics, but I\'ve

3条回答
  •  甜味超标
    2020-12-12 09:17

    Offscreen rendering / Rendering on the CPU

    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.


    This post covers blending and other things affecting performance: What triggers offscreen rendering, blending and layoutSubviews in iOS?

提交回复
热议问题