Summary: Write minispec on EGL extension for creating Textures from X pixmaps
Owner: Sachin Gupta
Overview of pixmap extensions
EGL Texture from Pixmap extension
Introduction : The Texture from pixmap EGL extension extension allows a content (color buffer/image buffer) of a pixmap to be used as a 2D Texture image in OpenGL ES . More specifically this extension is used on X.11 based native window system where contents of XPixmap are used as texture. Maemo uses this extension.This extension is named as EGL_NOKIA_texture_from_pixmap as it is defined by NOKIA Alternatively there ia a khronos extension by name EGL_KHR_image_pixmap which proivdes a similar functionality.Meego compositor uses this extension for Meego desktop composition.
Purpose: This extension is used by Maemo desktop compositor (hildon-desktop/clutter) to composite the non-fullscreen windows along with the maemo desktop. This extension is most efficient way of using OpenGL for desktop composition on X11 based system because of 2 reasons:
When the X11 window is not in full screen mode it has an underlying X11 pixmap which represents the window content. Since EGL is supposed to provide support for native pixmaps ( for X11 sytem this is X11 pixnap) through OpenGL pixmap surfaces ( eglcreatepixmapsurface) , this extension can directly use this feature. Note -> The standard OpenGl support for native pixmaps allows applications to render to pixmaps only ,this extension allows the contents of pixmaps to be used as textures as well)
- The standard API’s for using textures like glTexImage2D mandate that the OpenGL layer copy the contents into its internal buffer.This extension allows to avoid the copy of contents as it directly uses the underlyin color buffer of pixmap as texture thus saving mencpy operation which could be expensive .
Overview of Maemo desktop composition
Maemo desktop composition engine handles the case when apllication window is full screen differently from the case when application window is not fullscreen.
- When the application window is fullscreen the display driver frame buffer acts as the front buffer for the window i.e the application window contents are directly rendered to framebuffer bypassing the desktop composition engine.
- When ever the application window is not fullscreen , X Composite window manager is active and all the windows are redirected in pixmaps(offscreen memory) through X11 APIs XCompositeRedirectWindow and XCompositeRedirectSubwindows’. The desktop composition manager requests the composition manager to provide the pixmap corresponding to window through X11 API XCompositeNameWindowPixmap.This pixmap is wrapped into an egl surface through EGL API eglCreatePixmapSurface.This egl pixmap surface is registered as texture with OpenGL engine through texture from pixmap extension i.e EGL API eglbindteximage.Then this texture is composited with the desktop window using OpenGL engine.Finally eglreleaseteximage API is used to unregister the pixmap surface from the current texture object.This mechanism gives the look and feel of non fullscreen windows appearing on desktop.
Nokia Texture from pixmap usage sequence of calls
egl_extensions = eglQueryString (display,EGL_EXTENSIONS) check if the extensions string contains EGL_NOKIA_texture_from_pixmap eglChooseConfig(...) eglCreatePixmapSurface (...) glEnable (GL_TEXTURE_2D) glGenTextures(...) glBindTexture(...) eglBindTexImage(...) glDrawArrays(...) eglReleaseTexImage(...)
Nokia Texture from pixmap extension implementation
The texturefrompixmap extension basically requires that EGL API eglbindteximage is able to take a pixmap surface as a parameter and is able to bind the underlying color/image buffer of pixmap surface as a texture to currently active texture object. eglbindteximage is already defined by the standard but standard only defines usage of pbuffer surfaces with this API.The texture from pixmap extension extends this API to also use pixmap surfaces as textures.
Nokia EGL_KHR_image_pixmap extension
The EGL_KHR_image_pixmap extension is defined by khronos group.This extension also requires EGL_KHR_image extension ,EGL_KHR_image_base extension and GL_OES_EGL_image .The EGL_KHR_image extension defines a new object EGLImageKHR which is used for sharing image data between client and OpenGl layer. (EGL_NOKIA_texture_from_pixmap extension uses eglsurface). The EGL_KHR_image_base and EGL_KHR_image_pixmap define the API’s (eglCreateImageKHR and eglDestroyImageKHR) for creating objects of type EGLImageKHR from native pixmaps (X11 pixmaps). For more details refer to site http://www.khronos.org/registry/egl
GL_OES_EGL_image extension defines API glEGLImageTargetTexture2DOES Which can be used to bind the underlying imagebuffer of EGLImageKhr object.to currently active texture object.
EGL_KHR_image_pixmap extension usage sequence of calls
egl_image = eglCreateImageKHR(dpy, 0,EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)native_pixmap,attribs); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,textureId); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image); glDrawArrays(...); eglDestroyImageKHR(dpy, egl_image);
Meego Software components
Meego compositor uses Khronos extension for egl based system whereas for glx based systems it uses glXBindTexImageEXT and glXReleaseTexImageEXT which is same as NOKIA extension for texture from pixmap support. Though the Meego compositor also defines a way to use custom texture from pixmap extension its suppport needs to be verified (For eg rebindPixmap support)
Clutter released as part of Clutter project doesnot allow texture from pixmap functionality with egl backend.The texture from pixmap functionality is only provided by X11 and Glx backends.The glx backend uses glXBindTexImageEXT and glXReleaseTexImageEXT to provide this functionality.The X11 backend uses XShmGetImage API to get the image data corresponding to window pixmap and then this image is used as texture with OpenGL using OpenGL API’s glTexImage2d and glTexSubImage2D.
Clutter released as part of maemo does implement texture from pixmap functionality with egl backend using the NOKIA extension for texture from pixmap
Platform/UserPlatforms/Heads/EGL_Texture_From_Pixmap (last modified 2010-08-20 11:43:33)