we’re are wondering if eglCreateWindowSurface can be used for off-screen rendering and benefit from the eglSwapBuffers function instead of using the time consuming function glReadPixels.
Or should we only use eglCreatePbufferSurface which we know is made for off-screen rendering?
When you use eglCreateWindowSurface, the buffers are generally ownership of the window system and part of the “window”. The only way to get to the pixels is to use glReadPixels or use eglLockSurface and query for the buffer and all the attributes that describe its memory layout. But that is not always supported.
eglCreatePbufferSurface was intended for use of offscreen rendering - specifically EGL owns the buffer. However, since the addition of GL/GLES Renderbuffers objects these can be more efficient and have all the same features.
If access to the pixels is paramount, and your driver supports it, creating an EGLImage using eglCreateImage you either provide or have access to a texture, made from the image, or image made from texture, that can be used with a Framebufferobject. Then you can access the pixels of the image - provided you understand the memory layout of the pixels/buffer.
Hope that covers your use case.