0

I'm using CoreAnimation to draw things to the screen (e.g. CAShapeLayer, CAReplicatorLayer, CATextLayer).

What is the fastest way to obtain a texture of the drawn content on screen? (way faster than renderInContext which takes up to 2 seconds in my scenario)

Somewhere on my device exists a render buffer with this drawn content and the probably best solution would be to be able to access it.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Max
  • 2,699
  • 2
  • 27
  • 50
  • Are you interested in using private API or not (i.e. do you want your app on the store)? – David Rönnqvist Nov 23 '14 at 12:20
  • I want my app to be on the store in the end, but I'm looking for any way to get it to work at first. So if you know of a private API to do it, I'd be happy to know! – Max Nov 24 '14 at 13:14

1 Answers1

0

You can get to the frame buffer as an IOSurface and create an image from that (this is private API on iOS). This will likely be the fastest solution.

You should be able to puzzle something together by searching for "iOS IOSurface" (since it's private you can't really read any official documentation about it (however it is public on OS X so there is some documentation there that is mostly relevant). This questions seems to have gotten it mostly right, and looks like a good starting point.

However, this won't help you if you want to release the app on the store and I don't think that it will give you any code that you could reuse in the store.

Community
  • 1
  • 1
David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
  • Thank you, that looks promising! (I'm having a long term battle with the CARenderServer / CA Performance issues anyway, see my other questions....so this thing might give some more control!) But...where do I get these IOSurface Headers from? I found out I should copy them over from the Mac Headers, but they aren't there on Yosemite. – Max Nov 24 '14 at 16:13
  • Yeah, right, I saw this ;) But that's for Mac and not for iOS. I found the framework there too, but how to get it for iOS? I'll google a bit more! – Max Nov 24 '14 at 17:30