eglsurface.h revision 3464ebd5
13464ebd5Sriastradh/************************************************************************** 23464ebd5Sriastradh * 33464ebd5Sriastradh * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. 43464ebd5Sriastradh * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> 53464ebd5Sriastradh * Copyright 2010 LunarG, Inc. 63464ebd5Sriastradh * All Rights Reserved. 73464ebd5Sriastradh * 83464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a 93464ebd5Sriastradh * copy of this software and associated documentation files (the 103464ebd5Sriastradh * "Software"), to deal in the Software without restriction, including 113464ebd5Sriastradh * without limitation the rights to use, copy, modify, merge, publish, 123464ebd5Sriastradh * distribute, sub license, and/or sell copies of the Software, and to 133464ebd5Sriastradh * permit persons to whom the Software is furnished to do so, subject to 143464ebd5Sriastradh * the following conditions: 153464ebd5Sriastradh * 163464ebd5Sriastradh * The above copyright notice and this permission notice (including the 173464ebd5Sriastradh * next paragraph) shall be included in all copies or substantial portions 183464ebd5Sriastradh * of the Software. 193464ebd5Sriastradh * 203464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 213464ebd5Sriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 223464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 233464ebd5Sriastradh * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 243464ebd5Sriastradh * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 253464ebd5Sriastradh * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 263464ebd5Sriastradh * DEALINGS IN THE SOFTWARE. 273464ebd5Sriastradh * 283464ebd5Sriastradh **************************************************************************/ 293464ebd5Sriastradh 303464ebd5Sriastradh 314a49301eSmrg#ifndef EGLSURFACE_INCLUDED 324a49301eSmrg#define EGLSURFACE_INCLUDED 334a49301eSmrg 344a49301eSmrg 354a49301eSmrg#include "egltypedefs.h" 36cdc920a0Smrg#include "egldisplay.h" 374a49301eSmrg 384a49301eSmrg 394a49301eSmrg/** 404a49301eSmrg * "Base" class for device driver surfaces. 414a49301eSmrg */ 424a49301eSmrgstruct _egl_surface 434a49301eSmrg{ 44cdc920a0Smrg /* A surface is a display resource */ 45cdc920a0Smrg _EGLResource Resource; 464a49301eSmrg 47cdc920a0Smrg /* The context that is currently bound to the surface */ 48cdc920a0Smrg _EGLContext *CurrentContext; 494a49301eSmrg 504a49301eSmrg _EGLConfig *Config; 514a49301eSmrg 524a49301eSmrg EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */ 534a49301eSmrg 54cdc920a0Smrg /* attributes set by attribute list */ 55cdc920a0Smrg EGLint Width, Height; 56cdc920a0Smrg EGLenum TextureFormat; 57cdc920a0Smrg EGLenum TextureTarget; 58cdc920a0Smrg EGLBoolean MipmapTexture; 59cdc920a0Smrg EGLBoolean LargestPbuffer; 60cdc920a0Smrg EGLenum RenderBuffer; 61cdc920a0Smrg EGLenum VGAlphaFormat; 62cdc920a0Smrg EGLenum VGColorspace; 63cdc920a0Smrg 64cdc920a0Smrg /* attributes set by eglSurfaceAttrib */ 65cdc920a0Smrg EGLint MipmapLevel; 66cdc920a0Smrg EGLenum MultisampleResolve; 67cdc920a0Smrg EGLenum SwapBehavior; 684a49301eSmrg 694a49301eSmrg EGLint HorizontalResolution, VerticalResolution; 704a49301eSmrg EGLint AspectRatio; 71cdc920a0Smrg 72cdc920a0Smrg EGLint SwapInterval; 73cdc920a0Smrg 74cdc920a0Smrg /* True if the surface is bound to an OpenGL ES texture */ 75cdc920a0Smrg EGLBoolean BoundToTexture; 764a49301eSmrg}; 774a49301eSmrg 784a49301eSmrg 79cdc920a0SmrgPUBLIC EGLBoolean 80cdc920a0Smrg_eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, 814a49301eSmrg _EGLConfig *config, const EGLint *attrib_list); 824a49301eSmrg 834a49301eSmrg 844a49301eSmrgextern EGLBoolean 854a49301eSmrg_eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint *value); 864a49301eSmrg 874a49301eSmrg 884a49301eSmrgextern EGLBoolean 894a49301eSmrg_eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint value); 904a49301eSmrg 914a49301eSmrg 923464ebd5SriastradhPUBLIC extern EGLBoolean 934a49301eSmrg_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer); 944a49301eSmrg 954a49301eSmrg 964a49301eSmrgextern EGLBoolean 974a49301eSmrg_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval); 984a49301eSmrg 994a49301eSmrg 1003464ebd5Sriastradh/** 1013464ebd5Sriastradh * Increment reference count for the surface. 1023464ebd5Sriastradh */ 1033464ebd5Sriastradhstatic INLINE _EGLSurface * 1043464ebd5Sriastradh_eglGetSurface(_EGLSurface *surf) 1053464ebd5Sriastradh{ 1063464ebd5Sriastradh if (surf) 1073464ebd5Sriastradh _eglGetResource(&surf->Resource); 1083464ebd5Sriastradh return surf; 1093464ebd5Sriastradh} 1104a49301eSmrg 1114a49301eSmrg 1124a49301eSmrg/** 1133464ebd5Sriastradh * Decrement reference count for the surface. 1144a49301eSmrg */ 1154a49301eSmrgstatic INLINE EGLBoolean 1163464ebd5Sriastradh_eglPutSurface(_EGLSurface *surf) 1174a49301eSmrg{ 1183464ebd5Sriastradh return (surf) ? _eglPutResource(&surf->Resource) : EGL_FALSE; 119cdc920a0Smrg} 120cdc920a0Smrg 121cdc920a0Smrg 122cdc920a0Smrg/** 1233464ebd5Sriastradh * Link a surface to its display and return the handle of the link. 124cdc920a0Smrg * The handle can be passed to client directly. 125cdc920a0Smrg */ 126cdc920a0Smrgstatic INLINE EGLSurface 1273464ebd5Sriastradh_eglLinkSurface(_EGLSurface *surf) 128cdc920a0Smrg{ 1293464ebd5Sriastradh _eglLinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE); 130cdc920a0Smrg return (EGLSurface) surf; 131cdc920a0Smrg} 132cdc920a0Smrg 133cdc920a0Smrg 134cdc920a0Smrg/** 135cdc920a0Smrg * Unlink a linked surface from its display. 136cdc920a0Smrg * Accessing an unlinked surface should generate EGL_BAD_SURFACE error. 137cdc920a0Smrg */ 138cdc920a0Smrgstatic INLINE void 139cdc920a0Smrg_eglUnlinkSurface(_EGLSurface *surf) 140cdc920a0Smrg{ 141cdc920a0Smrg _eglUnlinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE); 142cdc920a0Smrg} 143cdc920a0Smrg 144cdc920a0Smrg 145cdc920a0Smrg/** 146cdc920a0Smrg * Lookup a handle to find the linked surface. 147cdc920a0Smrg * Return NULL if the handle has no corresponding linked surface. 148cdc920a0Smrg */ 149cdc920a0Smrgstatic INLINE _EGLSurface * 150cdc920a0Smrg_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) 151cdc920a0Smrg{ 152cdc920a0Smrg _EGLSurface *surf = (_EGLSurface *) surface; 153cdc920a0Smrg if (!dpy || !_eglCheckResource((void *) surf, _EGL_RESOURCE_SURFACE, dpy)) 154cdc920a0Smrg surf = NULL; 155cdc920a0Smrg return surf; 156cdc920a0Smrg} 157cdc920a0Smrg 158cdc920a0Smrg 159cdc920a0Smrg/** 160cdc920a0Smrg * Return the handle of a linked surface, or EGL_NO_SURFACE. 161cdc920a0Smrg */ 162cdc920a0Smrgstatic INLINE EGLSurface 163cdc920a0Smrg_eglGetSurfaceHandle(_EGLSurface *surf) 164cdc920a0Smrg{ 165cdc920a0Smrg _EGLResource *res = (_EGLResource *) surf; 166cdc920a0Smrg return (res && _eglIsResourceLinked(res)) ? 167cdc920a0Smrg (EGLSurface) surf : EGL_NO_SURFACE; 168cdc920a0Smrg} 169cdc920a0Smrg 170cdc920a0Smrg 1714a49301eSmrg#endif /* EGLSURFACE_INCLUDED */ 172