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