What is the context parameter to CGContextDrawLayerInRect()?

57 views Asked by At

The documentation says: The graphics context associated with the layer. But surely that is not correct? Surely it is an unrelated CGContext, that the layer is to be drawn into? And not related to the actual CGContext associated with the layer parameter, that which CGLayerGetContext() would return?

1

There are 1 answers

0
Kevin Grant On

When a CGLayer is constructed it is given a CGContext, and you can think of that context as a template whose characteristics determine the kinds of CGContexts that will work most efficiently when drawing your layer.

So when you draw your layer, you can pass in that same exact context, or any context with similar characteristics, and it should be as efficient. On the other hand, if you provide a context that has significantly different properties than your original template, the layer may not draw as efficiently as you’d like, and/or the result may not be exactly what you want.