OSDN Git Service

svga: remove pixelformat helpers from stw shared interface
authorKeith Whitwell <keithw@vmware.com>
Wed, 28 Jan 2009 18:25:46 +0000 (18:25 +0000)
committerKeith Whitwell <keithw@vmware.com>
Wed, 28 Jan 2009 18:25:46 +0000 (18:25 +0000)
Keep these internal structs private to wgl/shared.  Pull in
some pixelformat choosing code from wgl/wgl to avoid exporting them
more generally.

src/gallium/state_trackers/wgl/SConscript
src/gallium/state_trackers/wgl/icd/stw_icd.c
src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c
src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
src/gallium/state_trackers/wgl/wgl/stw_wgl.c
src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c [deleted file]

index 1915e39..c72f495 100644 (file)
@@ -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',
index 62d6adc..35a8eee 100644 (file)
@@ -34,7 +34,6 @@
 
 #include "shared/stw_public.h"
 #include "icd/stw_icd.h"
-#include "wgl/stw_wgl.h"
 #include "stw.h"
 
 
index d373ed0..f563635 100644 (file)
@@ -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
index 4ba763d..12b5ac6 100644 (file)
@@ -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(
index ed855f0..7ca4194 100644 (file)
@@ -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 );
 
index d89d089..d033418 100644 (file)
@@ -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 (file)
index 1143817..0000000
+++ /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 );
-}