summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/wgl/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/wgl/shared')
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c483
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c382
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.h43
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_device.c225
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_device.h77
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c59
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_extgallium.c79
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_extgallium.h47
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_extswapinterval.c57
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_framebuffer.c493
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_framebuffer.h148
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c86
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.c370
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.h65
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_public.h73
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_tls.c139
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_tls.h59
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_winsys.h65
18 files changed, 0 insertions, 2950 deletions
diff --git a/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c
deleted file mode 100644
index 0e2d407699..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c
+++ /dev/null
@@ -1,483 +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.
- *
- **************************************************************************/
-
-/**
- * @file
- *
- * WGL_ARB_pixel_format extension implementation.
- *
- * @sa http://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt
- */
-
-
-#include <windows.h>
-
-#define WGL_WGLEXT_PROTOTYPES
-
-#include <GL/gl.h>
-#include <GL/wglext.h>
-
-#include "pipe/p_compiler.h"
-#include "util/u_memory.h"
-#include "stw_public.h"
-#include "stw_pixelformat.h"
-
-
-static boolean
-stw_query_attrib(
- int iPixelFormat,
- int iLayerPlane,
- int attrib,
- int *pvalue )
-{
- uint count;
- uint index;
- const struct stw_pixelformat_info *pfi;
-
- count = stw_pixelformat_get_extended_count();
-
- if (attrib == WGL_NUMBER_PIXEL_FORMATS_ARB) {
- *pvalue = (int) count;
- return TRUE;
- }
-
- index = (uint) iPixelFormat - 1;
- if (index >= count)
- return FALSE;
-
- pfi = stw_pixelformat_get_info( index );
-
- switch (attrib) {
- case WGL_DRAW_TO_WINDOW_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_WINDOW ? TRUE : FALSE;
- return TRUE;
-
- case WGL_DRAW_TO_BITMAP_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_BITMAP ? TRUE : FALSE;
- return TRUE;
-
- case WGL_NEED_PALETTE_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_NEED_PALETTE ? TRUE : FALSE;
- return TRUE;
-
- case WGL_NEED_SYSTEM_PALETTE_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE;
- return TRUE;
-
- case WGL_SWAP_METHOD_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_SWAP_COPY ? WGL_SWAP_COPY_ARB : WGL_SWAP_UNDEFINED_ARB;
- return TRUE;
-
- case WGL_SWAP_LAYER_BUFFERS_ARB:
- *pvalue = FALSE;
- return TRUE;
-
- case WGL_NUMBER_OVERLAYS_ARB:
- *pvalue = 0;
- return TRUE;
-
- case WGL_NUMBER_UNDERLAYS_ARB:
- *pvalue = 0;
- return TRUE;
- }
-
- if (iLayerPlane != 0)
- return FALSE;
-
- switch (attrib) {
- case WGL_ACCELERATION_ARB:
- *pvalue = WGL_FULL_ACCELERATION_ARB;
- break;
-
- case WGL_TRANSPARENT_ARB:
- *pvalue = FALSE;
- break;
-
- case WGL_TRANSPARENT_RED_VALUE_ARB:
- case WGL_TRANSPARENT_GREEN_VALUE_ARB:
- case WGL_TRANSPARENT_BLUE_VALUE_ARB:
- case WGL_TRANSPARENT_ALPHA_VALUE_ARB:
- case WGL_TRANSPARENT_INDEX_VALUE_ARB:
- break;
-
- case WGL_SHARE_DEPTH_ARB:
- case WGL_SHARE_STENCIL_ARB:
- case WGL_SHARE_ACCUM_ARB:
- *pvalue = TRUE;
- break;
-
- case WGL_SUPPORT_GDI_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_GDI ? TRUE : FALSE;
- break;
-
- case WGL_SUPPORT_OPENGL_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_OPENGL ? TRUE : FALSE;
- break;
-
- case WGL_DOUBLE_BUFFER_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_DOUBLEBUFFER ? TRUE : FALSE;
- break;
-
- case WGL_STEREO_ARB:
- *pvalue = pfi->pfd.dwFlags & PFD_STEREO ? TRUE : FALSE;
- break;
-
- case WGL_PIXEL_TYPE_ARB:
- switch (pfi->pfd.iPixelType) {
- case PFD_TYPE_RGBA:
- *pvalue = WGL_TYPE_RGBA_ARB;
- break;
- case PFD_TYPE_COLORINDEX:
- *pvalue = WGL_TYPE_COLORINDEX_ARB;
- break;
- default:
- return FALSE;
- }
- break;
-
- case WGL_COLOR_BITS_ARB:
- *pvalue = pfi->pfd.cColorBits;
- break;
-
- case WGL_RED_BITS_ARB:
- *pvalue = pfi->pfd.cRedBits;
- break;
-
- case WGL_RED_SHIFT_ARB:
- *pvalue = pfi->pfd.cRedShift;
- break;
-
- case WGL_GREEN_BITS_ARB:
- *pvalue = pfi->pfd.cGreenBits;
- break;
-
- case WGL_GREEN_SHIFT_ARB:
- *pvalue = pfi->pfd.cGreenShift;
- break;
-
- case WGL_BLUE_BITS_ARB:
- *pvalue = pfi->pfd.cBlueBits;
- break;
-
- case WGL_BLUE_SHIFT_ARB:
- *pvalue = pfi->pfd.cBlueShift;
- break;
-
- case WGL_ALPHA_BITS_ARB:
- *pvalue = pfi->pfd.cAlphaBits;
- break;
-
- case WGL_ALPHA_SHIFT_ARB:
- *pvalue = pfi->pfd.cAlphaShift;
- break;
-
- case WGL_ACCUM_BITS_ARB:
- *pvalue = pfi->pfd.cAccumBits;
- break;
-
- case WGL_ACCUM_RED_BITS_ARB:
- *pvalue = pfi->pfd.cAccumRedBits;
- break;
-
- case WGL_ACCUM_GREEN_BITS_ARB:
- *pvalue = pfi->pfd.cAccumGreenBits;
- break;
-
- case WGL_ACCUM_BLUE_BITS_ARB:
- *pvalue = pfi->pfd.cAccumBlueBits;
- break;
-
- case WGL_ACCUM_ALPHA_BITS_ARB:
- *pvalue = pfi->pfd.cAccumAlphaBits;
- break;
-
- case WGL_DEPTH_BITS_ARB:
- *pvalue = pfi->pfd.cDepthBits;
- break;
-
- case WGL_STENCIL_BITS_ARB:
- *pvalue = pfi->pfd.cStencilBits;
- break;
-
- case WGL_AUX_BUFFERS_ARB:
- *pvalue = pfi->pfd.cAuxBuffers;
- break;
-
- case WGL_SAMPLE_BUFFERS_ARB:
- *pvalue = pfi->numSampleBuffers;
- break;
-
- case WGL_SAMPLES_ARB:
- *pvalue = pfi->numSamples;
- break;
-
- default:
- return FALSE;
- }
-
- return TRUE;
-}
-
-struct attrib_match_info
-{
- int attribute;
- int weight;
- BOOL exact;
-};
-
-static const struct attrib_match_info attrib_match[] = {
-
- /* WGL_ARB_pixel_format */
- { WGL_DRAW_TO_WINDOW_ARB, 0, TRUE },
- { WGL_DRAW_TO_BITMAP_ARB, 0, TRUE },
- { WGL_ACCELERATION_ARB, 0, TRUE },
- { WGL_NEED_PALETTE_ARB, 0, TRUE },
- { WGL_NEED_SYSTEM_PALETTE_ARB, 0, TRUE },
- { WGL_SWAP_LAYER_BUFFERS_ARB, 0, TRUE },
- { WGL_SWAP_METHOD_ARB, 0, TRUE },
- { WGL_NUMBER_OVERLAYS_ARB, 4, FALSE },
- { WGL_NUMBER_UNDERLAYS_ARB, 4, FALSE },
- /*{ WGL_SHARE_DEPTH_ARB, 0, TRUE },*/ /* no overlays -- ignore */
- /*{ WGL_SHARE_STENCIL_ARB, 0, TRUE },*/ /* no overlays -- ignore */
- /*{ WGL_SHARE_ACCUM_ARB, 0, TRUE },*/ /* no overlays -- ignore */
- { WGL_SUPPORT_GDI_ARB, 0, TRUE },
- { WGL_SUPPORT_OPENGL_ARB, 0, TRUE },
- { WGL_DOUBLE_BUFFER_ARB, 0, TRUE },
- { WGL_STEREO_ARB, 0, TRUE },
- { WGL_PIXEL_TYPE_ARB, 0, TRUE },
- { WGL_COLOR_BITS_ARB, 1, FALSE },
- { WGL_RED_BITS_ARB, 1, FALSE },
- { WGL_GREEN_BITS_ARB, 1, FALSE },
- { WGL_BLUE_BITS_ARB, 1, FALSE },
- { WGL_ALPHA_BITS_ARB, 1, FALSE },
- { WGL_ACCUM_BITS_ARB, 1, FALSE },
- { WGL_ACCUM_RED_BITS_ARB, 1, FALSE },
- { WGL_ACCUM_GREEN_BITS_ARB, 1, FALSE },
- { WGL_ACCUM_BLUE_BITS_ARB, 1, FALSE },
- { WGL_ACCUM_ALPHA_BITS_ARB, 1, FALSE },
- { WGL_DEPTH_BITS_ARB, 1, FALSE },
- { WGL_STENCIL_BITS_ARB, 1, FALSE },
- { WGL_AUX_BUFFERS_ARB, 2, FALSE },
-
- /* WGL_ARB_multisample */
- { WGL_SAMPLE_BUFFERS_ARB, 2, FALSE },
- { WGL_SAMPLES_ARB, 2, FALSE }
-};
-
-struct stw_pixelformat_score
-{
- int points;
- uint index;
-};
-
-static BOOL
-score_pixelformats(
- struct stw_pixelformat_score *scores,
- uint count,
- int attribute,
- int expected_value )
-{
- uint i;
- const struct attrib_match_info *ami = NULL;
- uint index;
-
- /* Find out if a given attribute should be considered for score calculation.
- */
- for (i = 0; i < sizeof( attrib_match ) / sizeof( attrib_match[0] ); i++) {
- if (attrib_match[i].attribute == attribute) {
- ami = &attrib_match[i];
- break;
- }
- }
- if (ami == NULL)
- return TRUE;
-
- /* Iterate all pixelformats, query the requested attribute and calculate
- * score points.
- */
- for (index = 0; index < count; index++) {
- int actual_value;
-
- if (!stw_query_attrib( index + 1, 0, attribute, &actual_value ))
- return FALSE;
-
- if (ami->exact) {
- /* For an exact match criteria, if the actual and expected values differ,
- * the score is set to 0 points, effectively removing the pixelformat
- * from a list of matching pixelformats.
- */
- if (actual_value != expected_value)
- scores[index].points = 0;
- }
- else {
- /* For a minimum match criteria, if the actual value is smaller than the expected
- * value, the pixelformat is rejected (score set to 0). However, if the actual
- * value is bigger, the pixelformat is given a penalty to favour pixelformats that
- * more closely match the expected values.
- */
- if (actual_value < expected_value)
- scores[index].points = 0;
- else if (actual_value > expected_value)
- scores[index].points -= (actual_value - expected_value) * ami->weight;
- }
- }
-
- return TRUE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglChoosePixelFormatARB(
- HDC hdc,
- const int *piAttribIList,
- const FLOAT *pfAttribFList,
- UINT nMaxFormats,
- int *piFormats,
- UINT *nNumFormats )
-{
- uint count;
- struct stw_pixelformat_score *scores;
- uint i;
-
- *nNumFormats = 0;
-
- /* Allocate and initialize pixelformat score table -- better matches
- * have higher scores. Start with a high score and take out penalty
- * points for a mismatch when the match does not have to be exact.
- * Set a score to 0 if there is a mismatch for an exact match criteria.
- */
- count = stw_pixelformat_get_extended_count();
- scores = (struct stw_pixelformat_score *) MALLOC( count * sizeof( struct stw_pixelformat_score ) );
- if (scores == NULL)
- return FALSE;
- for (i = 0; i < count; i++) {
- scores[i].points = 0x7fffffff;
- scores[i].index = i;
- }
-
- /* Given the attribute list calculate a score for each pixelformat.
- */
- if (piAttribIList != NULL) {
- while (*piAttribIList != 0) {
- if (!score_pixelformats( scores, count, piAttribIList[0], piAttribIList[1] )) {
- FREE( scores );
- return FALSE;
- }
- piAttribIList += 2;
- }
- }
- if (pfAttribFList != NULL) {
- while (*pfAttribFList != 0) {
- if (!score_pixelformats( scores, count, (int) pfAttribFList[0], (int) pfAttribFList[1] )) {
- FREE( scores );
- return FALSE;
- }
- pfAttribFList += 2;
- }
- }
-
- /* Bubble-sort the resulting scores. Pixelformats with higher scores go first.
- * TODO: Find out if there are any patent issues with it.
- */
- if (count > 1) {
- uint n = count;
- boolean swapped;
-
- do {
- swapped = FALSE;
- for (i = 1; i < n; i++) {
- if (scores[i - 1].points < scores[i].points) {
- struct stw_pixelformat_score score = scores[i - 1];
-
- scores[i - 1] = scores[i];
- scores[i] = score;
- swapped = TRUE;
- }
- }
- n--;
- }
- while (swapped);
- }
-
- /* Return a list of pixelformats that are the best match.
- * Reject pixelformats with non-positive scores.
- */
- for (i = 0; i < count; i++) {
- if (scores[i].points > 0) {
- if (*nNumFormats < nMaxFormats)
- piFormats[*nNumFormats] = scores[i].index + 1;
- (*nNumFormats)++;
- }
- }
-
- FREE( scores );
- return TRUE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglGetPixelFormatAttribfvARB(
- HDC hdc,
- int iPixelFormat,
- int iLayerPlane,
- UINT nAttributes,
- const int *piAttributes,
- FLOAT *pfValues )
-{
- UINT i;
-
- (void) hdc;
-
- for (i = 0; i < nAttributes; i++) {
- int value;
-
- if (!stw_query_attrib( iPixelFormat, iLayerPlane, piAttributes[i], &value ))
- return FALSE;
- pfValues[i] = (FLOAT) value;
- }
-
- return TRUE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglGetPixelFormatAttribivARB(
- HDC hdc,
- int iPixelFormat,
- int iLayerPlane,
- UINT nAttributes,
- const int *piAttributes,
- int *piValues )
-{
- UINT i;
-
- (void) hdc;
-
- for (i = 0; i < nAttributes; i++) {
- if (!stw_query_attrib( iPixelFormat, iLayerPlane, piAttributes[i], &piValues[i] ))
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
deleted file mode 100644
index 4968ecc692..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_context.c
+++ /dev/null
@@ -1,382 +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 "main/mtypes.h"
-#include "main/context.h"
-#include "pipe/p_compiler.h"
-#include "pipe/p_context.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
-
-#ifdef DEBUG
-#include "trace/tr_screen.h"
-#include "trace/tr_context.h"
-#endif
-
-#include "shared/stw_device.h"
-#include "shared/stw_winsys.h"
-#include "shared/stw_framebuffer.h"
-#include "shared/stw_pixelformat.h"
-#include "stw_public.h"
-#include "stw_context.h"
-#include "stw_tls.h"
-
-
-static INLINE struct stw_context *
-stw_context(GLcontext *glctx)
-{
- if(!glctx)
- return NULL;
- assert(glctx->DriverCtx);
- return (struct stw_context *)glctx->DriverCtx;
-}
-
-static INLINE struct stw_context *
-stw_current_context(void)
-{
- /* We must check if multiple threads are being used or GET_CURRENT_CONTEXT
- * might return the current context of the thread first seen. */
- _glapi_check_multithread();
-
- {
- GET_CURRENT_CONTEXT( glctx );
- return stw_context(glctx);
- }
-}
-
-BOOL
-stw_copy_context(
- UINT_PTR hglrcSrc,
- UINT_PTR hglrcDst,
- UINT mask )
-{
- struct stw_context *src;
- struct stw_context *dst;
- BOOL ret = FALSE;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
-
- src = stw_lookup_context_locked( hglrcSrc );
- dst = stw_lookup_context_locked( hglrcDst );
-
- if (src && dst) {
- /* FIXME */
- assert(0);
- (void) src;
- (void) dst;
- (void) mask;
- }
-
- pipe_mutex_unlock( stw_dev->ctx_mutex );
-
- return ret;
-}
-
-BOOL
-stw_share_lists(
- UINT_PTR hglrc1,
- UINT_PTR hglrc2 )
-{
- struct stw_context *ctx1;
- struct stw_context *ctx2;
- BOOL ret = FALSE;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
-
- ctx1 = stw_lookup_context_locked( hglrc1 );
- ctx2 = stw_lookup_context_locked( hglrc2 );
-
- if (ctx1 && ctx2 &&
- ctx1->iPixelFormat == ctx2->iPixelFormat) {
- ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx);
- }
-
- pipe_mutex_unlock( stw_dev->ctx_mutex );
-
- return ret;
-}
-
-static void
-stw_viewport(GLcontext * glctx, GLint x, GLint y,
- GLsizei width, GLsizei height)
-{
- struct stw_context *ctx = (struct stw_context *)glctx->DriverCtx;
- struct stw_framebuffer *fb;
-
- fb = stw_framebuffer_from_hdc( ctx->hdc );
- if(fb) {
- stw_framebuffer_update(fb);
- stw_framebuffer_release(fb);
- }
-}
-
-UINT_PTR
-stw_create_layer_context(
- HDC hdc,
- int iLayerPlane )
-{
- int iPixelFormat;
- const struct stw_pixelformat_info *pfi;
- GLvisual visual;
- struct stw_context *ctx = NULL;
- struct pipe_screen *screen = NULL;
- struct pipe_context *pipe = NULL;
-
- if(!stw_dev)
- return 0;
-
- if (iLayerPlane != 0)
- return 0;
-
- iPixelFormat = GetPixelFormat(hdc);
- if(!iPixelFormat)
- return 0;
-
- pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
- stw_pixelformat_visual(&visual, pfi);
-
- ctx = CALLOC_STRUCT( stw_context );
- if (ctx == NULL)
- goto no_ctx;
-
- ctx->hdc = hdc;
- ctx->iPixelFormat = iPixelFormat;
-
- screen = stw_dev->screen;
-
-#ifdef DEBUG
- /* Unwrap screen */
- if(stw_dev->trace_running)
- screen = trace_screen(screen)->screen;
-#endif
-
- pipe = stw_dev->stw_winsys->create_context( screen );
- if (pipe == NULL)
- goto no_pipe;
-
-#ifdef DEBUG
- /* Wrap context */
- if(stw_dev->trace_running)
- pipe = trace_context_create(stw_dev->screen, pipe);
-#endif
-
- /* pass to stw_flush_frontbuffer as context_private */
- assert(!pipe->priv);
- pipe->priv = hdc;
-
- ctx->st = st_create_context( pipe, &visual, NULL );
- if (ctx->st == NULL)
- goto no_st_ctx;
-
- ctx->st->ctx->DriverCtx = ctx;
- ctx->st->ctx->Driver.Viewport = stw_viewport;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
- ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx);
- pipe_mutex_unlock( stw_dev->ctx_mutex );
- if (!ctx->hglrc)
- goto no_hglrc;
-
- return ctx->hglrc;
-
-no_hglrc:
- st_destroy_context(ctx->st);
- goto no_pipe; /* st_context_destroy already destroys pipe */
-no_st_ctx:
- pipe->destroy( pipe );
-no_pipe:
- FREE(ctx);
-no_ctx:
- return 0;
-}
-
-BOOL
-stw_delete_context(
- UINT_PTR hglrc )
-{
- struct stw_context *ctx ;
- BOOL ret = FALSE;
-
- if (!stw_dev)
- return FALSE;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
- ctx = stw_lookup_context_locked(hglrc);
- handle_table_remove(stw_dev->ctx_table, hglrc);
- pipe_mutex_unlock( stw_dev->ctx_mutex );
-
- if (ctx) {
- struct stw_context *curctx = stw_current_context();
-
- /* Unbind current if deleting current context. */
- if (curctx == ctx)
- st_make_current( NULL, NULL, NULL );
-
- st_destroy_context(ctx->st);
- FREE(ctx);
-
- ret = TRUE;
- }
-
- return ret;
-}
-
-BOOL
-stw_release_context(
- UINT_PTR hglrc )
-{
- struct stw_context *ctx;
-
- if (!stw_dev)
- return FALSE;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
- ctx = stw_lookup_context_locked( hglrc );
- pipe_mutex_unlock( stw_dev->ctx_mutex );
-
- if (!ctx)
- return FALSE;
-
- /* The expectation is that ctx is the same context which is
- * current for this thread. We should check that and return False
- * if not the case.
- */
- if (ctx != stw_current_context())
- return FALSE;
-
- if (stw_make_current( NULL, 0 ) == FALSE)
- return FALSE;
-
- return TRUE;
-}
-
-
-UINT_PTR
-stw_get_current_context( void )
-{
- struct stw_context *ctx;
-
- ctx = stw_current_context();
- if(!ctx)
- return 0;
-
- return ctx->hglrc;
-}
-
-HDC
-stw_get_current_dc( void )
-{
- struct stw_context *ctx;
-
- ctx = stw_current_context();
- if(!ctx)
- return NULL;
-
- return ctx->hdc;
-}
-
-BOOL
-stw_make_current(
- HDC hdc,
- UINT_PTR hglrc )
-{
- struct stw_context *curctx = NULL;
- struct stw_context *ctx = NULL;
- struct stw_framebuffer *fb = NULL;
-
- if (!stw_dev)
- goto fail;
-
- curctx = stw_current_context();
- if (curctx != NULL) {
- if (curctx->hglrc != hglrc)
- st_flush(curctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
-
- /* Return if already current. */
- if (curctx->hglrc == hglrc && curctx->hdc == hdc) {
- ctx = curctx;
- fb = stw_framebuffer_from_hdc( hdc );
- goto success;
- }
- }
-
- if (hdc == NULL || hglrc == 0) {
- return st_make_current( NULL, NULL, NULL );
- }
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
- ctx = stw_lookup_context_locked( hglrc );
- pipe_mutex_unlock( stw_dev->ctx_mutex );
- if(!ctx)
- goto fail;
-
- fb = stw_framebuffer_from_hdc( hdc );
- if(!fb) {
- /* Applications should call SetPixelFormat before creating a context,
- * but not all do, and the opengl32 runtime seems to use a default pixel
- * format in some cases, so we must create a framebuffer for those here
- */
- int iPixelFormat = GetPixelFormat(hdc);
- if(iPixelFormat)
- fb = stw_framebuffer_create( hdc, iPixelFormat );
- if(!fb)
- goto fail;
- }
-
- if(fb->iPixelFormat != ctx->iPixelFormat)
- goto fail;
-
- /* Lazy allocation of the frame buffer */
- if(!stw_framebuffer_allocate(fb))
- goto fail;
-
- /* Bind the new framebuffer */
- ctx->hdc = hdc;
-
- /* pass to stw_flush_frontbuffer as context_private */
- ctx->st->pipe->priv = hdc;
-
- if(!st_make_current( ctx->st, fb->stfb, fb->stfb ))
- goto fail;
-
-success:
- assert(fb);
- if(fb) {
- stw_framebuffer_update(fb);
- stw_framebuffer_release(fb);
- }
-
- return TRUE;
-
-fail:
- if(fb)
- stw_framebuffer_release(fb);
- st_make_current( NULL, NULL, NULL );
- return FALSE;
-}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h
deleted file mode 100644
index 166471de5e..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_context.h
+++ /dev/null
@@ -1,43 +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.
- *
- **************************************************************************/
-
-#ifndef STW_CONTEXT_H
-#define STW_CONTEXT_H
-
-#include <windows.h>
-
-struct st_context;
-
-struct stw_context
-{
- struct st_context *st;
- UINT_PTR hglrc;
- int iPixelFormat;
- HDC hdc;
-};
-
-#endif /* STW_CONTEXT_H */
diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c
deleted file mode 100644
index 0b6954915a..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_device.c
+++ /dev/null
@@ -1,225 +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 "glapi/glthread.h"
-#include "util/u_debug.h"
-#include "pipe/p_screen.h"
-#include "state_tracker/st_public.h"
-
-#ifdef DEBUG
-#include "trace/tr_screen.h"
-#include "trace/tr_texture.h"
-#endif
-
-#include "shared/stw_device.h"
-#include "shared/stw_winsys.h"
-#include "shared/stw_pixelformat.h"
-#include "shared/stw_public.h"
-#include "shared/stw_tls.h"
-#include "shared/stw_framebuffer.h"
-
-#ifdef WIN32_THREADS
-extern _glthread_Mutex OneTimeLock;
-extern void FreeAllTSD(void);
-#endif
-
-
-struct stw_device *stw_dev = NULL;
-
-
-/**
- * XXX: Dispatch pipe_screen::flush_front_buffer to our
- * stw_winsys::flush_front_buffer.
- */
-static void
-stw_flush_frontbuffer(struct pipe_screen *screen,
- struct pipe_surface *surface,
- void *context_private )
-{
- const struct stw_winsys *stw_winsys = stw_dev->stw_winsys;
- HDC hdc = (HDC)context_private;
- struct stw_framebuffer *fb;
-
- fb = stw_framebuffer_from_hdc( hdc );
- /* fb can be NULL if window was destroyed already */
- if (fb) {
-#if DEBUG
- {
- struct pipe_surface *surface2;
-
- if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 ))
- assert(0);
- else
- assert(surface2 == surface);
- }
-#endif
-
-#ifdef DEBUG
- if(stw_dev->trace_running) {
- screen = trace_screen(screen)->screen;
- surface = trace_surface(surface)->surface;
- }
-#endif
- }
-
- stw_winsys->flush_frontbuffer(screen, surface, hdc);
-
- if(fb) {
- stw_framebuffer_update(fb);
- stw_framebuffer_release(fb);
- }
-}
-
-
-boolean
-stw_init(const struct stw_winsys *stw_winsys)
-{
- static struct stw_device stw_dev_storage;
- struct pipe_screen *screen;
-
- debug_printf("%s\n", __FUNCTION__);
-
- assert(!stw_dev);
-
- stw_tls_init();
-
- stw_dev = &stw_dev_storage;
- memset(stw_dev, 0, sizeof(*stw_dev));
-
-#ifdef DEBUG
- stw_dev->memdbg_no = debug_memory_begin();
-#endif
-
- stw_dev->stw_winsys = stw_winsys;
-
-#ifdef WIN32_THREADS
- _glthread_INIT_MUTEX(OneTimeLock);
-#endif
-
- screen = stw_winsys->create_screen();
- if(!screen)
- goto error1;
-
-#ifdef DEBUG
- stw_dev->screen = trace_screen_create(screen);
- stw_dev->trace_running = stw_dev->screen != screen ? TRUE : FALSE;
-#else
- stw_dev->screen = screen;
-#endif
-
- stw_dev->screen->flush_frontbuffer = &stw_flush_frontbuffer;
-
- pipe_mutex_init( stw_dev->ctx_mutex );
- pipe_mutex_init( stw_dev->fb_mutex );
-
- stw_dev->ctx_table = handle_table_create();
- if (!stw_dev->ctx_table) {
- goto error1;
- }
-
- stw_pixelformat_init();
-
- return TRUE;
-
-error1:
- stw_dev = NULL;
- return FALSE;
-}
-
-
-boolean
-stw_init_thread(void)
-{
- return stw_tls_init_thread();
-}
-
-
-void
-stw_cleanup_thread(void)
-{
- stw_tls_cleanup_thread();
-}
-
-
-void
-stw_cleanup(void)
-{
- unsigned i;
-
- debug_printf("%s\n", __FUNCTION__);
-
- if (!stw_dev)
- return;
-
- pipe_mutex_lock( stw_dev->ctx_mutex );
- {
- /* Ensure all contexts are destroyed */
- i = handle_table_get_first_handle(stw_dev->ctx_table);
- while (i) {
- stw_delete_context(i);
- i = handle_table_get_next_handle(stw_dev->ctx_table, i);
- }
- handle_table_destroy(stw_dev->ctx_table);
- }
- pipe_mutex_unlock( stw_dev->ctx_mutex );
-
- stw_framebuffer_cleanup();
-
- pipe_mutex_destroy( stw_dev->fb_mutex );
- pipe_mutex_destroy( stw_dev->ctx_mutex );
-
- stw_dev->screen->destroy(stw_dev->screen);
-
-#ifdef WIN32_THREADS
- _glthread_DESTROY_MUTEX(OneTimeLock);
- FreeAllTSD();
-#endif
-
-#ifdef DEBUG
- debug_memory_end(stw_dev->memdbg_no);
-#endif
-
- stw_tls_cleanup();
-
- stw_dev = NULL;
-}
-
-
-struct stw_context *
-stw_lookup_context_locked( UINT_PTR dhglrc )
-{
- if (dhglrc == 0)
- return NULL;
-
- if (stw_dev == NULL)
- return NULL;
-
- return (struct stw_context *) handle_table_get(stw_dev->ctx_table, dhglrc);
-}
-
diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.h b/src/gallium/state_trackers/wgl/shared/stw_device.h
deleted file mode 100644
index e1bb9518dd..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_device.h
+++ /dev/null
@@ -1,77 +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.
- *
- **************************************************************************/
-
-#ifndef STW_DEVICE_H_
-#define STW_DEVICE_H_
-
-
-#include <windows.h>
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_thread.h"
-#include "util/u_handle_table.h"
-#include "stw_pixelformat.h"
-
-
-#define STW_MAX_PIXELFORMATS 256
-
-
-struct pipe_screen;
-struct stw_framebuffer;
-
-struct stw_device
-{
- const struct stw_winsys *stw_winsys;
-
- struct pipe_screen *screen;
-
-#ifdef DEBUG
- boolean trace_running;
-#endif
-
- struct stw_pixelformat_info pixelformats[STW_MAX_PIXELFORMATS];
- unsigned pixelformat_count;
- unsigned pixelformat_extended_count;
-
- pipe_mutex ctx_mutex;
- struct handle_table *ctx_table;
-
- pipe_mutex fb_mutex;
- struct stw_framebuffer *fb_head;
-
-#ifdef DEBUG
- unsigned long memdbg_no;
-#endif
-};
-
-struct stw_context *
-stw_lookup_context_locked( UINT_PTR hglrc );
-
-extern struct stw_device *stw_dev;
-
-
-#endif /* STW_DEVICE_H_ */
diff --git a/src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c b/src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c
deleted file mode 100644
index 62c859e1f9..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_extensionsstring.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * 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>
-
-#define WGL_WGLEXT_PROTOTYPES
-
-#include <GL/gl.h>
-#include <GL/wglext.h>
-
-
-static const char *stw_extension_string =
- "WGL_ARB_extensions_string "
- "WGL_ARB_multisample "
- "WGL_ARB_pixel_format "
-/* "WGL_EXT_swap_interval " */
- "WGL_EXT_extensions_string";
-
-
-WINGDIAPI const char * APIENTRY
-wglGetExtensionsStringARB(
- HDC hdc )
-{
- (void) hdc;
-
- return stw_extension_string;
-}
-
-
-WINGDIAPI const char * APIENTRY
-wglGetExtensionsStringEXT( void )
-{
- return stw_extension_string;
-}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_extgallium.c b/src/gallium/state_trackers/wgl/shared/stw_extgallium.c
deleted file mode 100644
index fc22737d7e..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_extgallium.c
+++ /dev/null
@@ -1,79 +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 "pipe/p_screen.h"
-#include "stw_public.h"
-#include "stw_device.h"
-#include "stw_winsys.h"
-
-#ifdef DEBUG
-#include "trace/tr_screen.h"
-#include "trace/tr_context.h"
-#endif
-
-
-struct pipe_screen * APIENTRY
-wglGetGalliumScreenMESA(void)
-{
- return stw_dev ? stw_dev->screen : NULL;
-}
-
-
-/* XXX: Unify with stw_create_layer_context */
-struct pipe_context * APIENTRY
-wglCreateGalliumContextMESA(void)
-{
- struct pipe_screen *screen = NULL;
- struct pipe_context *pipe = NULL;
-
- if(!stw_dev)
- return NULL;
-
- screen = stw_dev->screen;
-
-#ifdef DEBUG
- /* Unwrap screen */
- if(stw_dev->trace_running)
- screen = trace_screen(screen)->screen;
-#endif
-
- pipe = stw_dev->stw_winsys->create_context( screen );
- if (pipe == NULL)
- goto no_pipe;
-
-#ifdef DEBUG
- /* Wrap context */
- if(stw_dev->trace_running)
- pipe = trace_context_create(stw_dev->screen, pipe);
-#endif
-
- return pipe;
-
-no_pipe:
- return NULL;
-}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_extgallium.h b/src/gallium/state_trackers/wgl/shared/stw_extgallium.h
deleted file mode 100644
index cc35f2bb7f..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_extgallium.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * 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 VMWARE 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.
- *
- **************************************************************************/
-
-#ifndef STW_EXTGALLIUM_H_
-#define STW_EXTGALLIUM_H_
-
-
-#include <windows.h>
-
-
-struct pipe_screen;
-struct pipe_context;
-
-
-struct pipe_screen * APIENTRY
-wglGetGalliumScreenMESA(void);
-
-
-struct pipe_context * APIENTRY
-wglCreateGalliumContextMESA(void);
-
-
-#endif /* STW_EXTGALLIUM_H_ */
diff --git a/src/gallium/state_trackers/wgl/shared/stw_extswapinterval.c b/src/gallium/state_trackers/wgl/shared/stw_extswapinterval.c
deleted file mode 100644
index 9eac6a1d09..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_extswapinterval.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * 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>
-
-#define WGL_WGLEXT_PROTOTYPES
-
-#include <GL/gl.h>
-#include <GL/wglext.h>
-#include "util/u_debug.h"
-
-/* A dummy implementation of this extension.
- *
- * Required as some applications retrieve and call these functions
- * regardless of the fact that we don't advertise the extension and
- * further more the results of wglGetProcAddress are NULL.
- */
-WINGDIAPI BOOL APIENTRY
-wglSwapIntervalEXT(int interval)
-{
- (void) interval;
- debug_printf("%s: %d\n", __FUNCTION__, interval);
- return TRUE;
-}
-
-WINGDIAPI int APIENTRY
-wglGetSwapIntervalEXT(void)
-{
- return 0;
-}
-
-
diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
deleted file mode 100644
index b8956bb550..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
+++ /dev/null
@@ -1,493 +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 "main/context.h"
-#include "pipe/p_format.h"
-#include "pipe/p_screen.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
-
-#ifdef DEBUG
-#include "trace/tr_screen.h"
-#include "trace/tr_texture.h"
-#endif
-
-#include "stw_framebuffer.h"
-#include "stw_device.h"
-#include "stw_public.h"
-#include "stw_winsys.h"
-#include "stw_tls.h"
-
-
-/**
- * Search the framebuffer with the matching HWND while holding the
- * stw_dev::fb_mutex global lock.
- */
-static INLINE struct stw_framebuffer *
-stw_framebuffer_from_hwnd_locked(
- HWND hwnd )
-{
- struct stw_framebuffer *fb;
-
- for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
- if (fb->hWnd == hwnd) {
- pipe_mutex_lock(fb->mutex);
- break;
- }
-
- return fb;
-}
-
-
-/**
- * Destroy this framebuffer. Both stw_dev::fb_mutex and stw_framebuffer::mutex
- * must be held, by this order. Obviously no further access to fb can be done
- * after this.
- */
-static INLINE void
-stw_framebuffer_destroy_locked(
- struct stw_framebuffer *fb )
-{
- struct stw_framebuffer **link;
-
- link = &stw_dev->fb_head;
- while (*link != fb)
- link = &(*link)->next;
- assert(*link);
- *link = fb->next;
- fb->next = NULL;
-
- st_unreference_framebuffer(fb->stfb);
-
- pipe_mutex_unlock( fb->mutex );
-
- pipe_mutex_destroy( fb->mutex );
-
- FREE( fb );
-}
-
-
-void
-stw_framebuffer_release(
- struct stw_framebuffer *fb)
-{
- assert(fb);
- pipe_mutex_unlock( fb->mutex );
-}
-
-
-static INLINE void
-stw_framebuffer_get_size( struct stw_framebuffer *fb )
-{
- unsigned width, height;
- RECT rect;
-
- assert(fb->hWnd);
-
- GetClientRect( fb->hWnd, &rect );
- width = rect.right - rect.left;
- height = rect.bottom - rect.top;
-
- if(width < 1)
- width = 1;
- if(height < 1)
- height = 1;
-
- if(width != fb->width || height != fb->height) {
- fb->must_resize = TRUE;
- fb->width = width;
- fb->height = height;
- }
-}
-
-
-/**
- * @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx
- * @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx
- */
-LRESULT CALLBACK
-stw_call_window_proc(
- int nCode,
- WPARAM wParam,
- LPARAM lParam )
-{
- struct stw_tls_data *tls_data;
- PCWPSTRUCT pParams = (PCWPSTRUCT)lParam;
- struct stw_framebuffer *fb;
-
- tls_data = stw_tls_get_data();
- if(!tls_data)
- return 0;
-
- if (nCode < 0)
- return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
-
- if (pParams->message == WM_WINDOWPOSCHANGED) {
- /* We handle WM_WINDOWPOSCHANGED instead of WM_SIZE because according to
- * http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx
- * WM_SIZE is generated from WM_WINDOWPOSCHANGED by DefWindowProc so it
- * can be masked out by the application. */
- LPWINDOWPOS lpWindowPos = (LPWINDOWPOS)pParams->lParam;
- if((lpWindowPos->flags & SWP_SHOWWINDOW) ||
- !(lpWindowPos->flags & SWP_NOSIZE)) {
- fb = stw_framebuffer_from_hwnd( pParams->hwnd );
- if(fb) {
- /* Size in WINDOWPOS includes the window frame, so get the size
- * of the client area via GetClientRect. */
- stw_framebuffer_get_size(fb);
- stw_framebuffer_release(fb);
- }
- }
- }
- else if (pParams->message == WM_DESTROY) {
- pipe_mutex_lock( stw_dev->fb_mutex );
- fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
- if(fb)
- stw_framebuffer_destroy_locked(fb);
- pipe_mutex_unlock( stw_dev->fb_mutex );
- }
-
- return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
-}
-
-
-struct stw_framebuffer *
-stw_framebuffer_create(
- HDC hdc,
- int iPixelFormat )
-{
- HWND hWnd;
- struct stw_framebuffer *fb;
- const struct stw_pixelformat_info *pfi;
-
- /* We only support drawing to a window. */
- hWnd = WindowFromDC( hdc );
- if(!hWnd)
- return NULL;
-
- fb = CALLOC_STRUCT( stw_framebuffer );
- if (fb == NULL)
- return NULL;
-
- fb->hDC = hdc;
- fb->hWnd = hWnd;
- fb->iPixelFormat = iPixelFormat;
-
- fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
-
- stw_pixelformat_visual(&fb->visual, pfi);
-
- stw_framebuffer_get_size(fb);
-
- pipe_mutex_init( fb->mutex );
-
- /* This is the only case where we lock the stw_framebuffer::mutex before
- * stw_dev::fb_mutex, since no other thread can know about this framebuffer
- * and we must prevent any other thread from destroying it before we return.
- */
- pipe_mutex_lock( fb->mutex );
-
- pipe_mutex_lock( stw_dev->fb_mutex );
- fb->next = stw_dev->fb_head;
- stw_dev->fb_head = fb;
- pipe_mutex_unlock( stw_dev->fb_mutex );
-
- return fb;
-}
-
-
-BOOL
-stw_framebuffer_allocate(
- struct stw_framebuffer *fb)
-{
- assert(fb);
-
- if(!fb->stfb) {
- const struct stw_pixelformat_info *pfi = fb->pfi;
- enum pipe_format colorFormat, depthFormat, stencilFormat;
-
- colorFormat = pfi->color_format;
-
- assert(pf_layout( pfi->depth_stencil_format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
-
- if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_Z ))
- depthFormat = pfi->depth_stencil_format;
- else
- depthFormat = PIPE_FORMAT_NONE;
-
- if(pf_get_component_bits( pfi->depth_stencil_format, PIPE_FORMAT_COMP_S ))
- stencilFormat = pfi->depth_stencil_format;
- else
- stencilFormat = PIPE_FORMAT_NONE;
-
- assert(fb->must_resize);
- assert(fb->width);
- assert(fb->height);
-
- fb->stfb = st_create_framebuffer(
- &fb->visual,
- colorFormat,
- depthFormat,
- stencilFormat,
- fb->width,
- fb->height,
- (void *) fb );
-
- // to notify the context
- fb->must_resize = TRUE;
- }
-
- return fb->stfb ? TRUE : FALSE;
-}
-
-
-/**
- * Update the framebuffer's size if necessary.
- */
-void
-stw_framebuffer_update(
- struct stw_framebuffer *fb)
-{
- assert(fb->stfb);
- assert(fb->height);
- assert(fb->width);
-
- /* XXX: It would be nice to avoid checking the size again -- in theory
- * stw_call_window_proc would have cought the resize and stored the right
- * size already, but unfortunately threads created before the DllMain is
- * called don't get a DLL_THREAD_ATTACH notification, and there is no way
- * to know of their existing without using the not very portable PSAPI.
- */
- stw_framebuffer_get_size(fb);
-
- if(fb->must_resize) {
- st_resize_framebuffer(fb->stfb, fb->width, fb->height);
- fb->must_resize = FALSE;
- }
-}
-
-
-void
-stw_framebuffer_cleanup( void )
-{
- struct stw_framebuffer *fb;
- struct stw_framebuffer *next;
-
- pipe_mutex_lock( stw_dev->fb_mutex );
-
- fb = stw_dev->fb_head;
- while (fb) {
- next = fb->next;
-
- pipe_mutex_lock(fb->mutex);
- stw_framebuffer_destroy_locked(fb);
-
- fb = next;
- }
- stw_dev->fb_head = NULL;
-
- pipe_mutex_unlock( stw_dev->fb_mutex );
-}
-
-
-/**
- * Given an hdc, return the corresponding stw_framebuffer.
- */
-static INLINE struct stw_framebuffer *
-stw_framebuffer_from_hdc_locked(
- HDC hdc )
-{
- HWND hwnd;
- struct stw_framebuffer *fb;
-
- /*
- * Some applications create and use several HDCs for the same window, so
- * looking up the framebuffer by the HDC is not reliable. Use HWND whenever
- * possible.
- */
- hwnd = WindowFromDC(hdc);
- if(hwnd)
- return stw_framebuffer_from_hwnd_locked(hwnd);
-
- for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
- if (fb->hDC == hdc) {
- pipe_mutex_lock(fb->mutex);
- break;
- }
-
- return fb;
-}
-
-
-/**
- * Given an hdc, return the corresponding stw_framebuffer.
- */
-struct stw_framebuffer *
-stw_framebuffer_from_hdc(
- HDC hdc )
-{
- struct stw_framebuffer *fb;
-
- pipe_mutex_lock( stw_dev->fb_mutex );
- fb = stw_framebuffer_from_hdc_locked(hdc);
- pipe_mutex_unlock( stw_dev->fb_mutex );
-
- return fb;
-}
-
-
-/**
- * Given an hdc, return the corresponding stw_framebuffer.
- */
-struct stw_framebuffer *
-stw_framebuffer_from_hwnd(
- HWND hwnd )
-{
- struct stw_framebuffer *fb;
-
- pipe_mutex_lock( stw_dev->fb_mutex );
- fb = stw_framebuffer_from_hwnd_locked(hwnd);
- pipe_mutex_unlock( stw_dev->fb_mutex );
-
- return fb;
-}
-
-
-BOOL
-stw_pixelformat_set(
- HDC hdc,
- int iPixelFormat )
-{
- uint count;
- uint index;
- struct stw_framebuffer *fb;
-
- index = (uint) iPixelFormat - 1;
- count = stw_pixelformat_get_extended_count();
- if (index >= count)
- return FALSE;
-
- fb = stw_framebuffer_from_hdc_locked(hdc);
- if(fb) {
- /* SetPixelFormat must be called only once */
- stw_framebuffer_release( fb );
- return FALSE;
- }
-
- fb = stw_framebuffer_create(hdc, iPixelFormat);
- if(!fb) {
- return FALSE;
- }
-
- stw_framebuffer_release( fb );
-
- /* Some applications mistakenly use the undocumented wglSetPixelFormat
- * function instead of SetPixelFormat, so we call SetPixelFormat here to
- * avoid opengl32.dll's wglCreateContext to fail */
- if (GetPixelFormat(hdc) == 0) {
- SetPixelFormat(hdc, iPixelFormat, NULL);
- }
-
- return TRUE;
-}
-
-
-int
-stw_pixelformat_get(
- HDC hdc )
-{
- int iPixelFormat = 0;
- struct stw_framebuffer *fb;
-
- fb = stw_framebuffer_from_hdc(hdc);
- if(fb) {
- iPixelFormat = fb->iPixelFormat;
- stw_framebuffer_release(fb);
- }
-
- return iPixelFormat;
-}
-
-
-BOOL
-stw_swap_buffers(
- HDC hdc )
-{
- struct stw_framebuffer *fb;
- struct pipe_screen *screen;
- struct pipe_surface *surface;
-
- fb = stw_framebuffer_from_hdc( hdc );
- if (fb == NULL)
- return FALSE;
-
- if (!(fb->pfi->pfd.dwFlags & PFD_DOUBLEBUFFER)) {
- stw_framebuffer_release(fb);
- return TRUE;
- }
-
- /* If we're swapping the buffer associated with the current context
- * we have to flush any pending rendering commands first.
- */
- st_notify_swapbuffers( fb->stfb );
-
- screen = stw_dev->screen;
-
- if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surface )) {
- /* FIXME: this shouldn't happen, but does on glean */
- stw_framebuffer_release(fb);
- return FALSE;
- }
-
-#ifdef DEBUG
- if(stw_dev->trace_running) {
- screen = trace_screen(screen)->screen;
- surface = trace_surface(surface)->surface;
- }
-#endif
-
- stw_dev->stw_winsys->flush_frontbuffer( screen, surface, hdc );
-
- stw_framebuffer_update(fb);
- stw_framebuffer_release(fb);
-
- return TRUE;
-}
-
-
-BOOL
-stw_swap_layer_buffers(
- HDC hdc,
- UINT fuPlanes )
-{
- if(fuPlanes & WGL_SWAP_MAIN_PLANE)
- return stw_swap_buffers(hdc);
-
- return FALSE;
-}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h
deleted file mode 100644
index 13d29f37e4..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h
+++ /dev/null
@@ -1,148 +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.
- *
- **************************************************************************/
-
-#ifndef STW_FRAMEBUFFER_H
-#define STW_FRAMEBUFFER_H
-
-#include <windows.h>
-
-#include "main/mtypes.h"
-
-#include "pipe/p_thread.h"
-
-struct stw_pixelformat_info;
-
-/**
- * Windows framebuffer, derived from gl_framebuffer.
- */
-struct stw_framebuffer
-{
- /**
- * This mutex has two purposes:
- * - protect the access to the mutable data members below
- * - prevent the the framebuffer from being deleted while being accessed.
- *
- * It is OK to lock this mutex while holding the stw_device::fb_mutex lock,
- * but the opposite must never happen.
- */
- pipe_mutex mutex;
-
- /*
- * Immutable members.
- *
- * Note that even access to immutable members implies acquiring the mutex
- * above, to prevent the framebuffer from being destroyed.
- */
-
- HDC hDC;
- HWND hWnd;
-
- int iPixelFormat;
- const struct stw_pixelformat_info *pfi;
- GLvisual visual;
-
- /*
- * Mutable members.
- */
-
- struct st_framebuffer *stfb;
-
- /* FIXME: Make this work for multiple contexts bound to the same framebuffer */
- boolean must_resize;
- unsigned width;
- unsigned height;
-
- /**
- * This is protected by stw_device::fb_mutex, not the mutex above.
- *
- * Deletions must be done by first acquiring stw_device::fb_mutex, and then
- * acquiring the stw_framebuffer::mutex of the framebuffer to be deleted.
- * This ensures that nobody else is reading/writing to the.
- *
- * It is not necessary to aquire the mutex above to navigate the linked list
- * given that deletions are done with stw_device::fb_mutex held, so no other
- * thread can delete.
- */
- struct stw_framebuffer *next;
-};
-
-
-/**
- * Create a new framebuffer object which will correspond to the given HDC.
- *
- * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
- * must be called when done
- */
-struct stw_framebuffer *
-stw_framebuffer_create(
- HDC hdc,
- int iPixelFormat );
-
-/**
- * Search a framebuffer with a matching HWND.
- *
- * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
- * must be called when done
- */
-struct stw_framebuffer *
-stw_framebuffer_from_hwnd(
- HWND hwnd );
-
-/**
- * Search a framebuffer with a matching HDC.
- *
- * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
- * must be called when done
- */
-struct stw_framebuffer *
-stw_framebuffer_from_hdc(
- HDC hdc );
-
-BOOL
-stw_framebuffer_allocate(
- struct stw_framebuffer *fb );
-
-void
-stw_framebuffer_update(
- struct stw_framebuffer *fb);
-
-/**
- * Release stw_framebuffer::mutex lock. This framebuffer must not be accessed
- * after calling this function, as it may have been deleted by another thread
- * in the meanwhile.
- */
-void
-stw_framebuffer_release(
- struct stw_framebuffer *fb);
-
-/**
- * Cleanup any existing framebuffers when exiting application.
- */
-void
-stw_framebuffer_cleanup(void);
-
-#endif /* STW_FRAMEBUFFER_H */
diff --git a/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c b/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c
deleted file mode 100644
index 879ced925a..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c
+++ /dev/null
@@ -1,86 +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>
-
-#define WGL_WGLEXT_PROTOTYPES
-
-#include <GL/gl.h>
-#include <GL/wglext.h>
-
-#include "glapi/glapi.h"
-#include "stw_public.h"
-#include "stw_extgallium.h"
-
-struct stw_extension_entry
-{
- const char *name;
- PROC proc;
-};
-
-#define STW_EXTENSION_ENTRY(P) { #P, (PROC) P }
-
-static const struct stw_extension_entry stw_extension_entries[] = {
-
- /* WGL_ARB_extensions_string */
- STW_EXTENSION_ENTRY( wglGetExtensionsStringARB ),
-
- /* WGL_ARB_pixel_format */
- STW_EXTENSION_ENTRY( wglChoosePixelFormatARB ),
- STW_EXTENSION_ENTRY( wglGetPixelFormatAttribfvARB ),
- STW_EXTENSION_ENTRY( wglGetPixelFormatAttribivARB ),
-
- /* WGL_EXT_extensions_string */
- STW_EXTENSION_ENTRY( wglGetExtensionsStringEXT ),
-
- /* WGL_EXT_swap_interval */
- STW_EXTENSION_ENTRY( wglGetSwapIntervalEXT ),
- STW_EXTENSION_ENTRY( wglSwapIntervalEXT ),
-
- /* WGL_EXT_gallium ? */
- STW_EXTENSION_ENTRY( wglGetGalliumScreenMESA ),
- STW_EXTENSION_ENTRY( wglCreateGalliumContextMESA ),
-
- { NULL, NULL }
-};
-
-PROC
-stw_get_proc_address(
- LPCSTR lpszProc )
-{
- const struct stw_extension_entry *entry;
-
- if (lpszProc[0] == 'w' && lpszProc[1] == 'g' && lpszProc[2] == 'l')
- for (entry = stw_extension_entries; entry->name; entry++)
- if (strcmp( lpszProc, entry->name ) == 0)
- return entry->proc;
-
- if (lpszProc[0] == 'g' && lpszProc[1] == 'l')
- return (PROC) _glapi_get_proc_address( lpszProc );
-
- return NULL;
-}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
deleted file mode 100644
index c296744838..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
+++ /dev/null
@@ -1,370 +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 "main/mtypes.h"
-#include "main/context.h"
-
-#include "pipe/p_format.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_screen.h"
-
-#include "util/u_debug.h"
-
-#include "stw_device.h"
-#include "stw_pixelformat.h"
-#include "stw_public.h"
-#include "stw_tls.h"
-
-
-struct stw_pf_color_info
-{
- enum pipe_format format;
- struct {
- unsigned char red;
- unsigned char green;
- unsigned char blue;
- unsigned char alpha;
- } bits;
- struct {
- unsigned char red;
- unsigned char green;
- unsigned char blue;
- unsigned char alpha;
- } shift;
-};
-
-struct stw_pf_depth_info
-{
- enum pipe_format format;
- struct {
- unsigned char depth;
- unsigned char stencil;
- } bits;
-};
-
-
-/* NOTE: order matters, since in otherwise equal circumstances the first
- * format listed will get chosen */
-
-static const struct stw_pf_color_info
-stw_pf_color[] = {
- /* no-alpha */
- { PIPE_FORMAT_X8R8G8B8_UNORM, { 8, 8, 8, 0}, {16, 8, 0, 0} },
- { PIPE_FORMAT_B8G8R8X8_UNORM, { 8, 8, 8, 0}, { 8, 16, 24, 0} },
- { PIPE_FORMAT_R5G6B5_UNORM, { 5, 6, 5, 0}, {11, 5, 0, 0} },
- /* alpha */
- { PIPE_FORMAT_A8R8G8B8_UNORM, { 8, 8, 8, 8}, {16, 8, 0, 24} },
- { PIPE_FORMAT_B8G8R8A8_UNORM, { 8, 8, 8, 8}, { 8, 16, 24, 0} },
-#if 0
- { PIPE_FORMAT_A2B10G10R10_UNORM, {10, 10, 10, 2}, { 0, 10, 20, 30} },
-#endif
- { PIPE_FORMAT_A1R5G5B5_UNORM, { 5, 5, 5, 1}, {10, 5, 0, 15} },
- { PIPE_FORMAT_A4R4G4B4_UNORM, { 4, 4, 4, 4}, {16, 4, 0, 12} }
-};
-
-
-static const struct stw_pf_depth_info
-stw_pf_depth_stencil[] = {
- /* pure depth */
- { PIPE_FORMAT_Z32_UNORM, {32, 0} },
- { PIPE_FORMAT_Z24X8_UNORM, {24, 0} },
- { PIPE_FORMAT_X8Z24_UNORM, {24, 0} },
- { PIPE_FORMAT_Z16_UNORM, {16, 0} },
- /* pure stencil */
- { PIPE_FORMAT_S8_UNORM, { 0, 8} },
- /* combined depth-stencil */
- { PIPE_FORMAT_S8Z24_UNORM, {24, 8} },
- { PIPE_FORMAT_Z24S8_UNORM, {24, 8} }
-};
-
-
-static const boolean
-stw_pf_doublebuffer[] = {
- FALSE,
- TRUE,
-};
-
-
-const unsigned
-stw_pf_multisample[] = {
- 0,
- 4
-};
-
-
-static void
-stw_pixelformat_add(
- struct stw_device *stw_dev,
- const struct stw_pf_color_info *color,
- const struct stw_pf_depth_info *depth,
- unsigned accum,
- boolean doublebuffer,
- unsigned samples )
-{
- boolean extended = FALSE;
- struct stw_pixelformat_info *pfi;
-
- assert(stw_dev->pixelformat_extended_count < STW_MAX_PIXELFORMATS);
- if(stw_dev->pixelformat_extended_count >= STW_MAX_PIXELFORMATS)
- return;
-
- assert(pf_layout( color->format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
- assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_R ) == color->bits.red );
- assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_G ) == color->bits.green );
- assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_B ) == color->bits.blue );
- assert(pf_get_component_bits( color->format, PIPE_FORMAT_COMP_A ) == color->bits.alpha );
- assert(pf_layout( depth->format ) == PIPE_FORMAT_LAYOUT_RGBAZS );
- assert(pf_get_component_bits( depth->format, PIPE_FORMAT_COMP_Z ) == depth->bits.depth );
- assert(pf_get_component_bits( depth->format, PIPE_FORMAT_COMP_S ) == depth->bits.stencil );
-
- pfi = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count];
-
- memset(pfi, 0, sizeof *pfi);
-
- pfi->color_format = color->format;
- pfi->depth_stencil_format = depth->format;
-
- pfi->pfd.nSize = sizeof pfi->pfd;
- pfi->pfd.nVersion = 1;
-
- pfi->pfd.dwFlags = PFD_SUPPORT_OPENGL;
-
- /* TODO: also support non-native pixel formats */
- pfi->pfd.dwFlags |= PFD_DRAW_TO_WINDOW ;
-
- if (doublebuffer)
- pfi->pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SWAP_COPY;
-
- pfi->pfd.iPixelType = PFD_TYPE_RGBA;
-
- pfi->pfd.cColorBits = color->bits.red + color->bits.green + color->bits.blue + color->bits.alpha;
- pfi->pfd.cRedBits = color->bits.red;
- pfi->pfd.cRedShift = color->shift.red;
- pfi->pfd.cGreenBits = color->bits.green;
- pfi->pfd.cGreenShift = color->shift.green;
- pfi->pfd.cBlueBits = color->bits.blue;
- pfi->pfd.cBlueShift = color->shift.blue;
- pfi->pfd.cAlphaBits = color->bits.alpha;
- pfi->pfd.cAlphaShift = color->shift.alpha;
- pfi->pfd.cAccumBits = 4*accum;
- pfi->pfd.cAccumRedBits = accum;
- pfi->pfd.cAccumGreenBits = accum;
- pfi->pfd.cAccumBlueBits = accum;
- pfi->pfd.cAccumAlphaBits = accum;
- pfi->pfd.cDepthBits = depth->bits.depth;
- pfi->pfd.cStencilBits = depth->bits.stencil;
- pfi->pfd.cAuxBuffers = 0;
- pfi->pfd.iLayerType = 0;
- pfi->pfd.bReserved = 0;
- pfi->pfd.dwLayerMask = 0;
- pfi->pfd.dwVisibleMask = 0;
- pfi->pfd.dwDamageMask = 0;
-
- if(samples) {
- pfi->numSampleBuffers = 1;
- pfi->numSamples = samples;
- extended = TRUE;
- }
-
- ++stw_dev->pixelformat_extended_count;
-
- if(!extended) {
- ++stw_dev->pixelformat_count;
- assert(stw_dev->pixelformat_count == stw_dev->pixelformat_extended_count);
- }
-}
-
-void
-stw_pixelformat_init( void )
-{
- struct pipe_screen *screen = stw_dev->screen;
- unsigned i, j, k, l;
-
- assert( !stw_dev->pixelformat_count );
- assert( !stw_dev->pixelformat_extended_count );
-
- for(i = 0; i < Elements(stw_pf_multisample); ++i) {
- unsigned samples = stw_pf_multisample[i];
-
- /* FIXME: re-enabled MSAA when we can query it */
- if(samples)
- continue;
-
- for(j = 0; j < Elements(stw_pf_color); ++j) {
- const struct stw_pf_color_info *color = &stw_pf_color[j];
-
- if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))
- continue;
-
- for(k = 0; k < Elements(stw_pf_doublebuffer); ++k) {
- unsigned doublebuffer = stw_pf_doublebuffer[k];
-
- for(l = 0; l < Elements(stw_pf_depth_stencil); ++l) {
- const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[l];
-
- if(!screen->is_format_supported(screen, depth->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
- continue;
-
- stw_pixelformat_add( stw_dev, color, depth, 0, doublebuffer, samples );
- stw_pixelformat_add( stw_dev, color, depth, 16, doublebuffer, samples );
- }
- }
- }
- }
-
- assert( stw_dev->pixelformat_count <= stw_dev->pixelformat_extended_count );
- assert( stw_dev->pixelformat_extended_count <= STW_MAX_PIXELFORMATS );
-}
-
-uint
-stw_pixelformat_get_count( void )
-{
- return stw_dev->pixelformat_count;
-}
-
-uint
-stw_pixelformat_get_extended_count( void )
-{
- return stw_dev->pixelformat_extended_count;
-}
-
-const struct stw_pixelformat_info *
-stw_pixelformat_get_info( uint index )
-{
- assert( index < stw_dev->pixelformat_extended_count );
-
- return &stw_dev->pixelformats[index];
-}
-
-
-void
-stw_pixelformat_visual(GLvisual *visual,
- const struct stw_pixelformat_info *pfi )
-{
- memset(visual, 0, sizeof *visual);
- _mesa_initialize_visual(
- visual,
- (pfi->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE,
- (pfi->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,
- (pfi->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE,
- pfi->pfd.cRedBits,
- pfi->pfd.cGreenBits,
- pfi->pfd.cBlueBits,
- pfi->pfd.cAlphaBits,
- (pfi->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pfi->pfd.cColorBits : 0,
- pfi->pfd.cDepthBits,
- pfi->pfd.cStencilBits,
- pfi->pfd.cAccumRedBits,
- pfi->pfd.cAccumGreenBits,
- pfi->pfd.cAccumBlueBits,
- pfi->pfd.cAccumAlphaBits,
- pfi->numSamples );
-}
-
-
-int
-stw_pixelformat_describe(
- HDC hdc,
- int iPixelFormat,
- UINT nBytes,
- LPPIXELFORMATDESCRIPTOR ppfd )
-{
- uint count;
- uint index;
- const struct stw_pixelformat_info *pfi;
-
- (void) hdc;
-
- count = stw_pixelformat_get_extended_count();
- index = (uint) iPixelFormat - 1;
-
- if (ppfd == NULL)
- return count;
- if (index >= count || nBytes != sizeof( PIXELFORMATDESCRIPTOR ))
- return 0;
-
- pfi = stw_pixelformat_get_info( index );
-
- memcpy(ppfd, &pfi->pfd, sizeof( PIXELFORMATDESCRIPTOR ));
-
- 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 = stw_pixelformat_get_count();
- bestindex = count;
- bestdelta = ~0U;
-
- for (index = 0; index < count; index++) {
- uint delta = 0;
- const struct stw_pixelformat_info *pfi = stw_pixelformat_get_info( index );
-
- if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
- !!(ppfd->dwFlags & PFD_DOUBLEBUFFER) !=
- !!(pfi->pfd.dwFlags & PFD_DOUBLEBUFFER))
- continue;
-
- /* FIXME: Take in account individual channel bits */
- if (ppfd->cColorBits != pfi->pfd.cColorBits)
- delta += 8;
-
- if (ppfd->cDepthBits != pfi->pfd.cDepthBits)
- delta += 4;
-
- if (ppfd->cStencilBits != pfi->pfd.cStencilBits)
- delta += 2;
-
- if (ppfd->cAlphaBits != pfi->pfd.cAlphaBits)
- delta++;
-
- if (delta < bestdelta) {
- bestindex = index;
- bestdelta = delta;
- if (bestdelta == 0)
- break;
- }
- }
-
- if (bestindex == count)
- return 0;
-
- return bestindex + 1;
-}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
deleted file mode 100644
index bec429231b..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
+++ /dev/null
@@ -1,65 +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.
- *
- **************************************************************************/
-
-#ifndef STW_PIXELFORMAT_H
-#define STW_PIXELFORMAT_H
-
-#include <windows.h>
-
-#include "main/mtypes.h"
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_format.h"
-
-struct stw_pixelformat_info
-{
- enum pipe_format color_format;
- enum pipe_format depth_stencil_format;
-
- PIXELFORMATDESCRIPTOR pfd;
-
- unsigned numSampleBuffers;
- unsigned numSamples;
-};
-
-void
-stw_pixelformat_init( void );
-
-uint
-stw_pixelformat_get_count( void );
-
-uint
-stw_pixelformat_get_extended_count( void );
-
-const struct stw_pixelformat_info *
-stw_pixelformat_get_info( uint index );
-
-void
-stw_pixelformat_visual(GLvisual *visual,
- const struct stw_pixelformat_info *pfi );
-
-#endif /* STW_PIXELFORMAT_H */
diff --git a/src/gallium/state_trackers/wgl/shared/stw_public.h b/src/gallium/state_trackers/wgl/shared/stw_public.h
deleted file mode 100644
index 7fe9cfb356..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_public.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * 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.
- *
- **************************************************************************/
-
-#ifndef STW_PUBLIC_H
-#define STW_PUBLIC_H
-
-#include <windows.h>
-
-BOOL stw_copy_context( UINT_PTR hglrcSrc,
- UINT_PTR hglrcDst,
- UINT mask );
-
-UINT_PTR stw_create_layer_context( HDC hdc,
- int iLayerPlane );
-
-BOOL stw_share_lists( UINT_PTR hglrc1, UINT_PTR hglrc2 );
-
-BOOL stw_delete_context( UINT_PTR hglrc );
-
-BOOL
-stw_release_context( UINT_PTR dhglrc );
-
-UINT_PTR stw_get_current_context( void );
-
-HDC stw_get_current_dc( void );
-
-BOOL stw_make_current( HDC hdc, UINT_PTR hglrc );
-
-BOOL stw_swap_buffers( HDC hdc );
-
-BOOL
-stw_swap_layer_buffers( HDC hdc, UINT fuPlanes );
-
-PROC stw_get_proc_address( LPCSTR lpszProc );
-
-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_pixelformat_choose( HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd );
-
-#endif
diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.c b/src/gallium/state_trackers/wgl/shared/stw_tls.c
deleted file mode 100644
index 4bd6a9289c..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_tls.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * 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 "util/u_memory.h"
-#include "stw_tls.h"
-
-static DWORD tlsIndex = TLS_OUT_OF_INDEXES;
-
-boolean
-stw_tls_init(void)
-{
- tlsIndex = TlsAlloc();
- if (tlsIndex == TLS_OUT_OF_INDEXES) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-static INLINE struct stw_tls_data *
-stw_tls_data_create()
-{
- struct stw_tls_data *data;
-
- data = CALLOC_STRUCT(stw_tls_data);
- if (!data)
- goto no_data;
-
- data->hCallWndProcHook = SetWindowsHookEx(WH_CALLWNDPROC,
- stw_call_window_proc,
- NULL,
- GetCurrentThreadId());
- if(data->hCallWndProcHook == NULL)
- goto no_hook;
-
- TlsSetValue(tlsIndex, data);
-
- return data;
-
-no_hook:
- FREE(data);
-no_data:
- return NULL;
-}
-
-boolean
-stw_tls_init_thread(void)
-{
- struct stw_tls_data *data;
-
- if (tlsIndex == TLS_OUT_OF_INDEXES) {
- return FALSE;
- }
-
- data = stw_tls_data_create();
- if(!data)
- return FALSE;
-
- return TRUE;
-}
-
-void
-stw_tls_cleanup_thread(void)
-{
- struct stw_tls_data *data;
-
- if (tlsIndex == TLS_OUT_OF_INDEXES) {
- return;
- }
-
- data = (struct stw_tls_data *) TlsGetValue(tlsIndex);
- if(data) {
- TlsSetValue(tlsIndex, NULL);
-
- if(data->hCallWndProcHook) {
- UnhookWindowsHookEx(data->hCallWndProcHook);
- data->hCallWndProcHook = NULL;
- }
-
- FREE(data);
- }
-}
-
-void
-stw_tls_cleanup(void)
-{
- if (tlsIndex != TLS_OUT_OF_INDEXES) {
- TlsFree(tlsIndex);
- tlsIndex = TLS_OUT_OF_INDEXES;
- }
-}
-
-struct stw_tls_data *
-stw_tls_get_data(void)
-{
- struct stw_tls_data *data;
-
- if (tlsIndex == TLS_OUT_OF_INDEXES) {
- return NULL;
- }
-
- data = (struct stw_tls_data *) TlsGetValue(tlsIndex);
- if(!data) {
- /* DllMain is called with DLL_THREAD_ATTACH only by threads created after
- * the DLL is loaded by the process */
- data = stw_tls_data_create();
- if(!data)
- return NULL;
- }
-
- return data;
-}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.h b/src/gallium/state_trackers/wgl/shared/stw_tls.h
deleted file mode 100644
index fbf8b1cbee..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_tls.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * 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.
- *
- **************************************************************************/
-
-#ifndef STW_TLS_H
-#define STW_TLS_H
-
-#include <windows.h>
-
-struct stw_tls_data
-{
- HHOOK hCallWndProcHook;
-};
-
-boolean
-stw_tls_init(void);
-
-boolean
-stw_tls_init_thread(void);
-
-void
-stw_tls_cleanup_thread(void);
-
-void
-stw_tls_cleanup(void);
-
-struct stw_tls_data *
-stw_tls_get_data(void);
-
-LRESULT CALLBACK
-stw_call_window_proc(
- int nCode,
- WPARAM wParam,
- LPARAM lParam );
-
-#endif /* STW_TLS_H */
diff --git a/src/gallium/state_trackers/wgl/shared/stw_winsys.h b/src/gallium/state_trackers/wgl/shared/stw_winsys.h
deleted file mode 100644
index c0bf82c9ed..0000000000
--- a/src/gallium/state_trackers/wgl/shared/stw_winsys.h
+++ /dev/null
@@ -1,65 +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.
- *
- **************************************************************************/
-
-#ifndef STW_WINSYS_H
-#define STW_WINSYS_H
-
-#include <windows.h> /* for HDC */
-
-#include "pipe/p_compiler.h"
-
-struct pipe_screen;
-struct pipe_context;
-struct pipe_surface;
-
-struct stw_winsys
-{
- struct pipe_screen *
- (*create_screen)( void );
-
- struct pipe_context *
- (*create_context)( struct pipe_screen *screen );
-
- void
- (*flush_frontbuffer)( struct pipe_screen *screen,
- struct pipe_surface *surf,
- HDC hDC );
-};
-
-boolean
-stw_init(const struct stw_winsys *stw_winsys);
-
-boolean
-stw_init_thread(void);
-
-void
-stw_cleanup_thread(void);
-
-void
-stw_cleanup(void);
-
-#endif /* STW_WINSYS_H */