views:

128

answers:

0

When creating a custom sequential CGDataProvder to render a custom image format you specify the CGDataProviderSequentialCallbacks that should be used. While doing some optimization work to improve the speed of my sequential CGDataProvider I started to wonder about the thread safety of those callbacks.

Let's assume I have created a single CGImage with the following conditions:

  • The CGImage is backed by the custom sequential CGDataProvider.
  • The CGImage is then used to set the contents of a CALayer.
  • The CGImage is also used to create a NSBitmapImageRep that is then added to an NSImage.
  • The NSImage then renders the CGImage from the main thread while the CALayer renders the CGImage from a background thread.
  1. If the rendering occurs at the same time, what is the thread safety of the CGDataProviderSequentialCallbacks and the internal state of the custom sequential CGDataProvider?

  2. Is there anything that the sequential CGDataProvider should be doing that is not mentioned in the documentation?