add gamma driver - no kernel driver yet
[mesa.git] / src / mesa / drivers / dri / gamma / gamma_lock.c
1 /* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c,v 1.4 2002/11/05 17:46:07 tsi Exp $ */
2
3 #include "gamma_context.h"
4 #include "gamma_lock.h"
5
6 #ifdef DEBUG_LOCKING
7 char *prevLockFile = NULL;
8 int prevLockLine = 0;
9 #endif
10
11
12 /* Update the hardware state. This is called if another context has
13 * grabbed the hardware lock, which includes the X server. This
14 * function also updates the driver's window state after the X server
15 * moves, resizes or restacks a window -- the change will be reflected
16 * in the drawable position and clip rects. Since the X server grabs
17 * the hardware lock when it changes the window state, this routine will
18 * automatically be called after such a change.
19 */
20 void gammaGetLock( gammaContextPtr gmesa, GLuint flags )
21 {
22 __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
23 __DRIscreenPrivate *sPriv = gmesa->driScreen;
24
25 drmGetLock( gmesa->driFd, gmesa->hHWContext, flags );
26
27 /* The window might have moved, so we might need to get new clip
28 * rects.
29 *
30 * NOTE: This releases and regrabs the hw lock to allow the X server
31 * to respond to the DRI protocol request for new drawable info.
32 * Since the hardware state depends on having the latest drawable
33 * clip rects, all state checking must be done _after_ this call.
34 */
35 DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
36
37 if ( gmesa->lastStamp != dPriv->lastStamp ) {
38 gmesa->lastStamp = dPriv->lastStamp;
39 gmesa->new_state |= GAMMA_NEW_WINDOW | GAMMA_NEW_CLIP;
40 }
41
42 gmesa->numClipRects = dPriv->numClipRects;
43 gmesa->pClipRects = dPriv->pClipRects;
44
45 #if 0
46 gmesa->dirty = ~0;
47
48 if ( sarea->ctxOwner != gmesa->hHWContext ) {
49 sarea->ctxOwner = gmesa->hHWContext;
50 gmesa->dirty = GAMMA_UPLOAD_ALL;
51 }
52
53 for ( i = 0 ; i < gmesa->lastTexHeap ; i++ ) {
54 if ( sarea->texAge[i] != gmesa->lastTexAge[i] ) {
55 gammaAgeTextures( gmesa, i );
56 }
57 }
58 #endif
59 }