Authors: Ove Kaaven <ovek@transgaming.com>, Andrew Lewycky <andrew@transgaming.com>, Gavriel State <gav@transgaming.com>
DIB section improvements; UpdateDIBSection has been replaced with
LockDIBSection and UnlockDIBSection, for improved thread safety.
DIB_Status_* is now driver-independent, and there's a new
DIB_Status_AuxMod. Better handling of DIB surfaces with nonstandard
pitch. Slight optimization of DIBsection->display BitBlt.

diff --git a/include/x11drv.h b/include/x11drv.h
index fd0c5ee..bb8421d 100644
--- a/include/x11drv.h
+++ b/include/x11drv.h
@@ -214,7 +214,7 @@
     DIBSECTION  dibSection;
 
     /* Mapping status */
-    enum { X11DRV_DIB_NoHandler, X11DRV_DIB_InSync, X11DRV_DIB_AppMod, X11DRV_DIB_GdiMod } status;
+    int         status, p_status;
 
     /* Color map info */
     int         nColorMap;
@@ -231,6 +231,13 @@
     XShmSegmentInfo shminfo;
 #endif
 
+    /* Aux buffer access function */
+    void (*copy_aux)(void*ctx, int req);
+    void *aux_ctx;
+
+    /* GDI access lock */
+    CRITICAL_SECTION lock;
+
 } X11DRV_DIBSECTION;
 
 /* This structure holds the arguments for DIB_SetImageBits() */
@@ -259,14 +266,18 @@
     DWORD             gMask;
     DWORD             bMask;
     BOOL        useShm;
+    int               dibpitch;
 
 } X11DRV_DIB_IMAGEBITS_DESCR;
 
 extern int *X11DRV_DIB_BuildColorMap( struct tagDC *dc, WORD coloruse,
 				      WORD depth, const BITMAPINFO *info,
 				      int *nColors );
-extern void X11DRV_DIB_UpdateDIBSection(struct tagDC *dc, BOOL toDIB);
-extern void X11DRV_DIB_UpdateDIBSection2(HBITMAP hbmp, BOOL toDIB);
+extern INT X11DRV_CoerceDIBSection(struct tagDC *dc,INT,BOOL);
+extern INT X11DRV_LockDIBSection(struct tagDC *dc,INT,BOOL);
+extern void X11DRV_UnlockDIBSection(struct tagDC *dc,BOOL);
+extern INT X11DRV_LockDIBSection2(HBITMAP bmp,INT,BOOL);
+extern void X11DRV_UnlockDIBSection2(HBITMAP bmp,BOOL);
 
 extern HBITMAP X11DRV_DIB_CreateDIBSection(struct tagDC *dc, BITMAPINFO *bmi, UINT usage,
 					   LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
@@ -284,6 +295,9 @@
 extern void X11DRV_DIB_DeleteDIBSection(struct tagBITMAPOBJ *bmp);
 extern UINT X11DRV_DIB_SetDIBColorTable(struct tagBITMAPOBJ *,struct tagDC*,UINT,UINT,const RGBQUAD *);
 extern UINT X11DRV_DIB_GetDIBColorTable(struct tagBITMAPOBJ *,struct tagDC*,UINT,UINT,RGBQUAD *);
+extern INT X11DRV_DIB_Coerce(struct tagBITMAPOBJ *,INT,BOOL);
+extern INT X11DRV_DIB_Lock(struct tagBITMAPOBJ *,INT,BOOL);
+extern void X11DRV_DIB_Unlock(struct tagBITMAPOBJ *,BOOL);
 
 /**************************************************************************
  * X11 GDI driver