Gnash  0.8.11dev
configTemplates.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef __CONFIG_TEMPLATES_H__
20 #define __CONFIG_TEMPLATES_H__ 1
21 
22 #ifdef HAVE_CONFIG_H
23 #include "gnashconfig.h"
24 #endif
25 
26 #ifdef HAVE_EGL_EGL_H
27 # include <EGL/egl.h>
28 #else
29 # error "This file needs EGL, which is part of OpenGL-ES"
30 #endif
31 
32 #include "eglDevice.h"
33 
34 namespace gnash {
35 namespace renderer {
36 
37 // From the EGL 1.4 spec:
38 //
39 // EGL defines several types of drawing surfaces collectively referred
40 // to as EGLSurfaces. These include windows, used for onscreen
41 // rendering; pbuffers, used for offscreen rendering; and pixmaps,
42 // used for offscreen rendering into buffers that may be accessed
43 // through native APIs. EGL windows and pixmaps are tied to native
44 // window system windows and pixmaps.
45 //
46 // depth, multisample, and stencil buffers are currently used only by
47 // OpenGL-ES.
48 
49 // EGL and OpenGL ES supports two rendering models: back buffered and
50 // single buffered. Back buffered rendering is used by window and
51 // pbuffer surfaces. Memory for the color buffer used during rendering
52 // is allocated and owned by EGL. When the client is finished drawing
53 // a frame, the back buffer may be copied to a visible window using
54 // eglSwapBuffers. Pbuffer surfaces have a back buffer but no
55 // associated window, so the back buffer need not be copied.
56 //
57 // Single buffered rendering is used by pixmap surfaces. Memory for
58 // the color buffer is specified at surface creation time in the form
59 // of a native pixmap, and client APIs are required to use that memory
60 // during rendering. When the client is finished drawing a frame, the
61 // native pixmap contains the final image. Pixmap surfaces typically
62 // do not support multisampling, since the native pixmap used as the
63 // color buffer is unlikely to provide space to store multisample
64 // information. Some client APIs , such as OpenGL and OpenVG , also
65 // support single buffered rendering to window surfaces. This behavior
66 // can be selected when creating the window surface, as defined in
67 // section 3.5.1. When mixing use of client APIs which do not support
68 // single buffered rendering into windows, like OpenGL ES , with
69 // client APIs which do support it, back color buffers and visible
70 // window contents must be kept consistent when binding window
71 // surfaces to contexts for each API type. Both back and single
72 // buffered surfaces may also be copied to a specified native pixmap
73 // using eglCopyBuffers.
74 
75 // Native rendering will always be supported by pixmap surfaces (to
76 // the extent that native rendering APIs can draw to native
77 // pixmaps). Pixmap surfaces are typically used when mixing native and
78 // client API rendering is desirable, since there is no need to move
79 // data between the back buffer visible to the client APIs and the
80 // native pixmap visible to native rendering APIs. However, pixmap
81 // surfaces may, for the same reason, have restricted capabilities and
82 // performance relative to window and pbuffer surfaces.
83 
84 // NOTE: Single Buffering appears not to work on X11, you get no visual.
85 // EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER,
86 
87 // These are the attributes for a 24bpp, 32bit display
88 static const EGLint attrib32_low[] = {
89  EGL_RED_SIZE, 8,
90  EGL_GREEN_SIZE, 8,
91  EGL_BLUE_SIZE, 8,
92  EGL_ALPHA_SIZE, 0,
93  EGL_DEPTH_SIZE, 24,
94  EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
95  EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT,
96  EGL_SAMPLES, 0,
97  EGL_SAMPLE_BUFFERS, 0,
98  EGL_NONE
99 };
100 
101 static const EGLint attrib32_medium[] = {
102  EGL_RED_SIZE, 8,
103  EGL_GREEN_SIZE, 8,
104  EGL_BLUE_SIZE, 8,
105  EGL_ALPHA_SIZE, 0,
106  EGL_DEPTH_SIZE, 24,
107  EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
108  EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT,
109  EGL_SAMPLES, 2,
110  EGL_SAMPLE_BUFFERS, 1,
111  EGL_NONE
112 };
113 
114 static const EGLint attrib32_high[] = {
115  EGL_RED_SIZE, 8,
116  EGL_GREEN_SIZE, 8,
117  EGL_BLUE_SIZE, 8,
118  EGL_DEPTH_SIZE, 24,
119  EGL_ALPHA_SIZE, 0,
120  EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
121  EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT,
122  EGL_SAMPLES, 4,
123  EGL_SAMPLE_BUFFERS, 1,
124  EGL_NONE
125 };
126 
127 // These are the attributes for a 24bpp, 32bit display
128 static EGLint const attrib16_low[] = {
129  EGL_RED_SIZE, 5,
130  EGL_GREEN_SIZE, 6,
131  EGL_BLUE_SIZE, 5,
132  EGL_ALPHA_SIZE, 0,
133  EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
134 // EGL_LUMINANCE_SIZE, EGL_DONT_CARE,
135 // EGL_SURFACE_TYPE, EGL_VG_COLORSPACE_LINEAR_BIT,
136  EGL_SAMPLES, 0,
137  EGL_DEPTH_SIZE, 16,
138  EGL_SAMPLES, 0,
139  EGL_SAMPLE_BUFFERS, 0,
140  EGL_NONE
141 };
142 
143 static EGLint const attrib16_medium[] = {
144  EGL_RED_SIZE, 5,
145  EGL_GREEN_SIZE, 6,
146  EGL_BLUE_SIZE, 5,
147  EGL_ALPHA_SIZE, 0,
148  EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
149  EGL_LUMINANCE_SIZE, EGL_DONT_CARE,
150  EGL_SURFACE_TYPE, EGL_VG_COLORSPACE_LINEAR_BIT,
151  EGL_SAMPLES, 0,
152  EGL_DEPTH_SIZE, 16,
153  EGL_SAMPLES, 2,
154  EGL_SAMPLE_BUFFERS, 1,
155  EGL_NONE
156 };
157 
158 static EGLint const attrib16_high[] = {
159  EGL_RED_SIZE, 5,
160  EGL_GREEN_SIZE, 6,
161  EGL_BLUE_SIZE, 5,
162  EGL_ALPHA_SIZE, 0,
163  EGL_RENDERABLE_TYPE, EGLDevice::getRenderableTypes(),
164  EGL_LUMINANCE_SIZE, EGL_DONT_CARE,
165  EGL_SURFACE_TYPE, EGL_VG_COLORSPACE_LINEAR_BIT,
166  EGL_SAMPLES, 0,
167  EGL_DEPTH_SIZE, 16,
168  EGL_SAMPLES, 4,
169  EGL_SAMPLE_BUFFERS, 1,
170  EGL_NONE
171 };
172 
173 // These are the same EGL config settings as used by the Mesa
174 // examples, which run on X11.
175 static const EGLint attrib1_list[] = {
176  EGL_RED_SIZE, 1,
177  EGL_GREEN_SIZE, 1,
178  EGL_BLUE_SIZE, 1,
179  EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
180  EGL_NONE
181 };
182 
183 const EGLint surface_attributes[] = {
184  // Back buffering is used for window and pbuffer surfaces. Windows
185  // require eglSwapBuffers() to become visible, and pbuffers don't.
186  // EGL_SINGLE_BUFFER is by pixmap surfaces. With OpenVG, windows
187  // can also be single buffered. eglCopyBuffers() can be used to copy
188  // both back and single buffered surfaces to a pixmap.
189  EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
190  EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_sRGB,
191  EGL_NONE
192 };
193 
194 #endif // end of __CONFIG_TEMPLATES_H__
195 
196 } // namespace renderer
197 } // namespace gnash
198 
199 // local Variables:
200 // mode: C++
201 // indent-tabs-mode: nil
202 // End:
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
const EGLint surface_attributes[]
Definition: configTemplates.h:183
static EGLint getRenderableTypes()
Definition: eglDevice.cpp:830