egl_dri2: Reorganize the EGLImage constructors to share more code