美文网首页iOS优化
离屏渲染 Offscreen rendering

离屏渲染 Offscreen rendering

作者: barry | 来源:发表于2018-04-25 14:13 被阅读24次

    Instruments

    1、打开方式

    打开Instruments.png
    图片.png
    图片.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

        本文链接:https://www.haomeiwen.com/subject/vvzelftx.html