{
uint count;
uint index;
- const struct stw_pixelformat_info *pf;
+ const struct stw_pixelformat_info *pfi;
count = stw_pixelformat_get_extended_count();
if (index >= count)
return FALSE;
- pf = stw_pixelformat_get_info( index );
+ pfi = stw_pixelformat_get_info( index );
switch (attrib) {
case WGL_DRAW_TO_WINDOW_ARB:
- *pvalue = TRUE;
+ *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_WINDOW ? TRUE : FALSE;
return TRUE;
case WGL_DRAW_TO_BITMAP_ARB:
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_BITMAP ? TRUE : FALSE;
return TRUE;
case WGL_NEED_PALETTE_ARB:
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_NEED_PALETTE ? TRUE : FALSE;
return TRUE;
case WGL_NEED_SYSTEM_PALETTE_ARB:
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE;
return TRUE;
case WGL_SWAP_METHOD_ARB:
- if (pf->flags & STW_PF_FLAG_DOUBLEBUFFER)
- *pvalue = WGL_SWAP_COPY_ARB;
- else
- *pvalue = WGL_SWAP_UNDEFINED_ARB;
+ *pvalue = pfi->pfd.dwFlags & PFD_SWAP_COPY ? WGL_SWAP_COPY_ARB : WGL_SWAP_UNDEFINED_ARB;
return TRUE;
case WGL_SWAP_LAYER_BUFFERS_ARB:
break;
case WGL_SUPPORT_GDI_ARB:
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_GDI ? TRUE : FALSE;
break;
case WGL_SUPPORT_OPENGL_ARB:
- *pvalue = TRUE;
+ *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_OPENGL ? TRUE : FALSE;
break;
case WGL_DOUBLE_BUFFER_ARB:
- if (pf->flags & STW_PF_FLAG_DOUBLEBUFFER)
- *pvalue = TRUE;
- else
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_DOUBLEBUFFER ? TRUE : FALSE;
break;
case WGL_STEREO_ARB:
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_STEREO ? TRUE : FALSE;
break;
case WGL_PIXEL_TYPE_ARB:
- *pvalue = WGL_TYPE_RGBA_ARB;
+ switch (pfi->pfd.iPixelType) {
+ case PFD_TYPE_RGBA:
+ *pvalue = WGL_TYPE_RGBA_ARB;
+ break;
+ case PFD_TYPE_COLORINDEX:
+ *pvalue = WGL_TYPE_COLORINDEX_ARB;
+ break;
+ default:
+ return FALSE;
+ }
break;
case WGL_COLOR_BITS_ARB:
- *pvalue = (int) (pf->color.redbits + pf->color.greenbits + pf->color.bluebits);
+ *pvalue = pfi->pfd.cColorBits;
break;
case WGL_RED_BITS_ARB:
- *pvalue = (int) pf->color.redbits;
+ *pvalue = pfi->pfd.cRedBits;
break;
case WGL_RED_SHIFT_ARB:
- *pvalue = (int) pf->color.redshift;
+ *pvalue = pfi->pfd.cRedShift;
break;
case WGL_GREEN_BITS_ARB:
- *pvalue = (int) pf->color.greenbits;
+ *pvalue = pfi->pfd.cGreenBits;
break;
case WGL_GREEN_SHIFT_ARB:
- *pvalue = (int) pf->color.greenshift;
+ *pvalue = pfi->pfd.cGreenShift;
break;
case WGL_BLUE_BITS_ARB:
- *pvalue = (int) pf->color.bluebits;
+ *pvalue = pfi->pfd.cBlueBits;
break;
case WGL_BLUE_SHIFT_ARB:
- *pvalue = (int) pf->color.blueshift;
+ *pvalue = pfi->pfd.cBlueShift;
break;
case WGL_ALPHA_BITS_ARB:
- *pvalue = (int) pf->color.alphabits;
+ *pvalue = pfi->pfd.cAlphaBits;
break;
case WGL_ALPHA_SHIFT_ARB:
- *pvalue = (int) pf->color.alphashift;
+ *pvalue = pfi->pfd.cAlphaShift;
break;
case WGL_ACCUM_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumBits;
+ break;
+
case WGL_ACCUM_RED_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumRedBits;
+ break;
+
case WGL_ACCUM_GREEN_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumGreenBits;
+ break;
+
case WGL_ACCUM_BLUE_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumBlueBits;
+ break;
+
case WGL_ACCUM_ALPHA_BITS_ARB:
- *pvalue = 0;
+ *pvalue = pfi->pfd.cAccumAlphaBits;
break;
case WGL_DEPTH_BITS_ARB:
- *pvalue = (int) pf->depth.depthbits;
+ *pvalue = pfi->pfd.cDepthBits;
break;
case WGL_STENCIL_BITS_ARB:
- *pvalue = (int) pf->depth.stencilbits;
+ *pvalue = pfi->pfd.cStencilBits;
break;
case WGL_AUX_BUFFERS_ARB:
- *pvalue = 0;
+ *pvalue = pfi->pfd.cAuxBuffers;
break;
case WGL_SAMPLE_BUFFERS_ARB:
- if (pf->flags & STW_PF_FLAG_MULTISAMPLED)
- *pvalue = stw_query_sample_buffers();
- else
- *pvalue = 0;
+ *pvalue = pfi->numSampleBuffers;
break;
case WGL_SAMPLES_ARB:
- if (pf->flags & STW_PF_FLAG_MULTISAMPLED)
- *pvalue = stw_query_samples();
- else
- *pvalue = 0;
+ *pvalue = pfi->numSamples;
break;
default:
static void
stw_pixelformat_add(
struct stw_device *stw_dev,
- unsigned flags,
const struct stw_pixelformat_color_info *color,
const struct stw_pixelformat_depth_info *depth,
+ boolean doublebuffer,
+ boolean multisampled,
boolean extended )
{
- struct stw_pixelformat_info *pf;
+ struct stw_pixelformat_info *pfi;
assert(stw_dev->pixelformat_extended_count < STW_MAX_PIXELFORMATS);
if(stw_dev->pixelformat_extended_count >= STW_MAX_PIXELFORMATS)
return;
- pf = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count];
+ pfi = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count];
- pf->flags = flags;
- pf->color = *color;
- pf->depth = *depth;
+ memset(pfi, 0, sizeof *pfi);
+
+ pfi->pfd.nSize = sizeof pfi->pfd;
+ pfi->pfd.nVersion = 1;
+ pfi->pfd.dwFlags = PFD_SUPPORT_OPENGL;
+
+ /* TODO: also support non-native pixel formats */
+ pfi->pfd.dwFlags |= PFD_DRAW_TO_WINDOW ;
+
+ if (doublebuffer)
+ pfi->pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SWAP_COPY;
+
+ pfi->pfd.iPixelType = PFD_TYPE_RGBA;
+
+ pfi->pfd.cColorBits = color->redbits + color->greenbits + color->bluebits;
+ pfi->pfd.cRedBits = color->redbits;
+ pfi->pfd.cRedShift = color->redshift;
+ pfi->pfd.cGreenBits = color->greenbits;
+ pfi->pfd.cGreenShift = color->greenshift;
+ pfi->pfd.cBlueBits = color->bluebits;
+ pfi->pfd.cBlueShift = color->blueshift;
+ pfi->pfd.cAlphaBits = color->alphabits;
+ pfi->pfd.cAlphaShift = color->alphashift;
+ pfi->pfd.cAccumBits = 0;
+ pfi->pfd.cAccumRedBits = 0;
+ pfi->pfd.cAccumGreenBits = 0;
+ pfi->pfd.cAccumBlueBits = 0;
+ pfi->pfd.cAccumAlphaBits = 0;
+ pfi->pfd.cDepthBits = depth->depthbits;
+ pfi->pfd.cStencilBits = depth->stencilbits;
+ pfi->pfd.cAuxBuffers = 0;
+ pfi->pfd.iLayerType = 0;
+ pfi->pfd.bReserved = 0;
+ pfi->pfd.dwLayerMask = 0;
+ pfi->pfd.dwVisibleMask = 0;
+ pfi->pfd.dwDamageMask = 0;
+
+ if(multisampled) {
+ /* FIXME: re-enable when we can query this */
+#if 0
+ pfi->numSampleBuffers = 1;
+ pfi->numSamples = 4;
+#else
+ return;
+#endif
+ }
+
++stw_dev->pixelformat_extended_count;
if(!extended) {
static void
stw_add_standard_pixelformats(
struct stw_device *stw_dev,
- uint flags,
+ boolean doublebuffer,
+ boolean multisampled,
boolean extended )
{
const struct stw_pixelformat_color_info color24 = { 8, 0, 8, 8, 8, 16, 0, 0 };
const struct stw_pixelformat_depth_info depth24s8 = { 24, 8 };
const struct stw_pixelformat_depth_info depth16 = { 16, 0 };
- stw_pixelformat_add( stw_dev, flags, &color24, &depth24s8, extended );
+ stw_pixelformat_add( stw_dev, &color24, &depth24s8, doublebuffer, multisampled, extended );
- stw_pixelformat_add( stw_dev, flags, &color24a8, &depth24s8, extended );
+ stw_pixelformat_add( stw_dev, &color24a8, &depth24s8, doublebuffer, multisampled, extended );
- stw_pixelformat_add( stw_dev, flags, &color24, &depth16, extended );
+ stw_pixelformat_add( stw_dev, &color24, &depth16, doublebuffer, multisampled, extended );
- stw_pixelformat_add( stw_dev, flags, &color24a8, &depth16, extended );
+ stw_pixelformat_add( stw_dev, &color24a8, &depth16, doublebuffer, multisampled, extended );
}
void
stw_pixelformat_init( void )
{
- stw_add_standard_pixelformats( stw_dev, STW_PF_FLAG_DOUBLEBUFFER | 0 , FALSE );
- stw_add_standard_pixelformats( stw_dev, 0 | 0, FALSE );
- stw_add_standard_pixelformats( stw_dev, STW_PF_FLAG_DOUBLEBUFFER | STW_PF_FLAG_MULTISAMPLED, TRUE );
- stw_add_standard_pixelformats( stw_dev, 0 | STW_PF_FLAG_MULTISAMPLED, TRUE );
+ stw_add_standard_pixelformats( stw_dev, FALSE, FALSE, FALSE );
+ stw_add_standard_pixelformats( stw_dev, TRUE, FALSE, FALSE );
+ stw_add_standard_pixelformats( stw_dev, FALSE, TRUE, TRUE );
+ stw_add_standard_pixelformats( stw_dev, TRUE, TRUE, TRUE );
assert( stw_dev->pixelformat_count <= STW_MAX_PIXELFORMATS );
assert( stw_dev->pixelformat_extended_count <= STW_MAX_PIXELFORMATS );
{
uint count;
uint index;
- const struct stw_pixelformat_info *pf;
+ const struct stw_pixelformat_info *pfi;
(void) hdc;
if (index >= count || nBytes != sizeof( PIXELFORMATDESCRIPTOR ))
return 0;
- pf = stw_pixelformat_get_info( index );
-
- ppfd->nSize = sizeof( PIXELFORMATDESCRIPTOR );
- ppfd->nVersion = 1;
- ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
- if (pf->flags & STW_PF_FLAG_DOUBLEBUFFER)
- ppfd->dwFlags |= PFD_DOUBLEBUFFER | PFD_SWAP_COPY;
- ppfd->iPixelType = PFD_TYPE_RGBA;
- ppfd->cColorBits = pf->color.redbits + pf->color.greenbits + pf->color.bluebits;
- ppfd->cRedBits = pf->color.redbits;
- ppfd->cRedShift = pf->color.redshift;
- ppfd->cGreenBits = pf->color.greenbits;
- ppfd->cGreenShift = pf->color.greenshift;
- ppfd->cBlueBits = pf->color.bluebits;
- ppfd->cBlueShift = pf->color.blueshift;
- ppfd->cAlphaBits = pf->color.alphabits;
- ppfd->cAlphaShift = pf->color.alphashift;
- ppfd->cAccumBits = 0;
- ppfd->cAccumRedBits = 0;
- ppfd->cAccumGreenBits = 0;
- ppfd->cAccumBlueBits = 0;
- ppfd->cAccumAlphaBits = 0;
- ppfd->cDepthBits = pf->depth.depthbits;
- ppfd->cStencilBits = pf->depth.stencilbits;
- ppfd->cAuxBuffers = 0;
- ppfd->iLayerType = 0;
- ppfd->bReserved = 0;
- ppfd->dwLayerMask = 0;
- ppfd->dwVisibleMask = 0;
- ppfd->dwDamageMask = 0;
+ pfi = stw_pixelformat_get_info( index );
+
+ memcpy(ppfd, &pfi->pfd, sizeof( PIXELFORMATDESCRIPTOR ));
return count;
}
for (index = 0; index < count; index++) {
uint delta = 0;
- const struct stw_pixelformat_info *pf = stw_pixelformat_get_info( index );
+ const struct stw_pixelformat_info *pfi = stw_pixelformat_get_info( index );
if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
!!(ppfd->dwFlags & PFD_DOUBLEBUFFER) !=
- !!(pf->flags & STW_PF_FLAG_DOUBLEBUFFER))
+ !!(pfi->pfd.dwFlags & PFD_DOUBLEBUFFER))
continue;
- if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits)
+ /* FIXME: Take in account individual channel bits */
+ if (ppfd->cColorBits != pfi->pfd.cColorBits)
delta += 8;
- if (ppfd->cDepthBits != pf->depth.depthbits)
+ if (ppfd->cDepthBits != pfi->pfd.cDepthBits)
delta += 4;
- if (ppfd->cStencilBits != pf->depth.stencilbits)
+ if (ppfd->cStencilBits != pfi->pfd.cStencilBits)
delta += 2;
- if (ppfd->cAlphaBits != pf->color.alphabits)
+ if (ppfd->cAlphaBits != pfi->pfd.cAlphaBits)
delta++;
if (delta < bestdelta) {
return TRUE;
}
-
-
-
-/* XXX: this needs to be turned into queries on pipe_screen or
- * stw_winsys.
- */
-int
-stw_query_sample_buffers( void )
-{
- return 1;
-}
-
-int
-stw_query_samples( void )
-{
- return 4;
-}
-