gl: Add private glReadPixels() wrapper
For the software fallback path in gdk_cairo_draw_from_gl() we use glReadPixels() to read the contents of a framebuffer object in order to put it inside a Cairo image surface we can blend on the CPU. In order to do that, we use GL_PACK_ROW_LENGTH, which is only available in desktop GL, GLES 3.0, or if the GL_EXT_unpack_subimage extension is present. Older GLES 2.0 drivers would just be out of luck. Instead of bailing out, let's implement unpacking line by line, to adjust for the Cairo image surface stride, like we do when uploading textures. In order to avoid complicating an already big function, we should wrap our glReadPixels() call with our own wrapper that performs checks and calls the appropriate functions with the appropriate data.
Showing with 61 additions and 27 deletions