Author: fireball Date: Tue Feb 16 19:45:49 2010 New Revision: 45600
URL: http://svn.reactos.org/svn/reactos?rev=45600&view=rev Log: - Implement kernelmode part of SetDIBitsToDevice (heavily based on win32k from r41760).
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] Tue Feb 16 19:45:49 2010 @@ -388,11 +388,33 @@
INT APIENTRY RosGdiSetDIBitsToDevice( HDC physDev, INT xDest, INT yDest, DWORD cx, DWORD cy, INT xSrc, INT ySrc, - UINT startscan, UINT lines, LPCVOID bits, - const BITMAPINFO *info, UINT coloruse ) -{ - UNIMPLEMENTED; - return 0; + UINT StartScan, UINT ScanLines, LPCVOID Bits, + const BITMAPINFO *bmi, UINT ColorUse ) +{ + PDC pDC; + + /* Get a pointer to the DCs */ + pDC = DC_Lock(physDev); + + /* Set the bits */ + ScanLines = GreSetDIBitsToDevice(pDC, + xDest, + yDest, + cx, + cy, + xSrc, + ySrc, + StartScan, + ScanLines, + Bits, + bmi, + ColorUse); + + /* Release DC objects */ + DC_Unlock(pDC); + + /* Return amount of lines set */ + return ScanLines; }
BOOL APIENTRY RosGdiStretchBlt( HDC physDevDst, INT xDst, INT yDst,
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c [iso-8859-1] Tue Feb 16 19:45:49 2010 @@ -1093,4 +1093,138 @@ return Result; }
+INT +NTAPI +GreSetDIBitsToDevice( + PDC pDC, + INT XDest, + INT YDest, + DWORD Width, + DWORD Height, + INT XSrc, + INT YSrc, + UINT StartScan, + UINT ScanLines, + CONST VOID *Bits, + CONST BITMAPINFO *bmi, + UINT ColorUse) +{ + INT ret = 0; + NTSTATUS Status = STATUS_SUCCESS; + HBITMAP hSourceBitmap = NULL; + SURFOBJ *pDestSurf, *pSourceSurf = NULL; + SURFACE *pSurf; + RECTL rcDest; + POINTL ptSource; + INT DIBWidth; + SIZEL SourceSize; + XLATEOBJ *XlateObj = NULL; + PPALETTE pDCPalette; + HPALETTE DDBPalette, DIBPalette = NULL; + ULONG DDBPaletteType, DIBPaletteType; + + if (!Bits) return 0; + + /* Use destination palette obtained from the DC by default */ + DDBPalette = pDC->pPDevice->DevInfo.hpalDefault; + + /* Try to use hDIBPalette if it exists */ + pSurf = pDC->pBitmap; + if (pSurf && pSurf->hDIBPalette) + { + DDBPalette = pSurf->hDIBPalette; + } + + pDestSurf = pSurf ? &pSurf->SurfObj : NULL; + + rcDest.left = XDest; + rcDest.top = YDest; + rcDest.left += pDC->rcVport.left + pDC->rcDcRect.left; + rcDest.top += pDC->rcVport.top + pDC->rcDcRect.top; + + rcDest.right = rcDest.left + Width; + rcDest.bottom = rcDest.top + Height; + ptSource.x = XSrc; + ptSource.y = YSrc; + + SourceSize.cx = bmi->bmiHeader.biWidth; + SourceSize.cy = ScanLines; // this one --> abs(bmi->bmiHeader.biHeight) - StartScan + DIBWidth = DIB_GetDIBWidthBytes(SourceSize.cx, bmi->bmiHeader.biBitCount); + + hSourceBitmap = EngCreateBitmap(SourceSize, + DIBWidth, + GrepBitmapFormat(bmi->bmiHeader.biBitCount, bmi->bmiHeader.biCompression), + bmi->bmiHeader.biHeight < 0 ? BMF_TOPDOWN : 0, + (PVOID) Bits); + if (!hSourceBitmap) + { + SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + Status = STATUS_NO_MEMORY; + goto Exit; + } + + pSourceSurf = EngLockSurface((HSURF)hSourceBitmap); + if (!pSourceSurf) + { + Status = STATUS_UNSUCCESSFUL; + goto Exit; + } + + /* Obtain destination palette */ + pDCPalette = PALETTE_LockPalette(DDBPalette); + if (!pDCPalette) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + Status = STATUS_UNSUCCESSFUL; + goto Exit; + } + + DDBPaletteType = pDCPalette->Mode; + PALETTE_UnlockPalette(pDCPalette); + + DIBPalette = BuildDIBPalette(bmi, (PINT)&DIBPaletteType); + if (!DIBPalette) + { + SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + Status = STATUS_NO_MEMORY; + goto Exit; + } + + /* Determine XlateObj */ + XlateObj = IntEngCreateXlate(DDBPaletteType, DIBPaletteType, DDBPalette, DIBPalette); + if (!XlateObj) + { + SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + Status = STATUS_NO_MEMORY; + goto Exit; + } + + /* Copy the bits */ + Status = GrepBitBltEx(pDestSurf, + pSourceSurf, + NULL, + pDC->CombinedClip, + XlateObj, + &rcDest, + &ptSource, + NULL, + NULL, + NULL, + ROP3_TO_ROP4(SRCCOPY), + TRUE); +Exit: + if (NT_SUCCESS(Status)) + { + /* FIXME: Should probably be only the number of lines actually copied */ + ret = ScanLines; // this one --> abs(Info->bmiHeader.biHeight) - StartScan; + } + + if (pSourceSurf) EngUnlockSurface(pSourceSurf); + if (hSourceBitmap) EngDeleteSurface((HSURF)hSourceBitmap); + if (XlateObj) EngDeleteXlate(XlateObj); + if (DIBPalette) PALETTE_FreePaletteByHandle(DIBPalette); + + return ret; +} + /* EOF */
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h [iso-8859-1] Tue Feb 16 19:45:49 2010 @@ -93,6 +93,22 @@ BITMAPINFO *bmi, UINT ColorUse);
+INT +NTAPI +GreSetDIBitsToDevice( + PDC DC, + INT xDest, + INT yDest, + DWORD cx, + DWORD cy, + INT xSrc, + INT ySrc, + UINT StartScan, + UINT ScanLines, + CONST VOID *Bits, + CONST BITMAPINFO *bmi, + UINT ColorUse); + INT FASTCALL BitsPerFormat(ULONG Format);
@@ -362,4 +378,7 @@ INT FASTCALL MouseSafetyOnDrawEnd(SURFOBJ *pso);
+/* Test functions */ +VOID NTAPI GrePerformTests(); + #endif