19

What I find interesting with CAReplicatorLayer:

  • It is able to display a CALayer multiple times with different transforms very efficiently (how?)
  • It seems like it somehow reuses the "backing store" for the replicated layer and even apply some color tints to it (how?)

I would like to get hands on either the source code or get some knowledge of the magic behind CAReplicatorLayer. I would like to have a CALayer class similar to CAReplicatorLayer, but with more control. I would like to have control on the transform individually for each replicated instance.

So asked in a totally different manner: is it possible to get the "backing store" for a CALayer and display it however I want as many times I want?

(by "backing store" I mean the rendered texture for the CALayer/UIView. I don't know much about what's happening under the hoods of CoreAnimation/QuartzCore).


Why I'm not looking at alternatives like e.g. rendering the CALayer to a UIImage:

  • Performance
  • Content is dynamic/changing pretty frequently under the transitions
  • It would be hands down awesome to do it the other way!
hfossli
  • 22,616
  • 10
  • 116
  • 130

1 Answers1

10

The special-purpose CALayers like CAReplicatorLayer or CAGradientLayer are able (via private APIs) do execute their drawing directly on the GPU using fast filling or copying. In a sense they are different such that the backing store is not in normal RAM, but directly on the GPU.

Cocoanetics
  • 8,171
  • 2
  • 30
  • 57
  • Thanks for the response. That does not sound promising for what I was hoping to do, but indeed clarifies some aspects. :) – hfossli Dec 13 '12 at 09:46
  • you can always use an EAGLLayer and draw on that with OpenGL with shaders. This would be the fasted way to do custom drawing. – Cocoanetics Dec 13 '12 at 12:27
  • I suppose I can't do that backed by UIViews? Or in my case: I'm doing something as bold as replicating a UIWebView. I would very much like something similar to CAReplicatorLayer, but with control over each individual instance' transform (instead of the incremental one CAReplicatorLayer offers). If OpenGL/EAGLLayer offers that I would be more than happy. – hfossli Dec 13 '12 at 13:46