Author: tkreuzer
Date: Thu Jan 8 20:06:39 2009
New Revision: 38658
URL:
http://svn.reactos.org/svn/reactos?rev=38658&view=rev
Log:
- Remove the dib pointer from SURFACE
- Handle mapped sections in SURFACE_Cleanup
- Handle user provided bitfields, when creating a dib
- Some code cleanup
Modified:
trunk/reactos/subsystems/win32/win32k/eng/surface.c
trunk/reactos/subsystems/win32/win32k/eng/xlate.c
trunk/reactos/subsystems/win32/win32k/include/bitmaps.h
trunk/reactos/subsystems/win32/win32k/include/surface.h
trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c
trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
trunk/reactos/subsystems/win32/win32k/objects/brush.c
trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
Modified: trunk/reactos/subsystems/win32/win32k/eng/surface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/en…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/surface.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/surface.c [iso-8859-1] Thu Jan 8 20:06:39
2009
@@ -93,35 +93,56 @@
BOOL INTERNAL_CALL
SURFACE_Cleanup(PVOID ObjectBody)
{
- PSURFACE psurf = (PSURFACE)ObjectBody;
-
- if (psurf->SurfObj.pvBits != NULL &&
- (psurf->flFlags & BITMAPOBJ_IS_APIBITMAP))
- {
- if (psurf->dib == NULL)
- {
- ExFreePool(psurf->SurfObj.pvBits);
- }
- else
- {
- EngFreeUserMem(psurf->SurfObj.pvBits);
- }
- if (psurf->hDIBPalette != NULL)
- {
- NtGdiDeleteObject(psurf->hDIBPalette);
- }
- }
-
- if (NULL != psurf->BitsLock)
- {
- ExFreePoolWithTag(psurf->BitsLock, TAG_SURFACE);
- psurf->BitsLock = NULL;
- }
-
- if (psurf->dib)
- ExFreePoolWithTag(psurf->dib, TAG_DIB);
-
- return TRUE;
+ PSURFACE psurf = (PSURFACE)ObjectBody;
+ PVOID pvBits = psurf->SurfObj.pvBits;
+
+ /* If this is an API bitmap, free the bits */
+ if (pvBits != NULL &&
+ (psurf->flFlags & BITMAPOBJ_IS_APIBITMAP))
+ {
+ /* Check if we have a DIB section */
+ if (psurf->hSecure)
+ {
+ // FIXME: IMPLEMENT ME!
+ // MmUnsecureVirtualMemory(psurf->hSecure);
+ if (psurf->hDIBSection)
+ {
+ /* DIB was created from a section */
+ NTSTATUS Status;
+
+ pvBits = (PVOID)((ULONG_PTR)pvBits - psurf->dwOffset);
+ Status = ZwUnmapViewOfSection(NtCurrentProcess(), pvBits);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Could not unmap section view!\n");
+ // Should we BugCheck here?
+ }
+ }
+ else
+ {
+ /* DIB was allocated */
+ EngFreeUserMem(pvBits);
+ }
+ }
+ else
+ {
+ // FIXME: use TAG
+ ExFreePool(psurf->SurfObj.pvBits);
+ }
+
+ if (psurf->hDIBPalette != NULL)
+ {
+ NtGdiDeleteObject(psurf->hDIBPalette);
+ }
+ }
+
+ if (NULL != psurf->BitsLock)
+ {
+ ExFreePoolWithTag(psurf->BitsLock, TAG_SURFACE);
+ psurf->BitsLock = NULL;
+ }
+
+ return TRUE;
}
BOOL INTERNAL_CALL
@@ -408,7 +429,9 @@
psurf->flFlags = 0;
psurf->dimension.cx = 0;
psurf->dimension.cy = 0;
- psurf->dib = NULL;
+
+ psurf->hSecure = NULL;
+ psurf->hDIBSection = NULL;
SURFACE_UnlockSurface(psurf);
Modified: trunk/reactos/subsystems/win32/win32k/eng/xlate.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/en…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/xlate.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/xlate.c [iso-8859-1] Thu Jan 8 20:06:39
2009
@@ -486,7 +486,7 @@
if (psurfSrc->SurfObj.iBitmapFormat == BMF_1BPP)
{
/* DIB sections need special handling */
- if (psurfSrc->dib)
+ if (psurfSrc->hSecure)
{
PPALGDI ppal = PALETTE_LockPalette(psurfSrc->hDIBPalette);
if (ppal)
Modified: trunk/reactos/subsystems/win32/win32k/include/bitmaps.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/bitmaps.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/bitmaps.h [iso-8859-1] Thu Jan 8
20:06:39 2009
@@ -8,5 +8,8 @@
INT FASTCALL DIB_BitmapInfoSize (const BITMAPINFO * info, WORD coloruse);
INT APIENTRY BITMAP_GetObject(SURFACE * bmp, INT count, LPVOID buffer);
HBITMAP FASTCALL IntCreateBitmap(IN SIZEL Size, IN LONG Width, IN ULONG Format, IN ULONG
Flags, IN PVOID Bits);
+HBITMAP FASTCALL BITMAP_CopyBitmap (HBITMAP hBitmap);
+UINT FASTCALL BITMAP_GetRealBitsPixel(UINT nBitsPixel);
+INT FASTCALL BITMAP_GetWidthBytes (INT bmWidth, INT bpp);
#endif
Modified: trunk/reactos/subsystems/win32/win32k/include/surface.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/surface.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/surface.h [iso-8859-1] Thu Jan 8
20:06:39 2009
@@ -20,9 +20,15 @@
the actual bits in the bitmap */
/* For device-independent bitmaps: */
- DIBSECTION *dib;
+ HANDLE hDIBSection;
+ HANDLE hSecure;
+ DWORD dwOffset;
+
HPALETTE hDIBPalette;
HDC hDC; // Doc in "Undocumented Windows", page 546, seems to be supported
with XP.
+ DWORD dsBitfields[3]; // hack, should probably use palette instead
+ DWORD biClrUsed;
+ DWORD biClrImportant;
} SURFACE, *PSURFACE;
#define BITMAPOBJ_IS_APIBITMAP 0x1
@@ -50,9 +56,6 @@
BOOL INTERNAL_CALL SURFACE_Cleanup(PVOID ObjectBody);
BOOL INTERNAL_CALL SURFACE_InitBitsLock(SURFACE *pBMObj);
void INTERNAL_CALL SURFACE_CleanupBitsLock(SURFACE *pBMObj);
-INT FASTCALL SURFACE_GetWidthBytes (INT bmWidth, INT bpp);
-UINT FASTCALL SURFACE_GetRealBitsPixel(UINT nBitsPixel);
-HBITMAP FASTCALL SURFACE_CopyBitmap (HBITMAP hBitmap);
#define GDIDEV(SurfObj) ((GDIDEVICE *)((SurfObj)->hdev))
#define GDIDEVFUNCS(SurfObj) ((GDIDEVICE *)((SurfObj)->hdev))->DriverFunctions
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] Thu Jan 8
20:06:39 2009
@@ -567,8 +567,8 @@
{
if(Indirect)
{
- CurIcon->IconInfo.hbmMask =
SURFACE_CopyBitmap(CurIcon->IconInfo.hbmMask);
- CurIcon->IconInfo.hbmColor =
SURFACE_CopyBitmap(CurIcon->IconInfo.hbmColor);
+ CurIcon->IconInfo.hbmMask =
BITMAP_CopyBitmap(CurIcon->IconInfo.hbmMask);
+ CurIcon->IconInfo.hbmColor =
BITMAP_CopyBitmap(CurIcon->IconInfo.hbmColor);
}
if(CurIcon->IconInfo.hbmColor &&
(psurfBmp = SURFACE_LockSurface(CurIcon->IconInfo.hbmColor)))
@@ -651,8 +651,8 @@
RtlCopyMemory(&ii, &CurIcon->IconInfo, sizeof(ICONINFO));
/* Copy bitmaps */
- ii.hbmMask = SURFACE_CopyBitmap(CurIcon->IconInfo.hbmMask);
- ii.hbmColor = SURFACE_CopyBitmap(CurIcon->IconInfo.hbmColor);
+ ii.hbmMask = BITMAP_CopyBitmap(CurIcon->IconInfo.hbmMask);
+ ii.hbmColor = BITMAP_CopyBitmap(CurIcon->IconInfo.hbmColor);
/* Copy fields */
_SEH2_TRY
@@ -1244,8 +1244,8 @@
ProbeForRead(pIconInfo, sizeof(ICONINFO), 1);
RtlCopyMemory(&CurIcon->IconInfo, pIconInfo, sizeof(ICONINFO));
- CurIcon->IconInfo.hbmMask = SURFACE_CopyBitmap(pIconInfo->hbmMask);
- CurIcon->IconInfo.hbmColor = SURFACE_CopyBitmap(pIconInfo->hbmColor);
+ CurIcon->IconInfo.hbmMask = BITMAP_CopyBitmap(pIconInfo->hbmMask);
+ CurIcon->IconInfo.hbmColor = BITMAP_CopyBitmap(pIconInfo->hbmColor);
if (CurIcon->IconInfo.hbmColor)
{
Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Thu Jan 8
20:06:39 2009
@@ -44,7 +44,7 @@
LONG WidthBytes;
/* NOTE: Windows also doesn't store nr. of planes separately! */
- BitsPixel = SURFACE_GetRealBitsPixel(BitsPixel * Planes);
+ BitsPixel = BITMAP_GetRealBitsPixel(BitsPixel * Planes);
/* Check parameters */
if (BitsPixel == 0 || Width <= 0 || Width >= 0x8000000 || Height == 0)
@@ -54,7 +54,7 @@
return 0;
}
- WidthBytes = SURFACE_GetWidthBytes(Width, BitsPixel);
+ WidthBytes = BITMAP_GetWidthBytes(Width, BitsPixel);
Size.cx = Width;
Size.cy = abs(Height);
@@ -113,7 +113,7 @@
if (pUnsafeBits)
{
BOOL Hit = FALSE;
- UINT cjBits = SURFACE_GetWidthBytes(Width, BitsPixel) * abs(Height);
+ UINT cjBits = BITMAP_GetWidthBytes(Width, BitsPixel) * abs(Height);
_SEH2_TRY
{
@@ -689,7 +689,7 @@
/* Internal Functions */
UINT FASTCALL
-SURFACE_GetRealBitsPixel(UINT nBitsPixel)
+BITMAP_GetRealBitsPixel(UINT nBitsPixel)
{
if (nBitsPixel <= 1)
return 1;
@@ -708,7 +708,7 @@
}
INT FASTCALL
-SURFACE_GetWidthBytes (INT bmWidth, INT bpp)
+BITMAP_GetWidthBytes (INT bmWidth, INT bpp)
{
#if 0
switch(bpp)
@@ -742,7 +742,7 @@
}
HBITMAP FASTCALL
-SURFACE_CopyBitmap(HBITMAP hBitmap)
+BITMAP_CopyBitmap(HBITMAP hBitmap)
{
HBITMAP res;
BITMAP bm;
@@ -807,45 +807,59 @@
}
INT APIENTRY
-BITMAP_GetObject(SURFACE * bmp, INT Count, LPVOID buffer)
-{
+BITMAP_GetObject(SURFACE *psurf, INT Count, LPVOID buffer)
+{
+ PBITMAP pBitmap;
+
+ if (!buffer) return sizeof(BITMAP);
if ((UINT)Count < sizeof(BITMAP)) return 0;
- if(bmp->dib)
- {
- if((UINT)Count < sizeof(DIBSECTION))
- {
- Count = sizeof(BITMAP);
- }
- else
- {
- Count = sizeof(DIBSECTION);
- }
- if (buffer)
- {
- memcpy(buffer, bmp->dib, Count);
- }
- return Count;
+ /* always fill a basic BITMAP structure */
+ pBitmap = buffer;
+ pBitmap->bmType = 0;
+ pBitmap->bmWidth = psurf->SurfObj.sizlBitmap.cx;
+ pBitmap->bmHeight = psurf->SurfObj.sizlBitmap.cy;
+ pBitmap->bmWidthBytes = abs(psurf->SurfObj.lDelta);
+ pBitmap->bmPlanes = 1;
+ pBitmap->bmBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
+
+ /* Check for DIB section */
+ if(psurf->hSecure)
+ {
+ /* Set bmBits in this case */
+ pBitmap->bmBits = psurf->SurfObj.pvBits;
+
+ if (Count >= sizeof(DIBSECTION))
+ {
+ /* Fill rest of DIBSECTION */
+ PDIBSECTION pds = buffer;
+
+ pds->dsBmih.biSize =
+ pds->dsBmih.biWidth = pds->dsBm.bmWidth;
+ pds->dsBmih.biHeight = pds->dsBm.bmHeight;
+ pds->dsBmih.biPlanes = pds->dsBm.bmPlanes;
+ pds->dsBmih.biBitCount = pds->dsBm.bmBitsPixel;
+ pds->dsBmih.biCompression = 0; // FIXME!
+ pds->dsBmih.biSizeImage = psurf->SurfObj.cjBits;
+ pds->dsBmih.biXPelsPerMeter = 0;
+ pds->dsBmih.biYPelsPerMeter = 0;
+ pds->dsBmih.biClrUsed = psurf->biClrUsed;
+ pds->dsBmih.biClrImportant = psurf->biClrImportant;
+ pds->dsBitfields[0] = psurf->dsBitfields[0];
+ pds->dsBitfields[1] = psurf->dsBitfields[1];
+ pds->dsBitfields[2] = psurf->dsBitfields[2];
+ pds->dshSection = psurf->hDIBSection;
+ pds->dsOffset = psurf->dwOffset;
+
+ return sizeof(DIBSECTION);
+ }
}
else
{
- Count = sizeof(BITMAP);
- if (buffer)
- {
- BITMAP Bitmap;
-
- Count = sizeof(BITMAP);
- Bitmap.bmType = 0;
- Bitmap.bmWidth = bmp->SurfObj.sizlBitmap.cx;
- Bitmap.bmHeight = bmp->SurfObj.sizlBitmap.cy;
- Bitmap.bmWidthBytes = abs(bmp->SurfObj.lDelta);
- Bitmap.bmPlanes = 1;
- Bitmap.bmBitsPixel = BitsPerFormat(bmp->SurfObj.iBitmapFormat);
- Bitmap.bmBits = NULL; /* not set according to wine test, confirmed in win2k */
- memcpy(buffer, &Bitmap, Count);
- }
- return Count;
- }
+ pBitmap->bmBits = NULL; /* not set according to wine test, confirmed in win2k
*/
+ }
+
+ return sizeof(BITMAP);
}
/*
@@ -917,9 +931,10 @@
psurfBmp->hDC = hDC;
// if we're working with a DIB, get the palette [fixme: only create if the
selected palette is null]
- if(psurfBmp->dib)
+ if(psurfBmp->hSecure)
{
- pDC->w.bitsPerPixel = psurfBmp->dib->dsBmih.biBitCount;
+// pDC->w.bitsPerPixel = psurfBmp->dib->dsBmih.biBitCount; ???
+ pDC->w.bitsPerPixel = BitsPerFormat(psurfBmp->SurfObj.iBitmapFormat);
}
else
{
Modified: trunk/reactos/subsystems/win32/win32k/objects/brush.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/brush.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/brush.c [iso-8859-1] Thu Jan 8 20:06:39
2009
@@ -437,7 +437,7 @@
PGDIBRUSHOBJ BrushObject;
HBITMAP hPattern;
- hPattern = SURFACE_CopyBitmap(hBitmap);
+ hPattern = BITMAP_CopyBitmap(hBitmap);
if (hPattern == NULL)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Thu Jan 8
20:06:39 2009
@@ -76,6 +76,7 @@
PSURFACE psurf;
PPALGDI PalGDI;
UINT Index;
+ ULONG biBitCount;
if (!(dc = DC_LockDc(hDC))) return 0;
if (dc->DC_Type == DC_TYPE_INFO)
@@ -92,7 +93,7 @@
return 0;
}
- if (psurf->dib == NULL)
+ if (psurf->hSecure == NULL)
{
SURFACE_UnlockSurface(psurf);
DC_UnlockDc(dc);
@@ -100,11 +101,11 @@
return 0;
}
- if (psurf->dib->dsBmih.biBitCount <= 8 &&
- StartIndex < (1 << psurf->dib->dsBmih.biBitCount))
+ biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
+ if (biBitCount <= 8 && StartIndex < (1 << biBitCount))
{
- if (StartIndex + Entries > (1 << psurf->dib->dsBmih.biBitCount))
- Entries = (1 << psurf->dib->dsBmih.biBitCount) - StartIndex;
+ if (StartIndex + Entries > (1 << biBitCount))
+ Entries = (1 << biBitCount) - StartIndex;
PalGDI = PALETTE_LockPalette(psurf->hDIBPalette);
if (PalGDI == NULL)
@@ -141,6 +142,7 @@
PSURFACE psurf;
PPALGDI PalGDI;
UINT Index;
+ ULONG biBitCount;
if (!(dc = DC_LockDc(hDC))) return 0;
if (dc->DC_Type == DC_TYPE_INFO)
@@ -157,7 +159,7 @@
return 0;
}
- if (psurf->dib == NULL)
+ if (psurf->hSecure == NULL)
{
SURFACE_UnlockSurface(psurf);
DC_UnlockDc(dc);
@@ -165,11 +167,12 @@
return 0;
}
- if (psurf->dib->dsBmih.biBitCount <= 8 &&
- StartIndex < (1 << psurf->dib->dsBmih.biBitCount))
+ biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
+ if (biBitCount <= 8 &&
+ StartIndex < (1 << biBitCount))
{
- if (StartIndex + Entries > (1 << psurf->dib->dsBmih.biBitCount))
- Entries = (1 << psurf->dib->dsBmih.biBitCount) - StartIndex;
+ if (StartIndex + Entries > (1 << biBitCount))
+ Entries = (1 << biBitCount) - StartIndex;
PalGDI = PALETTE_LockPalette(psurf->hDIBPalette);
if (PalGDI == NULL)
@@ -750,7 +753,8 @@
case 4:
case 8:
Info->bmiHeader.biClrUsed = 0;
- if ( psurf->dib && psurf->dib->dsBm.bmBitsPixel ==
Info->bmiHeader.biBitCount)
+ if ( psurf->hSecure &&
+ BitsPerFormat(psurf->SurfObj.iBitmapFormat) ==
Info->bmiHeader.biBitCount)
{
if (Usage == DIB_RGB_COLORS)
{
@@ -1316,7 +1320,6 @@
{
HBITMAP res = 0;
SURFACE *bmp = NULL;
- DIBSECTION *dib = NULL;
void *mapBits = NULL;
PDC_ATTR pDc_Attr;
@@ -1327,6 +1330,8 @@
BITMAP bm;
SIZEL Size;
RGBQUAD *lpRGB;
+ HANDLE hSecure;
+ DWORD dsBitfields[3] = {0};
DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
@@ -1374,7 +1379,7 @@
}
mapOffset = offset - (offset % Sbi.AllocationGranularity);
- mapSize = dib->dsBmih.biSizeImage + (offset - mapOffset);
+ mapSize = bi->biSizeImage + (offset - mapOffset);
SectionOffset.LowPart = mapOffset;
SectionOffset.HighPart = 0;
@@ -1405,44 +1410,44 @@
bm.bmBits = EngAllocUserMem( totalSize, 0 );
}
+// hSecure = MmSecureVirtualMemory(bm.bmBits, totalSize, PAGE_READWRITE);
+ hSecure = (HANDLE)0x1; // HACK OF UNIMPLEMENTED KERNEL STUFF !!!!
+
if(usage == DIB_PAL_COLORS)
lpRGB = DIB_MapPaletteColors(dc, bmi);
else
lpRGB = bmi->bmiColors;
- // Allocate Memory for DIB and fill structure
- if (bm.bmBits)
- {
- dib = ExAllocatePoolWithTag(PagedPool, sizeof(DIBSECTION), TAG_DIB);
- if (dib != NULL) RtlZeroMemory(dib, sizeof(DIBSECTION));
- }
-
- if (dib)
- {
- dib->dsBm = bm;
/* Set dsBitfields values */
if ( usage == DIB_PAL_COLORS || bi->biBitCount <= 8)
{
- dib->dsBitfields[0] = dib->dsBitfields[1] = dib->dsBitfields[2] = 0;
- }
- else switch(bi->biBitCount)
- {
- case 15:
- case 16:
- dib->dsBitfields[0] = (bi->biCompression == BI_BITFIELDS) ? *(DWORD *)lpRGB
: 0x7c00;
- dib->dsBitfields[1] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD
*)lpRGB + 1) : 0x03e0;
- dib->dsBitfields[2] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD
*)lpRGB + 2) : 0x001f;
- break;
-
- case 24:
- case 32:
- dib->dsBitfields[0] = (bi->biCompression == BI_BITFIELDS) ? *(DWORD *)lpRGB
: 0xff0000;
- dib->dsBitfields[1] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD
*)lpRGB + 1) : 0x00ff00;
- dib->dsBitfields[2] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD
*)lpRGB + 2) : 0x0000ff;
- break;
- }
- dib->dshSection = section;
- dib->dsOffset = offset;
+ dsBitfields[0] = dsBitfields[1] = dsBitfields[2] = 0;
+ }
+ else if (bi->biCompression == BI_RGB)
+ {
+ switch(bi->biBitCount)
+ {
+ case 15:
+ case 16:
+ dsBitfields[0] = (bi->biCompression == BI_BITFIELDS) ? *(DWORD *)lpRGB
: 0x7c00;
+ dsBitfields[1] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)lpRGB +
1) : 0x03e0;
+ dsBitfields[2] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)lpRGB +
2) : 0x001f;
+ break;
+
+ case 24:
+ case 32:
+ dsBitfields[0] = (bi->biCompression == BI_BITFIELDS) ? *(DWORD *)lpRGB
: 0xff0000;
+ dsBitfields[1] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)lpRGB +
1) : 0x00ff00;
+ dsBitfields[2] = (bi->biCompression == BI_BITFIELDS) ? *((DWORD *)lpRGB +
2) : 0x0000ff;
+ break;
+ }
+ }
+ else
+ {
+ dsBitfields[0] = ((DWORD*)bmi->bmiColors)[0];
+ dsBitfields[1] = ((DWORD*)bmi->bmiColors)[1];
+ dsBitfields[2] = ((DWORD*)bmi->bmiColors)[2];
+ }
// Create Device Dependent Bitmap and add DIB pointer
Size.cx = bm.bmWidth;
@@ -1469,12 +1474,19 @@
{
ExFreePoolWithTag(lpRGB, TAG_COLORMAP);
}
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- NtGdiDeleteObject(bmp);
- return NULL;
- }
- bmp->dib = (DIBSECTION *) dib;
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ NtGdiDeleteObject(bmp);
+ return NULL;
+ }
+ bmp->hDIBSection = section;
+ bmp->hSecure = hSecure;
+ bmp->dwOffset = offset;
bmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
+ bmp->dsBitfields[0] = dsBitfields[0];
+ bmp->dsBitfields[1] = dsBitfields[1];
+ bmp->dsBitfields[2] = dsBitfields[2];
+ bmp->biClrUsed = bi->biClrUsed;
+ bmp->biClrImportant = bi->biClrImportant;
/* WINE NOTE: WINE makes use of a colormap, which is a color translation
table between the DIB and the X physical device. Obviously,
@@ -1490,20 +1502,17 @@
bmp->hDIBPalette = PALETTE_AllocPaletteIndexedRGB(bi->biClrUsed, lpRGB);
else
bmp->hDIBPalette = PALETTE_AllocPalette(PAL_BITFIELDS, 0, NULL,
- dib->dsBitfields[0],
- dib->dsBitfields[1],
- dib->dsBitfields[2]);
-
- dib->dsBmih = *bi;
- dib->dsBmih.biSizeImage = totalSize;
- }
+ dsBitfields[0],
+ dsBitfields[1],
+ dsBitfields[2]);
// Clean up in case of errors
- if (!res || !bmp || !dib || !bm.bmBits)
- {
- DPRINT("got an error res=%08x, bmp=%p, dib=%p, bm.bmBits=%p\n", res, bmp,
dib, bm.bmBits);
+ if (!res || !bmp || !bm.bmBits)
+ {
+ DPRINT("got an error res=%08x, bmp=%p, bm.bmBits=%p\n", res, bmp,
bm.bmBits);
if (bm.bmBits)
{
+ // MmUnsecureVirtualMemory(hSecure); // FIXME: Implement this!
if (section)
{
ZwUnmapViewOfSection(NtCurrentProcess(), mapBits);
@@ -1514,7 +1523,6 @@
EngFreeUserMem(bm.bmBits), bm.bmBits = NULL;
}
- if (dib) { ExFreePoolWithTag(dib, TAG_DIB); dib = NULL; }
if (bmp) { bmp = NULL; }
if (res) { SURFACE_FreeSurfaceByHandle(res); res = 0; }
}