Merge branch '7.8'
[mesa.git] / src / gallium / targets / libgl-gdi / gdi_softpipe_winsys.c
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 *
26 *
27 **************************************************************************/
28
29 /**
30 * @file
31 * LLVMpipe support.
32 *
33 * @author Jose Fonseca <jfonseca@vmware.com>
34 */
35
36
37 #include <windows.h>
38
39 #include "stw_winsys.h"
40 #include "gdi/gdi_sw_winsys.h"
41 #include "softpipe/sp_texture.h"
42 #include "softpipe/sp_screen.h"
43 #include "softpipe/sp_public.h"
44
45
46 static struct pipe_screen *
47 gdi_softpipe_screen_create(void)
48 {
49 static struct sw_winsys *winsys;
50 struct pipe_screen *screen;
51
52 winsys = gdi_create_sw_winsys();
53 if(!winsys)
54 goto no_winsys;
55
56 screen = softpipe_create_screen(winsys);
57 if(!screen)
58 goto no_screen;
59
60 return screen;
61
62 no_screen:
63 winsys->destroy(winsys);
64 no_winsys:
65 return NULL;
66 }
67
68
69
70
71 static void
72 gdi_softpipe_present(struct pipe_screen *screen,
73 struct pipe_surface *surface,
74 HDC hDC)
75 {
76 /* This will fail if any interposing layer (trace, debug, etc) has
77 * been introduced between the state-trackers and softpipe.
78 *
79 * Ideally this would get replaced with a call to
80 * pipe_screen::flush_frontbuffer().
81 *
82 * Failing that, it may be necessary for intervening layers to wrap
83 * other structs such as this stw_winsys as well...
84 */
85 gdi_sw_display(softpipe_screen(screen)->winsys,
86 softpipe_texture(surface->texture)->dt,
87 hDC);
88 }
89
90
91 static const struct stw_winsys stw_winsys = {
92 &gdi_softpipe_screen_create,
93 &gdi_softpipe_present,
94 NULL, /* get_adapter_luid */
95 NULL, /* shared_surface_open */
96 NULL, /* shared_surface_close */
97 NULL /* compose */
98 };
99
100
101 BOOL WINAPI
102 DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
103 {
104 switch (fdwReason) {
105 case DLL_PROCESS_ATTACH:
106 stw_init(&stw_winsys);
107 stw_init_thread();
108 break;
109
110 case DLL_THREAD_ATTACH:
111 stw_init_thread();
112 break;
113
114 case DLL_THREAD_DETACH:
115 stw_cleanup_thread();
116 break;
117
118 case DLL_PROCESS_DETACH:
119 stw_cleanup_thread();
120 stw_cleanup();
121 break;
122 }
123 return TRUE;
124 }