mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-10 12:30:11 +01:00
st/wgl: Just pass pPixelFormat to stw_pixelformat_get_info().
Avoids the likely error of forgetting to subtract one.
This commit is contained in:
parent
6beed86ab8
commit
0cf554fa9b
6 changed files with 26 additions and 21 deletions
|
|
@ -154,7 +154,7 @@ stw_create_context_attribs(
|
|||
if(!iPixelFormat)
|
||||
return 0;
|
||||
|
||||
pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
|
||||
pfi = stw_pixelformat_get_info( iPixelFormat );
|
||||
|
||||
if (hShareContext != 0) {
|
||||
pipe_mutex_lock( stw_dev->ctx_mutex );
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ wglCreatePbufferARB(HDC _hDC,
|
|||
HWND hWnd;
|
||||
HDC hDC;
|
||||
|
||||
info = stw_pixelformat_get_info(iPixelFormat - 1);
|
||||
info = stw_pixelformat_get_info(iPixelFormat);
|
||||
if (!info) {
|
||||
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ stw_query_attrib(
|
|||
int *pvalue )
|
||||
{
|
||||
uint count;
|
||||
uint index;
|
||||
const struct stw_pixelformat_info *pfi;
|
||||
|
||||
count = stw_pixelformat_get_extended_count();
|
||||
|
|
@ -65,11 +64,10 @@ stw_query_attrib(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
index = (uint) iPixelFormat - 1;
|
||||
if (index >= count)
|
||||
pfi = stw_pixelformat_get_info( iPixelFormat );
|
||||
if (!pfi) {
|
||||
return FALSE;
|
||||
|
||||
pfi = stw_pixelformat_get_info( index );
|
||||
}
|
||||
|
||||
switch (attrib) {
|
||||
case WGL_DRAW_TO_WINDOW_ARB:
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ stw_framebuffer_create(
|
|||
fb->hWnd = hWnd;
|
||||
fb->iPixelFormat = iPixelFormat;
|
||||
|
||||
fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
|
||||
fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat );
|
||||
fb->stfb = stw_st_create_framebuffer( fb );
|
||||
if (!fb->stfb) {
|
||||
FREE( fb );
|
||||
|
|
|
|||
|
|
@ -262,9 +262,18 @@ stw_pixelformat_get_extended_count( void )
|
|||
}
|
||||
|
||||
const struct stw_pixelformat_info *
|
||||
stw_pixelformat_get_info( uint index )
|
||||
stw_pixelformat_get_info( int iPixelFormat )
|
||||
{
|
||||
assert( index < stw_dev->pixelformat_extended_count );
|
||||
int index;
|
||||
|
||||
if (iPixelFormat <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
index = iPixelFormat - 1;
|
||||
if (index >= stw_dev->pixelformat_extended_count) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &stw_dev->pixelformats[index];
|
||||
}
|
||||
|
|
@ -278,7 +287,6 @@ DrvDescribePixelFormat(
|
|||
PIXELFORMATDESCRIPTOR *ppfd )
|
||||
{
|
||||
uint count;
|
||||
uint index;
|
||||
const struct stw_pixelformat_info *pfi;
|
||||
|
||||
(void) hdc;
|
||||
|
|
@ -287,14 +295,16 @@ DrvDescribePixelFormat(
|
|||
return 0;
|
||||
|
||||
count = stw_pixelformat_get_extended_count();
|
||||
index = (uint) iPixelFormat - 1;
|
||||
|
||||
if (ppfd == NULL)
|
||||
return count;
|
||||
if (index >= count || cjpfd != sizeof( PIXELFORMATDESCRIPTOR ))
|
||||
if (cjpfd != sizeof( PIXELFORMATDESCRIPTOR ))
|
||||
return 0;
|
||||
|
||||
pfi = stw_pixelformat_get_info( index );
|
||||
pfi = stw_pixelformat_get_info( iPixelFormat );
|
||||
if (!pfi) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(ppfd, &pfi->pfd, sizeof( PIXELFORMATDESCRIPTOR ));
|
||||
|
||||
|
|
@ -361,10 +371,10 @@ int stw_pixelformat_choose( HDC hdc,
|
|||
(void) hdc;
|
||||
|
||||
count = stw_pixelformat_get_count();
|
||||
bestindex = count;
|
||||
bestindex = 0;
|
||||
bestdelta = ~0U;
|
||||
|
||||
for (index = 0; index < count; index++) {
|
||||
for (index = 1; index <= count; index++) {
|
||||
uint delta = 0;
|
||||
const struct stw_pixelformat_info *pfi = stw_pixelformat_get_info( index );
|
||||
|
||||
|
|
@ -394,8 +404,5 @@ int stw_pixelformat_choose( HDC hdc,
|
|||
}
|
||||
}
|
||||
|
||||
if (bestindex == count)
|
||||
return 0;
|
||||
|
||||
return bestindex + 1;
|
||||
return bestindex;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ uint
|
|||
stw_pixelformat_get_extended_count( void );
|
||||
|
||||
const struct stw_pixelformat_info *
|
||||
stw_pixelformat_get_info( uint index );
|
||||
stw_pixelformat_get_info( int iPixelFormat );
|
||||
|
||||
int
|
||||
stw_pixelformat_choose( HDC hdc,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue