Merge branch 'mesa_7_7_branch'
[mesa.git] / src / mesa / drivers / dri / sis / sis_lock.c
1 /**************************************************************************
2
3 Copyright 2003 Eric Anholt
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 "Software"),
8 to deal in the Software without restriction, including without limitation
9 on the rights to use, copy, modify, merge, publish, distribute, sub
10 license, and/or sell copies of the Software, and to permit persons to whom
11 the Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice (including the next
14 paragraph) shall be included in all copies or substantial portions of the
15 Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 **************************************************************************/
25
26 /*
27 * Authors:
28 * Eric Anholt <anholt@FreeBSD.org>
29 */
30
31 #include "main/context.h"
32 #include "sis_context.h"
33 #include "sis_lock.h"
34 #include "sis_dd.h"
35 #include "sis_state.h"
36 #include "drirenderbuffer.h"
37
38 /* Update the hardware state. This is called if another context has
39 * grabbed the hardware lock, which includes the X server. This
40 * function also updates the driver's window state after the X server
41 * moves, resizes or restacks a window -- the change will be reflected
42 * in the drawable position and clip rects. Since the X server grabs
43 * the hardware lock when it changes the window state, this routine will
44 * automatically be called after such a change.
45 */
46 void
47 sisGetLock( sisContextPtr smesa, GLuint flags )
48 {
49 __DRIdrawable *dPriv = smesa->driDrawable;
50 __DRIscreen *sPriv = smesa->driScreen;
51 SISSAREAPrivPtr sarea = smesa->sarea;
52
53 drmGetLock( smesa->driFd, smesa->hHWContext, flags );
54
55 /* The window might have moved, so we might need to get new clip
56 * rects.
57 *
58 * NOTE: This releases and regrabs the hw lock to allow the X server
59 * to respond to the DRI protocol request for new drawable info.
60 * Since the hardware state depends on having the latest drawable
61 * clip rects, all state checking must be done _after_ this call.
62 */
63 DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
64
65 if ( smesa->lastStamp != dPriv->lastStamp ) {
66 sisUpdateBufferSize( smesa );
67 sisUpdateClipping( smesa->glCtx );
68 if (smesa->is6326)
69 sis6326DDDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DrawBuffer[0] );
70 else
71 sisDDDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DrawBuffer[0] );
72 driUpdateFramebufferSize(smesa->glCtx, dPriv);
73 smesa->lastStamp = dPriv->lastStamp;
74 }
75
76 if ( sarea->CtxOwner != smesa->hHWContext ) {
77 sarea->CtxOwner = smesa->hHWContext;
78 smesa->GlobalFlag = GFLAG_ALL;
79 }
80 }