Skip to content

Commit 2a0b544

Browse files
committed
Merge remote-tracking branch 'jeremyhu/master'
2 parents 0eb1559 + ba4bb3b commit 2a0b544

File tree

3 files changed

+88
-147
lines changed

3 files changed

+88
-147
lines changed

hw/xquartz/GL/visualConfigs.c

+74-140
Original file line numberDiff line numberDiff line change
@@ -58,98 +58,82 @@
5858
#include "darwinfb.h"
5959

6060
/* Based originally on code from indirect.c which was based on code from i830_dri.c. */
61-
__GLXconfig *
62-
__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
63-
{
61+
__GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) {
6462
int numConfigs = 0;
6563
__GLXconfig *visualConfigs, *c;
6664
struct glCapabilities caps;
6765
struct glCapabilitiesConfig *conf;
6866
int stereo, depth, aux, buffers, stencil, accum, color, msample;
6967

70-
if (getGlCapabilities(&caps)) {
68+
if(getGlCapabilities(&caps)) {
7169
ErrorF("error from getGlCapabilities()!\n");
7270
return NULL;
7371
}
7472

7573
/*
76-
conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
77-
so we treat a true conf->stereo as 2.
74+
conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
75+
so we treat a true conf->stereo as 2.
7876
79-
The depth size is 0 or 24. Thus we do 2 iterations for that.
77+
The depth size is 0 or 24. Thus we do 2 iterations for that.
8078
81-
conf->aux_buffers (when available/non-zero) result in 2 iterations instead of 1.
79+
conf->aux_buffers (when available/non-zero) result in 2 iterations instead of 1.
8280
83-
conf->buffers indicates whether we have single or double buffering.
81+
conf->buffers indicates whether we have single or double buffering.
8482
85-
conf->total_stencil_bit_depths
83+
conf->total_stencil_bit_depths
8684
87-
conf->total_color_buffers indicates the RGB/RGBA color depths.
85+
conf->total_color_buffers indicates the RGB/RGBA color depths.
8886
89-
conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
87+
conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
9088
91-
conf->total_depth_buffer_depths
89+
conf->total_depth_buffer_depths
9290
93-
conf->multisample_buffers iterations (with at least 1 if equal to 0). We add 1
94-
for the 0 multisampling config.
91+
conf->multisample_buffers iterations (with at least 1 if equal to 0). We add 1
92+
for the 0 multisampling config.
9593
9694
*/
9795

9896
assert(NULL != caps.configurations);
9997

10098
numConfigs = 0;
10199

102-
for (conf = caps.configurations; conf; conf = conf->next) {
103-
if (conf->total_color_buffers <= 0)
100+
for(conf = caps.configurations; conf; conf = conf->next) {
101+
if(conf->total_color_buffers <= 0)
104102
continue;
105103

106104
numConfigs += (conf->stereo ? 2 : 1)
107-
* (conf->aux_buffers ? 2 : 1)
108-
* conf->buffers
109-
* ((conf->total_stencil_bit_depths >
110-
0) ? conf->total_stencil_bit_depths : 1)
111-
* conf->total_color_buffers
112-
* ((conf->total_accum_buffers >
113-
0) ? conf->total_accum_buffers : 1)
114-
* conf->total_depth_buffer_depths
115-
* (conf->multisample_buffers + 1);
105+
* (conf->aux_buffers ? 2 : 1)
106+
* conf->buffers
107+
* ((conf->total_stencil_bit_depths > 0) ? conf->total_stencil_bit_depths : 1)
108+
* conf->total_color_buffers
109+
* ((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1)
110+
* conf->total_depth_buffer_depths
111+
* (conf->multisample_buffers + 1);
116112
}
117113

118-
if (numConfigsPtr)
114+
if(numConfigsPtr)
119115
*numConfigsPtr = numConfigs;
120116

121117
visualConfigs = calloc(sizeof(*visualConfigs), numConfigs);
122118

123-
if (NULL == visualConfigs) {
119+
if(NULL == visualConfigs) {
124120
ErrorF("xcalloc failure when allocating visualConfigs\n");
125121
freeGlCapabilities(&caps);
126122
return NULL;
127123
}
128124

129125
c = visualConfigs; /* current buffer */
130-
for (conf = caps.configurations; conf; conf = conf->next) {
131-
for (stereo = 0; stereo < (conf->stereo ? 2 : 1); ++stereo) {
132-
for (aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) {
133-
for (buffers = 0; buffers < conf->buffers; ++buffers) {
134-
for (stencil = 0;
135-
stencil < ((conf->total_stencil_bit_depths > 0) ?
136-
conf->
137-
total_stencil_bit_depths : 1);
138-
++stencil) {
139-
for (color = 0; color < conf->total_color_buffers;
140-
++color) {
141-
for (accum = 0;
142-
accum < ((conf->total_accum_buffers > 0) ?
143-
conf->
144-
total_accum_buffers : 1);
145-
++accum) {
146-
for (depth = 0;
147-
depth < conf->total_depth_buffer_depths;
148-
++depth) {
149-
for (msample = 0;
150-
msample <
151-
(conf->multisample_buffers + 1);
152-
++msample) {
126+
for(conf = caps.configurations; conf; conf = conf->next) {
127+
for(stereo = 0; stereo < (conf->stereo ? 2 : 1); ++stereo) {
128+
for(aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) {
129+
for(buffers = 0; buffers < conf->buffers; ++buffers) {
130+
for(stencil = 0; stencil < ((conf->total_stencil_bit_depths > 0) ?
131+
conf->total_stencil_bit_depths : 1); ++stencil) {
132+
for(color = 0; color < conf->total_color_buffers; ++color) {
133+
for(accum = 0; accum < ((conf->total_accum_buffers > 0) ?
134+
conf->total_accum_buffers : 1); ++accum) {
135+
for(depth = 0; depth < conf->total_depth_buffer_depths; ++depth) {
136+
for(msample = 0; msample < (conf->multisample_buffers + 1); ++msample) {
153137

154138
// Global
155139
c->visualID = -1;
@@ -162,12 +146,10 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
162146
c->indexBits = 0;
163147
c->pixmapMode = 0; // TODO: What should this be?
164148

165-
if (conf->accelerated) {
149+
if(conf->accelerated) {
166150
c->visualRating = GLX_NONE;
167-
}
168-
else {
169-
c->visualRating =
170-
GLX_SLOW_VISUAL_EXT;
151+
} else {
152+
c->visualRating = GLX_SLOW_VISUAL_EXT;
171153
}
172154

173155
c->transparentPixel = GLX_NONE;
@@ -179,109 +161,66 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
179161

180162
c->visualSelectGroup = 0;
181163

182-
c->swapMethod =
183-
GLX_SWAP_UNDEFINED_OML;
164+
c->swapMethod = GLX_SWAP_UNDEFINED_OML;
184165

185166
// Stereo
186167
c->stereoMode = stereo ? TRUE : FALSE;
187168

188169
// Aux buffers
189-
c->numAuxBuffers =
190-
aux ? conf->aux_buffers : 0;
170+
c->numAuxBuffers = aux ? conf->aux_buffers : 0;
191171

192172
// Double Buffered
193-
c->doubleBufferMode =
194-
buffers ? TRUE : FALSE;
173+
c->doubleBufferMode = buffers ? TRUE : FALSE;
195174

196175
// Stencil Buffer
197-
if (conf->total_stencil_bit_depths >
198-
0) {
199-
c->stencilBits =
200-
conf->stencil_bit_depths[
201-
stencil];
202-
}
203-
else {
176+
if(conf->total_stencil_bit_depths > 0) {
177+
c->stencilBits = conf->stencil_bit_depths[stencil];
178+
} else {
204179
c->stencilBits = 0;
205180
}
206181

207182
// Color
208-
if (GLCAPS_COLOR_BUF_INVALID_VALUE !=
209-
conf->color_buffers[color].a) {
210-
c->alphaBits =
211-
conf->color_buffers[color].a;
212-
}
213-
else {
183+
if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->color_buffers[color].a) {
184+
c->alphaBits = conf->color_buffers[color].a;
185+
} else {
214186
c->alphaBits = 0;
215187
}
216-
c->redBits =
217-
conf->color_buffers[color].r;
218-
c->greenBits =
219-
conf->color_buffers[color].g;
220-
c->blueBits =
221-
conf->color_buffers[color].b;
222-
223-
c->rgbBits = c->alphaBits +
224-
c->redBits +
225-
c->greenBits +
226-
c->blueBits;
227-
228-
c->alphaMask =
229-
AM_ARGB(c->alphaBits, c->redBits,
230-
c->greenBits,
231-
c->blueBits);
232-
c->redMask =
233-
RM_ARGB(c->alphaBits, c->redBits,
234-
c->greenBits,
235-
c->blueBits);
236-
c->greenMask =
237-
GM_ARGB(c->alphaBits, c->redBits,
238-
c->greenBits,
239-
c->blueBits);
240-
c->blueMask =
241-
BM_ARGB(c->alphaBits, c->redBits,
242-
c->greenBits,
243-
c->blueBits);
188+
c->redBits = conf->color_buffers[color].r;
189+
c->greenBits = conf->color_buffers[color].g;
190+
c->blueBits = conf->color_buffers[color].b;
191+
192+
c->rgbBits = c->alphaBits + c->redBits + c->greenBits + c->blueBits;
193+
194+
c->alphaMask = AM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
195+
c->redMask = RM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
196+
c->greenMask = GM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
197+
c->blueMask = BM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
244198

245199
// Accumulation Buffers
246-
if (conf->total_accum_buffers > 0) {
247-
c->accumRedBits =
248-
conf->accum_buffers[accum].r;
249-
c->accumGreenBits =
250-
conf->accum_buffers[accum].g;
251-
c->accumBlueBits =
252-
conf->accum_buffers[accum].b;
253-
if (
254-
GLCAPS_COLOR_BUF_INVALID_VALUE
255-
!=
256-
conf->accum_buffers[accum].a)
257-
{
258-
c->accumAlphaBits =
259-
conf->accum_buffers[accum
260-
].a;
261-
}
262-
else {
200+
if(conf->total_accum_buffers > 0) {
201+
c->accumRedBits = conf->accum_buffers[accum].r;
202+
c->accumGreenBits = conf->accum_buffers[accum].g;
203+
c->accumBlueBits = conf->accum_buffers[accum].b;
204+
if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->accum_buffers[accum].a) {
205+
c->accumAlphaBits = conf->accum_buffers[accum].a;
206+
} else {
263207
c->accumAlphaBits = 0;
264208
}
265-
}
266-
else {
209+
} else {
267210
c->accumRedBits = 0;
268211
c->accumGreenBits = 0;
269212
c->accumBlueBits = 0;
270213
c->accumAlphaBits = 0;
271214
}
272215

273216
// Depth
274-
c->depthBits =
275-
conf->depth_buffers[depth];
217+
c->depthBits = conf->depth_buffers[depth];
276218

277219
// MultiSample
278-
if (msample > 0) {
279-
c->samples =
280-
conf->multisample_samples;
281-
c->sampleBuffers =
282-
conf->multisample_buffers;
283-
}
284-
else {
220+
if(msample > 0) {
221+
c->samples = conf->multisample_samples;
222+
c->sampleBuffers = conf->multisample_buffers;
223+
} else {
285224
c->samples = 0;
286225
c->sampleBuffers = 0;
287226
}
@@ -291,9 +230,7 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
291230
* GLXPbuffers in direct mode.
292231
*/
293232
/* SGIX_fbconfig / GLX 1.3 */
294-
c->drawableType = GLX_WINDOW_BIT |
295-
GLX_PIXMAP_BIT |
296-
GLX_PBUFFER_BIT;
233+
c->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
297234
c->renderType = GLX_RGBA_BIT;
298235
c->xRenderable = GL_TRUE;
299236
c->fbconfigID = -1;
@@ -310,8 +247,7 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
310247
*/
311248
c->maxPbufferWidth = 8192;
312249
c->maxPbufferHeight = 8192;
313-
c->maxPbufferPixels =
314-
/*Do we need this?*/ 0;
250+
c->maxPbufferPixels = /*Do we need this?*/ 0;
315251
/*
316252
* There is no introspection for this sort of thing
317253
* with CGL. What should we do realistically?
@@ -337,12 +273,10 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
337273
}
338274
}
339275

340-
(c - 1)->next = NULL;
276+
(c-1)->next = NULL;
341277

342278
if (c - visualConfigs != numConfigs) {
343-
FatalError(
344-
"numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n",
345-
numConfigs, (int)(c - visualConfigs));
279+
FatalError("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n", numConfigs, (int)(c - visualConfigs));
346280
}
347281

348282
freeGlCapabilities(&caps);

hw/xquartz/darwin.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,15 @@ DarwinScreenInit(ScreenPtr pScreen, int argc, char **argv)
230230
}
231231

232232
// TODO: Make PseudoColor visuals not suck in TrueColor mode
233-
// if(dfb->depth > 8)
234-
// miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0);
235-
if (dfb->depth > 15)
236-
miSetVisualTypesAndMasks(15, TrueColorMask, 5, TrueColor,
237-
RM_ARGB(0, 5, 5, 5), GM_ARGB(0, 5, 5,
238-
5),
239-
BM_ARGB(0, 5, 5, 5));
233+
// if(dfb->depth > 8)
234+
// miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0);
235+
//
236+
// TODO: Re-add support for 15bit
237+
// if (dfb->depth > 15)
238+
// miSetVisualTypesAndMasks(15, TrueColorMask, 5, TrueColor,
239+
// RM_ARGB(0, 5, 5, 5), GM_ARGB(0, 5, 5,
240+
// 5),
241+
// BM_ARGB(0, 5, 5, 5));
240242
if (dfb->depth > 24)
241243
miSetVisualTypesAndMasks(24, TrueColorMask, 8, TrueColor,
242244
RM_ARGB(0, 8, 8, 8), GM_ARGB(0, 8, 8,

hw/xquartz/xpr/xprScreen.c

+5
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ xprAddScreen(int index, ScreenPtr pScreen)
359359
dfb->blueMask = 0;
360360
break;
361361

362+
#if 0
363+
// Removed because Mountain Lion removed support for
364+
// 15bit backing stores. We can possibly re-add
365+
// this once libXplugin is updated to work around it.
362366
case 15:
363367
dfb->visuals = TrueColorMask; //LARGE_VISUALS;
364368
dfb->preferredCVC = TrueColor;
@@ -369,6 +373,7 @@ xprAddScreen(int index, ScreenPtr pScreen)
369373
dfb->greenMask = GM_ARGB(0, 5, 5, 5);
370374
dfb->blueMask = BM_ARGB(0, 5, 5, 5);
371375
break;
376+
#endif
372377

373378
// case 24:
374379
default:

0 commit comments

Comments
 (0)