0

Possible Duplicate:
On iOS, after we create a layer from context and get the layer's context, how do these contexts relate to each other?

On iOS, we could do a CGLayerCreateWithContext using the existing Graphics Context, and we would get a CGLayer, and we can also get the Graphics Context of this CGLayer using CGLayerGetContext.

Why do we have to create this CGLayer using an existing Graphics Context? Can't we just create it without the presence of any Graphics Context? And when we get the Graphics Context of this layer, how is it related to the original Graphics Context? Couldn't they be just two separate, independent Graphics Contexts?

Community
  • 1
  • 1
Jeremy L
  • 3,770
  • 6
  • 41
  • 62
  • Same question as this, yes? [After we create a layer from context and get the layer's context, how do these contexts relate to each other?](http://stackoverflow.com/q/10672691/1218876) – Kurt Revis May 27 '12 at 17:48
  • so the answer is... for better performance? That is, we can create a new `CGLayer` with a totally unrelated Graphics Context, but if they are based on one another, then there might be speed gain, that's the main reason? – Jeremy L May 27 '12 at 18:06
  • Yes. The [Quartz 2D Programming Guide](https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_layers/dq_layers.html#//apple_ref/doc/uid/TP30001066-CH219-TPXREF101) explains it too. (Except note that you rarely, if ever, get "a window graphics context", especially on iOS -- so you can ignore the hype about it caching things on the GPU.) – Kurt Revis May 27 '12 at 18:17
  • at first I thought the Graphics Card nowadays having 512MB or 1GB might be good for caching things as it is closest to where the display functionality is. But then I also wonder how much memory the graphics card on an iPad has (does the CPU, GPU, RAM, and graphics RAM all get packed into one chip as the "system on a chip" so the graphics memory is quite limited?) – Jeremy L May 28 '12 at 02:17
  • @Kurt by the way, it seems that there is Window Graphics Context, and there is View Graphics Context. So if a CGLayer has a View Graphics Context, is it likely that it is cached on a GPU, or do you mean any caching on the GPU tend to be rare... except CALayer (not CGLayer) is said to be often cached on the GPU – Jeremy L May 28 '12 at 04:56

0 Answers0