From 5dc0f49084f322dd8ff6eb585212eea8b50e3377 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 6 May 2010 22:40:25 -0400 Subject: egl: Implement EGL_NOK_texture_from_pixmap This extension allows a color buffer to be used for both rendering and texturing. EGL allows the use of color buffers of pbuffer drawables for texturing, this extension extends this to allow the use of color buffers of pixmaps too. --- src/egl/main/eglsurface.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/egl/main/eglsurface.c') diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 8026a6314d..d46bdb0672 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -36,12 +36,17 @@ _eglClampSwapInterval(_EGLSurface *surf, EGLint interval) static EGLint _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) { + _EGLDisplay *dpy = surf->Resource.Display; EGLint type = surf->Type; + EGLint texture_type = EGL_PBUFFER_BIT; EGLint i, err = EGL_SUCCESS; if (!attrib_list) return EGL_SUCCESS; + if (dpy->Extensions.NOK_texture_from_pixmap) + texture_type |= EGL_PIXMAP_BIT; + for (i = 0; attrib_list[i] != EGL_NONE; i++) { EGLint attr = attrib_list[i++]; EGLint val = attrib_list[i]; @@ -125,7 +130,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) surf->LargestPbuffer = !!val; break; case EGL_TEXTURE_FORMAT: - if (type != EGL_PBUFFER_BIT) { + if (!(type & texture_type)) { err = EGL_BAD_ATTRIBUTE; break; } @@ -143,7 +148,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) surf->TextureFormat = val; break; case EGL_TEXTURE_TARGET: - if (type != EGL_PBUFFER_BIT) { + if (!(type & texture_type)) { err = EGL_BAD_ATTRIBUTE; break; } @@ -160,7 +165,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) surf->TextureTarget = val; break; case EGL_MIPMAP_TEXTURE: - if (type != EGL_PBUFFER_BIT) { + if (!(type & texture_type)) { err = EGL_BAD_ATTRIBUTE; break; } @@ -452,11 +457,16 @@ EGLBoolean _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer) { + EGLint texture_type = EGL_PBUFFER_BIT; + /* Just do basic error checking and return success/fail. * Drivers must implement the real stuff. */ - if (surface->Type != EGL_PBUFFER_BIT) { + if (dpy->Extensions.NOK_texture_from_pixmap) + texture_type |= EGL_PIXMAP_BIT; + + if (!(surface->Type & texture_type)) { _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); return EGL_FALSE; } @@ -466,6 +476,11 @@ _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, return EGL_FALSE; } + if (surface->TextureTarget == EGL_NO_TEXTURE) { + _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + return EGL_FALSE; + } + if (buffer != EGL_BACK_BUFFER) { _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); return EGL_FALSE; -- cgit v1.2.3