Index: subsystems/win32/win32k/dib/dib1bpp.c =================================================================== --- subsystems/win32/win32k/dib/dib1bpp.c (revision 40280) +++ subsystems/win32/win32k/dib/dib1bpp.c (working copy) @@ -59,177 +59,6 @@ } } -static -void -DIB_1BPP_BitBltSrcCopy_From1BPP ( - SURFOBJ* DestSurf, SURFOBJ* SourceSurf, - PRECTL DestRect, POINTL *SourcePoint ) -{ - // the 'window' in this sense is the x-position that corresponds - // to the left-edge of the 8-pixel byte we are currently working with. - // dwx is current x-window, dwx2 is the 'last' window we need to process - int dwx, dwx2; // destination window x-position - int swx; // source window y-position - - // left and right edges of source and dest rectangles - int dl = DestRect->left; // dest left - int dr = DestRect->right-1; // dest right (inclusive) - int sl = SourcePoint->x; // source left - int sr = sl + dr - dl; // source right (inclusive) - - // which direction are we going? - int xinc; - int yinc; - int ySrcDelta, yDstDelta; - - // following 4 variables are used for the y-sweep - int dy; // dest y - int dy1; // dest y start - int dy2; // dest y end - int sy1; // src y start - - int dx; - int shift; - BYTE srcmask, dstmask; - - // 'd' and 's' are the dest & src buffer pointers that I use on my x-sweep - // 'pd' and 'ps' are the dest & src buffer pointers used on the inner y-sweep - PBYTE d, pd; // dest ptrs - PBYTE s, ps; // src ptrs - - shift = (dl-sl)&7; - - if ( DestRect->top <= SourcePoint->y ) - { - // moving up ( scan top -> bottom ) - dy1 = DestRect->top; - dy2 = DestRect->bottom - 1; - sy1 = SourcePoint->y; - yinc = 1; - ySrcDelta = SourceSurf->lDelta; - yDstDelta = DestSurf->lDelta; - } - else - { - // moving down ( scan bottom -> top ) - dy1 = DestRect->bottom - 1; - dy2 = DestRect->top; - sy1 = SourcePoint->y + dy1 - dy2; - yinc = -1; - ySrcDelta = -SourceSurf->lDelta; - yDstDelta = -DestSurf->lDelta; - } - if ( DestRect->left <= SourcePoint->x ) - { - // moving left ( scan left->right ) - dwx = dl&~7; - swx = (sl-(dl&7))&~7; - dwx2 = dr&~7; - xinc = 1; - } - else - { - // moving right ( scan right->left ) - dwx = dr&~7; - swx = (sr-(dr&7))&~7; //(sr-7)&~7; // we need the left edge of this block... thus the -7 - dwx2 = dl&~7; - xinc = -1; - } - d = &(((PBYTE)DestSurf->pvScan0)[dy1*DestSurf->lDelta + (dwx>>3)]); - s = &(((PBYTE)SourceSurf->pvScan0)[sy1*SourceSurf->lDelta + (swx>>3)]); - for ( ;; ) - { - dy = dy1; - pd = d; - ps = s; - srcmask = 0xff; - dx = dwx; /* dest x for this pass */ - if ( dwx < dl ) - { - int diff = dl-dwx; - srcmask &= (1<<(8-diff))-1; - dx = dl; - } - if ( dwx+7 > dr ) - { - int diff = dr-dwx+1; - srcmask &= ~((1<<(8-diff))-1); - } - dstmask = ~srcmask; - - // we unfortunately *must* have 5 different versions of the inner - // loop to be certain we don't try to read from memory that is not - // needed and may in fact be invalid - if ( !shift ) - { - for ( ;; ) - { - *pd = (BYTE)((*pd & dstmask) | (*ps & srcmask)); - - // this *must* be here, because we could be going up *or* down... - if ( dy == dy2 ) - break; - dy += yinc; - pd += yDstDelta; - ps += ySrcDelta; - } - } - else if ( !(0xFF00 & (srcmask<> shift ) & srcmask )); - - // this *must* be here, because we could be going up *or* down... - if ( dy == dy2 ) - break; - dy += yinc; - pd += yDstDelta; - ps += ySrcDelta; - } - } - else if ( !(0xFF & (srcmask<> shift ) & srcmask ); - - // this *must* be here, because we could be going up *or* down... - if ( dy == dy2 ) - break; - dy += yinc; - pd += yDstDelta; - ps += ySrcDelta; - } - } - - // this *must* be here, because we could be going right *or* left... - if ( dwx == dwx2 ) - break; - d += xinc; - s += xinc; - dwx += xinc<<3; - swx += xinc<<3; - } -} - BOOLEAN DIB_1BPP_BitBltSrcCopy(PBLTINFO BltInfo) { @@ -238,7 +67,18 @@ switch ( BltInfo->SourceSurface->iBitmapFormat ) { case BMF_1BPP: - DIB_1BPP_BitBltSrcCopy_From1BPP ( BltInfo->DestSurface, BltInfo->SourceSurface, &BltInfo->DestRect, &BltInfo->SourcePoint ); + for (j=BltInfo->DestRect.top; jDestRect.bottom; j++) + { + sx = BltInfo->SourcePoint.x; + for (i=BltInfo->DestRect.left; iDestRect.right; i++) + { + DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, + XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, + DIB_1BPP_GetPixel(BltInfo->SourceSurface, sx, sy))); + sx++; + } + sy++; + } break; case BMF_4BPP: @@ -247,12 +87,9 @@ sx = BltInfo->SourcePoint.x; for (i=BltInfo->DestRect.left; iDestRect.right; i++) { - if(XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_4BPP_GetPixel(BltInfo->SourceSurface, sx, sy)) == 0) - { - DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, 0); - } else { - DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, 1); - } + DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, + XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, + DIB_4BPP_GetPixel(BltInfo->SourceSurface, sx, sy))); sx++; } sy++; @@ -265,12 +102,9 @@ sx = BltInfo->SourcePoint.x; for (i=BltInfo->DestRect.left; iDestRect.right; i++) { - if(XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_8BPP_GetPixel(BltInfo->SourceSurface, sx, sy)) == 0) - { - DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, 0); - } else { - DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, 1); - } + DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, + XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, + DIB_8BPP_GetPixel(BltInfo->SourceSurface, sx, sy))); sx++; } sy++; @@ -283,12 +117,9 @@ sx = BltInfo->SourcePoint.x; for (i=BltInfo->DestRect.left; iDestRect.right; i++) { - if(XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_16BPP_GetPixel(BltInfo->SourceSurface, sx, sy)) == 0) - { - DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, 0); - } else { - DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, 1); - } + DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, + XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, + DIB_16BPP_GetPixel(BltInfo->SourceSurface, sx, sy))); sx++; } sy++; @@ -301,12 +132,9 @@ sx = BltInfo->SourcePoint.x; for (i=BltInfo->DestRect.left; iDestRect.right; i++) { - if(XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_24BPP_GetPixel(BltInfo->SourceSurface, sx, sy)) == 0) - { - DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, 0); - } else { - DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, 1); - } + DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, + XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, + DIB_24BPP_GetPixel(BltInfo->SourceSurface, sx, sy))); sx++; } sy++; @@ -319,12 +147,9 @@ sx = BltInfo->SourcePoint.x; for (i=BltInfo->DestRect.left; iDestRect.right; i++) { - if(XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_32BPP_GetPixel(BltInfo->SourceSurface, sx, sy)) == 0) - { - DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, 0); - } else { - DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, 1); - } + DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, + XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, + DIB_32BPP_GetPixel(BltInfo->SourceSurface, sx, sy))); sx++; } sy++; Index: subsystems/win32/win32k/objects/dibobj.c =================================================================== --- subsystems/win32/win32k/objects/dibobj.c (revision 40280) +++ subsystems/win32/win32k/objects/dibobj.c (working copy) @@ -436,7 +436,7 @@ NTSTATUS Status = STATUS_SUCCESS; PDC pDC; HBITMAP hSourceBitmap = NULL; - SURFOBJ *pDestSurf, *pSourceSurf = NULL; + SURFOBJ *pDestSurf = NULL, *pSourceSurf = NULL; RECTL rcDest; POINTL ptSource; INT DIBWidth; @@ -476,6 +476,19 @@ return 0; } + SURFACE *psurf = SURFACE_LockSurface(pDC->rosdc.hBitmap); + // Use hDIBPalette if it exists + if (psurf->hDIBPalette) + { + DDBPalette = psurf->hDIBPalette; + } + else + { + // Destination palette obtained from the DC + DDBPalette = pDC->ppdev->DevInfo.hpalDefault; + } + SURFACE_UnlockSurface(psurf); + pDestSurf = EngLockSurface((HSURF)pDC->rosdc.hBitmap); if (!pDestSurf) { @@ -522,7 +535,7 @@ } /* Obtain destination palette from the DC */ - pDCPalette = PALETTE_LockPalette(pDC->ppdev->DevInfo.hpalDefault); + pDCPalette = PALETTE_LockPalette(DDBPalette); if (!pDCPalette) { SetLastWin32Error(ERROR_INVALID_HANDLE); @@ -531,7 +544,6 @@ } DDBPaletteType = pDCPalette->Mode; - DDBPalette = pDC->ppdev->DevInfo.hpalDefault; PALETTE_UnlockPalette(pDCPalette); DIBPalette = BuildDIBPalette(bmi, (PINT)&DIBPaletteType);