Added DIB_CreateDIBSection with extra parameter ovr_pitch, added

ovr_pitch to pCreateDIBSection in DC_FUNCS. If ovr_pitch is nonzero,
it is a pitch override (specifies bytes per line), and tells to treat
the offset parameter as an already-mapped virtual memory address (if
the section parameter is zero). Fixed a DIB status init bug in
creating DIB sections from file mappings (if created from mapping, the
DIB is *not* really InSync).
This commit is contained in:
Ove Kaaven 2000-04-29 16:47:07 +00:00 committed by Alexandre Julliard
parent bda3e66201
commit 8b9f33851a
5 changed files with 49 additions and 24 deletions

View File

@ -3167,10 +3167,10 @@ void X11DRV_DIB_UpdateDIBSection(DC *dc, BOOL toDIB)
HBITMAP16 X11DRV_DIB_CreateDIBSection16(
DC *dc, BITMAPINFO *bmi, UINT16 usage,
SEGPTR *bits, HANDLE section,
DWORD offset)
DWORD offset, DWORD ovr_pitch)
{
HBITMAP res = X11DRV_DIB_CreateDIBSection(dc, bmi, usage, NULL,
section, offset);
section, offset, ovr_pitch);
if ( res )
{
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(res, BITMAP_MAGIC);
@ -3272,7 +3272,7 @@ extern BOOL X11DRV_XShmCreateImage(XImage** image, int width, int height, int bp
HBITMAP X11DRV_DIB_CreateDIBSection(
DC *dc, BITMAPINFO *bmi, UINT usage,
LPVOID *bits, HANDLE section,
DWORD offset)
DWORD offset, DWORD ovr_pitch)
{
HBITMAP res = 0;
BITMAPOBJ *bmp = NULL;
@ -3293,7 +3293,8 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
bm.bmType = 0;
bm.bmWidth = bi->biWidth;
bm.bmHeight = effHeight;
bm.bmWidthBytes = DIB_GetDIBWidthBytes(bm.bmWidth, bi->biBitCount);
bm.bmWidthBytes = ovr_pitch ? ovr_pitch
: DIB_GetDIBWidthBytes(bm.bmWidth, bi->biBitCount);
bm.bmPlanes = bi->biPlanes;
bm.bmBitsPixel = bi->biBitCount;
bm.bmBits = NULL;
@ -3304,9 +3305,13 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
if (section)
bm.bmBits = MapViewOfFile(section, FILE_MAP_ALL_ACCESS,
0L, offset, totalSize);
else
else if (ovr_pitch && offset)
bm.bmBits = offset;
else {
offset = 0;
bm.bmBits = VirtualAlloc(NULL, totalSize,
MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
}
/* Create Color Map */
if (bm.bmBits && bm.bmBitsPixel <= 8)
@ -3396,7 +3401,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
{
if (section)
UnmapViewOfFile(bm.bmBits), bm.bmBits = NULL;
else
else if (!offset)
VirtualFree(bm.bmBits, 0L, MEM_RELEASE), bm.bmBits = NULL;
}
@ -3411,8 +3416,16 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
{
if (VIRTUAL_SetFaultHandler(bm.bmBits, X11DRV_DIB_FaultHandler, (LPVOID)res))
{
X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READONLY );
if (dib) dib->status = X11DRV_DIB_InSync;
if (section || offset)
{
X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READWRITE );
if (dib) dib->status = X11DRV_DIB_AppMod;
}
else
{
X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READONLY );
if (dib) dib->status = X11DRV_DIB_InSync;
}
}
}

View File

@ -52,6 +52,8 @@ extern int DIB_GetDIBImageBytes( int width, int height, int depth );
extern int DIB_BitmapInfoSize( const BITMAPINFO * info, WORD coloruse );
extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
int *height, WORD *bpp, WORD *compr );
extern HBITMAP DIB_CreateDIBSection( HDC hdc, BITMAPINFO *bmi, UINT usage, LPVOID *bits,
HANDLE section, DWORD offset, DWORD ovr_pitch );
extern void DIB_UpdateDIBSection( DC *dc, BOOL toDIB );
extern void DIB_DeleteDIBSection( BITMAPOBJ *bmp );
extern void DIB_SelectDIBSection( DC *dc, BITMAPOBJ *bmp );

View File

@ -181,9 +181,9 @@ typedef struct tagDC_FUNCS
BOOL (*pCreateBitmap)(HBITMAP);
BOOL (*pCreateDC)(DC*,LPCSTR,LPCSTR,LPCSTR,const DEVMODEA*);
HBITMAP (*pCreateDIBSection)(DC *,BITMAPINFO *,UINT,LPVOID *,HANDLE,
DWORD);
DWORD,DWORD);
HBITMAP16 (*pCreateDIBSection16)(DC *,BITMAPINFO *,UINT16,SEGPTR *,HANDLE,
DWORD);
DWORD,DWORD);
BOOL (*pDeleteDC)(DC*);
BOOL (*pDeleteObject)(HGDIOBJ);
DWORD (*pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA);

View File

@ -254,9 +254,9 @@ extern int *X11DRV_DIB_BuildColorMap( struct tagDC *dc, WORD coloruse,
extern void X11DRV_DIB_UpdateDIBSection(struct tagDC *dc, BOOL toDIB);
extern HBITMAP X11DRV_DIB_CreateDIBSection(struct tagDC *dc, BITMAPINFO *bmi, UINT usage,
LPVOID *bits, HANDLE section, DWORD offset);
LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
extern HBITMAP16 X11DRV_DIB_CreateDIBSection16(struct tagDC *dc, BITMAPINFO *bmi, UINT16 usage,
SEGPTR *bits, HANDLE section, DWORD offset);
SEGPTR *bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
extern struct tagBITMAP_DRIVER X11DRV_BITMAP_Driver;

View File

@ -870,7 +870,26 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage,
if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if(!dc) return (HBITMAP16) NULL;
hbitmap = dc->funcs->pCreateDIBSection16(dc, bmi, usage, bits, section, offset);
hbitmap = dc->funcs->pCreateDIBSection16(dc, bmi, usage, bits, section, offset, 0);
GDI_HEAP_UNLOCK(hdc);
return hbitmap;
}
/***********************************************************************
* DIB_CreateDIBSection
*/
HBITMAP DIB_CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
LPVOID *bits, HANDLE section,
DWORD offset, DWORD ovr_pitch)
{
HBITMAP hbitmap;
DC *dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC);
if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if(!dc) return (HBITMAP) NULL;
hbitmap = dc->funcs->pCreateDIBSection(dc, bmi, usage, bits, section, offset, ovr_pitch);
GDI_HEAP_UNLOCK(hdc);
@ -884,16 +903,7 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
LPVOID *bits, HANDLE section,
DWORD offset)
{
HBITMAP hbitmap;
DC *dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC);
if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if(!dc) return (HBITMAP) NULL;
hbitmap = dc->funcs->pCreateDIBSection(dc, bmi, usage, bits, section, offset);
GDI_HEAP_UNLOCK(hdc);
return hbitmap;
return DIB_CreateDIBSection(hdc, bmi, usage, bits, section, offset, 0);
}
/***********************************************************************
@ -909,7 +919,7 @@ void DIB_DeleteDIBSection( BITMAPOBJ *bmp )
{
if (dib->dshSection)
UnmapViewOfFile(dib->dsBm.bmBits);
else
else if (!dib->dsOffset)
VirtualFree(dib->dsBm.bmBits, 0L, MEM_RELEASE );
}