Re: [SOLVED] Problem getting my layers to draw in the right order
Re: [SOLVED] Problem getting my layers to draw in the right order
- Subject: Re: [SOLVED] Problem getting my layers to draw in the right order
- From: David Duncan <email@hidden>
- Date: Tue, 26 Jul 2011 10:51:46 -0700
On Jul 26, 2011, at 7:50 AM, Kyle Sluder wrote:
> From the description given in the documentation, I would think that because CA is sorting the layers based on sibling order and zPosition that it would be possible to render a layer of zPosition=0 atop a nephew layer with zPosition=1000.
>
> But I can see why this would be difficult: Core Animation apparently applies the zPosition to the layer's GL quad. In order to support rendering zPosition=0 atop zPosition=1000, it would need to maintain a copy of the depth buffer at each level of the layer. Rendering a layer would involve a depth test, then copying the depth buffer to be used when rendering the sublayers and discarding that depth buffer when done.
Except for certain situations, Core Animation effectively treats each layer as a rendering target – that is, all of that layer's sublayers are flattened into that layer to produce the final image for that layer. What this means is that only local sibling ordering matters at any given level of the layer tree. Graphically that means if you have this:
X
| \
Y Z
|
W
W can never render on top of Z, because W always renders "into" Y, and Z always renders on top of Y.
Sibling drawing order is more complicated in the presence of certain types of transforms, such as perspective transforms and rotations around X/Y because these transforms make a layer's geometry more complex. To render these properly, Core Animation will cut a layer's rendered image properly to match expectations for that geometry.
> This is a place where the abstraction leaks. I think the documentation should be updated to make it clearer that zPosition can't be used for general Quartz Transparency Layer type effects, which it seems to imply. We should also probably get a CALayerGroup layer class that *does* render all of its sublayers into a quad whose z position is equal to that of the CALayerGroup's zPosition property.
This is basically what you have with a CALayer already (zPosition should be usable as a way to order layers, but sublayer order is generally better). If you use a CATransformLayer, or a CAReplicatorLayer with preservesDepth=YES then you are effectively asking Core Animation to act more like a textured quad renderer. See the CATransformLayer documentation for details on the restrictions that come with that.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden