nvfx: expose GLSL
[mesa/mesa-lb.git] / src / gallium / state_trackers / wgl / stw_framebuffer.h
blobe61e9bf9c26d113bf13a388263e12745e2eb2ad4
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
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.
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 TUNGSTEN GRAPHICS 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.
26 **************************************************************************/
28 #ifndef STW_FRAMEBUFFER_H
29 #define STW_FRAMEBUFFER_H
31 #include <windows.h>
33 #include "main/mtypes.h"
35 #include "os/os_thread.h"
37 struct pipe_surface;
38 struct stw_pixelformat_info;
40 /**
41 * Windows framebuffer, derived from gl_framebuffer.
43 struct stw_framebuffer
45 /**
46 * This mutex has two purposes:
47 * - protect the access to the mutable data members below
48 * - prevent the framebuffer from being deleted while being accessed.
50 * It is OK to lock this mutex while holding the stw_device::fb_mutex lock,
51 * but the opposite must never happen.
53 pipe_mutex mutex;
56 * Immutable members.
58 * Note that even access to immutable members implies acquiring the mutex
59 * above, to prevent the framebuffer from being destroyed.
62 HDC hDC;
63 HWND hWnd;
65 int iPixelFormat;
66 const struct stw_pixelformat_info *pfi;
67 GLvisual visual;
70 * Mutable members.
73 struct st_framebuffer *stfb;
75 /* FIXME: Make this work for multiple contexts bound to the same framebuffer */
76 boolean must_resize;
78 unsigned width;
79 unsigned height;
81 /**
82 * Client area rectangle, relative to the window upper-left corner.
84 * @sa GLCBPRESENTBUFFERSDATA::rect.
86 RECT client_rect;
88 HANDLE hSharedSurface;
89 struct stw_shared_surface *shared_surface;
91 /**
92 * This is protected by stw_device::fb_mutex, not the mutex above.
94 * Deletions must be done by first acquiring stw_device::fb_mutex, and then
95 * acquiring the stw_framebuffer::mutex of the framebuffer to be deleted.
96 * This ensures that nobody else is reading/writing to the.
98 * It is not necessary to aquire the mutex above to navigate the linked list
99 * given that deletions are done with stw_device::fb_mutex held, so no other
100 * thread can delete.
102 struct stw_framebuffer *next;
107 * Create a new framebuffer object which will correspond to the given HDC.
109 * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
110 * must be called when done
112 struct stw_framebuffer *
113 stw_framebuffer_create(
114 HDC hdc,
115 int iPixelFormat );
118 * Search a framebuffer with a matching HWND.
120 * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
121 * must be called when done
123 struct stw_framebuffer *
124 stw_framebuffer_from_hwnd(
125 HWND hwnd );
128 * Search a framebuffer with a matching HDC.
130 * This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
131 * must be called when done
133 struct stw_framebuffer *
134 stw_framebuffer_from_hdc(
135 HDC hdc );
137 BOOL
138 stw_framebuffer_allocate(
139 struct stw_framebuffer *fb );
141 BOOL
142 stw_framebuffer_present_locked(HDC hdc,
143 struct stw_framebuffer *fb,
144 struct pipe_surface *surface);
146 void
147 stw_framebuffer_update(
148 struct stw_framebuffer *fb);
151 * Release stw_framebuffer::mutex lock. This framebuffer must not be accessed
152 * after calling this function, as it may have been deleted by another thread
153 * in the meanwhile.
155 void
156 stw_framebuffer_release(
157 struct stw_framebuffer *fb);
160 * Cleanup any existing framebuffers when exiting application.
162 void
163 stw_framebuffer_cleanup(void);
165 #endif /* STW_FRAMEBUFFER_H */