1 /************************************************************************** 2 * 3 * Copyright 2008-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 above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28 #ifndef STW_WINSYS_H 29 #define STW_WINSYS_H 30 31 #include <windows.h> /* for HDC */ 32 33 #include "util/compiler.h" 34 #include "frontend/api.h" 35 36 struct pipe_screen; 37 struct pipe_context; 38 struct pipe_resource; 39 40 struct stw_shared_surface; 41 42 typedef enum 43 { 44 stw_pfd_gdi_support = 1 << 0, 45 stw_pfd_double_buffer = 1 << 1, 46 } stw_pfd_flag; 47 48 struct stw_winsys_framebuffer 49 { 50 void 51 (*destroy)(struct stw_winsys_framebuffer *fb, 52 struct pipe_context *context); 53 54 bool 55 (*present)(struct stw_winsys_framebuffer *fb, 56 int interval); 57 58 void 59 (*resize)(struct stw_winsys_framebuffer *fb, 60 struct pipe_context *context, 61 struct pipe_resource *templ); 62 63 struct pipe_resource * 64 (*get_resource)(struct stw_winsys_framebuffer *fb, 65 enum st_attachment_type statt); 66 67 void 68 (*flush_frontbuffer)(struct stw_winsys_framebuffer *fb, 69 struct pipe_context *context); 70 }; 71 72 struct stw_winsys 73 { 74 struct pipe_screen * 75 (*create_screen)( HDC hDC ); 76 77 /* XXX is it actually possible to have non-zero level/layer ??? */ 78 /** 79 * Present the color buffer to the window associated with the device context. 80 */ 81 void 82 (*present)( struct pipe_screen *screen, 83 struct pipe_context *context, 84 struct pipe_resource *res, 85 HDC hDC ); 86 87 /** 88 * Locally unique identifier (LUID) of the graphics adapter. 89 * 90 * @sa GLCBPRESENTBUFFERSDATA::AdapterLuid; 91 */ 92 bool 93 (*get_adapter_luid)( struct pipe_screen *screen, 94 HDC hDC, 95 LUID *pAdapterLuid ); 96 97 /** 98 * Open a shared surface (optional). 99 * 100 * @sa GLCBPRESENTBUFFERSDATA::hSharedSurface; 101 */ 102 struct stw_shared_surface * 103 (*shared_surface_open)(struct pipe_screen *screen, 104 HANDLE hSharedSurface); 105 106 /** 107 * Close a shared surface (optional). 108 */ 109 void 110 (*shared_surface_close)(struct pipe_screen *screen, 111 struct stw_shared_surface *surface); 112 113 /** 114 * Compose into a shared surface (optional). 115 * 116 * Blit the color buffer into a shared surface. 117 * 118 * @sa GLPRESENTBUFFERSDATA::PresentHistoryToken. 119 */ 120 void 121 (*compose)( struct pipe_screen *screen, 122 struct pipe_resource *res, 123 struct stw_shared_surface *dest, 124 LPCRECT pRect, 125 ULONGLONG PresentHistoryToken ); 126 127 /** 128 * Query whether the driver can support GDI and/or double-buffering in its 129 * pixel formats (optional). 130 */ 131 unsigned 132 (*get_pfd_flags)( struct pipe_screen *screen ); 133 134 /** 135 * Create a winsys-specific object for a given DC's framebuffer 136 */ 137 struct stw_winsys_framebuffer * 138 (*create_framebuffer)( struct pipe_screen *screen, 139 HWND hWnd, 140 int iPixelFormat ); 141 142 /** 143 * Get the name of the screen that was created 144 */ 145 const char * 146 (*get_name)(void); 147 }; 148 149 bool 150 stw_init(const struct stw_winsys *stw_winsys); 151 152 bool 153 stw_init_thread(void); 154 155 void 156 stw_cleanup_thread(void); 157 158 void 159 stw_cleanup(void); 160 161 #endif /* STW_WINSYS_H */ 162