mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-26 10:00:22 +01:00
stw: move pixelformat_get/set to shared
This commit is contained in:
parent
cb70d27dd1
commit
c3d744f5bb
5 changed files with 100 additions and 74 deletions
|
|
@ -594,12 +594,9 @@ DrvSetPixelFormat(
|
|||
HDC hdc,
|
||||
LONG iPixelFormat )
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
BOOL r;
|
||||
|
||||
stw_pixelformat_describe( hdc, iPixelFormat, sizeof( pfd ), &pfd );
|
||||
|
||||
r = wglSetPixelFormat( hdc, iPixelFormat, &pfd );
|
||||
r = stw_pixelformat_set( hdc, iPixelFormat );
|
||||
|
||||
debug_printf( "%s( 0x%p, %d ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" );
|
||||
|
||||
|
|
|
|||
|
|
@ -289,57 +289,3 @@ wgl_context_from_hdc(
|
|||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ static struct pixelformat_info pixelformats[MAX_PIXELFORMATS];
|
|||
static uint pixelformat_count = 0;
|
||||
static uint pixelformat_extended_count = 0;
|
||||
|
||||
static uint currentpixelformat = 0;
|
||||
|
||||
|
||||
static void
|
||||
add_standard_pixelformats(
|
||||
struct pixelformat_info **ppf,
|
||||
|
|
@ -118,3 +121,87 @@ pixelformat_get_info( uint index )
|
|||
|
||||
return &pixelformats[index];
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
stw_pixelformat_get(
|
||||
HDC hdc )
|
||||
{
|
||||
return currentpixelformat;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
stw_pixelformat_set(
|
||||
HDC hdc,
|
||||
int iPixelFormat )
|
||||
{
|
||||
uint count;
|
||||
uint index;
|
||||
|
||||
(void) hdc;
|
||||
|
||||
index = (uint) iPixelFormat - 1;
|
||||
count = pixelformat_get_extended_count();
|
||||
if (index >= count)
|
||||
return FALSE;
|
||||
|
||||
currentpixelformat = iPixelFormat;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,5 +83,14 @@ stw_pixelformat_describe(
|
|||
UINT nBytes,
|
||||
LPPIXELFORMATDESCRIPTOR ppfd );
|
||||
|
||||
int
|
||||
stw_pixelformat_get(
|
||||
HDC hdc );
|
||||
|
||||
BOOL
|
||||
stw_pixelformat_set(
|
||||
HDC hdc,
|
||||
int iPixelFormat );
|
||||
|
||||
|
||||
#endif /* PIXELFORMAT_H */
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@
|
|||
#include "shared/stw_pixelformat.h"
|
||||
#include "stw_wgl.h"
|
||||
|
||||
static uint currentpixelformat = 0;
|
||||
|
||||
WINGDIAPI int APIENTRY
|
||||
wglChoosePixelFormat(
|
||||
HDC hdc,
|
||||
|
|
@ -115,9 +113,7 @@ WINGDIAPI int APIENTRY
|
|||
wglGetPixelFormat(
|
||||
HDC hdc )
|
||||
{
|
||||
(void) hdc;
|
||||
|
||||
return currentpixelformat;
|
||||
return stw_pixelformat_get( hdc );
|
||||
}
|
||||
|
||||
WINGDIAPI BOOL APIENTRY
|
||||
|
|
@ -126,17 +122,8 @@ wglSetPixelFormat(
|
|||
int iPixelFormat,
|
||||
const PIXELFORMATDESCRIPTOR *ppfd )
|
||||
{
|
||||
uint count;
|
||||
uint index;
|
||||
|
||||
(void) hdc;
|
||||
|
||||
count = pixelformat_get_extended_count();
|
||||
index = (uint) iPixelFormat - 1;
|
||||
|
||||
if (index >= count || ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
|
||||
if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
|
||||
return FALSE;
|
||||
|
||||
currentpixelformat = index + 1;
|
||||
return TRUE;
|
||||
return stw_pixelformat_set( hdc, iPixelFormat );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue