Gnash  0.8.10
configTemplates.h
Go to the documentation of this file.
00001 //
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef __CONFIG_TEMPLATES_H__
00020 #define __CONFIG_TEMPLATES_H__ 1
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include "gnashconfig.h"
00024 #endif
00025 
00026 #ifdef HAVE_EGL_EGL_H
00027 # include <EGL/egl.h>
00028 #else
00029 # error "This file needs EGL, which is part of OpenGL-ES"
00030 #endif
00031 
00032 #include "eglDevice.h"
00033 
00034 namespace gnash {
00035 namespace renderer {
00036 
00037 // From the EGL 1.4 spec:
00038 //
00039 // EGL defines several types of drawing surfaces collectively referred
00040 // to as EGLSurfaces. These include windows, used for onscreen
00041 // rendering; pbuffers, used for offscreen rendering; and pixmaps,
00042 // used for offscreen rendering into buffers that may be accessed
00043 // through native APIs. EGL windows and pixmaps are tied to native
00044 // window system windows and pixmaps.
00045 //
00046 // depth, multisample, and stencil buffers are currently used only by
00047 // OpenGL-ES.
00048 
00049 // EGL and OpenGL ES supports two rendering models: back buffered and
00050 // single buffered. Back buffered rendering is used by window and
00051 // pbuffer surfaces. Memory for the color buffer used during rendering
00052 // is allocated and owned by EGL. When the client is finished drawing
00053 // a frame, the back buffer may be copied to a visible window using
00054 // eglSwapBuffers. Pbuffer surfaces have a back buffer but no
00055 // associated window, so the back buffer need not be copied.
00056 //
00057 // Single buffered rendering is used by pixmap surfaces. Memory for
00058 // the color buffer is specified at surface creation time in the form
00059 // of a native pixmap, and client APIs are required to use that memory
00060 // during rendering. When the client is finished drawing a frame, the
00061 // native pixmap contains the final image. Pixmap surfaces typically
00062 // do not support multisampling, since the native pixmap used as the
00063 // color buffer is unlikely to provide space to store multisample
00064 // information. Some client APIs , such as OpenGL and OpenVG , also
00065 // support single buffered rendering to window surfaces. This behavior
00066 // can be selected when creating the window surface, as defined in
00067 // section 3.5.1. When mixing use of client APIs which do not support
00068 // single buffered rendering into windows, like OpenGL ES , with
00069 // client APIs which do support it, back color buffers and visible
00070 // window contents must be kept consistent when binding window
00071 // surfaces to contexts for each API type. Both back and single
00072 // buffered surfaces may also be copied to a specified native pixmap
00073 // using eglCopyBuffers.
00074 
00075 // Native rendering will always be supported by pixmap surfaces (to
00076 // the extent that native rendering APIs can draw to native
00077 // pixmaps). Pixmap surfaces are typically used when mixing native and
00078 // client API rendering is desirable, since there is no need to move
00079 // data between the back buffer visible to the client APIs and the
00080 // native pixmap visible to native rendering APIs. However, pixmap
00081 // surfaces may, for the same reason, have restricted capabilities and
00082 // performance relative to window and pbuffer surfaces.
00083 
00084 // NOTE: Single Buffering appears not to work on X11, you get no visual.
00085 //    EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER,
00086 
00087 // These are the attributes for a 24bpp, 32bit display
00088 static const EGLint attrib32_low[] = {
00089     EGL_RED_SIZE,        8,
00090     EGL_GREEN_SIZE,      8,
00091     EGL_BLUE_SIZE,       8,
00092     EGL_ALPHA_SIZE,      0,
00093     EGL_DEPTH_SIZE,      24,
00094     EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
00095     EGL_SURFACE_TYPE,    EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT,
00096     EGL_SAMPLES,         0,
00097     EGL_SAMPLE_BUFFERS,  0,  
00098     EGL_NONE
00099 };
00100 
00101 static const EGLint attrib32_medium[] = {
00102     EGL_RED_SIZE,        8,
00103     EGL_GREEN_SIZE,      8,
00104     EGL_BLUE_SIZE,       8,
00105     EGL_ALPHA_SIZE,      0,
00106     EGL_DEPTH_SIZE,      24,
00107     EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
00108     EGL_SURFACE_TYPE,    EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT,
00109     EGL_SAMPLES,         2,
00110     EGL_SAMPLE_BUFFERS,  1,  
00111     EGL_NONE
00112 };
00113 
00114 static const EGLint attrib32_high[] = {
00115     EGL_RED_SIZE,        8,
00116     EGL_GREEN_SIZE,      8,
00117     EGL_BLUE_SIZE,       8,
00118     EGL_DEPTH_SIZE,      24,
00119     EGL_ALPHA_SIZE,      0,
00120     EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
00121     EGL_SURFACE_TYPE,    EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT,
00122     EGL_SAMPLES,         4,
00123     EGL_SAMPLE_BUFFERS,  1,  
00124     EGL_NONE
00125 };
00126 
00127 // These are the attributes for a 24bpp, 32bit display
00128 static EGLint const attrib16_low[] = {
00129     EGL_RED_SIZE,        5,
00130     EGL_GREEN_SIZE,      6,
00131     EGL_BLUE_SIZE,       5,
00132     EGL_ALPHA_SIZE,      0,
00133     EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
00134 //  EGL_LUMINANCE_SIZE,  EGL_DONT_CARE,
00135 //  EGL_SURFACE_TYPE,    EGL_VG_COLORSPACE_LINEAR_BIT,
00136     EGL_SAMPLES,         0,
00137     EGL_DEPTH_SIZE,      16,
00138     EGL_SAMPLES,         0,
00139     EGL_SAMPLE_BUFFERS,  0,  
00140     EGL_NONE
00141 };
00142 
00143 static EGLint const attrib16_medium[] = {
00144     EGL_RED_SIZE,        5,
00145     EGL_GREEN_SIZE,      6,
00146     EGL_BLUE_SIZE,       5,
00147     EGL_ALPHA_SIZE,      0,
00148     EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
00149     EGL_LUMINANCE_SIZE,  EGL_DONT_CARE,
00150     EGL_SURFACE_TYPE,    EGL_VG_COLORSPACE_LINEAR_BIT,
00151     EGL_SAMPLES,         0,
00152     EGL_DEPTH_SIZE,      16,
00153     EGL_SAMPLES,         2,
00154     EGL_SAMPLE_BUFFERS,  1,  
00155     EGL_NONE
00156 };
00157 
00158 static EGLint const attrib16_high[] = {
00159     EGL_RED_SIZE,        5,
00160     EGL_GREEN_SIZE,      6,
00161     EGL_BLUE_SIZE,       5,
00162     EGL_ALPHA_SIZE,      0,
00163     EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
00164     EGL_LUMINANCE_SIZE,  EGL_DONT_CARE,
00165     EGL_SURFACE_TYPE,    EGL_VG_COLORSPACE_LINEAR_BIT,
00166     EGL_SAMPLES,         0,
00167     EGL_DEPTH_SIZE,      16,
00168     EGL_SAMPLES,         4,
00169     EGL_SAMPLE_BUFFERS,  1,  
00170     EGL_NONE
00171 };
00172 
00173 // These are the same EGL config settings as used by the Mesa
00174 // examples, which run on X11.
00175 static const EGLint attrib1_list[] = {
00176     EGL_RED_SIZE, 1,
00177     EGL_GREEN_SIZE, 1,
00178     EGL_BLUE_SIZE, 1,
00179     EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
00180     EGL_NONE
00181 };
00182 
00183 const EGLint surface_attributes[] = {
00184     // Back buffering is used for window and pbuffer surfaces. Windows
00185     // require eglSwapBuffers() to become visible, and pbuffers don't.   
00186     // EGL_SINGLE_BUFFER is by pixmap surfaces. With OpenVG, windows
00187     // can also be single buffered. eglCopyBuffers() can be used to copy
00188     // both back and single buffered surfaces to a pixmap.
00189     EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
00190     EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_sRGB,
00191     EGL_NONE
00192 };
00193 
00194 #endif  // end of __CONFIG_TEMPLATES_H__
00195 
00196 } // namespace renderer
00197 } // namespace gnash
00198 
00199 // local Variables:
00200 // mode: C++
00201 // indent-tabs-mode: nil
00202 // End: