])
sources = [
+ 'stw.c',
'icd/stw_icd.c',
'shared/stw_context.c',
'shared/stw_device.c',
#include "pipe/p_debug.h"
-#include "shared/stw_device.h"
-#include "shared/stw_context.h"
-#include "shared/stw_pixelformat.h"
+#include "shared/stw_public.h"
#include "icd/stw_icd.h"
#include "wgl/stw_wgl.h"
+#include "stw.h"
+
+
+#define DRV_CONTEXT_MAX 32
+
+struct stw_icd
+{
+ struct {
+ HGLRC hglrc;
+ } ctx_array[DRV_CONTEXT_MAX];
+
+ DHGLRC ctx_current;
+};
+
+
+static struct stw_icd *stw_icd = NULL;
+
+
+boolean
+stw_icd_init( void )
+{
+ static struct stw_icd stw_icd_storage;
+
+ assert(!stw_icd);
+
+ stw_icd = &stw_icd_storage;
+ memset(stw_icd, 0, sizeof(*stw_icd));
+
+ return TRUE;
+}
+
+void
+stw_icd_cleanup(void)
+{
+ DHGLRC dhglrc;
+
+ if(!stw_icd)
+ return;
+
+ /* Ensure all contexts are destroyed */
+ for (dhglrc = 1; dhglrc <= DRV_CONTEXT_MAX; dhglrc++)
+ if (stw_icd->ctx_array[dhglrc - 1].hglrc)
+ DrvDeleteContext( dhglrc );
+
+ stw_icd = NULL;
+}
static HGLRC
dhglrc >= DRV_CONTEXT_MAX)
return NULL;
- return stw_dev->ctx_array[dhglrc - 1].hglrc;
+ return stw_icd->ctx_array[dhglrc - 1].hglrc;
}
BOOL APIENTRY
DWORD i;
for (i = 0; i < DRV_CONTEXT_MAX; i++) {
- if (stw_dev->ctx_array[i].hglrc == NULL)
+ if (stw_icd->ctx_array[i].hglrc == NULL)
goto found_slot;
}
return 0;
found_slot:
- stw_dev->ctx_array[i].hglrc = stw_create_context( hdc, iLayerPlane );
- if (stw_dev->ctx_array[i].hglrc == NULL)
+ stw_icd->ctx_array[i].hglrc = stw_create_context( hdc, iLayerPlane );
+ if (stw_icd->ctx_array[i].hglrc == NULL)
return 0;
return (DHGLRC) i + 1;
if (hglrc != NULL) {
success = stw_delete_context( hglrc );
if (success)
- stw_dev->ctx_array[dhglrc - 1].hglrc = NULL;
+ stw_icd->ctx_array[dhglrc - 1].hglrc = NULL;
}
debug_printf( "%s( %u ) = %s\n", __FUNCTION__, dhglrc, success ? "TRUE" : "FALSE" );
{
BOOL success = FALSE;
- if (dhglrc == stw_dev->ctx_current) {
+ if (dhglrc == stw_icd->ctx_current) {
HGLRC hglrc = lookup_hglrc( dhglrc );
if (hglrc != NULL) {
success = wglMakeCurrent( NULL, NULL );
if (success)
- stw_dev->ctx_current = 0;
+ stw_icd->ctx_current = 0;
}
}
#include "shared/stw_device.h"
#include "shared/stw_winsys.h"
#include "shared/stw_pixelformat.h"
+#include "shared/stw_public.h"
+#include "stw.h"
struct stw_device *stw_dev = NULL;
boolean
-st_init(const struct stw_winsys *stw_winsys)
+stw_shared_init(const struct stw_winsys *stw_winsys)
{
static struct stw_device stw_dev_storage;
void
-st_cleanup(void)
+stw_shared_cleanup(void)
{
- DHGLRC dhglrc;
-
- if(!stw_dev)
- return;
-
- /* Ensure all contexts are destroyed */
- for (dhglrc = 1; dhglrc <= DRV_CONTEXT_MAX; dhglrc++)
- if (stw_dev->ctx_array[dhglrc - 1].hglrc)
- DrvDeleteContext( dhglrc );
-
stw_dev = NULL;
}
#define ST_DEVICE_H_
-#include "icd/stw_icd.h"
-
struct pipe_screen;
-
-struct drv_context
-{
- HGLRC hglrc;
-};
-
-#define DRV_CONTEXT_MAX 32
-
-
struct stw_device
{
const struct stw_winsys *stw_winsys;
-
struct pipe_screen *screen;
-
- struct drv_context ctx_array[DRV_CONTEXT_MAX];
-
- DHGLRC ctx_current;
};
#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"
#include "stw_framebuffer.h"
+#include "stw_device.h"
+#include "stw_public.h"
+#include "stw_winsys.h"
+
void
framebuffer_resize(
return fb;
return NULL;
}
+
+
+BOOL
+stw_swap_buffers(
+ HDC hdc )
+{
+ struct stw_framebuffer *fb;
+ struct pipe_surface *surf;
+
+ fb = framebuffer_from_hdc( hdc );
+ if (fb == NULL)
+ return FALSE;
+
+ /* 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 );
+
+ st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surf );
+
+ stw_dev->stw_winsys->flush_frontbuffer(stw_dev->screen->winsys,
+ surf,
+ hdc );
+
+ return TRUE;
+}
#define PIXELFORMAT_H
#include <windows.h>
+#include "pipe/p_compiler.h"
#define PF_FLAG_DOUBLEBUFFER 0x00000001
#define PF_FLAG_MULTISAMPLED 0x00000002
--- /dev/null
+/**************************************************************************
+ *
+ * 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 "stw.h"
+#include "shared/stw_winsys.h"
+
+boolean
+st_init(const struct stw_winsys *stw_winsys)
+{
+ if (!stw_shared_init( stw_winsys ))
+ goto fail;
+
+ if (!stw_icd_init())
+ goto fail;
+
+ if (!stw_wgl_init())
+ goto fail;
+
+ return TRUE;
+
+fail:
+ st_cleanup();
+ return FALSE;
+}
+
+
+void
+st_cleanup(void)
+{
+ stw_icd_cleanup();
+ stw_shared_cleanup();
+ stw_wgl_cleanup();
+}
--- /dev/null
+/**************************************************************************
+ *
+ * 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_H
+#define STW_H
+
+#include "pipe/p_compiler.h"
+
+struct stw_winsys;
+
+/* Public interface:
+ */
+boolean stw_init( const struct stw_winsys *stw_winsys );
+void stw_cleanup( void );
+
+
+
+/* Internal functions
+ */
+boolean stw_shared_init( const struct stw_winsys *stw_winsys );
+boolean stw_icd_init( void );
+boolean stw_wgl_init( void );
+
+void stw_shared_cleanup( void );
+void stw_icd_cleanup( void );
+void stw_wgl_cleanup( void );
+
+
+#endif /* STW_H */
#include <windows.h>
#include "pipe/p_debug.h"
-#include "shared/stw_context.h"
+#include "shared/stw_public.h"
#include "stw_wgl.h"
+#include "stw.h"
+
+boolean stw_wgl_init( void )
+{
+ debug_printf("%s\n", __FUNCTION__);
+ return TRUE;
+}
+
+void stw_wgl_cleanup( void )
+{
+}
WINGDIAPI BOOL APIENTRY
#include "pipe/p_compiler.h"
#include "util/u_memory.h"
-#include "shared/stw_pixelformat.h"
+#include "shared/stw_public.h"
#include "stw_wgl_arbmultisample.h"
#include "stw_wgl_arbpixelformat.h"
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
-#include "shared/stw_pixelformat.h"
+#include "shared/stw_public.h"
#include "stw_wgl.h"
WINGDIAPI int APIENTRY
#include <windows.h>
-#include "pipe/p_winsys.h"
-#include "pipe/p_screen.h"
-#include "pipe/p_context.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
-#include "shared/stw_winsys.h"
-#include "shared/stw_device.h"
-#include "shared/stw_framebuffer.h"
+#include "shared/stw_public.h"
#include "stw_wgl.h"
WINGDIAPI BOOL APIENTRY
wglSwapBuffers(
HDC hdc )
{
- struct stw_framebuffer *fb;
- struct pipe_surface *surf;
-
- fb = framebuffer_from_hdc( hdc );
- if (fb == NULL)
- return FALSE;
-
- /* 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 );
-
- st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surf );
-
- stw_dev->stw_winsys->flush_frontbuffer(stw_dev->screen->winsys,
- surf,
- hdc );
-
- return TRUE;
+ return stw_swap_buffers( hdc );
}
WINGDIAPI BOOL APIENTRY