Author: jgardou
Date: Mon Aug 2 16:49:51 2010
New Revision: 48416
URL:
http://svn.reactos.org/svn/reactos?rev=48416&view=rev
Log:
[WIN32K]
- NtGdiGetBitmapBits : Bits we're given are 16 bits aligned.
- NtGdiGetDIBitsInternal : we must not stretch, for this there is
NtGdiStretchDIBitsInternal. Use lower level functions to do the work, there is no need to
create HDCs etc...
Now icons are back.
Modified:
branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c
branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Mon
Aug 2 16:49:51 2010
@@ -581,6 +581,36 @@
return ret;
}
+VOID
+FASTCALL
+UnsafeGetBitmapBits(
+ PSURFACE psurf,
+ DWORD Bytes,
+ OUT PBYTE pvBits)
+{
+ PUCHAR pjDst, pjSrc;
+ LONG lDeltaDst, lDeltaSrc;
+ ULONG nWidth, nHeight, cBitsPixel;
+
+ nWidth = psurf->SurfObj.sizlBitmap.cx;
+ nHeight = psurf->SurfObj.sizlBitmap.cy;
+ cBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
+
+ /* Get pointers */
+ pjSrc = psurf->SurfObj.pvScan0;
+ pjDst = pvBits;
+ lDeltaSrc = psurf->SurfObj.lDelta;
+ lDeltaDst = BITMAP_GetWidthBytes(nWidth, cBitsPixel);
+
+ while (nHeight--)
+ {
+ /* Copy one line */
+ RtlCopyMemory(pjDst, pjSrc, lDeltaDst);
+ pjSrc += lDeltaSrc;
+ pjDst += lDeltaDst;
+ }
+}
+
LONG APIENTRY
NtGdiGetBitmapBits(
HBITMAP hBitmap,
@@ -620,7 +650,8 @@
_SEH2_TRY
{
ProbeForWrite(pUnsafeBits, Bytes, 1);
- ret = IntGetBitmapBits(psurf, Bytes, pUnsafeBits);
+ UnsafeGetBitmapBits(psurf, Bytes, pUnsafeBits);
+ ret = Bytes;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Mon
Aug 2 16:49:51 2010
@@ -695,7 +695,7 @@
Info->bmiHeader.biYPelsPerMeter = 0;
Info->bmiHeader.biClrUsed = 0;
Info->bmiHeader.biClrImportant = 0;
- ScanLines = psurf->SurfObj.sizlBitmap.cy;
+ ScanLines = 1;
/* Get Complete info now */
goto done;
@@ -897,8 +897,11 @@
{
/* Create a DIBSECTION, blt it, profit */
PVOID pDIBits ;
- HBITMAP hBmpDest, hOldDest = NULL, hOldSrc = NULL;
- HDC hdcDest = NULL, hdcSrc;
+ HBITMAP hBmpDest;
+ PSURFACE psurfDest;
+ EXLATEOBJ exlo;
+ RECT rcDest;
+ POINTL srcPoint;
BOOL ret ;
if (StartScan > psurf->SurfObj.sizlBitmap.cy)
@@ -911,7 +914,15 @@
ScanLines = min(ScanLines, psurf->SurfObj.sizlBitmap.cy - StartScan);
}
+ /* Fixup values */
+ Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx;
+ Info->bmiHeader.biHeight = height < 0 ?
+ -ScanLines : ScanLines;
+ /* Create the DIB */
hBmpDest = DIB_CreateDIBSection(pDC, Info, Usage, &pDIBits, NULL, 0, 0);
+ /* Restore them */
+ Info->bmiHeader.biWidth = width;
+ Info->bmiHeader.biHeight = height;
if(!hBmpDest)
{
@@ -921,56 +932,25 @@
goto done ;
}
- if(psurf->hdc)
- hdcSrc = psurf->hdc;
- else
- {
- hdcSrc = NtGdiCreateCompatibleDC(0);
- if(!hdcSrc)
- {
- DPRINT1("Error: could not create HDC!\n");
- ScanLines = 0;
- goto cleanup_blt;
- }
- hOldSrc = NtGdiSelectBitmap(hdcSrc, hBitmap);
- if(!hOldSrc)
- {
- DPRINT1("Error : Could not Select bitmap\n");
- ScanLines = 0;
- goto cleanup_blt;
- }
- }
-
- hdcDest = NtGdiCreateCompatibleDC(0);
- if(!hdcDest)
- {
- DPRINT1("Error: could not create HDC!\n");
- ScanLines = 0;
- goto cleanup_blt;
- }
- hOldDest = NtGdiSelectBitmap(hdcDest, hBmpDest);
- if(!hOldDest)
- {
- DPRINT1("Error : Could not Select bitmap\n");
- ScanLines = 0;
- goto cleanup_blt;
- }
-
- ret = GreStretchBltMask(hdcDest,
- 0,
- 0,
- width,
- height,
- hdcSrc,
- 0,
- StartScan,
- psurf->SurfObj.sizlBitmap.cx,
- ScanLines,
- SRCCOPY,
- 0,
- NULL,
- 0,
- 0);
+ psurfDest = SURFACE_LockSurface(hBmpDest);
+
+ rcDest.left = 0;
+ rcDest.top = 0;
+ rcDest.bottom = ScanLines;
+ rcDest.right = psurf->SurfObj.sizlBitmap.cx;
+
+ srcPoint.x = 0;
+ srcPoint.y = height < 0 ?
+ psurf->SurfObj.sizlBitmap.cy - (StartScan + ScanLines) : StartScan;
+
+ EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0, 0, 0);
+
+ ret = IntEngCopyBits(&psurfDest->SurfObj,
+ &psurf->SurfObj,
+ NULL,
+ &exlo.xlo,
+ &rcDest,
+ &srcPoint);
if(!ret)
ScanLines = 0;
@@ -994,18 +974,8 @@
}
}
- cleanup_blt:
- if(hdcSrc && (hdcSrc != psurf->hdc))
- {
- if(hOldSrc) NtGdiSelectBitmap(hdcSrc, hOldSrc);
- NtGdiDeleteObjectApp(hdcSrc);
- }
- if(hdcSrc)
- {
- if(hOldDest) NtGdiSelectBitmap(hdcDest, hOldDest);
- NtGdiDeleteObjectApp(hdcDest);
- }
GreDeleteObject(hBmpDest);
+ EXLATEOBJ_vCleanup(&exlo);
}
done: