代码改变世界

EAGLLayer.opaque 设置为 YES

2012-11-13 16:32  三戒1993  阅读(302)  评论(0编辑  收藏  举报

By default, CALayers are set to non-opaque (i.e. transparent). However, this is bad for performance reasons (especially with OpenGL), so it’s best to set this as opaque when possible.

Improving Compositing Performance in Core Animation

The contents of renderbuffers are animated and composited along with any other Core Animation layers inyour view hierarchy, regardless of whether those layers were drawn with OpenGL ES, Quartz or other graphicslibraries. That’s helpful, because it means that OpenGL ES is a first-‐class citizen to Core Animation. However,mixing OpenGL ES content with other content takes time; when used improperly, your application may performtoo slowly to reach interactive frame rates. The performance penalties for mixing and matching content varydepending on the underlying graphics hardware on the iOS device; devices that use the PowerVR MBX graphicsprocessor incur more severe penalties when compositing complex scenes. For best results, alway test yourapplication on all iOS devices you intend it to ship on.

For the absolute best performance, your application should rely solely on OpenGL ES to render your content.To do this, size the view that holds your CAEAGLLayer object to match the screen, set its opaque propertyto YES, and ensure that no other Core Animation layers or views are visible. If your OpenGL ES layer is compositedon top of other layers, making your CAEAGLLayer object opaque reduces but doesn’t eliminate the performancecost.

If your CAEAGLLayer object is blended on top of layers underneath it in the layer hierarchy, the renderbuffer’scolor data must be in a premultiplied alpha format to be composited correctly by Core Animation. BlendingOpenGL ES content on top of other content has a severe performance penalty. 

版权声明:本文为博主原创文章,未经博主允许不得转载。