summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-01-28 13:35:18 +0000
committerKeith Whitwell <[email protected]>2009-01-28 13:35:49 +0000
commitcb70d27dd1b04ae7dc146d06a21fb32004265539 (patch)
treea9b134e5af5bbecd9a7c867a3ac9be55332ea865 /src/gallium/state_trackers
parentf17eb0b13c6a2e70746edd1d882bf71adec129fb (diff)
stw: move pixelformat_describe to shared
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/wgl/icd/stw_icd.c6
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c57
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.h11
-rw-r--r--src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c47
4 files changed, 73 insertions, 48 deletions
diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c
index 94c6dfe1081..5504ac19b10 100644
--- a/src/gallium/state_trackers/wgl/icd/stw_icd.c
+++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c
@@ -34,6 +34,7 @@
#include "shared/stw_device.h"
#include "shared/stw_context.h"
+#include "shared/stw_pixelformat.h"
#include "icd/stw_icd.h"
#include "wgl/stw_wgl.h"
@@ -135,7 +136,7 @@ DrvDescribePixelFormat(
{
LONG r;
- r = wglDescribePixelFormat( hdc, iPixelFormat, cjpfd, ppfd );
+ r = stw_pixelformat_describe( hdc, iPixelFormat, cjpfd, ppfd );
debug_printf( "%s( 0x%p, %d, %u, 0x%p ) = %d\n",
__FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r );
@@ -596,7 +597,8 @@ DrvSetPixelFormat(
PIXELFORMATDESCRIPTOR pfd;
BOOL r;
- wglDescribePixelFormat( hdc, iPixelFormat, sizeof( pfd ), &pfd );
+ stw_pixelformat_describe( hdc, iPixelFormat, sizeof( pfd ), &pfd );
+
r = wglSetPixelFormat( hdc, iPixelFormat, &pfd );
debug_printf( "%s( 0x%p, %d ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" );
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
index b54e084230f..e89438557de 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -286,3 +286,60 @@ wgl_context_from_hdc(
}
return NULL;
}
+
+
+
+int
+stw_pixelformat_describe(
+ HDC hdc,
+ int iPixelFormat,
+ UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd )
+{
+ uint count;
+ uint index;
+ const struct pixelformat_info *pf;
+
+ (void) hdc;
+
+ count = pixelformat_get_extended_count();
+ index = (uint) iPixelFormat - 1;
+
+ if (ppfd == NULL)
+ return count;
+ if (index >= count || nBytes != sizeof( PIXELFORMATDESCRIPTOR ))
+ return 0;
+
+ pf = pixelformat_get_info( index );
+
+ ppfd->nSize = sizeof( PIXELFORMATDESCRIPTOR );
+ ppfd->nVersion = 1;
+ ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
+ if (pf->flags & 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->alpha.alphabits;
+ ppfd->cAlphaShift = pf->alpha.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;
+
+ return count;
+}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
index 0b67da8d25c..da26df5c648 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
@@ -28,6 +28,8 @@
#ifndef PIXELFORMAT_H
#define PIXELFORMAT_H
+#include <windows.h>
+
#define PF_FLAG_DOUBLEBUFFER 0x00000001
#define PF_FLAG_MULTISAMPLED 0x00000002
@@ -73,4 +75,13 @@ pixelformat_get_extended_count( void );
const struct pixelformat_info *
pixelformat_get_info( uint index );
+
+int
+stw_pixelformat_describe(
+ HDC hdc,
+ int iPixelFormat,
+ UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd );
+
+
#endif /* PIXELFORMAT_H */
diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c
index 4646f57a198..20d7adc6645 100644
--- a/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c
+++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c
@@ -108,52 +108,7 @@ wglDescribePixelFormat(
UINT nBytes,
LPPIXELFORMATDESCRIPTOR ppfd )
{
- uint count;
- uint index;
- const struct pixelformat_info *pf;
-
- (void) hdc;
-
- count = pixelformat_get_extended_count();
- index = (uint) iPixelFormat - 1;
-
- if (ppfd == NULL)
- return count;
- if (index >= count || nBytes != sizeof( PIXELFORMATDESCRIPTOR ))
- return 0;
-
- pf = pixelformat_get_info( index );
-
- ppfd->nSize = sizeof( PIXELFORMATDESCRIPTOR );
- ppfd->nVersion = 1;
- ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
- if (pf->flags & 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->alpha.alphabits;
- ppfd->cAlphaShift = pf->alpha.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;
-
- return count;
+ return stw_pixelformat_describe( hdc, iPixelFormat, nBytes, ppfd );
}
WINGDIAPI int APIENTRY