2
votes

I'm using Core Animation to animate some layers, some of them will be used to display video.

I heard that it's not a good idea (inefficient) to use multiple layers to play multiple movies. After some search I find a way to create Open GL textures with the video frames. So I would like to access the layer properties to display them with Open GL using textures (avoiding having multiple CAOpenGLLayers with OpenGL contexts for each one).

I have subclassed CALayer to place breakpoints on setFrame: but it doesn't break each time the value change. How can I determine the frame of a CALayer as it changes during an animation?

PS: I'm using CARenderer because I have to create frames by mixing all my layers and not in real time.

1

1 Answers

2
votes

Your question seems to boil down to this:

How do I access the frame/transformation of the layer mid-animation?

The answer is you have to call -presentationLayer on your CALayer. This returns another CALayer whose properties reflect the current value of any in-progress animations. Be aware, though, that this only returns an approximation of the current displayed layer. I'm pretty sure it basically recalculates the values of the animations given the current time, rather than using whatever values there were the last time the screen updated. It should be pretty darn close as long as your frame rate is high.

In any case, you can't get notified when this changes. But what you can do is check the -presentationLayer every time you need to render a new frame. Alternatively, run a CADisplayLink and check the -presentationLayer on each firing of that.

But as always, you should do performance profiling. I have no idea what the cost of computing the -presentationLayer is.