Merge branch 'xa_branch'
[mesa.git] / src / egl / main / eglsurface.c
index ec51dd6ba224ffd57ac2a3ca45b1bd3b8b956ff9..c9cfb01388e60ff4a82fabb53a6f51c8648bdca0 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
 /**
  * Surface-related functions.
  */
@@ -269,8 +299,7 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
       return EGL_FALSE;
    }
 
-   memset(surf, 0, sizeof(_EGLSurface));
-   surf->Resource.Display = dpy;
+   _eglInitResource(&surf->Resource, sizeof(*surf), dpy);
    surf->Type = type;
    surf->Config = conf;
 
@@ -303,24 +332,6 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
 }
 
 
-EGLBoolean
-_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
-{
-   /* Drivers have to do the actual buffer swap.  */
-   return EGL_TRUE;
-}
-
-
-EGLBoolean
-_eglCopyBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
-                EGLNativePixmapType target)
-{
-   /* copy surface to native pixmap */
-   /* All implementation burdon for this is in the device driver */
-   return EGL_FALSE;
-}
-
-
 EGLBoolean
 _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
                  EGLint attribute, EGLint *value)
@@ -388,51 +399,6 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
 }
 
 
-/**
- * Drivers should do a proper implementation.
- */
-_EGLSurface *
-_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
-                        EGLNativeWindowType window, const EGLint *attrib_list)
-{
-   return NULL;
-}
-
-
-/**
- * Drivers should do a proper implementation.
- */
-_EGLSurface *
-_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
-                        EGLNativePixmapType pixmap, const EGLint *attrib_list)
-{
-   return NULL;
-}
-
-
-/**
- * Drivers should do a proper implementation.
- */
-_EGLSurface *
-_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
-                         const EGLint *attrib_list)
-{
-   return NULL;
-}
-
-
-/**
- * Default fallback routine - drivers should usually override this.
- */
-EGLBoolean
-_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
-{
-   if (!_eglIsSurfaceBound(surf))
-      free(surf);
-   return EGL_TRUE;
-}
-
-
 /**
  * Default fallback routine - drivers might override this.
  */
@@ -536,40 +502,6 @@ _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
 }
 
 
-EGLBoolean
-_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
-                    EGLint buffer)
-{
-   /* Just do basic error checking and return success/fail.
-    * Drivers must implement the real stuff.
-    */
-
-   if (surface->Type != EGL_PBUFFER_BIT) {
-      _eglError(EGL_BAD_SURFACE, "eglBindTexImage");
-      return EGL_FALSE;
-   }
-
-   if (surface->TextureFormat == EGL_NO_TEXTURE) {
-      _eglError(EGL_BAD_MATCH, "eglBindTexImage");
-      return EGL_FALSE;
-   }
-
-   if (buffer != EGL_BACK_BUFFER) {
-      _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage");
-      return EGL_FALSE;
-   }
-
-   if (!surface->BoundToTexture) {
-      _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage");
-      return EGL_FALSE;
-   }
-
-   surface->BoundToTexture = EGL_FALSE;
-
-   return EGL_TRUE;
-}
-
-
 EGLBoolean
 _eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
                  EGLint interval)
@@ -577,24 +509,3 @@ _eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
    _eglClampSwapInterval(surf, interval);
    return EGL_TRUE;
 }
-
-
-#ifdef EGL_VERSION_1_2
-
-/**
- * Example function - drivers should do a proper implementation.
- */
-_EGLSurface *
-_eglCreatePbufferFromClientBuffer(_EGLDriver *drv, _EGLDisplay *dpy,
-                                  EGLenum buftype, EGLClientBuffer buffer,
-                                  _EGLConfig *conf, const EGLint *attrib_list)
-{
-   if (buftype != EGL_OPENVG_IMAGE) {
-      _eglError(EGL_BAD_PARAMETER, "eglCreatePbufferFromClientBuffer");
-      return NULL;
-   }
-
-   return NULL;
-}
-
-#endif /* EGL_VERSION_1_2 */