diff options
7 files changed, 108 insertions, 149 deletions
| diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript index 1915e3921a..c72f495735 100644 --- a/src/gallium/state_trackers/wgl/SConscript +++ b/src/gallium/state_trackers/wgl/SConscript @@ -24,7 +24,6 @@ if env['platform'] in ['windows']:          'icd/stw_icd.c',          'wgl/stw_wgl.c', -        'wgl/stw_wgl_pixelformat.c',          'shared/stw_context.c',          'shared/stw_device.c', diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index 62d6adc734..35a8eee220 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -34,7 +34,6 @@  #include "shared/stw_public.h"  #include "icd/stw_icd.h" -#include "wgl/stw_wgl.h"  #include "stw.h" diff --git a/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c index d373ed0809..f563635420 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c +++ b/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c @@ -29,7 +29,8 @@  #include "pipe/p_compiler.h"  #include "util/u_memory.h" -#include "shared/stw_public.h" +#include "stw_public.h" +#include "stw_pixelformat.h"  #include "stw_arbpixelformat.h"  #define WGL_NUMBER_PIXEL_FORMATS_ARB            0x2000 diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c index 4ba763d933..12b5ac6d91 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c @@ -27,6 +27,7 @@  #include "pipe/p_debug.h"  #include "stw_pixelformat.h" +#include "stw_public.h"  #define MAX_PIXELFORMATS   16 @@ -178,6 +179,58 @@ stw_pixelformat_describe(     return count;  } +/* Only used by the wgl code, but have it here to avoid exporting the + * pixelformat.h functionality. + */ +int stw_pixelformat_choose( HDC hdc, +                            CONST PIXELFORMATDESCRIPTOR *ppfd ) +{ +   uint count; +   uint index; +   uint bestindex; +   uint bestdelta; + +   (void) hdc; + +   count = pixelformat_get_count(); +   bestindex = count; +   bestdelta = 0xffffffff; + +   for (index = 0; index < count; index++) { +      uint delta = 0; +      const struct pixelformat_info *pf = pixelformat_get_info( index ); + +      if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) && +          !!(ppfd->dwFlags & PFD_DOUBLEBUFFER) != +          !!(pf->flags & PF_FLAG_DOUBLEBUFFER)) +         continue; + +      if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits) +         delta += 8; + +      if (ppfd->cDepthBits != pf->depth.depthbits) +         delta += 4; + +      if (ppfd->cStencilBits != pf->depth.stencilbits) +         delta += 2; + +      if (ppfd->cAlphaBits != pf->alpha.alphabits) +         delta++; + +      if (delta < bestdelta) { +         bestindex = index; +         bestdelta = delta; +         if (bestdelta == 0) +            break; +      } +   } + +   if (bestindex == count) +      return 0; + +   return bestindex + 1; +} +  int  stw_pixelformat_get( diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h index ed855f08fd..7ca4194a2a 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h +++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h @@ -76,23 +76,6 @@ 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 ); - -int -stw_pixelformat_get( -   HDC hdc ); - -BOOL -stw_pixelformat_set( -   HDC hdc, -   int iPixelFormat ); -  int stw_query_sample_buffers( void );  int stw_query_samples( void ); diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c index d89d089822..d03341815e 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c @@ -123,6 +123,59 @@ wglGetProcAddress(  } +WINGDIAPI int APIENTRY +wglChoosePixelFormat( +   HDC hdc, +   CONST PIXELFORMATDESCRIPTOR *ppfd ) +{ +   if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1) +      return 0; +   if (ppfd->iPixelType != PFD_TYPE_RGBA) +      return 0; +   if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW)) +      return 0; +   if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL)) +      return 0; +   if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) +      return 0; +   if (ppfd->dwFlags & PFD_SUPPORT_GDI) +      return 0; +   if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO)) +      return 0; + +   return stw_pixelformat_choose( hdc, ppfd ); +} + +WINGDIAPI int APIENTRY +wglDescribePixelFormat( +   HDC hdc, +   int iPixelFormat, +   UINT nBytes, +   LPPIXELFORMATDESCRIPTOR ppfd ) +{ +   return stw_pixelformat_describe( hdc, iPixelFormat, nBytes, ppfd ); +} + +WINGDIAPI int APIENTRY +wglGetPixelFormat( +   HDC hdc ) +{ +   return stw_pixelformat_get( hdc ); +} + +WINGDIAPI BOOL APIENTRY +wglSetPixelFormat( +   HDC hdc, +   int iPixelFormat, +   const PIXELFORMATDESCRIPTOR *ppfd ) +{ +   if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR )) +      return FALSE; + +   return stw_pixelformat_set( hdc, iPixelFormat ); +} + +  WINGDIAPI BOOL APIENTRY  wglUseFontBitmapsA(     HDC hdc, diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c deleted file mode 100644 index 11438172e6..0000000000 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c +++ /dev/null @@ -1,129 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include <windows.h> - -#include "pipe/p_compiler.h" -#include "pipe/p_debug.h" -#include "shared/stw_public.h" -#include "stw_wgl.h" - -WINGDIAPI int APIENTRY -wglChoosePixelFormat( -   HDC hdc, -   CONST PIXELFORMATDESCRIPTOR *ppfd ) -{ -   uint count; -   uint index; -   uint bestindex; -   uint bestdelta; - -   (void) hdc; - -   count = pixelformat_get_count(); -   bestindex = count; -   bestdelta = 0xffffffff; - -   if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1) -      return 0; -   if (ppfd->iPixelType != PFD_TYPE_RGBA) -      return 0; -   if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW)) -      return 0; -   if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL)) -      return 0; -   if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) -      return 0; -   if (ppfd->dwFlags & PFD_SUPPORT_GDI) -      return 0; -   if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO)) -      return 0; - -   for (index = 0; index < count; index++) { -      uint delta = 0; -      const struct pixelformat_info *pf = pixelformat_get_info( index ); - -      if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE)) { -         if ((ppfd->dwFlags & PFD_DOUBLEBUFFER) && !(pf->flags & PF_FLAG_DOUBLEBUFFER)) -            continue; -         if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER) && (pf->flags & PF_FLAG_DOUBLEBUFFER)) -            continue; -      } - -      if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits) -         delta += 8; - -      if (ppfd->cDepthBits != pf->depth.depthbits) -         delta += 4; - -      if (ppfd->cStencilBits != pf->depth.stencilbits) -         delta += 2; - -      if (ppfd->cAlphaBits != pf->alpha.alphabits) -         delta++; - -      if (delta < bestdelta) { -         bestindex = index; -         bestdelta = delta; -         if (bestdelta == 0) -            break; -      } -   } - -   if (bestindex == count) -      return 0; -   return bestindex + 1; -} - -WINGDIAPI int APIENTRY -wglDescribePixelFormat( -   HDC hdc, -   int iPixelFormat, -   UINT nBytes, -   LPPIXELFORMATDESCRIPTOR ppfd ) -{ -   return stw_pixelformat_describe( hdc, iPixelFormat, nBytes, ppfd ); -} - -WINGDIAPI int APIENTRY -wglGetPixelFormat( -   HDC hdc ) -{ -   return stw_pixelformat_get( hdc ); -} - -WINGDIAPI BOOL APIENTRY -wglSetPixelFormat( -   HDC hdc, -   int iPixelFormat, -   const PIXELFORMATDESCRIPTOR *ppfd ) -{ -   if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR )) -      return FALSE; - -   return stw_pixelformat_set( hdc, iPixelFormat ); -} | 
