diff options
author | José Fonseca <[email protected]> | 2012-02-08 15:58:37 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2012-02-10 16:23:27 +0000 |
commit | 0cf554fa9b31dbac1890f496974392001e2df825 (patch) | |
tree | 2b8c964445a8e8c17fb27d5be7fb1d1d7781412f /src/gallium/state_trackers/wgl | |
parent | 6beed86ab8970b57aad8442a3e6bf6410fff13ec (diff) |
st/wgl: Just pass pPixelFormat to stw_pixelformat_get_info().
Avoids the likely error of forgetting to subtract one.
Diffstat (limited to 'src/gallium/state_trackers/wgl')
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_context.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_ext_pbuffer.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_ext_pixelformat.c | 8 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_framebuffer.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_pixelformat.c | 31 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_pixelformat.h | 2 |
6 files changed, 26 insertions, 21 deletions
diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index abdcf1edfea..1409f240ef5 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -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 ); diff --git a/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c b/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c index a2224fba2bc..252d07a90cc 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c +++ b/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c @@ -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; diff --git a/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c b/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c index d0a95863bb4..52253fc7d50 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c @@ -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: diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c index f595efe03f4..71b92f0d8f6 100644 --- a/src/gallium/state_trackers/wgl/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c @@ -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 ); diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c index ec044319e2c..ffb7488cb1c 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c @@ -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; } diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.h b/src/gallium/state_trackers/wgl/stw_pixelformat.h index 282c9f643c2..dae9c3fde9a 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.h +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.h @@ -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, |