X-Git-Url: http://git.jankratochvil.net/?p=reactos.git;a=blobdiff_plain;f=subsys%2Fwin32k%2Fdib%2Fdib8bpp.c;fp=subsys%2Fwin32k%2Fdib%2Fdib8bpp.c;h=a3fa91aef7f739c365fd1a275649f5a91cbfc467;hp=84bd38cc0594cdbbeec35b401e40d2041ef55b72;hb=7c0cf90e3b750f1f0dc83b2eec9e5c68a512c30f;hpb=ee8b63255465d8c28be3e7bd11628015708fc1ab diff --git a/subsys/win32k/dib/dib8bpp.c b/subsys/win32k/dib/dib8bpp.c index 84bd38c..a3fa91a 100644 --- a/subsys/win32k/dib/dib8bpp.c +++ b/subsys/win32k/dib/dib8bpp.c @@ -1,3 +1,22 @@ +/* + * ReactOS W32 Subsystem + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id$ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -8,21 +27,24 @@ #include "../eng/objects.h" #include "dib.h" -VOID DIB_8BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c) +VOID +DIB_8BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c) { PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta + x; *byteaddr = c; } -ULONG DIB_8BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y) +ULONG +DIB_8BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y) { PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta + x; return (ULONG)(*byteaddr); } -VOID DIB_8BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c) +VOID +DIB_8BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c) { PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta; PBYTE addr = byteaddr + x1; @@ -35,7 +57,8 @@ VOID DIB_8BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c) } } -VOID DIB_8BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c) +VOID +DIB_8BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c) { PBYTE byteaddr = SurfObj->pvScan0 + y1 * SurfObj->lDelta; PBYTE addr = byteaddr + x; @@ -49,12 +72,13 @@ VOID DIB_8BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c) } } -BOOLEAN DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, - SURFGDI *DestGDI, SURFGDI *SourceGDI, - PRECTL DestRect, POINTL *SourcePoint, - XLATEOBJ *ColorTranslation) +BOOLEAN +DIB_8BPP_BitBltSrcCopy(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, + SURFGDI *DestGDI, SURFGDI *SourceGDI, + PRECTL DestRect, POINTL *SourcePoint, + XLATEOBJ *ColorTranslation) { - ULONG i, j, sx, sy, xColor, f1; + LONG i, j, sx, sy, xColor, f1; PBYTE SourceBits, DestBits, SourceLine, DestLine; PBYTE SourceBits_4BPP, SourceLine_4BPP; @@ -108,19 +132,62 @@ BOOLEAN DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, case 8: if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL)) { - SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x; - for (j = DestRect->top; j < DestRect->bottom; j++) - { - RtlCopyMemory(DestBits, SourceBits, DestRect->right - DestRect->left); - SourceBits += SourceSurf->lDelta; - DestBits += DestSurf->lDelta; - } + if (DestRect->top < SourcePoint->y) + { + SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x; + for (j = DestRect->top; j < DestRect->bottom; j++) + { + RtlMoveMemory(DestBits, SourceBits, DestRect->right - DestRect->left); + SourceBits += SourceSurf->lDelta; + DestBits += DestSurf->lDelta; + } + } + else + { + SourceBits = SourceSurf->pvScan0 + ((SourcePoint->y + DestRect->bottom - DestRect->top - 1) * SourceSurf->lDelta) + SourcePoint->x; + DestBits = DestSurf->pvScan0 + ((DestRect->bottom - 1) * DestSurf->lDelta) + DestRect->left; + for (j = DestRect->bottom - 1; DestRect->top <= j; j--) + { + RtlMoveMemory(DestBits, SourceBits, DestRect->right - DestRect->left); + SourceBits -= SourceSurf->lDelta; + DestBits -= DestSurf->lDelta; + } + } } else { - /* FIXME */ - DPRINT1("DIB_8BPP_Bitblt: Unhandled ColorTranslation for 32 -> 32 copy"); - return FALSE; + if (DestRect->top < SourcePoint->y) + { + SourceLine = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x; + DestLine = DestBits; + for (j = DestRect->top; j < DestRect->bottom; j++) + { + SourceBits = SourceLine; + DestBits = DestLine; + for (i=DestRect->left; iright; i++) + { + *DestBits++ = XLATEOBJ_iXlate(ColorTranslation, *SourceBits++); + } + SourceLine += SourceSurf->lDelta; + DestLine += DestSurf->lDelta; + } + } + else + { + SourceLine = SourceSurf->pvScan0 + ((SourcePoint->y + DestRect->bottom - DestRect->top - 1) * SourceSurf->lDelta) + SourcePoint->x; + DestLine = DestSurf->pvScan0 + ((DestRect->bottom - 1) * DestSurf->lDelta) + DestRect->left; + for (j = DestRect->bottom - 1; DestRect->top <= j; j--) + { + SourceBits = SourceLine; + DestBits = DestLine; + for (i=DestRect->left; iright; i++) + { + *DestBits++ = XLATEOBJ_iXlate(ColorTranslation, *SourceBits++); + } + SourceLine -= SourceSurf->lDelta; + DestLine -= DestSurf->lDelta; + } + } } break; @@ -199,3 +266,78 @@ BOOLEAN DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, return TRUE; } + +BOOLEAN +DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, + SURFGDI *DestGDI, SURFGDI *SourceGDI, + PRECTL DestRect, POINTL *SourcePoint, + PBRUSHOBJ Brush, PPOINTL BrushOrigin, + XLATEOBJ *ColorTranslation, ULONG Rop4) +{ + LONG i, j, k, sx, sy; + ULONG Dest, Source, Pattern; + PULONG DestBits; + BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); + BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); + LONG RoundedRight = DestRect->right - (DestRect->right & 0x3); + + if (Rop4 == SRCCOPY) + { + return(DIB_8BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); + } + else + { + sy = SourcePoint->y; + + for (j=DestRect->top; jbottom; j++) + { + sx = SourcePoint->x; + DestBits = (PULONG)(DestSurf->pvScan0 + DestRect->left + j * DestSurf->lDelta); + for (i=DestRect->left; iiSolidColor & 0xFF) | + ((Brush->iSolidColor & 0xFF) << 8) | + ((Brush->iSolidColor & 0xFF) << 16) | + ((Brush->iSolidColor & 0xFF) << 24); + } + *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); + } + if (i < DestRect->right) + { + Dest = *DestBits; + for (; i < DestRect->right; i++) + { + if (UsesSource) + { + Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation); + } + if (UsesPattern) + { + /* FIXME: No support for pattern brushes. */ + Pattern = (Brush->iSolidColor & 0xFF) | + ((Brush->iSolidColor & 0xFF) << 8) | + ((Brush->iSolidColor & 0xFF) << 16) | + ((Brush->iSolidColor & 0xFF) << 24); + } + DIB_8BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xFFFF); + Dest >>= 8; + } + } + } + } + return TRUE; +} + +/* EOF */