We have a pixel buffer pool managed by the system(created using CVPixelBufferPoolCreate
API). And each time when we need a pixel buffer, we call CVPixelBufferPoolCreatePixelBuffer
to created one from the pool. Then we override all pixels of the buffer, getting IOSurface
from the buffer, and then set the IOSurface
as CALayer
's contents
property in another process to show it, everything works fine.
Now we want to do some optimization by only override pixels that's changed between frames. The way we'd like to do is that after we call CVPixelBufferPoolCreatePixelBuffer
to create a buffer, we get the underlying IOSurface
id map it with a frame info. Next time if we get the same IOSurface
id, we just compare the current frame info with the one we stored and only update the changed pixels in CVPixelBuffer
.
However, there is no document mentioning whether the CVPixelBuffer
created using CVPixelBufferPoolCreatePixelBuffer
will contain previous pixels(content before it's returned to the pool). Do we have this guarantee? If not, is there any way we can know whether the created buffer contains the previous pixels or not?