1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
/*
* Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* DongKyun Yun <dk77.yun@samsung.com>
* SangJin Kim <sangjin3.kim@samsung.com>
* HyunGoo Kang <hyungoo1.kang@samsung.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Contributors:
* - S-Core Co., Ltd
*
*/
#include "implement.h"
void EGLINTER(ConvertConfig)(struct DisplayExtra* pDisplay,
struct ConfigExtra* ptr, GLXFBConfig config) {
ptr->unique = EGLINTER(global).iConfigID++;
ptr->native = config;
int drawableType;
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_DRAWABLE_TYPE, &drawableType);
ptr->surfaceType = 0;
if (drawableType & GLX_PBUFFER_BIT != 0) ptr->surfaceType |= EGL_PBUFFER_BIT;
if (drawableType & GLX_PIXMAP_BIT != 0) ptr->surfaceType |= EGL_PIXMAP_BIT;
if (drawableType & GLX_WINDOW_BIT != 0) ptr->surfaceType |= EGL_WINDOW_BIT;
ptr->bindToTexRGB = (ptr->surfaceType & EGL_PBUFFER_BIT != 0) ? EGL_TRUE : EGL_FALSE;
ptr->bindToTexRGBA = (ptr->surfaceType & EGL_PBUFFER_BIT != 0) ? EGL_TRUE : EGL_FALSE;
int configCaveat;
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_CONFIG_CAVEAT, &configCaveat);
switch (configCaveat) {
case GLX_NONE: ptr->configCaveat = EGL_NONE; break;
case GLX_SLOW_CONFIG: ptr->configCaveat = EGL_SLOW_CONFIG; break;
case GLX_NON_CONFORMANT_CONFIG: ptr->configCaveat = EGL_NON_CONFORMANT_CONFIG; break;
default: assert(0); break;
}
int renderable;
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_X_RENDERABLE, &renderable);
ptr->nativeRenderable = (renderable == True) ? EGL_TRUE : EGL_FALSE;
int transparentType;
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_TRANSPARENT_TYPE, &transparentType);
ptr->transparentType = (transparentType == GLX_TRANSPARENT_RGB) ? EGL_TRANSPARENT_RGB : EGL_NONE;
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_BUFFER_SIZE, &ptr->bufferSize);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_RED_SIZE, &ptr->redSize);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_GREEN_SIZE, &ptr->greenSize);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_BLUE_SIZE, &ptr->blueSize);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_ALPHA_SIZE, &ptr->alphaSize);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_DEPTH_SIZE, &ptr->depthSize);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_LEVEL, &ptr->level);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_MAX_PBUFFER_WIDTH, &ptr->maxPbufferWidth);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_MAX_PBUFFER_HEIGHT, &ptr->maxPbufferHeight);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_MAX_PBUFFER_PIXELS, &ptr->maxPbufferPixels);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_VISUAL_ID, (int*)&ptr->nativeVisualID);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_X_VISUAL_TYPE, (int*)&ptr->nativeVisualType);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_SAMPLE_BUFFERS, &ptr->sampleBuffers);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_SAMPLES, &ptr->samples);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_STENCIL_SIZE, &ptr->stencilSize);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_TRANSPARENT_RED_VALUE, &ptr->transparentRedValue);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_TRANSPARENT_GREEN_VALUE, &ptr->transparentGreenValue);
FNPTR(GetFBConfigAttrib)(pDisplay->native, config, GLX_TRANSPARENT_BLUE_VALUE, &ptr->transparentBlueValue);
ptr->luminanceSize = 0;
ptr->alphaMaskSize = 0;
ptr->colorBufferType = EGL_RGB_BUFFER;
ptr->conformant = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT;
ptr->maxSwapInterval = 1000;
ptr->minSwapInterval = 0;
ptr->renderableType = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT;
}
int EGLAPIENTRY EGLINTER(PrepareConfig)(struct DisplayExtra* pDisplay) {
assert(pDisplay != NULL);
static int attribs_for_none[] = {
GLX_TRANSPARENT_TYPE, GLX_NONE,
GLX_DOUBLEBUFFER, True,
GLX_STEREO, False,
GLX_AUX_BUFFERS, 0,
GLX_ACCUM_RED_SIZE, 0,
GLX_ACCUM_GREEN_SIZE, 0,
GLX_ACCUM_BLUE_SIZE, 0,
GLX_ACCUM_ALPHA_SIZE, 0,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
None,
};
static int attribs_for_rgb[] = {
GLX_TRANSPARENT_TYPE, GLX_TRANSPARENT_RGB,
GLX_DOUBLEBUFFER, True,
GLX_STEREO, False,
GLX_AUX_BUFFERS, 0,
GLX_ACCUM_RED_SIZE, 0,
GLX_ACCUM_GREEN_SIZE, 0,
GLX_ACCUM_BLUE_SIZE, 0,
GLX_ACCUM_ALPHA_SIZE, 0,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
None,
};
struct ConfigExtra* pArea;
struct ConfigExtra* pUnit;
int nBytes;
int nTotalConfig = 0;
int nConfig;
int i;
pDisplay->pConfigBuffer = FNPTR(ChooseFBConfig)(pDisplay->native,
DefaultScreen(pDisplay->native), attribs_for_none, &nConfig);
if (nConfig > 0) {
nBytes = (pDisplay->nConfigExtra + nConfig) * sizeof(struct ConfigExtra);
if ((pArea = (struct ConfigExtra*)realloc(pDisplay->pConfigExtra, nBytes)) == NULL) {
EGLINTER(SetError)(EGL_BAD_ALLOC);
return 0;
}
pUnit = pArea + pDisplay->nConfigExtra;
pDisplay->nConfigExtra += nConfig;
pDisplay->pConfigExtra = pArea;
for (i = 0; i < nConfig; i++) {
EGLINTER(ConvertConfig)(pDisplay, pUnit, pDisplay->pConfigBuffer[i]);
pUnit++;
}
}
nTotalConfig = nConfig;
XFree(pDisplay->pConfigBuffer);
pDisplay->pConfigBuffer = NULL;
pDisplay->pConfigBuffer = FNPTR(ChooseFBConfig)(pDisplay->native,
DefaultScreen(pDisplay->native), attribs_for_rgb, &nConfig);
if (nConfig > 0) {
nBytes = (pDisplay->nConfigExtra + nConfig) * sizeof(struct ConfigExtra);
if ((pArea = (struct ConfigExtra*)realloc(pDisplay->pConfigExtra, nBytes)) == NULL) {
EGLINTER(SetError)(EGL_BAD_ALLOC);
return 0;
}
pUnit = pArea + pDisplay->nConfigExtra;
pDisplay->nConfigExtra += nConfig;
pDisplay->pConfigExtra = pArea;
for (i = 0; i < nConfig; i++) {
EGLINTER(ConvertConfig)(pDisplay, pUnit, pDisplay->pConfigBuffer[i]);
pUnit++;
}
}
nTotalConfig += nConfig;
XFree(pDisplay->pConfigBuffer);
pDisplay->pConfigBuffer = NULL;
nBytes = pDisplay->nConfigExtra * sizeof(EGLConfig);
EGLConfig* pAnswerArea;
if ((pAnswerArea = (EGLConfig*)realloc(pDisplay->pConfigAnswer, nBytes)) == NULL) {
EGLINTER(SetError)(EGL_BAD_ALLOC);
return 0;
}
pDisplay->pConfigAnswer = pAnswerArea;
//assert(nTotalConfig > 0);
return nTotalConfig;
}
EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
EGLint config_size, EGLint *num_config) {
int i;
struct DisplayExtra* pDisplay = EGLINTER(LookUpDisplay)(dpy);
if (pDisplay == NULL) {
EGLINTER(SetError)(EGL_BAD_DISPLAY);
return EGL_FALSE;
}
if (pDisplay->bInitialized == EGL_FALSE) {
EGLINTER(SetError)(EGL_NOT_INITIALIZED);
return EGL_FALSE;
}
if (num_config == NULL) {
EGLINTER(SetError)(EGL_BAD_PARAMETER);
return EGL_FALSE;
}
int num = pDisplay->nConfigExtra;
if (configs == NULL) {
*num_config = num;
} else {
if (config_size < num) num = config_size;
if (num < 0) num = 0;
*num_config = num;
for (i = 0; i < num; i++) {
configs[i] = (EGLConfig)(pDisplay->pConfigExtra + i);
}
}
return EGL_TRUE;
}
|