eglsurface.h revision af69d88d
13464ebd5Sriastradh/************************************************************************** 23464ebd5Sriastradh * 3af69d88dSmrg * Copyright 2008 VMware, Inc. 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; 76af69d88dSmrg 77af69d88dSmrg EGLBoolean PostSubBufferSupportedNV; 784a49301eSmrg}; 794a49301eSmrg 804a49301eSmrg 81cdc920a0SmrgPUBLIC EGLBoolean 82cdc920a0Smrg_eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, 834a49301eSmrg _EGLConfig *config, const EGLint *attrib_list); 844a49301eSmrg 854a49301eSmrg 864a49301eSmrgextern EGLBoolean 874a49301eSmrg_eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint *value); 884a49301eSmrg 894a49301eSmrg 904a49301eSmrgextern EGLBoolean 914a49301eSmrg_eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint value); 924a49301eSmrg 934a49301eSmrg 943464ebd5SriastradhPUBLIC extern EGLBoolean 954a49301eSmrg_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer); 964a49301eSmrg 97af69d88dSmrgPUBLIC extern EGLBoolean 98af69d88dSmrg_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer); 99af69d88dSmrg 1004a49301eSmrg 1014a49301eSmrgextern EGLBoolean 1024a49301eSmrg_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval); 1034a49301eSmrg 1044a49301eSmrg 1053464ebd5Sriastradh/** 1063464ebd5Sriastradh * Increment reference count for the surface. 1073464ebd5Sriastradh */ 1083464ebd5Sriastradhstatic INLINE _EGLSurface * 1093464ebd5Sriastradh_eglGetSurface(_EGLSurface *surf) 1103464ebd5Sriastradh{ 1113464ebd5Sriastradh if (surf) 1123464ebd5Sriastradh _eglGetResource(&surf->Resource); 1133464ebd5Sriastradh return surf; 1143464ebd5Sriastradh} 1154a49301eSmrg 1164a49301eSmrg 1174a49301eSmrg/** 1183464ebd5Sriastradh * Decrement reference count for the surface. 1194a49301eSmrg */ 1204a49301eSmrgstatic INLINE EGLBoolean 1213464ebd5Sriastradh_eglPutSurface(_EGLSurface *surf) 1224a49301eSmrg{ 1233464ebd5Sriastradh return (surf) ? _eglPutResource(&surf->Resource) : EGL_FALSE; 124cdc920a0Smrg} 125cdc920a0Smrg 126cdc920a0Smrg 127cdc920a0Smrg/** 1283464ebd5Sriastradh * Link a surface to its display and return the handle of the link. 129cdc920a0Smrg * The handle can be passed to client directly. 130cdc920a0Smrg */ 131cdc920a0Smrgstatic INLINE EGLSurface 1323464ebd5Sriastradh_eglLinkSurface(_EGLSurface *surf) 133cdc920a0Smrg{ 1343464ebd5Sriastradh _eglLinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE); 135cdc920a0Smrg return (EGLSurface) surf; 136cdc920a0Smrg} 137cdc920a0Smrg 138cdc920a0Smrg 139cdc920a0Smrg/** 140cdc920a0Smrg * Unlink a linked surface from its display. 141cdc920a0Smrg * Accessing an unlinked surface should generate EGL_BAD_SURFACE error. 142cdc920a0Smrg */ 143cdc920a0Smrgstatic INLINE void 144cdc920a0Smrg_eglUnlinkSurface(_EGLSurface *surf) 145cdc920a0Smrg{ 146cdc920a0Smrg _eglUnlinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE); 147cdc920a0Smrg} 148cdc920a0Smrg 149cdc920a0Smrg 150cdc920a0Smrg/** 151cdc920a0Smrg * Lookup a handle to find the linked surface. 152cdc920a0Smrg * Return NULL if the handle has no corresponding linked surface. 153cdc920a0Smrg */ 154cdc920a0Smrgstatic INLINE _EGLSurface * 155cdc920a0Smrg_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) 156cdc920a0Smrg{ 157cdc920a0Smrg _EGLSurface *surf = (_EGLSurface *) surface; 158cdc920a0Smrg if (!dpy || !_eglCheckResource((void *) surf, _EGL_RESOURCE_SURFACE, dpy)) 159cdc920a0Smrg surf = NULL; 160cdc920a0Smrg return surf; 161cdc920a0Smrg} 162cdc920a0Smrg 163cdc920a0Smrg 164cdc920a0Smrg/** 165cdc920a0Smrg * Return the handle of a linked surface, or EGL_NO_SURFACE. 166cdc920a0Smrg */ 167cdc920a0Smrgstatic INLINE EGLSurface 168cdc920a0Smrg_eglGetSurfaceHandle(_EGLSurface *surf) 169cdc920a0Smrg{ 170cdc920a0Smrg _EGLResource *res = (_EGLResource *) surf; 171cdc920a0Smrg return (res && _eglIsResourceLinked(res)) ? 172cdc920a0Smrg (EGLSurface) surf : EGL_NO_SURFACE; 173cdc920a0Smrg} 174cdc920a0Smrg 175cdc920a0Smrg 1764a49301eSmrg#endif /* EGLSURFACE_INCLUDED */ 177