Commit 8b9f3385 authored by Ove Kaaven's avatar Ove Kaaven Committed by Alexandre Julliard

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).
parent bda3e662
...@@ -3167,10 +3167,10 @@ void X11DRV_DIB_UpdateDIBSection(DC *dc, BOOL toDIB) ...@@ -3167,10 +3167,10 @@ void X11DRV_DIB_UpdateDIBSection(DC *dc, BOOL toDIB)
HBITMAP16 X11DRV_DIB_CreateDIBSection16( HBITMAP16 X11DRV_DIB_CreateDIBSection16(
DC *dc, BITMAPINFO *bmi, UINT16 usage, DC *dc, BITMAPINFO *bmi, UINT16 usage,
SEGPTR *bits, HANDLE section, SEGPTR *bits, HANDLE section,
DWORD offset) DWORD offset, DWORD ovr_pitch)
{ {
HBITMAP res = X11DRV_DIB_CreateDIBSection(dc, bmi, usage, NULL, HBITMAP res = X11DRV_DIB_CreateDIBSection(dc, bmi, usage, NULL,
section, offset); section, offset, ovr_pitch);
if ( res ) if ( res )
{ {
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(res, BITMAP_MAGIC); BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr(res, BITMAP_MAGIC);
...@@ -3272,7 +3272,7 @@ extern BOOL X11DRV_XShmCreateImage(XImage** image, int width, int height, int bp ...@@ -3272,7 +3272,7 @@ extern BOOL X11DRV_XShmCreateImage(XImage** image, int width, int height, int bp
HBITMAP X11DRV_DIB_CreateDIBSection( HBITMAP X11DRV_DIB_CreateDIBSection(
DC *dc, BITMAPINFO *bmi, UINT usage, DC *dc, BITMAPINFO *bmi, UINT usage,
LPVOID *bits, HANDLE section, LPVOID *bits, HANDLE section,
DWORD offset) DWORD offset, DWORD ovr_pitch)
{ {
HBITMAP res = 0; HBITMAP res = 0;
BITMAPOBJ *bmp = NULL; BITMAPOBJ *bmp = NULL;
...@@ -3293,7 +3293,8 @@ HBITMAP X11DRV_DIB_CreateDIBSection( ...@@ -3293,7 +3293,8 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
bm.bmType = 0; bm.bmType = 0;
bm.bmWidth = bi->biWidth; bm.bmWidth = bi->biWidth;
bm.bmHeight = effHeight; 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.bmPlanes = bi->biPlanes;
bm.bmBitsPixel = bi->biBitCount; bm.bmBitsPixel = bi->biBitCount;
bm.bmBits = NULL; bm.bmBits = NULL;
...@@ -3304,9 +3305,13 @@ HBITMAP X11DRV_DIB_CreateDIBSection( ...@@ -3304,9 +3305,13 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
if (section) if (section)
bm.bmBits = MapViewOfFile(section, FILE_MAP_ALL_ACCESS, bm.bmBits = MapViewOfFile(section, FILE_MAP_ALL_ACCESS,
0L, offset, totalSize); 0L, offset, totalSize);
else else if (ovr_pitch && offset)
bm.bmBits = offset;
else {
offset = 0;
bm.bmBits = VirtualAlloc(NULL, totalSize, bm.bmBits = VirtualAlloc(NULL, totalSize,
MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
}
/* Create Color Map */ /* Create Color Map */
if (bm.bmBits && bm.bmBitsPixel <= 8) if (bm.bmBits && bm.bmBitsPixel <= 8)
...@@ -3396,7 +3401,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection( ...@@ -3396,7 +3401,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
{ {
if (section) if (section)
UnmapViewOfFile(bm.bmBits), bm.bmBits = NULL; UnmapViewOfFile(bm.bmBits), bm.bmBits = NULL;
else else if (!offset)
VirtualFree(bm.bmBits, 0L, MEM_RELEASE), bm.bmBits = NULL; VirtualFree(bm.bmBits, 0L, MEM_RELEASE), bm.bmBits = NULL;
} }
...@@ -3411,10 +3416,18 @@ HBITMAP X11DRV_DIB_CreateDIBSection( ...@@ -3411,10 +3416,18 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
{ {
if (VIRTUAL_SetFaultHandler(bm.bmBits, X11DRV_DIB_FaultHandler, (LPVOID)res)) if (VIRTUAL_SetFaultHandler(bm.bmBits, X11DRV_DIB_FaultHandler, (LPVOID)res))
{ {
if (section || offset)
{
X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READWRITE );
if (dib) dib->status = X11DRV_DIB_AppMod;
}
else
{
X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READONLY ); X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READONLY );
if (dib) dib->status = X11DRV_DIB_InSync; if (dib) dib->status = X11DRV_DIB_InSync;
} }
} }
}
/* Return BITMAP handle and storage location */ /* Return BITMAP handle and storage location */
if (res) GDI_HEAP_UNLOCK(res); if (res) GDI_HEAP_UNLOCK(res);
......
...@@ -52,6 +52,8 @@ extern int DIB_GetDIBImageBytes( int width, int height, int depth ); ...@@ -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_BitmapInfoSize( const BITMAPINFO * info, WORD coloruse );
extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width, extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
int *height, WORD *bpp, WORD *compr ); 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_UpdateDIBSection( DC *dc, BOOL toDIB );
extern void DIB_DeleteDIBSection( BITMAPOBJ *bmp ); extern void DIB_DeleteDIBSection( BITMAPOBJ *bmp );
extern void DIB_SelectDIBSection( DC *dc, BITMAPOBJ *bmp ); extern void DIB_SelectDIBSection( DC *dc, BITMAPOBJ *bmp );
......
...@@ -181,9 +181,9 @@ typedef struct tagDC_FUNCS ...@@ -181,9 +181,9 @@ typedef struct tagDC_FUNCS
BOOL (*pCreateBitmap)(HBITMAP); BOOL (*pCreateBitmap)(HBITMAP);
BOOL (*pCreateDC)(DC*,LPCSTR,LPCSTR,LPCSTR,const DEVMODEA*); BOOL (*pCreateDC)(DC*,LPCSTR,LPCSTR,LPCSTR,const DEVMODEA*);
HBITMAP (*pCreateDIBSection)(DC *,BITMAPINFO *,UINT,LPVOID *,HANDLE, HBITMAP (*pCreateDIBSection)(DC *,BITMAPINFO *,UINT,LPVOID *,HANDLE,
DWORD); DWORD,DWORD);
HBITMAP16 (*pCreateDIBSection16)(DC *,BITMAPINFO *,UINT16,SEGPTR *,HANDLE, HBITMAP16 (*pCreateDIBSection16)(DC *,BITMAPINFO *,UINT16,SEGPTR *,HANDLE,
DWORD); DWORD,DWORD);
BOOL (*pDeleteDC)(DC*); BOOL (*pDeleteDC)(DC*);
BOOL (*pDeleteObject)(HGDIOBJ); BOOL (*pDeleteObject)(HGDIOBJ);
DWORD (*pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA); DWORD (*pDeviceCapabilities)(LPSTR,LPCSTR,LPCSTR,WORD,LPSTR,LPDEVMODEA);
......
...@@ -254,9 +254,9 @@ extern int *X11DRV_DIB_BuildColorMap( struct tagDC *dc, WORD coloruse, ...@@ -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 void X11DRV_DIB_UpdateDIBSection(struct tagDC *dc, BOOL toDIB);
extern HBITMAP X11DRV_DIB_CreateDIBSection(struct tagDC *dc, BITMAPINFO *bmi, UINT usage, 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, 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; extern struct tagBITMAP_DRIVER X11DRV_BITMAP_Driver;
......
...@@ -870,7 +870,7 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage, ...@@ -870,7 +870,7 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage,
if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if(!dc) return (HBITMAP16) NULL; 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); GDI_HEAP_UNLOCK(hdc);
...@@ -878,18 +878,18 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage, ...@@ -878,18 +878,18 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, BITMAPINFO *bmi, UINT16 usage,
} }
/*********************************************************************** /***********************************************************************
* CreateDIBSection (GDI32.36) * DIB_CreateDIBSection
*/ */
HBITMAP WINAPI CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage, HBITMAP DIB_CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
LPVOID *bits, HANDLE section, LPVOID *bits, HANDLE section,
DWORD offset) DWORD offset, DWORD ovr_pitch)
{ {
HBITMAP hbitmap; HBITMAP hbitmap;
DC *dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC); DC *dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC);
if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); if(!dc) dc = (DC *) GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if(!dc) return (HBITMAP) NULL; if(!dc) return (HBITMAP) NULL;
hbitmap = dc->funcs->pCreateDIBSection(dc, bmi, usage, bits, section, offset); hbitmap = dc->funcs->pCreateDIBSection(dc, bmi, usage, bits, section, offset, ovr_pitch);
GDI_HEAP_UNLOCK(hdc); GDI_HEAP_UNLOCK(hdc);
...@@ -897,6 +897,16 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage, ...@@ -897,6 +897,16 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
} }
/*********************************************************************** /***********************************************************************
* CreateDIBSection (GDI32.36)
*/
HBITMAP WINAPI CreateDIBSection(HDC hdc, BITMAPINFO *bmi, UINT usage,
LPVOID *bits, HANDLE section,
DWORD offset)
{
return DIB_CreateDIBSection(hdc, bmi, usage, bits, section, offset, 0);
}
/***********************************************************************
* DIB_DeleteDIBSection * DIB_DeleteDIBSection
*/ */
void DIB_DeleteDIBSection( BITMAPOBJ *bmp ) void DIB_DeleteDIBSection( BITMAPOBJ *bmp )
...@@ -909,7 +919,7 @@ void DIB_DeleteDIBSection( BITMAPOBJ *bmp ) ...@@ -909,7 +919,7 @@ void DIB_DeleteDIBSection( BITMAPOBJ *bmp )
{ {
if (dib->dshSection) if (dib->dshSection)
UnmapViewOfFile(dib->dsBm.bmBits); UnmapViewOfFile(dib->dsBm.bmBits);
else else if (!dib->dsOffset)
VirtualFree(dib->dsBm.bmBits, 0L, MEM_RELEASE ); VirtualFree(dib->dsBm.bmBits, 0L, MEM_RELEASE );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment