24
|
1 |
/* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
*
|
|
3 |
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
4 |
* copy of this software and /or associated documentation files
|
|
5 |
* (the "Materials "), to deal in the Materials without restriction,
|
|
6 |
* including without limitation the rights to use, copy, modify, merge,
|
|
7 |
* publish, distribute, sublicense, and/or sell copies of the Materials,
|
|
8 |
* and to permit persons to whom the Materials are furnished to do so,
|
|
9 |
* subject to the following conditions:
|
|
10 |
*
|
|
11 |
* The above copyright notice and this permission notice shall be included
|
|
12 |
* in all copies or substantial portions of the Materials.
|
|
13 |
*
|
|
14 |
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17 |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18 |
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
19 |
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
|
|
20 |
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
|
21 |
*
|
|
22 |
* Initial Contributors:
|
|
23 |
* Nokia Corporation - initial contribution.
|
|
24 |
*
|
|
25 |
* Contributors:
|
|
26 |
*
|
|
27 |
* Description:
|
|
28 |
*
|
|
29 |
*/
|
|
30 |
|
|
31 |
#include "EGLConfig.h"
|
|
32 |
#include "ColorDescriptor.h"
|
|
33 |
#include "TransparentColor.h"
|
|
34 |
|
|
35 |
const int KPbufferHeight = 16384;
|
|
36 |
const int KPbufferWidth = 16384;
|
|
37 |
const int KPbufferPixels = KPbufferHeight * KPbufferWidth;
|
|
38 |
|
|
39 |
CEGLConfig::CEGLConfig(void) :
|
|
40 |
m_nativeVisualId( NULL )
|
|
41 |
{
|
|
42 |
}
|
|
43 |
|
|
44 |
CEGLConfig::CEGLConfig( CColorDescriptor& colorDescriptor,
|
|
45 |
EGLBoolean bindToTexRGB, /* EGL_BIND_TO_TEXTURE_RGB*/
|
|
46 |
EGLBoolean bindToTexRGBA, /* EGL_BIND_TO_TEXTURE_RGBA */
|
|
47 |
EGLenum configCaveat, /* EGL_CONFIG_CAVEAT */
|
|
48 |
EGLint configId, /* EGL_CONFIG_ID */
|
|
49 |
EGLint conformant, /* EGL_CONFORMANT */
|
|
50 |
EGLint depthSize, /* EGL_DEPTH_SIZE */
|
|
51 |
EGLint level, /* EGL_LEVEL */
|
|
52 |
EGLint maxSwapInterval, /* EGL_MAX_SWAP_INTERVAL */
|
|
53 |
EGLint minSwapInterval, /* EGL_MIN_SWAP_INTERVAL */
|
|
54 |
EGLBoolean nativeRenderable, /* EGL_NATIVE_RENDERABLE */
|
|
55 |
EGLint nativeVisualType, /* EGL_NATIVE_VIDUAL_TYPE */
|
|
56 |
EGLint renderableType, /* EGL_RENDERABLE_TYPE */
|
|
57 |
EGLint sampleBuffers, /* EGL_SAMPLE_BUFFERS */
|
|
58 |
EGLint samples, /* EGL_SAMPLES */
|
|
59 |
EGLint stencilSize, /* EGL_STENCIL_SIZE */
|
|
60 |
EGLint surfaceType,
|
|
61 |
CTransparentColor* transparentColor) :
|
|
62 |
m_bindToTexRGB( bindToTexRGB ),
|
|
63 |
m_bindToTexRGBA( bindToTexRGBA ),
|
|
64 |
m_configCaveat( configCaveat ),
|
|
65 |
m_configId( configId ),
|
|
66 |
m_conformant( conformant ),
|
|
67 |
m_depthSize( depthSize ),
|
|
68 |
m_level( level ),
|
|
69 |
m_maxPbufferWidth( KPbufferWidth ),
|
|
70 |
m_maxPbufferHeight( KPbufferHeight ),
|
|
71 |
m_maxPbufferPixels( KPbufferPixels ),
|
|
72 |
m_maxSwapInterval( maxSwapInterval ),
|
|
73 |
m_minSwapInterval( minSwapInterval ),
|
|
74 |
m_nativeRenderable( nativeRenderable ),
|
|
75 |
m_nativeVisualId( NULL ),
|
|
76 |
m_nativeVisualType( nativeVisualType ),
|
|
77 |
m_renderableType( renderableType ),
|
|
78 |
m_sampleBuffers( samples > 1 ? 1 : 0 ),
|
|
79 |
m_samples( samples ),
|
|
80 |
m_stencilSize( stencilSize ),
|
|
81 |
m_surfaceType( surfaceType )
|
|
82 |
{
|
|
83 |
m_colorDescriptor = colorDescriptor;
|
|
84 |
if( m_colorDescriptor.isLuminance() )
|
|
85 |
{
|
|
86 |
m_bufferSize = m_colorDescriptor.LuminanceSize() + m_colorDescriptor.AlphaSize();
|
|
87 |
}
|
|
88 |
else
|
|
89 |
{
|
|
90 |
m_bufferSize = m_colorDescriptor.RedSize() +
|
|
91 |
m_colorDescriptor.GreenSize() +
|
|
92 |
m_colorDescriptor.BlueSize() +
|
|
93 |
m_colorDescriptor.AlphaSize();
|
|
94 |
}
|
|
95 |
if( transparentColor )
|
|
96 |
{
|
|
97 |
m_transparentColor = *transparentColor;
|
|
98 |
}
|
|
99 |
}
|
|
100 |
|
|
101 |
CEGLConfig::~CEGLConfig(void)
|
|
102 |
{
|
|
103 |
}
|
|
104 |
|
|
105 |
EGLint CEGLConfig::SetUpConfig( EGLint red, EGLint green, EGLint blue,
|
|
106 |
EGLint luminance, EGLint alpha,
|
|
107 |
EGLint alphaMask, EGLint samples, EGLint bpp, EGLint id )
|
|
108 |
{
|
|
109 |
int ret = EGL_SUCCESS;
|
|
110 |
int rgb = red + green + blue;
|
|
111 |
if( luminance && rgb )
|
|
112 |
{
|
|
113 |
return EGL_BAD_PARAMETER;
|
|
114 |
}
|
|
115 |
m_colorDescriptor.Set( red, green, blue, luminance, false, alpha, true, alphaMask, bpp );
|
|
116 |
//m_colorDescriptor = EGLI_NEW CColorDescriptor( red, green, blue, luminance, false, alpha, true, alphaMask, bpp );
|
|
117 |
|
|
118 |
m_configId = id;
|
|
119 |
|
|
120 |
if( m_colorDescriptor.isLuminance() )
|
|
121 |
{
|
|
122 |
m_bufferSize = luminance + alpha;
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
m_bufferSize = red + green + blue + alpha;
|
|
127 |
}
|
|
128 |
|
|
129 |
if( rgb )
|
|
130 |
{
|
|
131 |
m_bindToTexRGB = EGL_TRUE;
|
|
132 |
m_bindToTexRGBA = EGL_TRUE;
|
|
133 |
}
|
|
134 |
else
|
|
135 |
{
|
|
136 |
m_bindToTexRGB = EGL_FALSE;
|
|
137 |
m_bindToTexRGBA = EGL_FALSE;
|
|
138 |
}
|
|
139 |
|
|
140 |
/*
|
|
141 |
The EGL_CONFIG_CAVEAT attribute may be set to one of the following values:
|
|
142 |
EGL_NONE, EGL_SLOW_CONFIG or EGL_NON_CONFORMANT_CONFIG. If the
|
|
143 |
attribute is set to EGL_NONE then the configuration has no caveats; if it is set to
|
|
144 |
EGL_SLOW_CONFIG then rendering to a surface with this configuration may run at
|
|
145 |
reduced performance (for example, the hardware may not support the color buffer
|
|
146 |
depths described by the configuration); if it is set to EGL_NON_CONFORMANT_-
|
|
147 |
CONFIG then rendering to a surface with this configuration will not pass the required
|
|
148 |
OpenGL ES conformance tests (note that EGL_NON_CONFORMANT_CONFIG
|
|
149 |
is obsolete, and the same information can be obtained from the EGL_CONFORMANT
|
|
150 |
attribute on a per-client-API basis, not just for OpenGL ES ).
|
|
151 |
*/
|
|
152 |
m_configCaveat = EGL_NONE;
|
|
153 |
|
|
154 |
/*
|
|
155 |
Same as EGL_RENDERABLE_TYPE:
|
|
156 |
EGL_OPENGL_ES_BIT,
|
|
157 |
EGL_OPENVG_BIT,
|
|
158 |
EGL_OPENGL_ES2_BIT,
|
|
159 |
EGL_OPENGL_BIT
|
|
160 |
*/
|
|
161 |
m_conformant = EGL_OPENGL_ES2_BIT;//0;
|
|
162 |
m_renderableType = EGL_OPENVG_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT;
|
|
163 |
|
|
164 |
/*
|
|
165 |
The Depth Buffer
|
|
166 |
The depth buffer is shared by OpenGL and OpenGL ES . It contains fragment
|
|
167 |
depth (Z) information generated during rasterization. EGL_DEPTH_SIZE indicates
|
|
168 |
the depth of this buffer in bits.
|
|
169 |
*/
|
|
170 |
m_depthSize = 0;
|
|
171 |
|
|
172 |
/*
|
|
173 |
EGL_LEVEL is the framebuffer overlay or underlay level in which an
|
|
174 |
EGLSurface created with eglCreateWindowSurface will be placed. Level zero
|
|
175 |
indicates the default layer. The behavior of windows placed in overlay and under-
|
|
176 |
lay levels depends on the underlying native window system.
|
|
177 |
*/
|
|
178 |
m_level = 0;
|
|
179 |
|
|
180 |
/*
|
|
181 |
EGL_MAX_PBUFFER_WIDTH and EGL_MAX_PBUFFER_HEIGHT indicate the
|
|
182 |
maximum width and height that can be passed into eglCreatePbufferSurface,
|
|
183 |
and EGL_MAX_PBUFFER_PIXELS indicates the maximum number of pixels (width
|
|
184 |
times height) for a pbuffer surface. Note that an implementation may return a value
|
|
185 |
for EGL_MAX_PBUFFER_PIXELS that is less than the maximum width times the
|
|
186 |
maximum height. The value for EGL_MAX_PBUFFER_PIXELS is static and assumes
|
|
187 |
that no other pbuffers or native resources are contending for the framebuffer
|
|
188 |
memory. Thus it may not be possible to allocate a pbuffer of the size given by
|
|
189 |
EGL_MAX_PBUFFER_PIXELS.
|
|
190 |
*/
|
|
191 |
m_maxPbufferHeight = KPbufferHeight;
|
|
192 |
m_maxPbufferWidth = KPbufferWidth;
|
|
193 |
m_maxPbufferPixels = KPbufferPixels;
|
|
194 |
|
|
195 |
/*
|
|
196 |
EGL_MAX_SWAP_INTERVAL is the maximum value that can be passed to
|
|
197 |
eglSwapInterval, and indicates the number of swap intervals that will elapse before
|
|
198 |
a buffer swap takes place after calling eglSwapBuffers. Larger values will be
|
|
199 |
silently clamped to this value.
|
|
200 |
*/
|
|
201 |
m_maxSwapInterval = 1;
|
|
202 |
|
|
203 |
/*
|
|
204 |
EGL_MIN_SWAP_INTERVAL is the minimum value that can be passed to
|
|
205 |
eglSwapInterval, and indicates the number of swap intervals that will elapse before
|
|
206 |
a buffer swap takes place after calling eglSwapBuffers. Smaller values will
|
|
207 |
be silently clamped to this value.
|
|
208 |
*/
|
|
209 |
m_minSwapInterval = 1;
|
|
210 |
|
|
211 |
/*
|
|
212 |
EGL_NATIVE_RENDERABLE is an EGLBoolean indicating whether the native
|
|
213 |
window system can be used to render into a surface created with the EGLConfig.
|
|
214 |
*/
|
|
215 |
m_nativeRenderable = EGL_FALSE;
|
|
216 |
|
|
217 |
/*
|
|
218 |
If an EGLConfig supports windows then it may have an associated native visual.
|
|
219 |
EGL_NATIVE_VISUAL_ID specifies an identifier for this visual, and EGL_-
|
|
220 |
NATIVE_VISUAL_TYPE specifies its type. If an EGLConfig does not support
|
|
221 |
windows, or if there is no associated native visual type, then querying EGL_-
|
|
222 |
NATIVE_VISUAL_ID will return 0 and querying EGL_NATIVE_VISUAL_TYPE
|
|
223 |
will return EGL_NONE.
|
|
224 |
The interpretation of the native visual identifier and type is platform-dependent.
|
|
225 |
For example, if the native window system is X, then the identifier will be the XID
|
|
226 |
of an X Visual.
|
|
227 |
*/
|
|
228 |
m_nativeVisualId = 0;
|
|
229 |
|
|
230 |
m_nativeVisualType = EGL_NONE;
|
|
231 |
|
|
232 |
/*
|
|
233 |
EGL_SAMPLE_BUFFERS indicates the number of multisample buffers, which
|
|
234 |
must be zero or one. EGL_SAMPLES gives the number of samples per pixel; if
|
|
235 |
EGL_SAMPLE_BUFFERS is zero, then EGL_SAMPLES will also be zero. If EGL_-
|
|
236 |
SAMPLE_BUFFERS is one, then the number of color, depth, and stencil bits for each
|
|
237 |
sample in the multisample buffer are as specified by the EGL_*_SIZE attributes.
|
|
238 |
There are no single-sample depth or stencil buffers for a multisample
|
|
239 |
EGLConfig; the only depth and stencil buffers are those in the multisample
|
|
240 |
buffer. If the color samples in the multisample buffer store fewer bits than are
|
|
241 |
stored in the color buffers, this fact will not be reported accurately. Presumably a
|
|
242 |
compression scheme is being employed, and is expected to maintain an aggregate
|
|
243 |
resolution equal to that of the color buffers.
|
|
244 |
*/
|
|
245 |
m_samples = samples;
|
|
246 |
m_sampleBuffers = samples > 1 ? 1 : 0;
|
|
247 |
|
|
248 |
/*
|
|
249 |
The stencil buffer is shared by OpenGL and OpenGL ES . It contains fragment
|
|
250 |
stencil information generated during rasterization. EGL_STENCIL_SIZE indicates
|
|
251 |
the depth of this buffer in bits.
|
|
252 |
*/
|
|
253 |
m_stencilSize = 0;
|
|
254 |
|
|
255 |
/*
|
|
256 |
EGL_SURFACE_TYPE is a mask indicating capabilities of surfaces that can be
|
|
257 |
created with the corresponding EGLConfig (the config is said to support these
|
|
258 |
surface types).
|
|
259 |
|
|
260 |
EGL_SURFACE_TYPE is a mask indicating capabilities of surfaces that can be
|
|
261 |
created with the corresponding EGLConfig (the config is said to support these
|
|
262 |
surface types). The valid bit settings are shown in Table 3.2.
|
|
263 |
For example, an EGLConfig for which the value of the EGL_SURFACE_TYPE
|
|
264 |
attribute is
|
|
265 |
EGL_WINDOW_BIT j EGL_PIXMAP_BIT j EGL_PBUFFER_BIT
|
|
266 |
can be used to create any type of EGL surface, while an EGLConfig for which this
|
|
267 |
attribute value is EGL_WINDOW_BIT cannot be used to create a pbuffer or pixmap.
|
|
268 |
If EGL_MULTISAMPLE_RESOLVE_BOX_BIT is set in EGL_SURFACE_TYPE,
|
|
269 |
then the EGL_MULTISAMPLE_RESOLVE attribute of a surface can be specified as a
|
|
270 |
box filter with eglSurfaceAttrib (see section 3.5.6).
|
|
271 |
If EGL_SWAP_BEHAVIOR_PRESERVED_BIT is set in EGL_SURFACE_TYPE,
|
|
272 |
then the EGL_SWAP_BEHAVIOR attribute of a surface can be specified to preserve
|
|
273 |
color buffer contents using eglSurfaceAttrib (see section 3.5.6).
|
|
274 |
If EGL_VG_COLORSPACE_LINEAR_BIT is set in EGL_SURFACE_TYPE, then
|
|
275 |
the EGL_VG_COLORSPACE attribute may be set to EGL_VG_COLORSPACE_-
|
|
276 |
LINEAR when creating a window, pixmap, or pbuffer surface (see section 3.5).
|
|
277 |
If EGL_VG_ALPHA_FORMAT_PRE_BIT is set in EGL_SURFACE_TYPE, then the
|
|
278 |
EGL_VG_ALPHA_FORMAT attribute may be set to EGL_VG_ALPHA_FORMAT_PRE
|
|
279 |
when creating a window, pixmap, or pbuffer surface (see section 3.5).
|
|
280 |
|
|
281 |
*/
|
|
282 |
m_surfaceType = EGL_WINDOW_BIT |
|
|
283 |
EGL_PBUFFER_BIT |
|
|
284 |
//EGL_VG_COLORSPACE_LINEAR_BIT |
|
|
285 |
EGL_VG_ALPHA_FORMAT_PRE_BIT |
|
|
286 |
EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
|
|
287 |
m_colorDescriptor.SetSurfaceType( m_surfaceType );
|
|
288 |
m_surfaceType |= EGL_VG_COLORSPACE_LINEAR_BIT;
|
|
289 |
|
|
290 |
/*
|
|
291 |
If EGL_TRANSPARENT_TYPE is EGL_NONE, then the values for EGL_-
|
|
292 |
TRANSPARENT_RED_VALUE, EGL_TRANSPARENT_GREEN_VALUE, and EGL_-
|
|
293 |
TRANSPARENT_BLUE_VALUE are undefined. Otherwise, they are interpreted as
|
|
294 |
integer framebuffer values between 0 and the maximum framebuffer value for the
|
|
295 |
component. For example, EGL_TRANSPARENT_RED_VALUE will range between 0
|
|
296 |
and 2EGL_RED_SIZE 1.
|
|
297 |
*/
|
|
298 |
|
|
299 |
return ret;
|
|
300 |
}
|
|
301 |
|
|
302 |
EGLBoolean CEGLConfig::SetAttribute( EGLint attribute, EGLint value )
|
|
303 |
{
|
|
304 |
EGLBoolean ret = EGL_FALSE;
|
|
305 |
switch( attribute )
|
|
306 |
{
|
|
307 |
case EGL_BUFFER_SIZE:
|
|
308 |
{
|
|
309 |
if( value == EGL_DONT_CARE ||
|
|
310 |
value >= 0 )
|
|
311 |
{
|
|
312 |
m_bufferSize = value;
|
|
313 |
ret = EGL_TRUE;
|
|
314 |
}
|
|
315 |
break;
|
|
316 |
}
|
|
317 |
|
|
318 |
case EGL_BLUE_SIZE:
|
|
319 |
case EGL_GREEN_SIZE:
|
|
320 |
case EGL_RED_SIZE:
|
|
321 |
case EGL_LUMINANCE_SIZE:
|
|
322 |
case EGL_ALPHA_SIZE:
|
|
323 |
case EGL_ALPHA_MASK_SIZE:
|
|
324 |
{
|
|
325 |
if( (value == EGL_DONT_CARE ||
|
|
326 |
value >= 0) )
|
|
327 |
{
|
|
328 |
m_colorDescriptor.SetAttribute( attribute, value );
|
|
329 |
ret = EGL_TRUE;
|
|
330 |
}
|
|
331 |
break;
|
|
332 |
}
|
|
333 |
|
|
334 |
case EGL_COLOR_BUFFER_TYPE:
|
|
335 |
{
|
|
336 |
if( (value == EGL_DONT_CARE ||
|
|
337 |
value == EGL_RGB_BUFFER ||
|
|
338 |
value == EGL_LUMINANCE_BUFFER) )
|
|
339 |
{
|
|
340 |
m_colorDescriptor.SetAttribute( attribute, value );
|
|
341 |
ret = EGL_TRUE;
|
|
342 |
}
|
|
343 |
break;
|
|
344 |
}
|
|
345 |
|
|
346 |
case EGL_DEPTH_SIZE:
|
|
347 |
{
|
|
348 |
if( value == EGL_DONT_CARE ||
|
|
349 |
value >= 0 )
|
|
350 |
{
|
|
351 |
m_depthSize = value;
|
|
352 |
ret = EGL_TRUE;
|
|
353 |
}
|
|
354 |
break;
|
|
355 |
}
|
|
356 |
case EGL_STENCIL_SIZE:
|
|
357 |
{
|
|
358 |
if( value == EGL_DONT_CARE ||
|
|
359 |
value >= 0 )
|
|
360 |
{
|
|
361 |
m_stencilSize = value;
|
|
362 |
ret = EGL_TRUE;
|
|
363 |
}
|
|
364 |
break;
|
|
365 |
}
|
|
366 |
case EGL_CONFIG_CAVEAT:
|
|
367 |
{
|
|
368 |
if( value == EGL_DONT_CARE ||
|
|
369 |
value == EGL_NONE ||
|
|
370 |
value == EGL_SLOW_CONFIG ||
|
|
371 |
value == EGL_NON_CONFORMANT_CONFIG )
|
|
372 |
{
|
|
373 |
m_configCaveat = value;
|
|
374 |
ret = EGL_TRUE;
|
|
375 |
}
|
|
376 |
break;
|
|
377 |
}
|
|
378 |
case EGL_CONFIG_ID:
|
|
379 |
{
|
|
380 |
if( value == EGL_DONT_CARE ||
|
|
381 |
value > 0 )
|
|
382 |
{
|
|
383 |
m_configId = value;
|
|
384 |
ret = EGL_TRUE;
|
|
385 |
}
|
|
386 |
break;
|
|
387 |
}
|
|
388 |
case EGL_LEVEL:
|
|
389 |
{
|
|
390 |
// \todo validate value
|
|
391 |
m_level = value;
|
|
392 |
ret = EGL_TRUE;
|
|
393 |
break;
|
|
394 |
}
|
|
395 |
|
|
396 |
case EGL_NATIVE_VISUAL_ID:
|
|
397 |
case EGL_MAX_PBUFFER_HEIGHT:
|
|
398 |
case EGL_MAX_PBUFFER_PIXELS:
|
|
399 |
case EGL_MAX_PBUFFER_WIDTH:
|
|
400 |
{
|
|
401 |
// \todo?
|
|
402 |
break;
|
|
403 |
}
|
|
404 |
|
|
405 |
case EGL_NATIVE_RENDERABLE:
|
|
406 |
{
|
|
407 |
if( value == EGL_DONT_CARE ||
|
|
408 |
value == EGL_TRUE ||
|
|
409 |
value == EGL_FALSE )
|
|
410 |
{
|
|
411 |
m_nativeRenderable = value;
|
|
412 |
ret = EGL_TRUE;
|
|
413 |
}
|
|
414 |
break;
|
|
415 |
}
|
|
416 |
|
|
417 |
case EGL_NATIVE_VISUAL_TYPE:
|
|
418 |
{
|
|
419 |
if( value == EGL_DONT_CARE ||
|
|
420 |
value >= 0 )
|
|
421 |
{
|
|
422 |
m_nativeVisualType = value;
|
|
423 |
ret = EGL_TRUE;
|
|
424 |
}
|
|
425 |
break;
|
|
426 |
}
|
|
427 |
case EGL_SAMPLES:
|
|
428 |
{
|
|
429 |
if( value == EGL_DONT_CARE ||
|
|
430 |
value >= 0 )
|
|
431 |
{
|
|
432 |
m_samples = value;
|
|
433 |
ret = EGL_TRUE;
|
|
434 |
}
|
|
435 |
break;
|
|
436 |
}
|
|
437 |
case EGL_SAMPLE_BUFFERS:
|
|
438 |
{
|
|
439 |
if( value == EGL_DONT_CARE ||
|
|
440 |
value >= 0 )
|
|
441 |
{
|
|
442 |
m_sampleBuffers = value;
|
|
443 |
ret = EGL_TRUE;
|
|
444 |
}
|
|
445 |
break;
|
|
446 |
}
|
|
447 |
case EGL_SURFACE_TYPE:
|
|
448 |
{
|
|
449 |
if( (value == EGL_DONT_CARE ||
|
|
450 |
!(value & ~(EGL_WINDOW_BIT |
|
|
451 |
EGL_PIXMAP_BIT |
|
|
452 |
EGL_PBUFFER_BIT |
|
|
453 |
EGL_MULTISAMPLE_RESOLVE_BOX_BIT |
|
|
454 |
EGL_SWAP_BEHAVIOR_PRESERVED_BIT |
|
|
455 |
EGL_VG_COLORSPACE_LINEAR_BIT |
|
|
456 |
EGL_VG_ALPHA_FORMAT_PRE_BIT))) )
|
|
457 |
{
|
|
458 |
m_colorDescriptor.SetSurfaceType(value);
|
|
459 |
m_surfaceType = value;
|
|
460 |
ret = EGL_TRUE;
|
|
461 |
}
|
|
462 |
break;
|
|
463 |
}
|
|
464 |
case EGL_TRANSPARENT_TYPE:
|
|
465 |
{
|
|
466 |
if( (value == EGL_DONT_CARE ||
|
|
467 |
value == EGL_NONE ||
|
|
468 |
value == EGL_TRANSPARENT_RGB) )
|
|
469 |
{
|
|
470 |
m_transparentColor.SetAttribute( attribute, value );
|
|
471 |
ret = EGL_TRUE;
|
|
472 |
}
|
|
473 |
break;
|
|
474 |
}
|
|
475 |
case EGL_TRANSPARENT_BLUE_VALUE:
|
|
476 |
case EGL_TRANSPARENT_GREEN_VALUE:
|
|
477 |
case EGL_TRANSPARENT_RED_VALUE:
|
|
478 |
{
|
|
479 |
if( value == EGL_DONT_CARE ||
|
|
480 |
value >= 0 )
|
|
481 |
{
|
|
482 |
// \todo If EGL_TRANSPARENT_TYPE is EGL_NONE, then the values for EGL_-
|
|
483 |
// TRANSPARENT_RED_VALUE, EGL_TRANSPARENT_GREEN_VALUE, and EGL_-
|
|
484 |
// TRANSPARENT_BLUE_VALUE are undefined. Otherwise, they are interpreted as
|
|
485 |
// integer framebuffer values between 0 and the maximum framebuffer value for the
|
|
486 |
// component. For example, EGL_TRANSPARENT_RED_VALUE will range between 0
|
|
487 |
// and 2^EGL_RED_SIZE - 1.
|
|
488 |
m_transparentColor.SetAttribute( attribute, value );
|
|
489 |
ret = EGL_TRUE;
|
|
490 |
}
|
|
491 |
break;
|
|
492 |
}
|
|
493 |
case EGL_BIND_TO_TEXTURE_RGB:
|
|
494 |
{
|
|
495 |
if( value == EGL_DONT_CARE ||
|
|
496 |
value == EGL_TRUE ||
|
|
497 |
value == EGL_FALSE )
|
|
498 |
{
|
|
499 |
m_bindToTexRGB = value;
|
|
500 |
ret = EGL_TRUE;
|
|
501 |
}
|
|
502 |
break;
|
|
503 |
}
|
|
504 |
case EGL_BIND_TO_TEXTURE_RGBA:
|
|
505 |
{
|
|
506 |
if( value == EGL_DONT_CARE ||
|
|
507 |
value == EGL_TRUE ||
|
|
508 |
value == EGL_FALSE )
|
|
509 |
{
|
|
510 |
m_bindToTexRGBA = value;
|
|
511 |
ret = EGL_TRUE;
|
|
512 |
}
|
|
513 |
break;
|
|
514 |
}
|
|
515 |
case EGL_MIN_SWAP_INTERVAL:
|
|
516 |
{
|
|
517 |
if( value == EGL_DONT_CARE ||
|
|
518 |
value >= 0 )
|
|
519 |
{
|
|
520 |
m_minSwapInterval = value;
|
|
521 |
ret = EGL_TRUE;
|
|
522 |
}
|
|
523 |
break;
|
|
524 |
}
|
|
525 |
case EGL_MAX_SWAP_INTERVAL:
|
|
526 |
{
|
|
527 |
if( value == EGL_DONT_CARE ||
|
|
528 |
value >= 0 )
|
|
529 |
{
|
|
530 |
m_maxSwapInterval = value;
|
|
531 |
ret = EGL_TRUE;
|
|
532 |
}
|
|
533 |
break;
|
|
534 |
}
|
|
535 |
case EGL_RENDERABLE_TYPE:
|
|
536 |
{
|
|
537 |
if( value == EGL_DONT_CARE ||
|
|
538 |
!(value & ~(EGL_OPENGL_BIT |
|
|
539 |
EGL_OPENGL_ES_BIT |
|
|
540 |
EGL_OPENGL_ES2_BIT |
|
|
541 |
EGL_OPENVG_BIT)) )
|
|
542 |
{
|
|
543 |
m_renderableType = value;
|
|
544 |
ret = EGL_TRUE;
|
|
545 |
}
|
|
546 |
break;
|
|
547 |
}
|
|
548 |
case EGL_CONFORMANT:
|
|
549 |
{
|
|
550 |
if( value == EGL_DONT_CARE ||
|
|
551 |
!(value & ~(EGL_OPENGL_BIT |
|
|
552 |
EGL_OPENGL_ES_BIT |
|
|
553 |
EGL_OPENGL_ES2_BIT |
|
|
554 |
EGL_OPENVG_BIT)) )
|
|
555 |
{
|
|
556 |
m_conformant = value;
|
|
557 |
ret = EGL_TRUE;
|
|
558 |
}
|
|
559 |
break;
|
|
560 |
}
|
|
561 |
|
|
562 |
default:
|
|
563 |
{
|
|
564 |
// Unknown attribute
|
|
565 |
EGLI_ASSERT( false );
|
|
566 |
}
|
|
567 |
}
|
|
568 |
return ret;
|
|
569 |
}
|
|
570 |
|
|
571 |
EGLint CEGLConfig::GetAttribute( EGLint attribute ) const
|
|
572 |
{
|
|
573 |
EGLint ret = 0;
|
|
574 |
switch( attribute )
|
|
575 |
{
|
|
576 |
case EGL_BUFFER_SIZE:
|
|
577 |
{
|
|
578 |
ret = m_bufferSize;
|
|
579 |
break;
|
|
580 |
}
|
|
581 |
case EGL_BLUE_SIZE:
|
|
582 |
case EGL_GREEN_SIZE:
|
|
583 |
case EGL_RED_SIZE:
|
|
584 |
case EGL_LUMINANCE_SIZE:
|
|
585 |
case EGL_ALPHA_SIZE:
|
|
586 |
case EGL_ALPHA_MASK_SIZE:
|
|
587 |
case EGL_COLOR_BUFFER_TYPE:
|
|
588 |
{
|
|
589 |
ret = m_colorDescriptor.GetAttribute( attribute );
|
|
590 |
break;
|
|
591 |
}
|
|
592 |
|
|
593 |
case EGL_DEPTH_SIZE:
|
|
594 |
{
|
|
595 |
ret = m_depthSize;
|
|
596 |
break;
|
|
597 |
}
|
|
598 |
case EGL_STENCIL_SIZE:
|
|
599 |
{
|
|
600 |
ret = m_stencilSize;
|
|
601 |
break;
|
|
602 |
}
|
|
603 |
case EGL_CONFIG_CAVEAT:
|
|
604 |
{
|
|
605 |
ret = m_configCaveat;
|
|
606 |
break;
|
|
607 |
}
|
|
608 |
case EGL_CONFIG_ID:
|
|
609 |
{
|
|
610 |
ret = m_configId;
|
|
611 |
break;
|
|
612 |
}
|
|
613 |
case EGL_LEVEL:
|
|
614 |
{
|
|
615 |
ret = m_level;
|
|
616 |
break;
|
|
617 |
}
|
|
618 |
|
|
619 |
case EGL_NATIVE_VISUAL_ID:
|
|
620 |
{
|
|
621 |
ret = m_nativeVisualId;
|
|
622 |
break;
|
|
623 |
}
|
|
624 |
case EGL_MAX_PBUFFER_HEIGHT:
|
|
625 |
{
|
|
626 |
ret = m_maxPbufferHeight;
|
|
627 |
break;
|
|
628 |
}
|
|
629 |
case EGL_MAX_PBUFFER_PIXELS:
|
|
630 |
{
|
|
631 |
ret = m_maxPbufferPixels;
|
|
632 |
break;
|
|
633 |
}
|
|
634 |
case EGL_MAX_PBUFFER_WIDTH:
|
|
635 |
{
|
|
636 |
ret = m_maxPbufferWidth;
|
|
637 |
break;
|
|
638 |
}
|
|
639 |
case EGL_NATIVE_RENDERABLE:
|
|
640 |
{
|
|
641 |
ret = m_nativeRenderable;
|
|
642 |
break;
|
|
643 |
}
|
|
644 |
case EGL_NATIVE_VISUAL_TYPE:
|
|
645 |
{
|
|
646 |
ret = m_nativeVisualType;
|
|
647 |
break;
|
|
648 |
}
|
|
649 |
case EGL_SAMPLES:
|
|
650 |
{
|
|
651 |
ret = m_samples;
|
|
652 |
break;
|
|
653 |
}
|
|
654 |
case EGL_SAMPLE_BUFFERS:
|
|
655 |
{
|
|
656 |
ret = m_sampleBuffers;
|
|
657 |
break;
|
|
658 |
}
|
|
659 |
case EGL_SURFACE_TYPE:
|
|
660 |
{
|
|
661 |
ret = m_surfaceType;
|
|
662 |
break;
|
|
663 |
}
|
|
664 |
case EGL_TRANSPARENT_TYPE:
|
|
665 |
{
|
|
666 |
ret = m_transparentColor.Type();
|
|
667 |
break;
|
|
668 |
}
|
|
669 |
case EGL_TRANSPARENT_BLUE_VALUE:
|
|
670 |
{
|
|
671 |
ret = m_transparentColor.BlueValue();
|
|
672 |
break;
|
|
673 |
}
|
|
674 |
case EGL_TRANSPARENT_GREEN_VALUE:
|
|
675 |
{
|
|
676 |
ret = m_transparentColor.GreenValue();
|
|
677 |
break;
|
|
678 |
}
|
|
679 |
case EGL_TRANSPARENT_RED_VALUE:
|
|
680 |
{
|
|
681 |
ret = m_transparentColor.RedValue();
|
|
682 |
break;
|
|
683 |
}
|
|
684 |
case EGL_BIND_TO_TEXTURE_RGB:
|
|
685 |
{
|
|
686 |
ret = m_bindToTexRGB;
|
|
687 |
break;
|
|
688 |
}
|
|
689 |
case EGL_BIND_TO_TEXTURE_RGBA:
|
|
690 |
{
|
|
691 |
ret = m_bindToTexRGBA;
|
|
692 |
break;
|
|
693 |
}
|
|
694 |
case EGL_MIN_SWAP_INTERVAL:
|
|
695 |
{
|
|
696 |
ret = m_minSwapInterval;
|
|
697 |
break;
|
|
698 |
}
|
|
699 |
case EGL_MAX_SWAP_INTERVAL:
|
|
700 |
{
|
|
701 |
ret = m_maxSwapInterval;
|
|
702 |
break;
|
|
703 |
}
|
|
704 |
case EGL_RENDERABLE_TYPE:
|
|
705 |
{
|
|
706 |
ret = m_renderableType;
|
|
707 |
break;
|
|
708 |
}
|
|
709 |
case EGL_CONFORMANT:
|
|
710 |
{
|
|
711 |
ret = m_conformant;
|
|
712 |
break;
|
|
713 |
}
|
|
714 |
|
|
715 |
default:
|
|
716 |
{
|
|
717 |
ret = EGL_BAD_ATTRIBUTE;
|
|
718 |
}
|
|
719 |
}
|
|
720 |
return ret;
|
|
721 |
}
|
|
722 |
|
|
723 |
bool CEGLConfig::operator<( const CEGLConfig& rhs ) const
|
|
724 |
{
|
|
725 |
if( this == &rhs ) return false;
|
|
726 |
|
|
727 |
return !(operator>(rhs));
|
|
728 |
}
|
|
729 |
|
|
730 |
bool CEGLConfig::operator>( const CEGLConfig& rhs ) const
|
|
731 |
{
|
|
732 |
if( this == &rhs ) return false;
|
|
733 |
|
|
734 |
// 1 Special: by EGL_CONFIG_CAVEAT where the precedence is EGL_NONE,
|
|
735 |
// EGL_SLOW_CONFIG, EGL_NON_CONFORMANT_CONFIG.
|
|
736 |
if( m_configCaveat != rhs.m_configCaveat )
|
|
737 |
{
|
|
738 |
// \note depends on EGL_NON_CONFORMANT_CONFIG > EGL_SLOW_CONFIG
|
|
739 |
if( rhs.m_configCaveat < m_configCaveat )
|
|
740 |
return false;
|
|
741 |
if( m_configCaveat > rhs.m_configCaveat )
|
|
742 |
return true;
|
|
743 |
}
|
|
744 |
|
|
745 |
// 2 Special: by EGL_COLOR_BUFFER_TYPE where the precedence is EGL_-
|
|
746 |
// RGB_BUFFER, EGL_LUMINANCE_BUFFER.
|
|
747 |
if( !(m_colorDescriptor.isLuminance()) && rhs.m_colorDescriptor.isLuminance() )
|
|
748 |
return true;
|
|
749 |
if( m_colorDescriptor.isLuminance() && !(rhs.m_colorDescriptor.isLuminance()) )
|
|
750 |
return false;
|
|
751 |
|
|
752 |
// 3 Special: by larger total number of color bits (for an RGB color buffer,
|
|
753 |
// this is the sum of EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE,
|
|
754 |
// and EGL_ALPHA_SIZE; for a luminance color buffer, the sum of EGL_-
|
|
755 |
// LUMINANCE_SIZE and EGL_ALPHA_SIZE)
|
|
756 |
|
|
757 |
// \todo If the requested number of bits in attrib list for a particular color
|
|
758 |
// component is 0 or EGL_DONT_CARE, then the number of bits for that component
|
|
759 |
// is not considered.
|
|
760 |
|
|
761 |
if( m_bufferSize > rhs.m_bufferSize )
|
|
762 |
return true;
|
|
763 |
if( rhs.m_bufferSize > m_bufferSize )
|
|
764 |
return false;
|
|
765 |
|
|
766 |
if( m_sampleBuffers > rhs.m_sampleBuffers )
|
|
767 |
return true;
|
|
768 |
if( rhs.m_sampleBuffers > m_sampleBuffers )
|
|
769 |
return false;
|
|
770 |
|
|
771 |
if( m_samples > rhs.m_samples )
|
|
772 |
return true;
|
|
773 |
if( rhs.m_samples > m_samples )
|
|
774 |
return false;
|
|
775 |
|
|
776 |
if( m_depthSize > rhs.m_depthSize )
|
|
777 |
return true;
|
|
778 |
if( rhs.m_depthSize > m_depthSize )
|
|
779 |
return false;
|
|
780 |
|
|
781 |
if( m_stencilSize > rhs.m_stencilSize )
|
|
782 |
return true;
|
|
783 |
if( rhs.m_stencilSize > m_stencilSize )
|
|
784 |
return false;
|
|
785 |
|
|
786 |
if( m_colorDescriptor.AlphaMaskSize() > rhs.m_colorDescriptor.AlphaMaskSize() )
|
|
787 |
return true;
|
|
788 |
if( rhs.m_colorDescriptor.AlphaMaskSize() > m_colorDescriptor.AlphaMaskSize() )
|
|
789 |
return false;
|
|
790 |
|
|
791 |
// \todo Special: by EGL_NATIVE_VISUAL_TYPE (the actual sort order is
|
|
792 |
// implementation-defined, depending on the meaning of native visual types).
|
|
793 |
|
|
794 |
if( m_configId > rhs.m_configId )
|
|
795 |
return true;
|
|
796 |
if( rhs.m_configId > m_configId )
|
|
797 |
return false;
|
|
798 |
|
|
799 |
// Shouldn't reach this point.
|
|
800 |
EGLI_ASSERT( false );
|
|
801 |
return false;
|
|
802 |
}
|
|
803 |
|
|
804 |
bool CEGLConfig::Match( const CEGLConfig& filter ) const
|
|
805 |
{
|
|
806 |
if( this == &filter ) return true;
|
|
807 |
|
|
808 |
if( m_bufferSize < filter.m_bufferSize ) return false;
|
|
809 |
|
|
810 |
if( m_colorDescriptor.RedSize() < filter.m_colorDescriptor.RedSize() ||
|
|
811 |
m_colorDescriptor.GreenSize() < filter.m_colorDescriptor.GreenSize() ||
|
|
812 |
m_colorDescriptor.BlueSize() < filter.m_colorDescriptor.BlueSize() ||
|
|
813 |
m_colorDescriptor.AlphaSize() < filter.m_colorDescriptor.AlphaSize() ) return false;
|
|
814 |
|
|
815 |
if( m_colorDescriptor.AlphaMaskSize() < filter.m_colorDescriptor.AlphaMaskSize() ) return false;
|
|
816 |
|
|
817 |
if( filter.m_bindToTexRGB != EGL_DONT_CARE && (m_bindToTexRGB != filter.m_bindToTexRGB) ) return false;
|
|
818 |
|
|
819 |
if( filter.m_bindToTexRGBA != EGL_DONT_CARE && (m_bindToTexRGBA != filter.m_bindToTexRGBA) ) return false;
|
|
820 |
|
|
821 |
if( filter.m_colorDescriptor.Format() != EGL_DONT_CARE )
|
|
822 |
{
|
|
823 |
EGLint thisBufType = m_colorDescriptor.isLuminance() ? EGL_LUMINANCE_BUFFER : EGL_RGB_BUFFER;
|
|
824 |
EGLint filterBufType = filter.m_colorDescriptor.isLuminance() ? EGL_LUMINANCE_BUFFER : EGL_RGB_BUFFER;
|
|
825 |
if( thisBufType != filterBufType ) return false;
|
|
826 |
}
|
|
827 |
|
|
828 |
if( filter.m_configCaveat != EGL_DONT_CARE && (m_configCaveat != filter.m_configCaveat) ) return false;
|
|
829 |
|
|
830 |
if( m_configId == filter.m_configId ) return false;
|
|
831 |
|
|
832 |
if( (filter.m_conformant & m_conformant) != filter.m_conformant ) return false;
|
|
833 |
|
|
834 |
if( m_depthSize < filter.m_depthSize ) return false;
|
|
835 |
|
|
836 |
if( m_level != filter.m_level ) return false;
|
|
837 |
|
|
838 |
if( filter.m_maxSwapInterval != EGL_DONT_CARE && (m_maxSwapInterval != filter.m_maxSwapInterval) ) return false;
|
|
839 |
|
|
840 |
if( filter.m_minSwapInterval != EGL_DONT_CARE && (m_minSwapInterval != filter.m_minSwapInterval) ) return false;
|
|
841 |
|
|
842 |
if( filter.m_nativeRenderable != EGL_DONT_CARE && (m_nativeRenderable != filter.m_nativeRenderable) ) return false;
|
|
843 |
|
|
844 |
if( filter.m_nativeVisualType != EGL_DONT_CARE && (m_nativeVisualType != filter.m_nativeVisualType) ) return false;
|
|
845 |
|
|
846 |
if( (filter.m_renderableType & m_renderableType) != filter.m_renderableType ) return false;
|
|
847 |
|
|
848 |
if( m_sampleBuffers < filter.m_sampleBuffers ) return false;
|
|
849 |
|
|
850 |
if( m_samples < filter.m_samples ) return false;
|
|
851 |
|
|
852 |
if( m_stencilSize < filter.m_stencilSize ) return false;
|
|
853 |
|
|
854 |
if( (filter.m_surfaceType & m_surfaceType) != filter.m_surfaceType ) return false;
|
|
855 |
|
|
856 |
if( filter.m_transparentColor.Type() != m_transparentColor.Type() ) return false;
|
|
857 |
|
|
858 |
return true;
|
|
859 |
}
|
|
860 |
|
|
861 |
CEGLConfig& CEGLConfig::operator=( const CEGLConfig& rhs )
|
|
862 |
{
|
|
863 |
if( this == &rhs ) return *this;
|
|
864 |
|
|
865 |
m_bufferSize = rhs.m_bufferSize;
|
|
866 |
m_colorDescriptor = rhs.m_colorDescriptor;
|
|
867 |
m_bindToTexRGB = rhs.m_bindToTexRGB;
|
|
868 |
m_bindToTexRGBA = rhs.m_bindToTexRGBA;
|
|
869 |
m_configCaveat = rhs.m_configCaveat;
|
|
870 |
m_configId = rhs.m_configId;
|
|
871 |
m_conformant = rhs.m_conformant;
|
|
872 |
m_depthSize = rhs.m_depthSize;
|
|
873 |
m_level = rhs.m_level;
|
|
874 |
m_maxPbufferWidth = rhs.m_maxPbufferWidth;
|
|
875 |
m_maxPbufferHeight = rhs.m_maxPbufferHeight;
|
|
876 |
m_maxPbufferPixels = rhs.m_maxPbufferPixels;
|
|
877 |
m_maxSwapInterval = rhs.m_maxSwapInterval;
|
|
878 |
m_minSwapInterval = rhs.m_minSwapInterval;
|
|
879 |
m_nativeRenderable = rhs.m_nativeRenderable;
|
|
880 |
m_nativeVisualId = rhs.m_nativeVisualId;
|
|
881 |
m_nativeVisualType = rhs.m_nativeVisualType;
|
|
882 |
m_renderableType = rhs.m_renderableType;
|
|
883 |
m_sampleBuffers = rhs.m_sampleBuffers;
|
|
884 |
m_samples = rhs.m_samples;
|
|
885 |
m_stencilSize = rhs.m_stencilSize;
|
|
886 |
m_surfaceType = rhs.m_surfaceType;
|
|
887 |
m_transparentColor = rhs.m_transparentColor;
|
|
888 |
return *this;
|
|
889 |
}
|
|
890 |
|
|
891 |
bool CEGLConfig::IsCompatible( const CEGLConfig& config, const EGLenum contextApi ) const
|
|
892 |
{
|
|
893 |
if( m_colorDescriptor.isLuminance() != config.m_colorDescriptor.isLuminance() )
|
|
894 |
return false;
|
|
895 |
|
|
896 |
if( m_colorDescriptor.isLuminance() &&
|
|
897 |
(m_colorDescriptor.m_luminanceSize != config.m_colorDescriptor.m_luminanceSize ||
|
|
898 |
m_colorDescriptor.m_alphaSize != config.m_colorDescriptor.m_alphaSize) )
|
|
899 |
return false;
|
|
900 |
else if ( m_colorDescriptor.m_redSize != config.m_colorDescriptor.m_redSize ||
|
|
901 |
m_colorDescriptor.m_greenSize != config.m_colorDescriptor.m_greenSize ||
|
|
902 |
m_colorDescriptor.m_blueSize != config.m_colorDescriptor.m_blueSize ||
|
|
903 |
m_colorDescriptor.m_alphaSize != config.m_colorDescriptor.m_alphaSize )
|
|
904 |
return false;
|
|
905 |
|
|
906 |
if( m_samples != config.m_samples )
|
|
907 |
return false;
|
|
908 |
|
|
909 |
switch( contextApi )
|
|
910 |
{
|
|
911 |
case EGL_OPENVG_API:
|
|
912 |
{
|
|
913 |
if( m_colorDescriptor.m_alphaMaskSize != config.m_colorDescriptor.m_alphaMaskSize )
|
|
914 |
return false;
|
|
915 |
break;
|
|
916 |
}
|
|
917 |
case EGL_OPENGL_ES_API:
|
|
918 |
{
|
|
919 |
if( m_stencilSize != config.m_stencilSize )
|
|
920 |
return false;
|
|
921 |
if( m_depthSize != config.m_depthSize )
|
|
922 |
return false;
|
|
923 |
|
|
924 |
break;
|
|
925 |
}
|
|
926 |
}
|
|
927 |
return true;
|
|
928 |
}
|
|
929 |
|