作者:范大可
链接:https://juejin.cn/post/6899635441201643534
什么是离屏渲染
Off-Screen Rendering意为离屏渲染,指的是GPU在当前屏幕缓冲区以外新开辟一个缓冲区进行渲染操作
为什么需要离屏渲染
因为在帧缓冲区渲染一个视图到屏幕中就抛弃的机制.所以当我们有多组视图需要组合随后统一处理的时候.需要在屏缓冲区额外开辟一个离屏的缓冲区去记录这些视图.随后统一处理.最后渲染显示出来
怎么产生离屏渲染
我们首先分析圆角产生离屏渲染的情况:
回顾一下.当我们给一个视图添加cornerRadius时.是给哪些视图添加了圆角?
苹果官方的解答是:
Setting the radius to a value greater than 0.0 causes the layer to begin drawing rounded corners on its background. By default, the corner radius does not apply to the image in the layer’s contents property; it applies only to the background color and border of the layer. However, setting the masksToBounds property to YES causes the content to be clipped to the rounded corners.The default value of this property