summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/wgl/shared
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2009-01-28 18:25:46 +0000
committerKeith Whitwell <keithw@vmware.com>2009-01-28 18:25:46 +0000
commit906230d16e8950004cb5e1deed14c78f7d9f2817 (patch)
treebd24da34206463059e92f9afbc1bdd70c9542b0f /src/gallium/state_trackers/wgl/shared
parent66059cd3c95bf5eba7922a4a09c2596514e5e956 (diff)
svga: remove pixelformat helpers from stw shared interface
Keep these internal structs private to wgl/shared. Pull in some pixelformat choosing code from wgl/wgl to avoid exporting them more generally.
Diffstat (limited to 'src/gallium/state_trackers/wgl/shared')
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c3
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.c53
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.h17
3 files changed, 55 insertions, 18 deletions
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 );