ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
February 2011
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
18 participants
352 discussions
Start a n
N
ew thread
[jgardou] 50940: [FORMATTING] fix dibobj.c, to please pigglesworth
by jgardou@svn.reactos.org
Author: jgardou Date: Mon Feb 28 23:46:02 2011 New Revision: 50940 URL:
http://svn.reactos.org/svn/reactos?rev=50940&view=rev
Log: [FORMATTING] fix dibobj.c, to please pigglesworth Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c 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] Mon Feb 28 23:46:02 2011 @@ -22,8 +22,9 @@ #define NDEBUG #include <debug.h> -static const RGBQUAD EGAColorsQuads[16] = { -/* rgbBlue, rgbGreen, rgbRed, rgbReserved */ +static const RGBQUAD EGAColorsQuads[16] = +{ + /* rgbBlue, rgbGreen, rgbRed, rgbReserved */ { 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x80, 0x00 }, { 0x00, 0x80, 0x00, 0x00 }, @@ -42,8 +43,9 @@ { 0xff, 0xff, 0xff, 0x00 } }; -static const RGBTRIPLE EGAColorsTriples[16] = { -/* rgbBlue, rgbGreen, rgbRed */ +static const RGBTRIPLE EGAColorsTriples[16] = +{ + /* rgbBlue, rgbGreen, rgbRed */ { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x80 }, { 0x00, 0x80, 0x00 }, @@ -62,8 +64,9 @@ { 0xff, 0xff, 0xff } }; -static const RGBQUAD DefLogPaletteQuads[20] = { /* Copy of Default Logical Palette */ -/* rgbBlue, rgbGreen, rgbRed, rgbReserved */ +static const RGBQUAD DefLogPaletteQuads[20] = /* Copy of Default Logical Palette */ +{ + /* rgbBlue, rgbGreen, rgbRed, rgbReserved */ { 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x80, 0x00 }, { 0x00, 0x80, 0x00, 0x00 }, @@ -86,8 +89,9 @@ { 0xff, 0xff, 0xff, 0x00 } }; -static const RGBQUAD DefLogPaletteTriples[20] = { /* Copy of Default Logical Palette */ -/* rgbBlue, rgbGreen, rgbRed, rgbReserved */ +static const RGBQUAD DefLogPaletteTriples[20] = /* Copy of Default Logical Palette */ +{ + /* rgbBlue, rgbGreen, rgbRed, rgbReserved */ { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x80 }, { 0x00, 0x80, 0x00 }, @@ -163,8 +167,8 @@ PalGDI = PALETTE_LockPalette(psurf->ppal->BaseObject.hHmgr); for (Index = StartIndex; - Index < StartIndex + Entries && Index < PalGDI->NumColors; - Index++) + Index < StartIndex + Entries && Index < PalGDI->NumColors; + Index++) { PalGDI->IndexedColors[Index].peRed = Colors[Index - StartIndex].rgbRed; PalGDI->IndexedColors[Index].peGreen = Colors[Index - StartIndex].rgbGreen; @@ -225,8 +229,8 @@ { for (Index = StartIndex; - Index < StartIndex + Entries && Index < ppal->NumColors; - Index++) + Index < StartIndex + Entries && Index < ppal->NumColors; + Index++) { Colors[Index - StartIndex].rgbRed = ppal->IndexedColors[Index].peRed; Colors[Index - StartIndex].rgbGreen = ppal->IndexedColors[Index].peGreen; @@ -254,66 +258,66 @@ UINT ColorUse) { HBITMAP SourceBitmap; - PSURFACE psurfDst, psurfSrc; + PSURFACE psurfDst, psurfSrc; INT result = 0; - RECT rcDst; - POINTL ptSrc; - PVOID pvBits; - EXLATEOBJ exlo; + RECT rcDst; + POINTL ptSrc; + PVOID pvBits; + EXLATEOBJ exlo; SourceBitmap = DIB_CreateDIBSection(DC, bmi, ColorUse, &pvBits, NULL, 0, 0); - if (0 == SourceBitmap) - { - DPRINT1("Error : Could not create a DIBSection.\n"); + if (0 == SourceBitmap) + { + DPRINT1("Error : Could not create a DIBSection.\n"); EngSetLastError(ERROR_NO_SYSTEM_RESOURCES); return 0; } - RtlCopyMemory(pvBits, Bits, DIB_GetDIBImageBytes(bmi->bmiHeader.biWidth, - bmi->bmiHeader.biHeight, - bmi->bmiHeader.biBitCount)); - - psurfDst = SURFACE_LockSurface(hBitmap); - psurfSrc = SURFACE_LockSurface(SourceBitmap); - - if(!(psurfSrc && psurfDst)) - { - DPRINT1("Error, could not lock surfaces\n"); - goto cleanup; - } - - rcDst.top = bmi->bmiHeader.biHeight < 0 ? - abs(bmi->bmiHeader.biHeight) - (ScanLines + StartScan) : StartScan; - rcDst.left = 0; - rcDst.bottom = rcDst.top + ScanLines; - rcDst.right = psurfDst->SurfObj.sizlBitmap.cx; - - ptSrc.x = 0; - ptSrc.y = 0; - - EXLATEOBJ_vInitialize(&exlo, psurfSrc->ppal, psurfDst->ppal, 0, 0, 0); - - result = IntEngCopyBits(&psurfDst->SurfObj, - &psurfSrc->SurfObj, - NULL, - &exlo.xlo, - &rcDst, - &ptSrc); - if(result) - result = ScanLines; - - EXLATEOBJ_vCleanup(&exlo); + RtlCopyMemory(pvBits, Bits, DIB_GetDIBImageBytes(bmi->bmiHeader.biWidth, + bmi->bmiHeader.biHeight, + bmi->bmiHeader.biBitCount)); + + psurfDst = SURFACE_LockSurface(hBitmap); + psurfSrc = SURFACE_LockSurface(SourceBitmap); + + if(!(psurfSrc && psurfDst)) + { + DPRINT1("Error, could not lock surfaces\n"); + goto cleanup; + } + + rcDst.top = bmi->bmiHeader.biHeight < 0 ? + abs(bmi->bmiHeader.biHeight) - (ScanLines + StartScan) : StartScan; + rcDst.left = 0; + rcDst.bottom = rcDst.top + ScanLines; + rcDst.right = psurfDst->SurfObj.sizlBitmap.cx; + + ptSrc.x = 0; + ptSrc.y = 0; + + EXLATEOBJ_vInitialize(&exlo, psurfSrc->ppal, psurfDst->ppal, 0, 0, 0); + + result = IntEngCopyBits(&psurfDst->SurfObj, + &psurfSrc->SurfObj, + NULL, + &exlo.xlo, + &rcDst, + &ptSrc); + if(result) + result = ScanLines; + + EXLATEOBJ_vCleanup(&exlo); cleanup: - if(psurfSrc) - { - SURFACE_UnlockSurface(psurfSrc); - } - if(psurfDst) - { - SURFACE_UnlockSurface(psurfDst); - } - GreDeleteObject(SourceBitmap); + if(psurfSrc) + { + SURFACE_UnlockSurface(psurfSrc); + } + if(psurfDst) + { + SURFACE_UnlockSurface(psurfDst); + } + GreDeleteObject(SourceBitmap); return result; } @@ -341,13 +345,13 @@ _SEH2_TRY { ProbeForRead(&bmi->bmiHeader.biSize, sizeof(DWORD), 1); - ProbeForRead(bmi, bmi->bmiHeader.biSize, 1); - ProbeForRead(bmi, DIB_BitmapInfoSize(bmi, ColorUse), 1); + ProbeForRead(bmi, bmi->bmiHeader.biSize, 1); + ProbeForRead(bmi, DIB_BitmapInfoSize(bmi, ColorUse), 1); ProbeForRead(Bits, - DIB_GetDIBImageBytes(bmi->bmiHeader.biWidth, - ScanLines, - bmi->bmiHeader.biBitCount), - 1); + DIB_GetDIBImageBytes(bmi->bmiHeader.biWidth, + ScanLines, + bmi->bmiHeader.biBitCount), + 1); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -473,7 +477,7 @@ hSourceBitmap = EngCreateBitmap(SourceSize, DIBWidth, BitmapFormat(bmi->bmiHeader.biBitCount, - bmi->bmiHeader.biCompression), + bmi->bmiHeader.biCompression), bmi->bmiHeader.biHeight < 0 ? BMF_TOPDOWN : 0, (PVOID) Bits); if (!hSourceBitmap) @@ -515,8 +519,8 @@ /* Copy the bits */ DPRINT("BitsToDev with dstsurf=(%d|%d) (%d|%d), src=(%d|%d) w=%d h=%d\n", - rcDest.left, rcDest.top, rcDest.right, rcDest.bottom, - ptSource.x, ptSource.y, SourceSize.cx, SourceSize.cy); + rcDest.left, rcDest.top, rcDest.right, rcDest.bottom, + ptSource.x, ptSource.y, SourceSize.cx, SourceSize.cy); Status = IntEngBitBlt(pDestSurf, pSourceSurf, NULL, @@ -563,17 +567,17 @@ UINT MaxBits, UINT MaxInfo) { - BITMAPCOREINFO* pbmci = NULL; - PSURFACE psurf = NULL; - PDC pDC; - LONG width, height; - WORD planes, bpp; - DWORD compr, size ; - int i, bitmap_type; - RGBTRIPLE* rgbTriples; - RGBQUAD* rgbQuads; - VOID* colorPtr; - NTSTATUS Status = STATUS_SUCCESS; + BITMAPCOREINFO* pbmci = NULL; + PSURFACE psurf = NULL; + PDC pDC; + LONG width, height; + WORD planes, bpp; + DWORD compr, size ; + int i, bitmap_type; + RGBTRIPLE* rgbTriples; + RGBQUAD* rgbQuads; + VOID* colorPtr; + NTSTATUS Status = STATUS_SUCCESS; DPRINT("Entered NtGdiGetDIBitsInternal()\n"); @@ -582,9 +586,9 @@ _SEH2_TRY { - /* Probe for read and write */ + /* Probe for read and write */ ProbeForRead(Info, MaxInfo, 1); - ProbeForWrite(Info, MaxInfo, 1); + ProbeForWrite(Info, MaxInfo, 1); if (Bits) ProbeForWrite(Bits, MaxBits, 1); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) @@ -598,41 +602,41 @@ return 0; } - colorPtr = (LPBYTE)Info + Info->bmiHeader.biSize; - rgbTriples = colorPtr; - rgbQuads = colorPtr; - - bitmap_type = DIB_GetBitmapInfo(&Info->bmiHeader, - &width, - &height, - &planes, - &bpp, - &compr, - &size); - if(bitmap_type == -1) - { - DPRINT("Wrong bitmap format\n"); - EngSetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - else if(bitmap_type == 0) - { - /* We need a BITMAPINFO to create a DIB, but we have to fill - * the BITMAPCOREINFO we're provided */ - pbmci = (BITMAPCOREINFO*)Info; - Info = DIB_ConvertBitmapInfo((BITMAPINFO*)pbmci, Usage); - if(Info == NULL) - { - DPRINT1("Error, could not convert the BITMAPCOREINFO!\n"); - return 0; - } - rgbQuads = Info->bmiColors; - } + colorPtr = (LPBYTE)Info + Info->bmiHeader.biSize; + rgbTriples = colorPtr; + rgbQuads = colorPtr; + + bitmap_type = DIB_GetBitmapInfo(&Info->bmiHeader, + &width, + &height, + &planes, + &bpp, + &compr, + &size); + if(bitmap_type == -1) + { + DPRINT("Wrong bitmap format\n"); + EngSetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + else if(bitmap_type == 0) + { + /* We need a BITMAPINFO to create a DIB, but we have to fill + * the BITMAPCOREINFO we're provided */ + pbmci = (BITMAPCOREINFO*)Info; + Info = DIB_ConvertBitmapInfo((BITMAPINFO*)pbmci, Usage); + if(Info == NULL) + { + DPRINT1("Error, could not convert the BITMAPCOREINFO!\n"); + return 0; + } + rgbQuads = Info->bmiColors; + } pDC = DC_LockDc(hDC); if (pDC == NULL || pDC->dctype == DC_TYPE_INFO) { - ScanLines = 0; + ScanLines = 0; goto done; } @@ -644,117 +648,119 @@ goto done; } - /* Fill in the structure */ - switch(bpp) - { - case 0: /* Only info */ - if(pbmci) - { - pbmci->bmciHeader.bcWidth = psurf->SurfObj.sizlBitmap.cx; - pbmci->bmciHeader.bcHeight = (psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ? - -psurf->SurfObj.sizlBitmap.cy : - psurf->SurfObj.sizlBitmap.cy; - pbmci->bmciHeader.bcPlanes = 1; - pbmci->bmciHeader.bcBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat); - } - Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx; - Info->bmiHeader.biHeight = (psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ? - -psurf->SurfObj.sizlBitmap.cy : - psurf->SurfObj.sizlBitmap.cy;; - Info->bmiHeader.biPlanes = 1; - Info->bmiHeader.biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat); - Info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes( Info->bmiHeader.biWidth, - Info->bmiHeader.biHeight, - Info->bmiHeader.biBitCount); - if(psurf->hSecure) - { - switch(Info->bmiHeader.biBitCount) - { - case 16: - case 32: - Info->bmiHeader.biCompression = BI_BITFIELDS; - break; - default: - Info->bmiHeader.biCompression = BI_RGB; - break; - } - } - else if(Info->bmiHeader.biBitCount > 8) - { - Info->bmiHeader.biCompression = BI_BITFIELDS; - } - else - { - Info->bmiHeader.biCompression = BI_RGB; - } - Info->bmiHeader.biXPelsPerMeter = 0; + /* Fill in the structure */ + switch(bpp) + { + case 0: /* Only info */ + if(pbmci) + { + pbmci->bmciHeader.bcWidth = psurf->SurfObj.sizlBitmap.cx; + pbmci->bmciHeader.bcHeight = (psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ? + -psurf->SurfObj.sizlBitmap.cy : + psurf->SurfObj.sizlBitmap.cy; + pbmci->bmciHeader.bcPlanes = 1; + pbmci->bmciHeader.bcBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat); + } + Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx; + Info->bmiHeader.biHeight = (psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ? + -psurf->SurfObj.sizlBitmap.cy : + psurf->SurfObj.sizlBitmap.cy;; + Info->bmiHeader.biPlanes = 1; + Info->bmiHeader.biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat); + Info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes( Info->bmiHeader.biWidth, + Info->bmiHeader.biHeight, + Info->bmiHeader.biBitCount); + if(psurf->hSecure) + { + switch(Info->bmiHeader.biBitCount) + { + case 16: + case 32: + Info->bmiHeader.biCompression = BI_BITFIELDS; + break; + default: + Info->bmiHeader.biCompression = BI_RGB; + break; + } + } + else if(Info->bmiHeader.biBitCount > 8) + { + Info->bmiHeader.biCompression = BI_BITFIELDS; + } + else + { + Info->bmiHeader.biCompression = BI_RGB; + } + Info->bmiHeader.biXPelsPerMeter = 0; Info->bmiHeader.biYPelsPerMeter = 0; Info->bmiHeader.biClrUsed = 0; Info->bmiHeader.biClrImportant = 0; - ScanLines = abs(Info->bmiHeader.biHeight); - goto done; - - case 1: - case 4: - case 8: - Info->bmiHeader.biClrUsed = 0; - - /* If the bitmap if a DIB section and has the same format than what - * we're asked, go ahead! */ - if((psurf->hSecure) && - (BitsPerFormat(psurf->SurfObj.iBitmapFormat) == bpp)) - { - if(Usage == DIB_RGB_COLORS) - { - unsigned int colors = min(psurf->ppal->NumColors, 1 << bpp); - - if(pbmci) - { - for(i=0; i < colors; i++) - { - rgbTriples[i].rgbtRed = psurf->ppal->IndexedColors[i].peRed; - rgbTriples[i].rgbtGreen = psurf->ppal->IndexedColors[i].peGreen; - rgbTriples[i].rgbtBlue = psurf->ppal->IndexedColors[i].peBlue; - } - } - if(colors != 1 << bpp) Info->bmiHeader.biClrUsed = colors; - for(i=0; i < colors; i++) - { - rgbQuads[i].rgbRed = psurf->ppal->IndexedColors[i].peRed; - rgbQuads[i].rgbGreen = psurf->ppal->IndexedColors[i].peGreen; - rgbQuads[i].rgbBlue = psurf->ppal->IndexedColors[i].peBlue; - } - } - else - { - for(i=0; i < 1 << bpp; i++) - { - if(pbmci) ((WORD*)rgbTriples)[i] = i; - ((WORD*)rgbQuads)[i] = i; - } - } - } - else - { - if(Usage == DIB_PAL_COLORS) - { - for(i=0; i < 1 << bpp; i++) - { - if(pbmci) ((WORD*)rgbTriples)[i] = i; - ((WORD*)rgbQuads)[i] = i; - } - } - else if(bpp > 1 && bpp == BitsPerFormat(psurf->SurfObj.iBitmapFormat)) { + ScanLines = abs(Info->bmiHeader.biHeight); + goto done; + + case 1: + case 4: + case 8: + Info->bmiHeader.biClrUsed = 0; + + /* If the bitmap if a DIB section and has the same format than what + * we're asked, go ahead! */ + if((psurf->hSecure) && + (BitsPerFormat(psurf->SurfObj.iBitmapFormat) == bpp)) + { + if(Usage == DIB_RGB_COLORS) + { + unsigned int colors = min(psurf->ppal->NumColors, 1 << bpp); + + if(pbmci) + { + for(i=0; i < colors; i++) + { + rgbTriples[i].rgbtRed = psurf->ppal->IndexedColors[i].peRed; + rgbTriples[i].rgbtGreen = psurf->ppal->IndexedColors[i].peGreen; + rgbTriples[i].rgbtBlue = psurf->ppal->IndexedColors[i].peBlue; + } + } + if(colors != 1 << bpp) Info->bmiHeader.biClrUsed = colors; + for(i=0; i < colors; i++) + { + rgbQuads[i].rgbRed = psurf->ppal->IndexedColors[i].peRed; + rgbQuads[i].rgbGreen = psurf->ppal->IndexedColors[i].peGreen; + rgbQuads[i].rgbBlue = psurf->ppal->IndexedColors[i].peBlue; + } + } + else + { + for(i=0; i < 1 << bpp; i++) + { + if(pbmci) ((WORD*)rgbTriples)[i] = i; + ((WORD*)rgbQuads)[i] = i; + } + } + } + else + { + if(Usage == DIB_PAL_COLORS) + { + for(i=0; i < 1 << bpp; i++) + { + if(pbmci) ((WORD*)rgbTriples)[i] = i; + ((WORD*)rgbQuads)[i] = i; + } + } + else if(bpp > 1 && bpp == BitsPerFormat(psurf->SurfObj.iBitmapFormat)) + { /* For color DDBs in native depth (mono DDBs always have a black/white palette): Generate the color map from the selected palette */ PPALETTE pDcPal = PALETTE_LockPalette(pDC->dclevel.hpal); - if(!pDcPal) - { - ScanLines = 0 ; - goto done ; - } - for (i = 0; i < pDcPal->NumColors; i++) { + if(!pDcPal) + { + ScanLines = 0 ; + goto done ; + } + for (i = 0; i < pDcPal->NumColors; i++) + { if (pbmci) { rgbTriples[i].rgbtRed = pDcPal->IndexedColors[i].peRed; @@ -766,23 +772,26 @@ rgbQuads[i].rgbGreen = pDcPal->IndexedColors[i].peGreen; rgbQuads[i].rgbBlue = pDcPal->IndexedColors[i].peBlue; rgbQuads[i].rgbReserved = 0; - } - PALETTE_UnlockPalette(pDcPal); - } else { - switch (bpp) { + } + PALETTE_UnlockPalette(pDcPal); + } + else + { + switch (bpp) + { case 1: if (pbmci) { rgbTriples[0].rgbtRed = rgbTriples[0].rgbtGreen = - rgbTriples[0].rgbtBlue = 0; + rgbTriples[0].rgbtBlue = 0; rgbTriples[1].rgbtRed = rgbTriples[1].rgbtGreen = - rgbTriples[1].rgbtBlue = 0xff; + rgbTriples[1].rgbtBlue = 0xff; } rgbQuads[0].rgbRed = rgbQuads[0].rgbGreen = - rgbQuads[0].rgbBlue = 0; + rgbQuads[0].rgbBlue = 0; rgbQuads[0].rgbReserved = 0; rgbQuads[1].rgbRed = rgbQuads[1].rgbGreen = - rgbQuads[1].rgbBlue = 0xff; + rgbQuads[1].rgbBlue = 0xff; rgbQuads[1].rgbReserved = 0; break; @@ -794,52 +803,52 @@ break; case 8: + { + INT r, g, b; + RGBQUAD *color; + if (pbmci) { - INT r, g, b; - RGBQUAD *color; - if (pbmci) + RGBTRIPLE *colorTriple; + + RtlCopyMemory(rgbTriples, DefLogPaletteTriples, + 10 * sizeof(RGBTRIPLE)); + RtlCopyMemory(rgbTriples + 246, DefLogPaletteTriples + 10, + 10 * sizeof(RGBTRIPLE)); + colorTriple = rgbTriples + 10; + for(r = 0; r <= 5; r++) /* FIXME */ { - RGBTRIPLE *colorTriple; - - RtlCopyMemory(rgbTriples, DefLogPaletteTriples, - 10 * sizeof(RGBTRIPLE)); - RtlCopyMemory(rgbTriples + 246, DefLogPaletteTriples + 10, - 10 * sizeof(RGBTRIPLE)); - colorTriple = rgbTriples + 10; - for(r = 0; r <= 5; r++) /* FIXME */ - { - for(g = 0; g <= 5; g++) - { - for(b = 0; b <= 5; b++) - { - colorTriple->rgbtRed = (r * 0xff) / 5; - colorTriple->rgbtGreen = (g * 0xff) / 5; - colorTriple->rgbtBlue = (b * 0xff) / 5; - color++; - } - } - } - } - memcpy(rgbQuads, DefLogPaletteQuads, - 10 * sizeof(RGBQUAD)); - memcpy(rgbQuads + 246, DefLogPaletteQuads + 10, - 10 * sizeof(RGBQUAD)); - color = rgbQuads + 10; - for(r = 0; r <= 5; r++) /* FIXME */ - { for(g = 0; g <= 5; g++) - { + { for(b = 0; b <= 5; b++) - { - color->rgbRed = (r * 0xff) / 5; - color->rgbGreen = (g * 0xff) / 5; - color->rgbBlue = (b * 0xff) / 5; - color->rgbReserved = 0; + { + colorTriple->rgbtRed = (r * 0xff) / 5; + colorTriple->rgbtGreen = (g * 0xff) / 5; + colorTriple->rgbtBlue = (b * 0xff) / 5; color++; } - } - } + } + } } + memcpy(rgbQuads, DefLogPaletteQuads, + 10 * sizeof(RGBQUAD)); + memcpy(rgbQuads + 246, DefLogPaletteQuads + 10, + 10 * sizeof(RGBQUAD)); + color = rgbQuads + 10; + for(r = 0; r <= 5; r++) /* FIXME */ + { + for(g = 0; g <= 5; g++) + { + for(b = 0; b <= 5; b++) + { + color->rgbRed = (r * 0xff) / 5; + color->rgbGreen = (g * 0xff) / 5; + color->rgbBlue = (b * 0xff) / 5; + color->rgbReserved = 0; + color++; + } + } + } + } } } } @@ -858,11 +867,11 @@ if (Info->bmiHeader.biCompression == BI_BITFIELDS) { if (psurf->hSecure) - { - ((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask; + { + ((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask; ((PDWORD)Info->bmiColors)[1] = psurf->ppal->GreenMask; ((PDWORD)Info->bmiColors)[2] = psurf->ppal->BlueMask; - } + } else { ((PDWORD)Info->bmiColors)[0] = 0xf800; @@ -877,11 +886,11 @@ if (Info->bmiHeader.biCompression == BI_BITFIELDS) { if (psurf->hSecure) - { - ((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask; + { + ((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask; ((PDWORD)Info->bmiColors)[1] = psurf->ppal->GreenMask; ((PDWORD)Info->bmiColors)[2] = psurf->ppal->BlueMask; - } + } else { ((PDWORD)Info->bmiColors)[0] = 0xff0000; @@ -891,53 +900,53 @@ } break; } - Info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes(width, height, bpp); - - if(Bits && ScanLines) - { - /* Create a DIBSECTION, blt it, profit */ - PVOID pDIBits ; - HBITMAP hBmpDest; - PSURFACE psurfDest; - EXLATEOBJ exlo; - RECT rcDest; - POINTL srcPoint; - BOOL ret ; - - if (StartScan > psurf->SurfObj.sizlBitmap.cy) - { - ScanLines = 0; + Info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes(width, height, bpp); + + if(Bits && ScanLines) + { + /* Create a DIBSECTION, blt it, profit */ + PVOID pDIBits ; + HBITMAP hBmpDest; + PSURFACE psurfDest; + EXLATEOBJ exlo; + RECT rcDest; + POINTL srcPoint; + BOOL ret ; + + if (StartScan > psurf->SurfObj.sizlBitmap.cy) + { + ScanLines = 0; goto done; } else { 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) - { - DPRINT1("Unable to create a DIB Section!\n"); - EngSetLastError(ERROR_INVALID_PARAMETER); - ScanLines = 0; - goto done ; - } - - psurfDest = SURFACE_ShareLockSurface(hBmpDest); - - rcDest.left = 0; - rcDest.top = 0; - rcDest.bottom = ScanLines; - rcDest.right = psurf->SurfObj.sizlBitmap.cx; + } + + /* 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) + { + DPRINT1("Unable to create a DIB Section!\n"); + EngSetLastError(ERROR_INVALID_PARAMETER); + ScanLines = 0; + goto done ; + } + + psurfDest = SURFACE_ShareLockSurface(hBmpDest); + + rcDest.left = 0; + rcDest.top = 0; + rcDest.bottom = ScanLines; + rcDest.right = psurf->SurfObj.sizlBitmap.cx; srcPoint.x = 0; @@ -960,51 +969,51 @@ srcPoint.y = StartScan; } - EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0xffffff, 0xffffff, 0); - - ret = IntEngCopyBits(&psurfDest->SurfObj, - &psurf->SurfObj, - NULL, - &exlo.xlo, - &rcDest, - &srcPoint); + EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0xffffff, 0xffffff, 0); + + ret = IntEngCopyBits(&psurfDest->SurfObj, + &psurf->SurfObj, + NULL, + &exlo.xlo, + &rcDest, + &srcPoint); SURFACE_ShareUnlockSurface(psurfDest); - if(!ret) - ScanLines = 0; - else - { - Status = STATUS_SUCCESS; - _SEH2_TRY - { - RtlCopyMemory(Bits, pDIBits, DIB_GetDIBImageBytes (width, ScanLines, bpp)); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END - - if(!NT_SUCCESS(Status)) - { - DPRINT1("Unable to copy bits to the user provided pointer\n"); - ScanLines = 0; - } - } - - GreDeleteObject(hBmpDest); - EXLATEOBJ_vCleanup(&exlo); - } - else ScanLines = abs(height); + if(!ret) + ScanLines = 0; + else + { + Status = STATUS_SUCCESS; + _SEH2_TRY + { + RtlCopyMemory(Bits, pDIBits, DIB_GetDIBImageBytes (width, ScanLines, bpp)); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END + + if(!NT_SUCCESS(Status)) + { + DPRINT1("Unable to copy bits to the user provided pointer\n"); + ScanLines = 0; + } + } + + GreDeleteObject(hBmpDest); + EXLATEOBJ_vCleanup(&exlo); + } + else ScanLines = abs(height); done: - if(pDC) DC_UnlockDc(pDC); - if(psurf) SURFACE_ShareUnlockSurface(psurf); - if(pbmci) DIB_FreeConvertedBitmapInfo(Info, (BITMAPINFO*)pbmci); - - return ScanLines; + if(pDC) DC_UnlockDc(pDC); + if(psurf) SURFACE_ShareUnlockSurface(psurf); + if(pbmci) DIB_FreeConvertedBitmapInfo(Info, (BITMAPINFO*)pbmci); + + return ScanLines; } @@ -1084,17 +1093,17 @@ } if (XDest == 0 && YDest == 0 && XSrc == 0 && XSrc == 0 && - DestWidth == SrcWidth && DestHeight == SrcHeight && - compr == BI_RGB && - ROP == SRCCOPY) + DestWidth == SrcWidth && DestHeight == SrcHeight && + compr == BI_RGB && + ROP == SRCCOPY) { BITMAP bmp; ret = IntGdiGetObject(hBitmap, sizeof(bmp), &bmp) == sizeof(bmp); if (ret && - bmp.bmBitsPixel == bpp && - bmp.bmWidth == SrcWidth && - bmp.bmHeight == SrcHeight && - bmp.bmPlanes == planes) + bmp.bmBitsPixel == bpp && + bmp.bmWidth == SrcWidth && + bmp.bmHeight == SrcHeight && + bmp.bmPlanes == planes) { /* fast path */ ret = IntSetDIBits(pdc, hBitmap, 0, height, safeBits, BitsInfo, Usage); @@ -1122,8 +1131,8 @@ /* Origin for DIBitmap may be bottom left (positive biHeight) or top left (negative biHeight) */ ret = NtGdiStretchBlt(hDC, XDest, YDest, DestWidth, DestHeight, - hdcMem, XSrc, abs(height) - SrcHeight - YSrc, - SrcWidth, SrcHeight, ROP, 0); + hdcMem, XSrc, abs(height) - SrcHeight - YSrc, + SrcWidth, SrcHeight, ROP, 0); if(ret) ret = SrcHeight; @@ -1217,27 +1226,27 @@ IN HANDLE hcmXform) { NTSTATUS Status = STATUS_SUCCESS; - PBYTE safeBits = NULL; - HBITMAP hbmResult = NULL; - - if(pjInit && (fInit == CBM_INIT)) - { - safeBits = ExAllocatePoolWithTag(PagedPool, cjMaxBits, TAG_DIB); - if(!safeBits) - { - EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); - return NULL; - } - } + PBYTE safeBits = NULL; + HBITMAP hbmResult = NULL; + + if(pjInit && (fInit == CBM_INIT)) + { + safeBits = ExAllocatePoolWithTag(PagedPool, cjMaxBits, TAG_DIB); + if(!safeBits) + { + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); + return NULL; + } + } _SEH2_TRY { if(pbmi) ProbeForRead(pbmi, cjMaxInitInfo, 1); if(pjInit && (fInit == CBM_INIT)) - { - ProbeForRead(pjInit, cjMaxBits, 1); - RtlCopyMemory(safeBits, pjInit, cjMaxBits); - } + { + ProbeForRead(pjInit, cjMaxBits, 1); + RtlCopyMemory(safeBits, pjInit, cjMaxBits); + } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -1248,13 +1257,13 @@ if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - goto cleanup; + goto cleanup; } hbmResult = GreCreateDIBitmapInternal(hDc, - cx, - cy, - fInit, + cx, + cy, + fInit, safeBits, pbmi, iUsage, @@ -1262,8 +1271,8 @@ hcmXform); cleanup: - if (safeBits) ExFreePoolWithTag(safeBits, TAG_DIB); - return hbmResult; + if (safeBits) ExFreePoolWithTag(safeBits, TAG_DIB); + return hbmResult; } HBITMAP @@ -1285,7 +1294,8 @@ HDC hdcDest; if (!hDc) /* 1bpp monochrome bitmap */ - { // Should use System Bitmap DC hSystemBM, with CreateCompatibleDC for this. + { + // Should use System Bitmap DC hSystemBM, with CreateCompatibleDC for this. hdcDest = NtGdiCreateCompatibleDC(0); if(!hdcDest) { @@ -1336,15 +1346,15 @@ HBITMAP hbitmap = 0; DC *dc; BOOL bDesktopDC = FALSE; - NTSTATUS Status = STATUS_SUCCESS; + NTSTATUS Status = STATUS_SUCCESS; if (!bmi) return hbitmap; // Make sure. - _SEH2_TRY + _SEH2_TRY { ProbeForRead(&bmi->bmiHeader.biSize, sizeof(DWORD), 1); - ProbeForRead(bmi, bmi->bmiHeader.biSize, 1); - ProbeForRead(bmi, DIB_BitmapInfoSize(bmi, Usage), 1); + ProbeForRead(bmi, bmi->bmiHeader.biSize, 1); + ProbeForRead(bmi, DIB_BitmapInfoSize(bmi, Usage), 1); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -1483,7 +1493,7 @@ { offset = 0; bm.bmBits = EngAllocUserMem(totalSize, 0); - if(!bm.bmBits) goto cleanup; + if(!bm.bmBits) goto cleanup; } // hSecure = MmSecureVirtualMemory(bm.bmBits, totalSize, PAGE_READWRITE); @@ -1491,31 +1501,31 @@ if (usage == DIB_PAL_COLORS) { - if(dc) - { - PPALETTE pdcPal ; - pdcPal = PALETTE_LockPalette(dc->dclevel.hpal); - hpal = DIB_MapPaletteColors(pdcPal, bmi); - PALETTE_UnlockPalette(pdcPal); - } - else - { - /* For DIB Brushes */ - DPRINT1("FIXME : Unsupported DIB_PAL_COLORS without a DC to map colors.\n"); - /* HACK */ - hpal = (HPALETTE) 0xFFFFFFFF; - } + if(dc) + { + PPALETTE pdcPal ; + pdcPal = PALETTE_LockPalette(dc->dclevel.hpal); + hpal = DIB_MapPaletteColors(pdcPal, bmi); + PALETTE_UnlockPalette(pdcPal); + } + else + { + /* For DIB Brushes */ + DPRINT1("FIXME : Unsupported DIB_PAL_COLORS without a DC to map colors.\n"); + /* HACK */ + hpal = (HPALETTE) 0xFFFFFFFF; + } } else - { + { hpal = BuildDIBPalette(bmi); - } - - if(!hpal) - { - DPRINT1("Error : Could not create a palette for the DIB.\n"); - goto cleanup; - } + } + + if(!hpal) + { + DPRINT1("Error : Could not create a palette for the DIB.\n"); + goto cleanup; + } // Create Device Dependent Bitmap and add DIB pointer Size.cx = bm.bmWidth; @@ -1525,10 +1535,10 @@ bm.bmWidthBytes, BitmapFormat(bi->biBitCount * bi->biPlanes, bi->biCompression), BMF_DONTCACHE | BMF_USERMEM | BMF_NOZEROINIT | - (bi->biHeight < 0 ? BMF_TOPDOWN : 0), + (bi->biHeight < 0 ? BMF_TOPDOWN : 0), bi->biSizeImage, bm.bmBits, - 0); + 0); if (!res) { EngSetLastError(ERROR_NO_SYSTEM_RESOURCES); @@ -1537,7 +1547,7 @@ bmp = SURFACE_LockSurface(res); if (NULL == bmp) { - EngSetLastError(ERROR_INVALID_HANDLE); + EngSetLastError(ERROR_INVALID_HANDLE); goto cleanup; } @@ -1552,13 +1562,13 @@ bmp->biClrImportant = bi->biClrImportant; bmp->SurfObj.fjBitmap &= ~BMF_DONT_FREE; - /* HACK */ - if(hpal != (HPALETTE)0xFFFFFFFF) - { - bmp->ppal = PALETTE_ShareLockPalette(hpal); - /* Lazy delete hpal, it will be freed at surface release */ - GreDeleteObject(hpal); - } + /* HACK */ + if(hpal != (HPALETTE)0xFFFFFFFF) + { + bmp->ppal = PALETTE_ShareLockPalette(hpal); + /* Lazy delete hpal, it will be freed at surface release */ + GreDeleteObject(hpal); + } // Clean up in case of errors cleanup: @@ -1573,9 +1583,8 @@ ZwUnmapViewOfSection(NtCurrentProcess(), mapBits); bm.bmBits = NULL; } - else - if (!offset) - EngFreeUserMem(bm.bmBits), bm.bmBits = NULL; + else if (!offset) + EngFreeUserMem(bm.bmBits), bm.bmBits = NULL; } if (bmp) @@ -1611,7 +1620,7 @@ int FASTCALL DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width, - LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size ) + LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size ) { if (header->biSize == sizeof(BITMAPCOREHEADER)) { @@ -1666,7 +1675,7 @@ const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info; colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0; return sizeof(BITMAPCOREHEADER) + colors * - ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD)); + ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD)); } else /* assume BITMAPINFOHEADER */ { @@ -1687,7 +1696,7 @@ PALETTEENTRY* ppalEntries; ULONG nNumColors,i; USHORT *lpIndex; - HPALETTE hpal; + HPALETTE hpal; if (!(ppal->flFlags & PAL_INDEXED)) { @@ -1700,8 +1709,8 @@ nNumColors = min(nNumColors, lpbmi->bmiHeader.biClrUsed); } - /* Don't have more colors than we need */ - nNumColors = min(ppal->NumColors, nNumColors); + /* Don't have more colors than we need */ + nNumColors = min(ppal->NumColors, nNumColors); ppalEntries = ExAllocatePoolWithTag(PagedPool, sizeof(PALETTEENTRY) * nNumColors, TAG_COLORMAP); if (ppalEntries == NULL) @@ -1721,19 +1730,19 @@ else { ppalEntries[i].peRed = 0; - ppalEntries[i].peGreen = 0; - ppalEntries[i].peBlue = 0; - ppalEntries[i].peFlags = 0; + ppalEntries[i].peGreen = 0; + ppalEntries[i].peBlue = 0; + ppalEntries[i].peFlags = 0; } lpIndex++; } - hpal = PALETTE_AllocPalette(PAL_INDEXED, nNumColors, (ULONG*)ppalEntries, 0, 0, 0); - - ExFreePoolWithTag(ppalEntries, TAG_COLORMAP); - - return hpal; + hpal = PALETTE_AllocPalette(PAL_INDEXED, nNumColors, (ULONG*)ppalEntries, 0, 0, 0); + + ExFreePoolWithTag(ppalEntries, TAG_COLORMAP); + + return hpal; } HPALETTE @@ -1745,7 +1754,7 @@ HPALETTE hPal; ULONG RedMask = 0, GreenMask = 0, BlueMask = 0; PDWORD pdwColors = (PDWORD)((PBYTE)bmi + bmi->bmiHeader.biSize); - INT paletteType; + INT paletteType; // Determine Bits Per Pixel bits = bmi->bmiHeader.biBitCount; @@ -1778,20 +1787,20 @@ paletteType = PAL_BITFIELDS; switch (bits) { - case 16: - paletteType |= PAL_RGB16_555; - RedMask = 0x7C00; - GreenMask = 0x03E0; - BlueMask = 0x001F; - break; - - case 24: - case 32: - paletteType |= PAL_BGR; - RedMask = 0xFF0000; - GreenMask = 0x00FF00; - BlueMask = 0x0000FF; - break; + case 16: + paletteType |= PAL_RGB16_555; + RedMask = 0x7C00; + GreenMask = 0x03E0; + BlueMask = 0x001F; + break; + + case 24: + case 32: + paletteType |= PAL_BGR; + RedMask = 0xFF0000; + GreenMask = 0x00FF00; + BlueMask = 0x0000FF; + break; } } @@ -1824,62 +1833,62 @@ FASTCALL DIB_ConvertBitmapInfo (CONST BITMAPINFO* pbmi, DWORD Usage) { - CONST BITMAPCOREINFO* pbmci = (BITMAPCOREINFO*)pbmi; - BITMAPINFO* pNewBmi ; - UINT numColors = 0, ColorsSize = 0; - - if(pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) return (BITMAPINFO*)pbmi; - if(pbmi->bmiHeader.biSize != sizeof(BITMAPCOREHEADER)) return NULL; - - if(pbmci->bmciHeader.bcBitCount <= 8) - { - numColors = 1 << pbmci->bmciHeader.bcBitCount; - if(Usage == DIB_PAL_COLORS) - { - ColorsSize = numColors * sizeof(WORD); - } - else - { - ColorsSize = numColors * sizeof(RGBQUAD); - } - } - else if (Usage == DIB_PAL_COLORS) - { - /* Invalid at high Res */ - return NULL; - } - - pNewBmi = ExAllocatePoolWithTag(PagedPool, sizeof(BITMAPINFOHEADER) + ColorsSize, TAG_DIB); - if(!pNewBmi) return NULL; - - RtlZeroMemory(pNewBmi, sizeof(BITMAPINFOHEADER) + ColorsSize); - - pNewBmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pNewBmi->bmiHeader.biBitCount = pbmci->bmciHeader.bcBitCount; - pNewBmi->bmiHeader.biWidth = pbmci->bmciHeader.bcWidth; - pNewBmi->bmiHeader.biHeight = pbmci->bmciHeader.bcHeight; - pNewBmi->bmiHeader.biPlanes = pbmci->bmciHeader.bcPlanes; - pNewBmi->bmiHeader.biCompression = BI_RGB ; - pNewBmi->bmiHeader.biSizeImage = DIB_GetDIBImageBytes(pNewBmi->bmiHeader.biWidth, - pNewBmi->bmiHeader.biHeight, - pNewBmi->bmiHeader.biBitCount); - - if(Usage == DIB_PAL_COLORS) - { - RtlCopyMemory(pNewBmi->bmiColors, pbmci->bmciColors, ColorsSize); - } - else - { - UINT i; - for(i=0; i<numColors; i++) - { - pNewBmi->bmiColors[i].rgbRed = pbmci->bmciColors[i].rgbtRed; - pNewBmi->bmiColors[i].rgbGreen = pbmci->bmciColors[i].rgbtGreen; - pNewBmi->bmiColors[i].rgbBlue = pbmci->bmciColors[i].rgbtBlue; - } - } - - return pNewBmi ; + CONST BITMAPCOREINFO* pbmci = (BITMAPCOREINFO*)pbmi; + BITMAPINFO* pNewBmi ; + UINT numColors = 0, ColorsSize = 0; + + if(pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) return (BITMAPINFO*)pbmi; + if(pbmi->bmiHeader.biSize != sizeof(BITMAPCOREHEADER)) return NULL; + + if(pbmci->bmciHeader.bcBitCount <= 8) + { + numColors = 1 << pbmci->bmciHeader.bcBitCount; + if(Usage == DIB_PAL_COLORS) + { + ColorsSize = numColors * sizeof(WORD); + } + else + { + ColorsSize = numColors * sizeof(RGBQUAD); + } + } + else if (Usage == DIB_PAL_COLORS) + { + /* Invalid at high Res */ + return NULL; + } + + pNewBmi = ExAllocatePoolWithTag(PagedPool, sizeof(BITMAPINFOHEADER) + ColorsSize, TAG_DIB); + if(!pNewBmi) return NULL; + + RtlZeroMemory(pNewBmi, sizeof(BITMAPINFOHEADER) + ColorsSize); + + pNewBmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + pNewBmi->bmiHeader.biBitCount = pbmci->bmciHeader.bcBitCount; + pNewBmi->bmiHeader.biWidth = pbmci->bmciHeader.bcWidth; + pNewBmi->bmiHeader.biHeight = pbmci->bmciHeader.bcHeight; + pNewBmi->bmiHeader.biPlanes = pbmci->bmciHeader.bcPlanes; + pNewBmi->bmiHeader.biCompression = BI_RGB ; + pNewBmi->bmiHeader.biSizeImage = DIB_GetDIBImageBytes(pNewBmi->bmiHeader.biWidth, + pNewBmi->bmiHeader.biHeight, + pNewBmi->bmiHeader.biBitCount); + + if(Usage == DIB_PAL_COLORS) + { + RtlCopyMemory(pNewBmi->bmiColors, pbmci->bmciColors, ColorsSize); + } + else + { + UINT i; + for(i=0; i<numColors; i++) + { + pNewBmi->bmiColors[i].rgbRed = pbmci->bmciColors[i].rgbtRed; + pNewBmi->bmiColors[i].rgbGreen = pbmci->bmciColors[i].rgbtGreen; + pNewBmi->bmiColors[i].rgbBlue = pbmci->bmciColors[i].rgbtBlue; + } + } + + return pNewBmi ; } /* Frees a BITMAPINFO created with DIB_ConvertBitmapInfo */ @@ -1887,8 +1896,8 @@ FASTCALL DIB_FreeConvertedBitmapInfo(BITMAPINFO* converted, BITMAPINFO* orig) { - if(converted != orig) - ExFreePoolWithTag(converted, TAG_DIB); + if(converted != orig) + ExFreePoolWithTag(converted, TAG_DIB); }
13 years, 9 months
1
0
0
0
[jgardou] 50939: [FORMATTING] fix formatting. No code change
by jgardou@svn.reactos.org
Author: jgardou Date: Mon Feb 28 23:29:36 2011 New Revision: 50939 URL:
http://svn.reactos.org/svn/reactos?rev=50939&view=rev
Log: [FORMATTING] fix formatting. No code change Modified: trunk/reactos/subsystems/win32/win32k/objects/drawing.c Modified: trunk/reactos/subsystems/win32/win32k/objects/drawing.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/drawing.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/drawing.c [iso-8859-1] Mon Feb 28 23:29:36 2011 @@ -61,8 +61,8 @@ typedef struct _Rect { - int x, y; /* top-left point inside rect */ - int width, height; /* width and height of rect */ + int x, y; /* top-left point inside rect */ + int width, height; /* width and height of rect */ } Rect, *PRect; int FASTCALL IntFillRect(DC *dc, INT XLeft, INT YLeft, INT Width, INT Height, PBRUSH pbrush, BOOL Pen); @@ -73,10 +73,10 @@ INTERNAL_CALL app_new_point(int x, int y) { - POINT p; - p.x = x; - p.y = y; - return p; + POINT p; + p.x = x; + p.y = y; + return p; } #define pt(x,y) app_new_point((x),(y)) @@ -85,12 +85,12 @@ INTERNAL_CALL rect(int x, int y, int width, int height) { - Rect r; - r.x = x; - r.y = y; - r.width = width; - r.height = height; - return r; + Rect r; + r.x = x; + r.y = y; + r.width = width; + r.height = height; + return r; } @@ -125,202 +125,214 @@ INTERNAL_CALL app_draw_ellipse(DC *g, Rect r, PBRUSH pbrush) { - /* Outer ellipse: e(x,y) = b*b*x*x + a*a*y*y - a*a*b*b */ - - int a = r.width / 2; - int b = r.height / 2; - int x = 0; - int y = b; - long a2 = a*a; - long b2 = b*b; - long xcrit = (3 * a2 / 4) + 1; - long ycrit = (3 * b2 / 4) + 1; - long t = b2 + a2 - 2*a2*b; /* t = e(x+1,y-1) */ - long dxt = b2*(3+x+x); - long dyt = a2*(3-y-y); - int d2xt = b2+b2; - int d2yt = a2+a2; - - int w = pbrush->ptPenWidth.x; - - /* Inner ellipse: E(X,Y) = B*B*X*X + A*A*Y*Y - A*A*B*B */ - - int A = a-w > 0 ? a-w : 0; - int B = b-w > 0 ? b-w : 0; - int X = 0; - int Y = B; - long A2 = A*A; - long B2 = B*B; - long XCRIT = (3 * A2 / 4) + 1; - long YCRIT = (3 * B2 / 4) + 1; - long T = B2 + A2 - 2*A2*B; /* T = E(X+1,Y-1) */ - long DXT = B2*(3+X+X); - long DYT = A2*(3-Y-Y); - int D2XT = B2+B2; - int D2YT = A2+A2; - - int movedown, moveout; - int innerX = 0, prevx, prevy, W; - Rect r1, r2; - int result = 1; + /* Outer ellipse: e(x,y) = b*b*x*x + a*a*y*y - a*a*b*b */ + + int a = r.width / 2; + int b = r.height / 2; + int x = 0; + int y = b; + long a2 = a*a; + long b2 = b*b; + long xcrit = (3 * a2 / 4) + 1; + long ycrit = (3 * b2 / 4) + 1; + long t = b2 + a2 - 2*a2*b; /* t = e(x+1,y-1) */ + long dxt = b2*(3+x+x); + long dyt = a2*(3-y-y); + int d2xt = b2+b2; + int d2yt = a2+a2; + + int w = pbrush->ptPenWidth.x; + + /* Inner ellipse: E(X,Y) = B*B*X*X + A*A*Y*Y - A*A*B*B */ + + int A = a-w > 0 ? a-w : 0; + int B = b-w > 0 ? b-w : 0; + int X = 0; + int Y = B; + long A2 = A*A; + long B2 = B*B; + long XCRIT = (3 * A2 / 4) + 1; + long YCRIT = (3 * B2 / 4) + 1; + long T = B2 + A2 - 2*A2*B; /* T = E(X+1,Y-1) */ + long DXT = B2*(3+X+X); + long DYT = A2*(3-Y-Y); + int D2XT = B2+B2; + int D2YT = A2+A2; + + int movedown, moveout; + int innerX = 0, prevx, prevy, W; + Rect r1, r2; + int result = 1; // START_DEBUG(); - if ((r.width <= 2) || (r.height <= 2)) - return app_fill_rect(g, r, pbrush, TRUE); - - r1.x = r.x + a; - r1.y = r.y; - r1.width = r.width & 1; /* i.e. if width is odd */ - r1.height = 1; - - r2 = r1; - r2.y = r.y + r.height - 1; - - prevx = r1.x; - prevy = r1.y; - - while (y > 0) - { - while (Y == y) - { - innerX = X; - - if (T + A2*Y < XCRIT) /* E(X+1,Y-1/2) <= 0 */ - { - /* move outwards to encounter edge */ - X += 1; - T += DXT; - DXT += D2XT; - } - else if (T - B2*X >= YCRIT) /* e(x+1/2,y-1) > 0 */ - { - /* drop down one line */ - Y -= 1; - T += DYT; - DYT += D2YT; - } - else { - /* drop diagonally down and out */ - X += 1; - Y -= 1; - T += DXT + DYT; - DXT += D2XT; - DYT += D2YT; - } - } - - movedown = moveout = 0; - - W = x - innerX; - if (r1.x + W < prevx) - W = prevx - r1.x; - if (W < w) - W = w; - - if (t + a2*y < xcrit) /* e(x+1,y-1/2) <= 0 */ - { - /* move outwards to encounter edge */ - x += 1; - t += dxt; - dxt += d2xt; - - moveout = 1; - } - else if (t - b2*x >= ycrit) /* e(x+1/2,y-1) > 0 */ - { - /* drop down one line */ - y -= 1; - t += dyt; - dyt += d2yt; - - movedown = 1; - } - else { - /* drop diagonally down and out */ - x += 1; - y -= 1; - t += dxt + dyt; - dxt += d2xt; - dyt += d2yt; - - movedown = 1; - moveout = 1; - } - - if (movedown) { - if (r1.width == 0) { - r1.x -= 1; r1.width += 2; - r2.x -= 1; r2.width += 2; - moveout = 0; - } - - if (r1.x < r.x) - r1.x = r2.x = r.x; - if (r1.width > r.width) - r1.width = r2.width = r.width; - if (r1.y == r2.y-1) { - r1.x = r2.x = r.x; - r1.width = r2.width = r.width; - } - - if ((r1.y < r.y+w) || (r1.x+W >= r1.x+r1.width-W)) - { - result &= app_fill_rect(g, r1, pbrush, TRUE); - result &= app_fill_rect(g, r2, pbrush, TRUE); - - prevx = r1.x; - prevy = r1.y; - } - else if (r1.y+r1.height < r2.y) - { - /* draw distinct rectangles */ - result &= app_fill_rect(g, rect(r1.x,r1.y, - W,1), pbrush, TRUE); - result &= app_fill_rect(g, rect( - r1.x+r1.width-W,r1.y,W,1), pbrush, TRUE); - result &= app_fill_rect(g, rect(r2.x, - r2.y,W,1), pbrush, TRUE); - result &= app_fill_rect(g, rect( - r2.x+r2.width-W,r2.y,W,1), pbrush, TRUE); - - prevx = r1.x; - prevy = r1.y; - } - - /* move down */ - r1.y += 1; - r2.y -= 1; - } - - if (moveout) { - /* move outwards */ - r1.x -= 1; r1.width += 2; - r2.x -= 1; r2.width += 2; - } - } - if ((x <= a) && (prevy < r2.y)) { - /* draw final line */ - r1.height = r1.y+r1.height-r2.y; - r1.y = r2.y; - - W = w; - if (r.x + W != prevx) - W = prevx - r.x; - if (W < w) - W = w; - - if (W+W >= r.width) { - result &= app_fill_rect(g, rect(r.x, r1.y, - r.width, r1.height), pbrush, TRUE); - return result; - } - - result &= app_fill_rect(g, rect(r.x, r1.y, W, r1.height), pbrush, TRUE); - result &= app_fill_rect(g, rect(r.x+r.width-W, r1.y, - W, r1.height), pbrush, TRUE); - } - return result; + if ((r.width <= 2) || (r.height <= 2)) + return app_fill_rect(g, r, pbrush, TRUE); + + r1.x = r.x + a; + r1.y = r.y; + r1.width = r.width & 1; /* i.e. if width is odd */ + r1.height = 1; + + r2 = r1; + r2.y = r.y + r.height - 1; + + prevx = r1.x; + prevy = r1.y; + + while (y > 0) + { + while (Y == y) + { + innerX = X; + + if (T + A2*Y < XCRIT) /* E(X+1,Y-1/2) <= 0 */ + { + /* move outwards to encounter edge */ + X += 1; + T += DXT; + DXT += D2XT; + } + else if (T - B2*X >= YCRIT) /* e(x+1/2,y-1) > 0 */ + { + /* drop down one line */ + Y -= 1; + T += DYT; + DYT += D2YT; + } + else + { + /* drop diagonally down and out */ + X += 1; + Y -= 1; + T += DXT + DYT; + DXT += D2XT; + DYT += D2YT; + } + } + + movedown = moveout = 0; + + W = x - innerX; + if (r1.x + W < prevx) + W = prevx - r1.x; + if (W < w) + W = w; + + if (t + a2*y < xcrit) /* e(x+1,y-1/2) <= 0 */ + { + /* move outwards to encounter edge */ + x += 1; + t += dxt; + dxt += d2xt; + + moveout = 1; + } + else if (t - b2*x >= ycrit) /* e(x+1/2,y-1) > 0 */ + { + /* drop down one line */ + y -= 1; + t += dyt; + dyt += d2yt; + + movedown = 1; + } + else + { + /* drop diagonally down and out */ + x += 1; + y -= 1; + t += dxt + dyt; + dxt += d2xt; + dyt += d2yt; + + movedown = 1; + moveout = 1; + } + + if (movedown) + { + if (r1.width == 0) + { + r1.x -= 1; + r1.width += 2; + r2.x -= 1; + r2.width += 2; + moveout = 0; + } + + if (r1.x < r.x) + r1.x = r2.x = r.x; + if (r1.width > r.width) + r1.width = r2.width = r.width; + if (r1.y == r2.y-1) + { + r1.x = r2.x = r.x; + r1.width = r2.width = r.width; + } + + if ((r1.y < r.y+w) || (r1.x+W >= r1.x+r1.width-W)) + { + result &= app_fill_rect(g, r1, pbrush, TRUE); + result &= app_fill_rect(g, r2, pbrush, TRUE); + + prevx = r1.x; + prevy = r1.y; + } + else if (r1.y+r1.height < r2.y) + { + /* draw distinct rectangles */ + result &= app_fill_rect(g, rect(r1.x,r1.y, + W,1), pbrush, TRUE); + result &= app_fill_rect(g, rect( + r1.x+r1.width-W,r1.y,W,1), pbrush, TRUE); + result &= app_fill_rect(g, rect(r2.x, + r2.y,W,1), pbrush, TRUE); + result &= app_fill_rect(g, rect( + r2.x+r2.width-W,r2.y,W,1), pbrush, TRUE); + + prevx = r1.x; + prevy = r1.y; + } + + /* move down */ + r1.y += 1; + r2.y -= 1; + } + + if (moveout) + { + /* move outwards */ + r1.x -= 1; + r1.width += 2; + r2.x -= 1; + r2.width += 2; + } + } + if ((x <= a) && (prevy < r2.y)) + { + /* draw final line */ + r1.height = r1.y+r1.height-r2.y; + r1.y = r2.y; + + W = w; + if (r.x + W != prevx) + W = prevx - r.x; + if (W < w) + W = w; + + if (W+W >= r.width) + { + result &= app_fill_rect(g, rect(r.x, r1.y, + r.width, r1.height), pbrush, TRUE); + return result; + } + + result &= app_fill_rect(g, rect(r.x, r1.y, W, r1.height), pbrush, TRUE); + result &= app_fill_rect(g, rect(r.x+r.width-W, r1.y, + W, r1.height), pbrush, TRUE); + } + return result; } /* @@ -360,220 +372,220 @@ int FASTCALL app_fill_arc_rect(DC *g, - Rect r, // top, left, width, height - POINT p0, // Center - POINT p1, // Start - POINT p2, // End - int start_angle, - int end_angle, - PBRUSH pbrush, - BOOL Pen) + Rect r, // top, left, width, height + POINT p0, // Center + POINT p1, // Start + POINT p2, // End + int start_angle, + int end_angle, + PBRUSH pbrush, + BOOL Pen) { - int x1, x2; - int start_above, end_above; - long rise1, run1, rise2, run2; - - rise1 = p1.y - p0.y; - run1 = p1.x - p0.x; - rise2 = p2.y - p0.y; - run2 = p2.x - p0.x; - - if (r.y <= p0.y) // - { - /* in top half of arc ellipse */ - - if (p1.y <= r.y) - { - /* start_line is in the top half and is */ - /* intersected by the current Y scan line */ - if (rise1 == 0) - x1 = p1.x; - else - x1 = p0.x + (r.y-p0.y)*run1/rise1; - start_above = 1; - } - else if ((start_angle >= 0) && (start_angle <= 180)) - { - /* start_line is above middle */ - x1 = p1.x; - start_above = 1; - } - else - { - /* start_line is below middle */ - x1 = r.x + r.width; - start_above = 0; - } - if (x1 < r.x) - x1 = r.x; - if (x1 > r.x+r.width) - x1 = r.x+r.width; - - if (p2.y <= r.y) - { - /* end_line is in the top half and is */ - /* intersected by the current Y scan line */ - if (rise2 == 0) - x2 = p2.x; - else - x2 = p0.x + (r.y-p0.y)*run2/rise2; - end_above = 1; - } - else if ((end_angle >= 0) && (end_angle <= 180)) - { - /* end_line is above middle */ - x2 = p2.x; - end_above = 1; - } - else - { - /* end_line is below middle */ - x2 = r.x; - end_above = 0; - } - - if (x2 < r.x) x2 = r.x; - - if (x2 > r.x+r.width) x2 = r.x+r.width; - - if (start_above && end_above) - { - if (start_angle > end_angle) - { - /* fill outsides of wedge */ - if (! app_fill_rect(g, rect(r.x, r.y, - x1-r.x, r.height), pbrush, Pen)) - return 0; - return app_fill_rect(g, rect(x2, r.y, - r.x+r.width-x2, r.height), pbrush, Pen); - } - else - { - /* fill inside of wedge */ - r.width = x1-x2; - r.x = x2; - return app_fill_rect(g, r, pbrush, Pen); - } - } - else if (start_above) - { - /* fill to the left of the start_line */ - r.width = x1-r.x; - return app_fill_rect(g, r, pbrush, Pen); - } - else if (end_above) - { - /* fill right of end_line */ - r.width = r.x+r.width-x2; - r.x = x2; - return app_fill_rect(g, r, pbrush, Pen); - } - else - { - if (start_angle > end_angle) - return app_fill_rect(g,r, pbrush, Pen); - else - return 1; - } - } - else - { - /* in lower half of arc ellipse */ - - if (p1.y >= r.y) - { - /* start_line is in the lower half and is */ - /* intersected by the current Y scan line */ - if (rise1 == 0) - x1 = p1.x; - else - x1 = p0.x + (r.y-p0.y)*run1/rise1; - start_above = 0; - } - else if ((start_angle >= 180) && (start_angle <= 360)) - { - /* start_line is below middle */ - x1 = p1.x; - start_above = 0; - } - else - { - /* start_line is above middle */ - x1 = r.x; - start_above = 1; - } - if (x1 < r.x) - x1 = r.x; - if (x1 > r.x+r.width) - x1 = r.x+r.width; - - if (p2.y >= r.y) - { - /* end_line is in the lower half and is */ - /* intersected by the current Y scan line */ - if (rise2 == 0) - x2 = p2.x; - else - x2 = p0.x + (r.y-p0.y)*run2/rise2; - end_above = 0; - } - else if ((end_angle >= 180) && (end_angle <= 360)) - { - /* end_line is below middle */ - x2 = p2.x; - end_above = 0; - } - else - { - /* end_line is above middle */ - x2 = r.x + r.width; - end_above = 1; - } - if (x2 < r.x) - x2 = r.x; - if (x2 > r.x+r.width) - x2 = r.x+r.width; - - if (start_above && end_above) - { - if (start_angle > end_angle) - return app_fill_rect(g,r, pbrush, Pen); - else - return 1; - } - else if (start_above) - { - /* fill to the left of end_line */ - r.width = x2-r.x; - return app_fill_rect(g,r, pbrush, Pen); - } - else if (end_above) - { - /* fill right of start_line */ - r.width = r.x+r.width-x1; - r.x = x1; - return app_fill_rect(g,r, pbrush, Pen); - } - else - { - if (start_angle > end_angle) - { - /* fill outsides of wedge */ - if (! app_fill_rect(g, rect(r.x, r.y, - x2-r.x, r.height), pbrush, Pen)) - return 0; - return app_fill_rect(g, rect(x1, r.y, - r.x+r.width-x1, r.height), pbrush, Pen); - } - else - { - /* fill inside of wedge */ - r.width = x2-x1; - r.x = x1; - return app_fill_rect(g, r, pbrush, Pen); - } - } - } + int x1, x2; + int start_above, end_above; + long rise1, run1, rise2, run2; + + rise1 = p1.y - p0.y; + run1 = p1.x - p0.x; + rise2 = p2.y - p0.y; + run2 = p2.x - p0.x; + + if (r.y <= p0.y) // + { + /* in top half of arc ellipse */ + + if (p1.y <= r.y) + { + /* start_line is in the top half and is */ + /* intersected by the current Y scan line */ + if (rise1 == 0) + x1 = p1.x; + else + x1 = p0.x + (r.y-p0.y)*run1/rise1; + start_above = 1; + } + else if ((start_angle >= 0) && (start_angle <= 180)) + { + /* start_line is above middle */ + x1 = p1.x; + start_above = 1; + } + else + { + /* start_line is below middle */ + x1 = r.x + r.width; + start_above = 0; + } + if (x1 < r.x) + x1 = r.x; + if (x1 > r.x+r.width) + x1 = r.x+r.width; + + if (p2.y <= r.y) + { + /* end_line is in the top half and is */ + /* intersected by the current Y scan line */ + if (rise2 == 0) + x2 = p2.x; + else + x2 = p0.x + (r.y-p0.y)*run2/rise2; + end_above = 1; + } + else if ((end_angle >= 0) && (end_angle <= 180)) + { + /* end_line is above middle */ + x2 = p2.x; + end_above = 1; + } + else + { + /* end_line is below middle */ + x2 = r.x; + end_above = 0; + } + + if (x2 < r.x) x2 = r.x; + + if (x2 > r.x+r.width) x2 = r.x+r.width; + + if (start_above && end_above) + { + if (start_angle > end_angle) + { + /* fill outsides of wedge */ + if (! app_fill_rect(g, rect(r.x, r.y, + x1-r.x, r.height), pbrush, Pen)) + return 0; + return app_fill_rect(g, rect(x2, r.y, + r.x+r.width-x2, r.height), pbrush, Pen); + } + else + { + /* fill inside of wedge */ + r.width = x1-x2; + r.x = x2; + return app_fill_rect(g, r, pbrush, Pen); + } + } + else if (start_above) + { + /* fill to the left of the start_line */ + r.width = x1-r.x; + return app_fill_rect(g, r, pbrush, Pen); + } + else if (end_above) + { + /* fill right of end_line */ + r.width = r.x+r.width-x2; + r.x = x2; + return app_fill_rect(g, r, pbrush, Pen); + } + else + { + if (start_angle > end_angle) + return app_fill_rect(g,r, pbrush, Pen); + else + return 1; + } + } + else + { + /* in lower half of arc ellipse */ + + if (p1.y >= r.y) + { + /* start_line is in the lower half and is */ + /* intersected by the current Y scan line */ + if (rise1 == 0) + x1 = p1.x; + else + x1 = p0.x + (r.y-p0.y)*run1/rise1; + start_above = 0; + } + else if ((start_angle >= 180) && (start_angle <= 360)) + { + /* start_line is below middle */ + x1 = p1.x; + start_above = 0; + } + else + { + /* start_line is above middle */ + x1 = r.x; + start_above = 1; + } + if (x1 < r.x) + x1 = r.x; + if (x1 > r.x+r.width) + x1 = r.x+r.width; + + if (p2.y >= r.y) + { + /* end_line is in the lower half and is */ + /* intersected by the current Y scan line */ + if (rise2 == 0) + x2 = p2.x; + else + x2 = p0.x + (r.y-p0.y)*run2/rise2; + end_above = 0; + } + else if ((end_angle >= 180) && (end_angle <= 360)) + { + /* end_line is below middle */ + x2 = p2.x; + end_above = 0; + } + else + { + /* end_line is above middle */ + x2 = r.x + r.width; + end_above = 1; + } + if (x2 < r.x) + x2 = r.x; + if (x2 > r.x+r.width) + x2 = r.x+r.width; + + if (start_above && end_above) + { + if (start_angle > end_angle) + return app_fill_rect(g,r, pbrush, Pen); + else + return 1; + } + else if (start_above) + { + /* fill to the left of end_line */ + r.width = x2-r.x; + return app_fill_rect(g,r, pbrush, Pen); + } + else if (end_above) + { + /* fill right of start_line */ + r.width = r.x+r.width-x1; + r.x = x1; + return app_fill_rect(g,r, pbrush, Pen); + } + else + { + if (start_angle > end_angle) + { + /* fill outsides of wedge */ + if (! app_fill_rect(g, rect(r.x, r.y, + x2-r.x, r.height), pbrush, Pen)) + return 0; + return app_fill_rect(g, rect(x1, r.y, + r.x+r.width-x1, r.height), pbrush, Pen); + } + else + { + /* fill inside of wedge */ + r.width = x2-x1; + r.x = x1; + return app_fill_rect(g, r, pbrush, Pen); + } + } + } } /* @@ -608,110 +620,125 @@ FASTCALL app_fill_ellipse(DC *g, Rect r, PBRUSH pbrush) { - /* e(x,y) = b*b*x*x + a*a*y*y - a*a*b*b */ - - int a = r.width / 2; - int b = r.height / 2; - int x = 0; - int y = b; - long a2 = a*a; - long b2 = b*b; - long xcrit = (3 * a2 / 4) + 1; - long ycrit = (3 * b2 / 4) + 1; - long t = b2 + a2 - 2*a2*b; /* t = e(x+1,y-1) */ - long dxt = b2*(3+x+x); - long dyt = a2*(3-y-y); - int d2xt = b2+b2; - int d2yt = a2+a2; - Rect r1, r2; - int result = 1; + /* e(x,y) = b*b*x*x + a*a*y*y - a*a*b*b */ + + int a = r.width / 2; + int b = r.height / 2; + int x = 0; + int y = b; + long a2 = a*a; + long b2 = b*b; + long xcrit = (3 * a2 / 4) + 1; + long ycrit = (3 * b2 / 4) + 1; + long t = b2 + a2 - 2*a2*b; /* t = e(x+1,y-1) */ + long dxt = b2*(3+x+x); + long dyt = a2*(3-y-y); + int d2xt = b2+b2; + int d2yt = a2+a2; + Rect r1, r2; + int result = 1; // START_DEBUG(); - if ((r.width <= 2) || (r.height <= 2)) - return app_fill_rect(g, r, pbrush, FALSE); - - r1.x = r.x + a; - r1.y = r.y; - r1.width = r.width & 1; /* i.e. if width is odd */ - r1.height = 1; - - r2 = r1; - r2.y = r.y + r.height - 1; - - while (y > 0) - { - if (t + a2*y < xcrit) { /* e(x+1,y-1/2) <= 0 */ - /* move outwards to encounter edge */ - x += 1; - t += dxt; - dxt += d2xt; - - /* move outwards */ - r1.x -= 1; r1.width += 2; - r2.x -= 1; r2.width += 2; - } - else if (t - b2*x >= ycrit) { /* e(x+1/2,y-1) > 0 */ - /* drop down one line */ - y -= 1; - t += dyt; - dyt += d2yt; - - /* enlarge rectangles */ - r1.height += 1; - r2.height += 1; r2.y -= 1; - } - else { - /* drop diagonally down and out */ - x += 1; - y -= 1; - t += dxt + dyt; - dxt += d2xt; - dyt += d2yt; - - if ((r1.width > 0) && (r1.height > 0)) - { - /* draw rectangles first */ - - if (r1.y+r1.height < r2.y) { - /* distinct rectangles */ - result &= app_fill_rect(g, r1, pbrush, FALSE); - result &= app_fill_rect(g, r2, pbrush, FALSE); - } - - /* move down */ - r1.y += r1.height; r1.height = 1; - r2.y -= 1; r2.height = 1; - } - else { - /* skipped pixels on initial diagonal */ - - /* enlarge, rather than moving down */ - r1.height += 1; - r2.height += 1; r2.y -= 1; - } - - /* move outwards */ - r1.x -= 1; r1.width += 2; - r2.x -= 1; r2.width += 2; - } - } - if (r1.y < r2.y) { - /* overlap */ - r1.x = r.x; - r1.width = r.width; - r1.height = r2.y+r2.height-r1.y; - result &= app_fill_rect(g, r1, pbrush, FALSE); - } - else if (x <= a) { - /* crossover, draw final line */ - r1.x = r.x; - r1.width = r.width; - r1.height = r1.y+r1.height-r2.y; - r1.y = r2.y; - result &= app_fill_rect(g, r1, pbrush, FALSE); - } - return result; + if ((r.width <= 2) || (r.height <= 2)) + return app_fill_rect(g, r, pbrush, FALSE); + + r1.x = r.x + a; + r1.y = r.y; + r1.width = r.width & 1; /* i.e. if width is odd */ + r1.height = 1; + + r2 = r1; + r2.y = r.y + r.height - 1; + + while (y > 0) + { + if (t + a2*y < xcrit) /* e(x+1,y-1/2) <= 0 */ + { + /* move outwards to encounter edge */ + x += 1; + t += dxt; + dxt += d2xt; + + /* move outwards */ + r1.x -= 1; + r1.width += 2; + r2.x -= 1; + r2.width += 2; + } + else if (t - b2*x >= ycrit) /* e(x+1/2,y-1) > 0 */ + { + /* drop down one line */ + y -= 1; + t += dyt; + dyt += d2yt; + + /* enlarge rectangles */ + r1.height += 1; + r2.height += 1; + r2.y -= 1; + } + else + { + /* drop diagonally down and out */ + x += 1; + y -= 1; + t += dxt + dyt; + dxt += d2xt; + dyt += d2yt; + + if ((r1.width > 0) && (r1.height > 0)) + { + /* draw rectangles first */ + + if (r1.y+r1.height < r2.y) + { + /* distinct rectangles */ + result &= app_fill_rect(g, r1, pbrush, FALSE); + result &= app_fill_rect(g, r2, pbrush, FALSE); + } + + /* move down */ + r1.y += r1.height; + r1.height = 1; + r2.y -= 1; + r2.height = 1; + } + else + { + /* skipped pixels on initial diagonal */ + + /* enlarge, rather than moving down */ + r1.height += 1; + r2.height += 1; + r2.y -= 1; + } + + /* move outwards */ + r1.x -= 1; + r1.width += 2; + r2.x -= 1; + r2.width += 2; + } + } + if (r1.y < r2.y) + { + /* overlap */ + r1.x = r.x; + r1.width = r.width; + r1.height = r2.y+r2.height-r1.y; + result &= app_fill_rect(g, r1, pbrush, FALSE); + } + else if (x <= a) + { + /* crossover, draw final line */ + r1.x = r.x; + r1.width = r.width; + r1.height = r1.y+r1.height-r2.y; + r1.y = r2.y; + result &= app_fill_rect(g, r1, pbrush, FALSE); + } + return result; } static @@ -719,465 +746,495 @@ FASTCALL app_boundary_point(Rect r, int angle) { - int cx, cy; - double tangent; - - cx = r.width; - cx /= 2; - cx += r.x; - - cy = r.height; - cy /= 2; - cy += r.y; - - if (angle == 0) - return pt(r.x+r.width, cy); - else if (angle == 45) - return pt(r.x+r.width, r.y); - else if (angle == 90) - return pt(cx, r.y); - else if (angle == 135) - return pt(r.x, r.y); - else if (angle == 180) - return pt(r.x, cy); - else if (angle == 225) - return pt(r.x, r.y+r.height); - else if (angle == 270) - return pt(cx, r.y+r.height); - else if (angle == 315) - return pt(r.x+r.width, r.y+r.height); - - tangent = tan(DEGREES_TO_RADIANS(angle)); - - if ((angle > 45) && (angle < 135)) - return pt((int)(cx+r.height/tangent/2), r.y); - else if ((angle > 225) && (angle < 315)) - return pt((int)(cx-r.height/tangent/2), r.y+r.height); - else if ((angle > 135) && (angle < 225)) - return pt(r.x, (int)(cy+r.width*tangent/2)); - else - return pt(r.x+r.width, (int)(cy-r.width*tangent/2)); + int cx, cy; + double tangent; + + cx = r.width; + cx /= 2; + cx += r.x; + + cy = r.height; + cy /= 2; + cy += r.y; + + if (angle == 0) + return pt(r.x+r.width, cy); + else if (angle == 45) + return pt(r.x+r.width, r.y); + else if (angle == 90) + return pt(cx, r.y); + else if (angle == 135) + return pt(r.x, r.y); + else if (angle == 180) + return pt(r.x, cy); + else if (angle == 225) + return pt(r.x, r.y+r.height); + else if (angle == 270) + return pt(cx, r.y+r.height); + else if (angle == 315) + return pt(r.x+r.width, r.y+r.height); + + tangent = tan(DEGREES_TO_RADIANS(angle)); + + if ((angle > 45) && (angle < 135)) + return pt((int)(cx+r.height/tangent/2), r.y); + else if ((angle > 225) && (angle < 315)) + return pt((int)(cx-r.height/tangent/2), r.y+r.height); + else if ((angle > 135) && (angle < 225)) + return pt(r.x, (int)(cy+r.width*tangent/2)); + else + return pt(r.x+r.width, (int)(cy-r.width*tangent/2)); } int FASTCALL app_fill_arc(DC *g, Rect r, int start_angle, int end_angle, PBRUSH pbrush, BOOL Chord) { - /* e(x,y) = b*b*x*x + a*a*y*y - a*a*b*b */ - - int a = r.width / 2; - int b = r.height / 2; - int x = 0; - int y = b; - long a2 = a*a; - long b2 = b*b; - long xcrit = (3 * a2 / 4) + 1; - long ycrit = (3 * b2 / 4) + 1; - long t = b2 + a2 - 2*a2*b; /* t = e(x+1,y-1) */ - long dxt = b2*(3+x+x); - long dyt = a2*(3-y-y); - int d2xt = b2+b2; - int d2yt = a2+a2; - Rect r1, r2; - int movedown, moveout; - int result = 1; - - /* line descriptions */ - POINT p0, p1, p2; + /* e(x,y) = b*b*x*x + a*a*y*y - a*a*b*b */ + + int a = r.width / 2; + int b = r.height / 2; + int x = 0; + int y = b; + long a2 = a*a; + long b2 = b*b; + long xcrit = (3 * a2 / 4) + 1; + long ycrit = (3 * b2 / 4) + 1; + long t = b2 + a2 - 2*a2*b; /* t = e(x+1,y-1) */ + long dxt = b2*(3+x+x); + long dyt = a2*(3-y-y); + int d2xt = b2+b2; + int d2yt = a2+a2; + Rect r1, r2; + int movedown, moveout; + int result = 1; + + /* line descriptions */ + POINT p0, p1, p2; // START_DEBUG(); - /* if angles differ by 360 degrees or more, close the shape */ - if ((start_angle + 360 <= end_angle) || - (start_angle - 360 >= end_angle)) - { - return app_fill_ellipse(g, r, pbrush); - } - - /* make start_angle >= 0 and <= 360 */ - while (start_angle < 0) - start_angle += 360; - start_angle %= 360; - - /* make end_angle >= 0 and <= 360 */ - while (end_angle < 0) - end_angle += 360; - end_angle %= 360; - - /* draw nothing if the angles are equal */ - if (start_angle == end_angle) - return 1; - - /* find arc wedge line end points */ - p1 = app_boundary_point(r, start_angle); - p2 = app_boundary_point(r, end_angle); - if (Chord) - p0 = pt((p1.x+p2.x)/2,(p1.y+p2.y)/2); - else - p0 = pt(r.x + r.width/2, r.y + r.height/2); - - /* initialise rectangles to be drawn */ - r1.x = r.x + a; - r1.y = r.y; - r1.width = r.width & 1; /* i.e. if width is odd */ - r1.height = 1; - - r2 = r1; - r2.y = r.y + r.height - 1; - - while (y > 0) - { - moveout = movedown = 0; - - if (t + a2*y < xcrit) { /* e(x+1,y-1/2) <= 0 */ - /* move outwards to encounter edge */ - x += 1; - t += dxt; - dxt += d2xt; - - moveout = 1; - } - else if (t - b2*x >= ycrit) { /* e(x+1/2,y-1) > 0 */ - /* drop down one line */ - y -= 1; - t += dyt; - dyt += d2yt; - - movedown = 1; - } - else { - /* drop diagonally down and out */ - x += 1; - y -= 1; - t += dxt + dyt; - dxt += d2xt; - dyt += d2yt; - - moveout = 1; - movedown = 1; - } - - if (movedown) { - if (r1.width == 0) { - r1.x -= 1; r1.width += 2; - r2.x -= 1; r2.width += 2; - moveout = 0; - } - - if (r1.x < r.x) - r1.x = r2.x = r.x; - if (r1.width > r.width) - r1.width = r2.width = r.width; - if (r1.y == r2.y-1) { - r1.x = r2.x = r.x; - r1.width = r2.width = r.width; - } - - if ((r1.width > 0) && (r1.y+r1.height < r2.y)) { - /* distinct rectangles */ - result &= app_fill_arc_rect(g, r1, - p0, p1, p2, - start_angle, end_angle, pbrush, FALSE); - result &= app_fill_arc_rect(g, r2, - p0, p1, p2, - start_angle, end_angle, pbrush, FALSE); - } - - /* move down */ - r1.y += 1; - r2.y -= 1; - } - - if (moveout) { - /* move outwards */ - r1.x -= 1; r1.width += 2; - r2.x -= 1; r2.width += 2; - } - } - if (r1.y < r2.y) { - /* overlap */ - r1.x = r.x; - r1.width = r.width; - r1.height = r2.y+r2.height-r1.y; - while (r1.height > 0) { - result &= app_fill_arc_rect(g, - rect(r1.x, r1.y, r1.width, 1), - p0, p1, p2, start_angle, end_angle, pbrush, FALSE); - r1.y += 1; - r1.height -= 1; - } - } - else if (x <= a) { - /* crossover, draw final line */ - r1.x = r.x; - r1.width = r.width; - r1.height = r1.y+r1.height-r2.y; - r1.y = r2.y; - while (r1.height > 0) { - result &= app_fill_arc_rect(g, - rect(r1.x, r1.y, r1.width, 1), - p0, p1, p2, start_angle, end_angle, pbrush, FALSE); - r1.y += 1; - r1.height -= 1; - } - } - return result; + /* if angles differ by 360 degrees or more, close the shape */ + if ((start_angle + 360 <= end_angle) || + (start_angle - 360 >= end_angle)) + { + return app_fill_ellipse(g, r, pbrush); + } + + /* make start_angle >= 0 and <= 360 */ + while (start_angle < 0) + start_angle += 360; + start_angle %= 360; + + /* make end_angle >= 0 and <= 360 */ + while (end_angle < 0) + end_angle += 360; + end_angle %= 360; + + /* draw nothing if the angles are equal */ + if (start_angle == end_angle) + return 1; + + /* find arc wedge line end points */ + p1 = app_boundary_point(r, start_angle); + p2 = app_boundary_point(r, end_angle); + if (Chord) + p0 = pt((p1.x+p2.x)/2,(p1.y+p2.y)/2); + else + p0 = pt(r.x + r.width/2, r.y + r.height/2); + + /* initialise rectangles to be drawn */ + r1.x = r.x + a; + r1.y = r.y; + r1.width = r.width & 1; /* i.e. if width is odd */ + r1.height = 1; + + r2 = r1; + r2.y = r.y + r.height - 1; + + while (y > 0) + { + moveout = movedown = 0; + + if (t + a2*y < xcrit) /* e(x+1,y-1/2) <= 0 */ + { + /* move outwards to encounter edge */ + x += 1; + t += dxt; + dxt += d2xt; + + moveout = 1; + } + else if (t - b2*x >= ycrit) /* e(x+1/2,y-1) > 0 */ + { + /* drop down one line */ + y -= 1; + t += dyt; + dyt += d2yt; + + movedown = 1; + } + else + { + /* drop diagonally down and out */ + x += 1; + y -= 1; + t += dxt + dyt; + dxt += d2xt; + dyt += d2yt; + + moveout = 1; + movedown = 1; + } + + if (movedown) + { + if (r1.width == 0) + { + r1.x -= 1; + r1.width += 2; + r2.x -= 1; + r2.width += 2; + moveout = 0; + } + + if (r1.x < r.x) + r1.x = r2.x = r.x; + if (r1.width > r.width) + r1.width = r2.width = r.width; + if (r1.y == r2.y-1) + { + r1.x = r2.x = r.x; + r1.width = r2.width = r.width; + } + + if ((r1.width > 0) && (r1.y+r1.height < r2.y)) + { + /* distinct rectangles */ + result &= app_fill_arc_rect(g, r1, + p0, p1, p2, + start_angle, end_angle, pbrush, FALSE); + result &= app_fill_arc_rect(g, r2, + p0, p1, p2, + start_angle, end_angle, pbrush, FALSE); + } + + /* move down */ + r1.y += 1; + r2.y -= 1; + } + + if (moveout) + { + /* move outwards */ + r1.x -= 1; + r1.width += 2; + r2.x -= 1; + r2.width += 2; + } + } + if (r1.y < r2.y) + { + /* overlap */ + r1.x = r.x; + r1.width = r.width; + r1.height = r2.y+r2.height-r1.y; + while (r1.height > 0) + { + result &= app_fill_arc_rect(g, + rect(r1.x, r1.y, r1.width, 1), + p0, p1, p2, start_angle, end_angle, pbrush, FALSE); + r1.y += 1; + r1.height -= 1; + } + } + else if (x <= a) + { + /* crossover, draw final line */ + r1.x = r.x; + r1.width = r.width; + r1.height = r1.y+r1.height-r2.y; + r1.y = r2.y; + while (r1.height > 0) + { + result &= app_fill_arc_rect(g, + rect(r1.x, r1.y, r1.width, 1), + p0, p1, p2, start_angle, end_angle, pbrush, FALSE); + r1.y += 1; + r1.height -= 1; + } + } + return result; } int app_draw_arc(DC *g, Rect r, int start_angle, int end_angle, PBRUSH pbrushPen, BOOL Chord) { - /* Outer ellipse: e(x,y) = b*b*x*x + a*a*y*y - a*a*b*b */ - - int a = r.width / 2; - int b = r.height / 2; - int x = 0; - int y = b; - long a2 = a*a; - long b2 = b*b; - long xcrit = (3 * a2 / 4) + 1; - long ycrit = (3 * b2 / 4) + 1; - long t = b2 + a2 - 2*a2*b; /* t = e(x+1,y-1) */ - long dxt = b2*(3+x+x); - long dyt = a2*(3-y-y); - int d2xt = b2+b2; - int d2yt = a2+a2; - - int w = pbrushPen->ptPenWidth.x; - - /* Inner ellipse: E(X,Y) = B*B*X*X + A*A*Y*Y - A*A*B*B */ - - int A = a-w > 0 ? a-w : 0; - int B = b-w > 0 ? b-w : 0; - int X = 0; - int Y = B; - long A2 = A*A; - long B2 = B*B; - long XCRIT = (3 * A2 / 4) + 1; - long YCRIT = (3 * B2 / 4) + 1; - long T = B2 + A2 - 2*A2*B; /* T = E(X+1,Y-1) */ - long DXT = B2*(3+X+X); - long DYT = A2*(3-Y-Y); - int D2XT = B2+B2; - int D2YT = A2+A2; - - /* arc rectangle calculations */ - int movedown, moveout; - int innerX = 0, prevx, prevy, W; - Rect r1, r2; - int result = 1; - - /* line descriptions */ - POINT p0, p1, p2; + /* Outer ellipse: e(x,y) = b*b*x*x + a*a*y*y - a*a*b*b */ + + int a = r.width / 2; + int b = r.height / 2; + int x = 0; + int y = b; + long a2 = a*a; + long b2 = b*b; + long xcrit = (3 * a2 / 4) + 1; + long ycrit = (3 * b2 / 4) + 1; + long t = b2 + a2 - 2*a2*b; /* t = e(x+1,y-1) */ + long dxt = b2*(3+x+x); + long dyt = a2*(3-y-y); + int d2xt = b2+b2; + int d2yt = a2+a2; + + int w = pbrushPen->ptPenWidth.x; + + /* Inner ellipse: E(X,Y) = B*B*X*X + A*A*Y*Y - A*A*B*B */ + + int A = a-w > 0 ? a-w : 0; + int B = b-w > 0 ? b-w : 0; + int X = 0; + int Y = B; + long A2 = A*A; + long B2 = B*B; + long XCRIT = (3 * A2 / 4) + 1; + long YCRIT = (3 * B2 / 4) + 1; + long T = B2 + A2 - 2*A2*B; /* T = E(X+1,Y-1) */ + long DXT = B2*(3+X+X); + long DYT = A2*(3-Y-Y); + int D2XT = B2+B2; + int D2YT = A2+A2; + + /* arc rectangle calculations */ + int movedown, moveout; + int innerX = 0, prevx, prevy, W; + Rect r1, r2; + int result = 1; + + /* line descriptions */ + POINT p0, p1, p2; // START_DEBUG(); - /* if angles differ by 360 degrees or more, close the shape */ - if ((start_angle + 360 <= end_angle) || - (start_angle - 360 >= end_angle)) - { - return app_draw_ellipse(g, r, pbrushPen); - } - - /* make start_angle >= 0 and <= 360 */ - while (start_angle < 0) - start_angle += 360; - start_angle %= 360; - - /* make end_angle >= 0 and <= 360 */ - while (end_angle < 0) - end_angle += 360; - end_angle %= 360; - - /* draw nothing if the angles are equal */ - if (start_angle == end_angle) - return 1; - - /* find arc wedge line end points */ - p1 = app_boundary_point(r, start_angle); - p2 = app_boundary_point(r, end_angle); - if (Chord) - p0 = pt((p1.x+p2.x)/2,(p1.y+p2.y)/2); - else - p0 = pt(r.x + r.width/2, r.y + r.height/2); - - /* determine ellipse rectangles */ - r1.x = r.x + a; - r1.y = r.y; - r1.width = r.width & 1; /* i.e. if width is odd */ - r1.height = 1; - - r2 = r1; - r2.y = r.y + r.height - 1; - - prevx = r1.x; - prevy = r1.y; - - while (y > 0) - { - while (Y == y) - { - innerX = X; - - if (T + A2*Y < XCRIT) /* E(X+1,Y-1/2) <= 0 */ - { - /* move outwards to encounter edge */ - X += 1; - T += DXT; - DXT += D2XT; - } - else if (T - B2*X >= YCRIT) /* e(x+1/2,y-1) > 0 */ - { - /* drop down one line */ - Y -= 1; - T += DYT; - DYT += D2YT; - } - else { - /* drop diagonally down and out */ - X += 1; - Y -= 1; - T += DXT + DYT; - DXT += D2XT; - DYT += D2YT; - } - } - - movedown = moveout = 0; - - W = x - innerX; - if (r1.x + W < prevx) - W = prevx - r1.x; - if (W < w) - W = w; - - if (t + a2*y < xcrit) /* e(x+1,y-1/2) <= 0 */ - { - /* move outwards to encounter edge */ - x += 1; - t += dxt; - dxt += d2xt; - - moveout = 1; - } - else if (t - b2*x >= ycrit) /* e(x+1/2,y-1) > 0 */ - { - /* drop down one line */ - y -= 1; - t += dyt; - dyt += d2yt; - - movedown = 1; - } - else { - /* drop diagonally down and out */ - x += 1; - y -= 1; - t += dxt + dyt; - dxt += d2xt; - dyt += d2yt; - - movedown = 1; - moveout = 1; - } - - if (movedown) { - if (r1.width == 0) { - r1.x -= 1; r1.width += 2; - r2.x -= 1; r2.width += 2; - moveout = 0; - } - - if (r1.x < r.x) - r1.x = r2.x = r.x; - if (r1.width > r.width) - r1.width = r2.width = r.width; - if (r1.y == r2.y-1) { - r1.x = r2.x = r.x; - r1.width = r2.width = r.width; - } - - if ((r1.y < r.y+w) || (r1.x+W >= r1.x+r1.width-W)) - { - result &= app_fill_arc_rect(g, r1, - p0, p1, p2, - start_angle, end_angle, pbrushPen, TRUE); - result &= app_fill_arc_rect(g, r2, - p0, p1, p2, - start_angle, end_angle, pbrushPen, TRUE); - - prevx = r1.x; - prevy = r1.y; - } - else if (r1.y+r1.height < r2.y) - { - /* draw distinct rectangles */ - result &= app_fill_arc_rect(g, rect( - r1.x,r1.y,W,1), - p0, p1, p2, - start_angle, end_angle, pbrushPen, TRUE); - result &= app_fill_arc_rect(g, rect( - r1.x+r1.width-W,r1.y,W,1), - p0, p1, p2, - start_angle, end_angle, pbrushPen, TRUE); - result &= app_fill_arc_rect(g, rect( - r2.x,r2.y,W,1), - p0, p1, p2, - start_angle, end_angle, pbrushPen, TRUE); - result &= app_fill_arc_rect(g, rect( - r2.x+r2.width-W,r2.y,W,1), - p0, p1, p2, - start_angle, end_angle, pbrushPen, TRUE); - - prevx = r1.x; - prevy = r1.y; - } - - /* move down */ - r1.y += 1; - r2.y -= 1; - } - - if (moveout) { - /* move outwards */ - r1.x -= 1; r1.width += 2; - r2.x -= 1; r2.width += 2; - } - } - if ((x <= a) && (prevy < r2.y)) { - /* draw final lines */ - r1.height = r1.y+r1.height-r2.y; - r1.y = r2.y; - - W = w; - if (r.x + W != prevx) - W = prevx - r.x; - if (W < w) - W = w; - - if (W+W >= r.width) { - while (r1.height > 0) { - result &= app_fill_arc_rect(g, rect(r.x, - r1.y, r.width, 1), p0, p1, p2, - start_angle, end_angle, pbrushPen, TRUE); - r1.y += 1; - r1.height -= 1; - } - return result; - } - - while (r1.height > 0) { - result &= app_fill_arc_rect(g, rect(r.x, r1.y, - W, 1), p0, p1, p2, - start_angle, end_angle, pbrushPen, TRUE); - result &= app_fill_arc_rect(g, rect(r.x+r.width-W, - r1.y, W, 1), p0, p1, p2, - start_angle, end_angle, pbrushPen, TRUE); - r1.y += 1; - r1.height -= 1; - } - } - - return result; + /* if angles differ by 360 degrees or more, close the shape */ + if ((start_angle + 360 <= end_angle) || + (start_angle - 360 >= end_angle)) + { + return app_draw_ellipse(g, r, pbrushPen); + } + + /* make start_angle >= 0 and <= 360 */ + while (start_angle < 0) + start_angle += 360; + start_angle %= 360; + + /* make end_angle >= 0 and <= 360 */ + while (end_angle < 0) + end_angle += 360; + end_angle %= 360; + + /* draw nothing if the angles are equal */ + if (start_angle == end_angle) + return 1; + + /* find arc wedge line end points */ + p1 = app_boundary_point(r, start_angle); + p2 = app_boundary_point(r, end_angle); + if (Chord) + p0 = pt((p1.x+p2.x)/2,(p1.y+p2.y)/2); + else + p0 = pt(r.x + r.width/2, r.y + r.height/2); + + /* determine ellipse rectangles */ + r1.x = r.x + a; + r1.y = r.y; + r1.width = r.width & 1; /* i.e. if width is odd */ + r1.height = 1; + + r2 = r1; + r2.y = r.y + r.height - 1; + + prevx = r1.x; + prevy = r1.y; + + while (y > 0) + { + while (Y == y) + { + innerX = X; + + if (T + A2*Y < XCRIT) /* E(X+1,Y-1/2) <= 0 */ + { + /* move outwards to encounter edge */ + X += 1; + T += DXT; + DXT += D2XT; + } + else if (T - B2*X >= YCRIT) /* e(x+1/2,y-1) > 0 */ + { + /* drop down one line */ + Y -= 1; + T += DYT; + DYT += D2YT; + } + else + { + /* drop diagonally down and out */ + X += 1; + Y -= 1; + T += DXT + DYT; + DXT += D2XT; + DYT += D2YT; + } + } + + movedown = moveout = 0; + + W = x - innerX; + if (r1.x + W < prevx) + W = prevx - r1.x; + if (W < w) + W = w; + + if (t + a2*y < xcrit) /* e(x+1,y-1/2) <= 0 */ + { + /* move outwards to encounter edge */ + x += 1; + t += dxt; + dxt += d2xt; + + moveout = 1; + } + else if (t - b2*x >= ycrit) /* e(x+1/2,y-1) > 0 */ + { + /* drop down one line */ + y -= 1; + t += dyt; + dyt += d2yt; + + movedown = 1; + } + else + { + /* drop diagonally down and out */ + x += 1; + y -= 1; + t += dxt + dyt; + dxt += d2xt; + dyt += d2yt; + + movedown = 1; + moveout = 1; + } + + if (movedown) + { + if (r1.width == 0) + { + r1.x -= 1; + r1.width += 2; + r2.x -= 1; + r2.width += 2; + moveout = 0; + } + + if (r1.x < r.x) + r1.x = r2.x = r.x; + if (r1.width > r.width) + r1.width = r2.width = r.width; + if (r1.y == r2.y-1) + { + r1.x = r2.x = r.x; + r1.width = r2.width = r.width; + } + + if ((r1.y < r.y+w) || (r1.x+W >= r1.x+r1.width-W)) + { + result &= app_fill_arc_rect(g, r1, + p0, p1, p2, + start_angle, end_angle, pbrushPen, TRUE); + result &= app_fill_arc_rect(g, r2, + p0, p1, p2, + start_angle, end_angle, pbrushPen, TRUE); + + prevx = r1.x; + prevy = r1.y; + } + else if (r1.y+r1.height < r2.y) + { + /* draw distinct rectangles */ + result &= app_fill_arc_rect(g, rect( + r1.x,r1.y,W,1), + p0, p1, p2, + start_angle, end_angle, pbrushPen, TRUE); + result &= app_fill_arc_rect(g, rect( + r1.x+r1.width-W,r1.y,W,1), + p0, p1, p2, + start_angle, end_angle, pbrushPen, TRUE); + result &= app_fill_arc_rect(g, rect( + r2.x,r2.y,W,1), + p0, p1, p2, + start_angle, end_angle, pbrushPen, TRUE); + result &= app_fill_arc_rect(g, rect( + r2.x+r2.width-W,r2.y,W,1), + p0, p1, p2, + start_angle, end_angle, pbrushPen, TRUE); + + prevx = r1.x; + prevy = r1.y; + } + + /* move down */ + r1.y += 1; + r2.y -= 1; + } + + if (moveout) + { + /* move outwards */ + r1.x -= 1; + r1.width += 2; + r2.x -= 1; + r2.width += 2; + } + } + if ((x <= a) && (prevy < r2.y)) + { + /* draw final lines */ + r1.height = r1.y+r1.height-r2.y; + r1.y = r2.y; + + W = w; + if (r.x + W != prevx) + W = prevx - r.x; + if (W < w) + W = w; + + if (W+W >= r.width) + { + while (r1.height > 0) + { + result &= app_fill_arc_rect(g, rect(r.x, + r1.y, r.width, 1), p0, p1, p2, + start_angle, end_angle, pbrushPen, TRUE); + r1.y += 1; + r1.height -= 1; + } + return result; + } + + while (r1.height > 0) + { + result &= app_fill_arc_rect(g, rect(r.x, r1.y, + W, 1), p0, p1, p2, + start_angle, end_angle, pbrushPen, TRUE); + result &= app_fill_arc_rect(g, rect(r.x+r.width-W, + r1.y, W, 1), p0, p1, p2, + start_angle, end_angle, pbrushPen, TRUE); + r1.y += 1; + r1.height -= 1; + } + } + + return result; } /* ReactOS Interface *********************************************************/ @@ -1192,67 +1249,65 @@ PBRUSH pbrush, BOOL Pen) { - DWORD ROP = PATCOPY; - RECTL DestRect; - SURFACE *psurf; - POINTL BrushOrigin; - BOOL Ret = TRUE; - PDC_ATTR pdcattr; - - ASSERT(pbrush); - - psurf = dc->dclevel.pSurface; - if (psurf == NULL) - { - EngSetLastError(ERROR_INVALID_HANDLE); - return 0; - } - - if (!(pbrush->flAttrs & GDIBRUSH_IS_NULL)) - { - pdcattr = dc->pdcattr; - - /* fix negative spaces */ - if (Width < 0) - { - XLeft += Width; - Width = 0 - Width; - } - if (Height < 0) - { - YLeft += Height; - Height = 0 - Height; - } - - DestRect.left = XLeft; - DestRect.right = XLeft + Width; - - DestRect.top = YLeft; - DestRect.bottom = YLeft + Height; - - BrushOrigin.x = pbrush->ptOrigin.x; - BrushOrigin.y = pbrush->ptOrigin.y; - - if (pdcattr->jROP2 == R2_XORPEN) - ROP = PATINVERT; - else - ROP = PATCOPY; - - Ret = IntEngBitBlt( - &psurf->SurfObj, - NULL, - NULL, - dc->rosdc.CombinedClip, - NULL, - &DestRect, - NULL, - NULL, - Pen ? &dc->eboLine.BrushObject : &dc->eboFill.BrushObject, - &BrushOrigin, - ROP3_TO_ROP4(ROP)); - } - - return (int)Ret; + DWORD ROP = PATCOPY; + RECTL DestRect; + SURFACE *psurf; + POINTL BrushOrigin; + BOOL Ret = TRUE; + PDC_ATTR pdcattr; + + ASSERT(pbrush); + + psurf = dc->dclevel.pSurface; + if (psurf == NULL) + { + EngSetLastError(ERROR_INVALID_HANDLE); + return 0; + } + + if (!(pbrush->flAttrs & GDIBRUSH_IS_NULL)) + { + pdcattr = dc->pdcattr; + + /* fix negative spaces */ + if (Width < 0) + { + XLeft += Width; + Width = 0 - Width; + } + if (Height < 0) + { + YLeft += Height; + Height = 0 - Height; + } + + DestRect.left = XLeft; + DestRect.right = XLeft + Width; + + DestRect.top = YLeft; + DestRect.bottom = YLeft + Height; + + BrushOrigin.x = pbrush->ptOrigin.x; + BrushOrigin.y = pbrush->ptOrigin.y; + + if (pdcattr->jROP2 == R2_XORPEN) + ROP = PATINVERT; + + Ret = IntEngBitBlt( + &psurf->SurfObj, + NULL, + NULL, + dc->rosdc.CombinedClip, + NULL, + &DestRect, + NULL, + NULL, + Pen ? &dc->eboLine.BrushObject : &dc->eboFill.BrushObject, + &BrushOrigin, + ROP3_TO_ROP4(ROP)); + } + + return (int)Ret; } BOOL @@ -1266,29 +1321,29 @@ double EndArc, ARCTYPE arctype) { - PDC_ATTR pdcattr; - PBRUSH pbrush; - int Start = ceil(StartArc); - int End = ceil(EndArc); - BOOL Chord = (arctype == GdiTypeChord), ret; - - pdcattr = dc->pdcattr; - - pbrush = BRUSH_LockBrush(pdcattr->hbrush); - if (!pbrush) - { - DPRINT1("FillArc Fail\n"); - EngSetLastError(ERROR_INTERNAL_ERROR); - return FALSE; - } - // Sort out alignment here. - ret = app_fill_arc(dc, rect( XLeft, YLeft, Width, Height), - (dc->dclevel.flPath & DCPATH_CLOCKWISE) ? -End : -Start, - (dc->dclevel.flPath & DCPATH_CLOCKWISE) ? -Start : -End, - pbrush, Chord); - - BRUSH_UnlockBrush(pbrush); - return ret; + PDC_ATTR pdcattr; + PBRUSH pbrush; + int Start = ceil(StartArc); + int End = ceil(EndArc); + BOOL Chord = (arctype == GdiTypeChord), ret; + + pdcattr = dc->pdcattr; + + pbrush = BRUSH_LockBrush(pdcattr->hbrush); + if (!pbrush) + { + DPRINT1("FillArc Fail\n"); + EngSetLastError(ERROR_INTERNAL_ERROR); + return FALSE; + } + // Sort out alignment here. + ret = app_fill_arc(dc, rect( XLeft, YLeft, Width, Height), + (dc->dclevel.flPath & DCPATH_CLOCKWISE) ? -End : -Start, + (dc->dclevel.flPath & DCPATH_CLOCKWISE) ? -Start : -End, + pbrush, Chord); + + BRUSH_UnlockBrush(pbrush); + return ret; } BOOL @@ -1303,14 +1358,14 @@ ARCTYPE arctype, PBRUSH pbrush) { - int Start = ceil(StartArc); - int End = ceil(EndArc); - BOOL Chord = (arctype == GdiTypeChord); - // Sort out alignment here. - return app_draw_arc(dc, rect( XLeft, YLeft, Width, Height), - (dc->dclevel.flPath & DCPATH_CLOCKWISE) ? -End : -Start, - (dc->dclevel.flPath & DCPATH_CLOCKWISE) ? -Start : -End, - pbrush, Chord); + int Start = ceil(StartArc); + int End = ceil(EndArc); + BOOL Chord = (arctype == GdiTypeChord); + // Sort out alignment here. + return app_draw_arc(dc, rect( XLeft, YLeft, Width, Height), + (dc->dclevel.flPath & DCPATH_CLOCKWISE) ? -End : -Start, + (dc->dclevel.flPath & DCPATH_CLOCKWISE) ? -Start : -End, + pbrush, Chord); } BOOL @@ -1322,7 +1377,7 @@ INT Height, PBRUSH pbrush) { - return (BOOL)app_draw_ellipse(dc, rect( XLeft, YLeft, Width, Height), pbrush); + return (BOOL)app_draw_ellipse(dc, rect( XLeft, YLeft, Width, Height), pbrush); } BOOL @@ -1334,7 +1389,7 @@ INT Height, PBRUSH pbrush) { - return (BOOL)app_fill_ellipse(dc, rect( XLeft, YLeft, Width, Height), pbrush); + return (BOOL)app_fill_ellipse(dc, rect( XLeft, YLeft, Width, Height), pbrush); } BOOL @@ -1348,58 +1403,58 @@ INT Hellipse, PBRUSH pbrush) { - Rect r; - int rx, ry; /* radius in x and y directions */ - - // x y Width Height - r = rect( Left, Top, abs(Right-Left), abs(Bottom-Top)); - rx = Wellipse/2; - ry = Hellipse/2; - - if (Wellipse > r.width) - { - if (Hellipse > r.height) // > W > H - app_fill_ellipse(dc, r, pbrush); - else // > W < H - { - app_fill_arc(dc, rect( r.x, r.y, r.width - 1, Hellipse), - 0, 180, pbrush,FALSE); - app_fill_arc(dc, rect(r.x, Bottom - Hellipse - 1, r.width - 1, Hellipse), - 180, 360, pbrush, FALSE); - } - } - else if(Hellipse > r.height) // < W > H - { - app_fill_arc(dc, rect(r.x, r.y, Wellipse, r.height - 1), - 90, 270, pbrush, FALSE); - app_fill_arc(dc, rect(Right - Wellipse - 1, r.y, Wellipse, r.height - 1), - 270, 90, pbrush,FALSE); - } - else // < W < H - { - app_fill_arc(dc, rect(r.x, r.y, rx+rx, ry+ry), - 90, 180, pbrush, FALSE); - - app_fill_arc(dc, rect(r.x, r.y+r.height-ry-ry, rx+rx, ry+ry), - 180, 270, pbrush, FALSE); - - app_fill_arc(dc, rect(r.x+r.width-rx-rx, r.y+r.height-ry-ry, rx+rx, ry+ry), - 270, 360, pbrush,FALSE); - - app_fill_arc(dc, rect(r.x+r.width-rx-rx, r.y, rx+rx, ry+ry), - 0, 90, pbrush,FALSE); - } - if (Wellipse < r.width) - { - app_fill_rect(dc, rect(r.x+rx, r.y, r.width-rx-rx, ry+1), pbrush, FALSE); - app_fill_rect(dc, rect(r.x+rx, r.y+r.height-ry+1, r.width-rx-rx, ry-1), pbrush, FALSE); - } - if (Hellipse < r.height) - { - app_fill_rect(dc, rect(r.x, r.y+ry+1, r.width, r.height-ry-ry), pbrush, FALSE); - } - - return TRUE; + Rect r; + int rx, ry; /* radius in x and y directions */ + + // x y Width Height + r = rect( Left, Top, abs(Right-Left), abs(Bottom-Top)); + rx = Wellipse/2; + ry = Hellipse/2; + + if (Wellipse > r.width) + { + if (Hellipse > r.height) // > W > H + app_fill_ellipse(dc, r, pbrush); + else // > W < H + { + app_fill_arc(dc, rect( r.x, r.y, r.width - 1, Hellipse), + 0, 180, pbrush,FALSE); + app_fill_arc(dc, rect(r.x, Bottom - Hellipse - 1, r.width - 1, Hellipse), + 180, 360, pbrush, FALSE); + } + } + else if(Hellipse > r.height) // < W > H + { + app_fill_arc(dc, rect(r.x, r.y, Wellipse, r.height - 1), + 90, 270, pbrush, FALSE); + app_fill_arc(dc, rect(Right - Wellipse - 1, r.y, Wellipse, r.height - 1), + 270, 90, pbrush,FALSE); + } + else // < W < H + { + app_fill_arc(dc, rect(r.x, r.y, rx+rx, ry+ry), + 90, 180, pbrush, FALSE); + + app_fill_arc(dc, rect(r.x, r.y+r.height-ry-ry, rx+rx, ry+ry), + 180, 270, pbrush, FALSE); + + app_fill_arc(dc, rect(r.x+r.width-rx-rx, r.y+r.height-ry-ry, rx+rx, ry+ry), + 270, 360, pbrush,FALSE); + + app_fill_arc(dc, rect(r.x+r.width-rx-rx, r.y, rx+rx, ry+ry), + 0, 90, pbrush,FALSE); + } + if (Wellipse < r.width) + { + app_fill_rect(dc, rect(r.x+rx, r.y, r.width-rx-rx, ry+1), pbrush, FALSE); + app_fill_rect(dc, rect(r.x+rx, r.y+r.height-ry+1, r.width-rx-rx, ry-1), pbrush, FALSE); + } + if (Hellipse < r.height) + { + app_fill_rect(dc, rect(r.x, r.y+ry+1, r.width, r.height-ry-ry), pbrush, FALSE); + } + + return TRUE; } @@ -1414,62 +1469,62 @@ INT Hellipse, PBRUSH pbrushPen) { - Rect r; - int rx, ry; /* radius in x and y directions */ - int w = pbrushPen->ptPenWidth.x; - - r = rect( Left, Top, abs(Right-Left), abs(Bottom-Top)); - rx = Wellipse/2; - ry = Hellipse/2; - - if (Wellipse > r.width) - { - if (Hellipse > r.height) // > W > H - app_draw_ellipse(dc, r, pbrushPen); - else // > W < H - { - app_draw_arc(dc, rect( r.x, r.y, r.width - 1, Hellipse - 1), + Rect r; + int rx, ry; /* radius in x and y directions */ + int w = pbrushPen->ptPenWidth.x; + + r = rect( Left, Top, abs(Right-Left), abs(Bottom-Top)); + rx = Wellipse/2; + ry = Hellipse/2; + + if (Wellipse > r.width) + { + if (Hellipse > r.height) // > W > H + app_draw_ellipse(dc, r, pbrushPen); + else // > W < H + { + app_draw_arc(dc, rect( r.x, r.y, r.width - 1, Hellipse - 1), 0, 180, pbrushPen, FALSE); - app_draw_arc(dc, rect(r.x, Bottom - Hellipse, r.width - 1, Hellipse - 1), + app_draw_arc(dc, rect(r.x, Bottom - Hellipse, r.width - 1, Hellipse - 1), 180, 360, pbrushPen, FALSE); - } - } - else if(Hellipse > r.height) // < W > H - { + } + } + else if(Hellipse > r.height) // < W > H + { app_draw_arc(dc, rect(r.x, r.y, Wellipse - 1, r.height - 1), - 90, 270, pbrushPen, FALSE); + 90, 270, pbrushPen, FALSE); app_draw_arc(dc, rect(Right - Wellipse, r.y, Wellipse - 1, r.height - 1), - 270, 90, pbrushPen, FALSE); - } - else // < W < H - { - app_draw_arc(dc, rect(r.x, r.y, rx+rx, ry+ry), - 90, 180, pbrushPen, FALSE); - - app_draw_arc(dc, rect(r.x,r.y+r.height-ry-ry,rx+rx,ry+ry), - 180, 270, pbrushPen, FALSE); - - app_draw_arc(dc, rect(r.x+r.width-rx-rx, r.y+r.height-ry-ry, rx+rx, ry+ry), - 270, 360, pbrushPen, FALSE); - - app_draw_arc(dc, rect(r.x+r.width-rx-rx,r.y,rx+rx,ry+ry), - 0, 90, pbrushPen, FALSE); - } - if ( Hellipse < r.height) - { - app_fill_rect(dc, rect(r.x, r.y+ry+1, w, r.height-ry-ry), pbrushPen, TRUE); - - - app_fill_rect(dc, rect(r.x+r.width-w, r.y+ry+1, w, r.height-ry-ry), - pbrushPen, TRUE); - } - if ( Wellipse < r.width) - { - app_fill_rect(dc, rect(r.x+rx, r.y+r.height-w, r.width-rx-rx, w), - pbrushPen, TRUE); - - app_fill_rect(dc, rect(r.x+rx, r.y, r.width-rx-rx, w), pbrushPen, TRUE); - } - return TRUE; + 270, 90, pbrushPen, FALSE); + } + else // < W < H + { + app_draw_arc(dc, rect(r.x, r.y, rx+rx, ry+ry), + 90, 180, pbrushPen, FALSE); + + app_draw_arc(dc, rect(r.x,r.y+r.height-ry-ry,rx+rx,ry+ry), + 180, 270, pbrushPen, FALSE); + + app_draw_arc(dc, rect(r.x+r.width-rx-rx, r.y+r.height-ry-ry, rx+rx, ry+ry), + 270, 360, pbrushPen, FALSE); + + app_draw_arc(dc, rect(r.x+r.width-rx-rx,r.y,rx+rx,ry+ry), + 0, 90, pbrushPen, FALSE); + } + if ( Hellipse < r.height) + { + app_fill_rect(dc, rect(r.x, r.y+ry+1, w, r.height-ry-ry), pbrushPen, TRUE); + + + app_fill_rect(dc, rect(r.x+r.width-w, r.y+ry+1, w, r.height-ry-ry), + pbrushPen, TRUE); + } + if ( Wellipse < r.width) + { + app_fill_rect(dc, rect(r.x+rx, r.y+r.height-w, r.width-rx-rx, w), + pbrushPen, TRUE); + + app_fill_rect(dc, rect(r.x+rx, r.y, r.width-rx-rx, w), pbrushPen, TRUE); + } + return TRUE; }
13 years, 9 months
1
0
0
0
[tkreuzer] 50938: [GDI32_APITEST] Fix a bug
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Mon Feb 28 20:04:10 2011 New Revision: 50938 URL:
http://svn.reactos.org/svn/reactos?rev=50938&view=rev
Log: [GDI32_APITEST] Fix a bug Modified: trunk/rostests/apitests/gdi32/MaskBlt.c Modified: trunk/rostests/apitests/gdi32/MaskBlt.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/MaskBlt.c?…
============================================================================== --- trunk/rostests/apitests/gdi32/MaskBlt.c [iso-8859-1] (original) +++ trunk/rostests/apitests/gdi32/MaskBlt.c [iso-8859-1] Mon Feb 28 20:04:10 2011 @@ -140,8 +140,8 @@ Test_MaskBlt_1bpp(); switch (GetDeviceCaps(GetDC(NULL), BITSPIXEL)) { - case 16: Test_MaskBlt_16bpp(); - case 32: Test_MaskBlt_32bpp(); + case 16: Test_MaskBlt_16bpp(); break; + case 32: Test_MaskBlt_32bpp(); break; } }
13 years, 9 months
1
0
0
0
[tkreuzer] 50937: [GDI32_APITEST] More tests for MaskBlt
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Mon Feb 28 18:01:12 2011 New Revision: 50937 URL:
http://svn.reactos.org/svn/reactos?rev=50937&view=rev
Log: [GDI32_APITEST] More tests for MaskBlt Modified: trunk/rostests/apitests/gdi32/MaskBlt.c Modified: trunk/rostests/apitests/gdi32/MaskBlt.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/MaskBlt.c?…
============================================================================== --- trunk/rostests/apitests/gdi32/MaskBlt.c [iso-8859-1] (original) +++ trunk/rostests/apitests/gdi32/MaskBlt.c [iso-8859-1] Mon Feb 28 18:01:12 2011 @@ -45,51 +45,104 @@ ok(ret == 1, "MaskBlt failed (%d)\n", ret); ok (pjBitsDst[0] == 0xF0, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]); - - } -void Test_MaskBlt_RGBA() +void Test_MaskBlt_16bpp() +{ + HDC hdcDst, hdcSrc; + BITMAPINFO bmi1 = {{sizeof(BITMAPINFOHEADER), 8, 1, 1, 1, BI_RGB, 0, 10, 10, 0,0}}; + BITMAPINFO bmi32 = {{sizeof(BITMAPINFOHEADER), 8, 1, 1, 16, BI_RGB, 0, 10, 10, 0,0}}; + HBITMAP hbmDst, hbmSrc, hbmMsk; + PUCHAR pjBitsMsk; + PUSHORT pusBitsDst, pusBitsSrc; + BOOL ret; + + /* Create a dest dc and bitmap */ + hdcDst = CreateCompatibleDC(NULL); + hbmDst = CreateDIBSection(hdcDst, &bmi32, DIB_RGB_COLORS, (PVOID*)&pusBitsDst, NULL, 0); + SelectObject(hdcDst, hbmDst); + + /* Create a source dc and bitmap */ + hdcSrc = CreateCompatibleDC(NULL); + hbmSrc = CreateDIBSection(hdcSrc, &bmi32, DIB_RGB_COLORS, (PVOID*)&pusBitsSrc, NULL, 0); + SelectObject(hdcSrc, hbmSrc); + ok(hdcSrc && hbmSrc, "\n"); + + /* Create a 1 bpp mask bitmap */ + hbmMsk = CreateDIBSection(hdcDst, &bmi1, DIB_RGB_COLORS, (PVOID*)&pjBitsMsk, NULL, 0); + ok(hbmMsk != 0, "CreateDIBSection failed\n"); + + /* Do the masking */ + pusBitsDst[0] = 0x1234; + pusBitsDst[1] = 0x5678; + pusBitsSrc[0] = 0x4321; + pusBitsSrc[1] = 0x8765; + pjBitsMsk[0] = 0x80; + ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000)); + ok(ret == 1, "MaskBlt failed (%d)\n", ret); + ok (pusBitsDst[0] == 0x4321, "pusBitsDst[0] == 0x%x\n", pusBitsDst[0]); + ok (pusBitsDst[1] == 0x5678, "pusBitsDst[0] == 0x%x\n", pusBitsDst[1]); + + pusBitsDst[0] = 0x1234; + pusBitsDst[1] = 0x5678; + ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCPAINT, MERGEPAINT)); + ok(ret == 1, "MaskBlt failed (%d)\n", ret); + ok (pusBitsDst[0] == 0x5335, "pusBitsDst[0] == 0x%x\n", pusBitsDst[0]); + ok (pusBitsDst[1] == 0x7efa, "pusBitsDst[0] == 0x%x\n", pusBitsDst[1]); +} + +void Test_MaskBlt_32bpp() { HDC hdcDst, hdcSrc; BITMAPINFO bmi1 = {{sizeof(BITMAPINFOHEADER), 8, 1, 1, 1, BI_RGB, 0, 10, 10, 0,0}}; BITMAPINFO bmi32 = {{sizeof(BITMAPINFOHEADER), 8, 1, 1, 32, BI_RGB, 0, 10, 10, 0,0}}; HBITMAP hbmDst, hbmSrc, hbmMsk; - PUCHAR pjBitsDst, pjBitsSrc, pjBitsMsk; + PUCHAR pjBitsMsk; + PULONG pulBitsDst, pulBitsSrc; BOOL ret; /* Create a dest dc and bitmap */ hdcDst = CreateCompatibleDC(NULL); - hbmDst = CreateDIBSection(hdcDst, &bmi32, DIB_RGB_COLORS, (PVOID*)&pjBitsDst, NULL, 0); + hbmDst = CreateDIBSection(hdcDst, &bmi32, DIB_RGB_COLORS, (PVOID*)&pulBitsDst, NULL, 0); SelectObject(hdcDst, hbmDst); /* Create a source dc and bitmap */ hdcSrc = CreateCompatibleDC(NULL); - hbmSrc = CreateDIBSection(hdcSrc, &bmi32, DIB_RGB_COLORS, (PVOID*)&pjBitsSrc, NULL, 0); + hbmSrc = CreateDIBSection(hdcSrc, &bmi32, DIB_RGB_COLORS, (PVOID*)&pulBitsSrc, NULL, 0); SelectObject(hdcSrc, hbmSrc); + ok(hdcSrc && hbmSrc, "\n"); /* Create a 1 bpp mask bitmap */ hbmMsk = CreateDIBSection(hdcDst, &bmi1, DIB_RGB_COLORS, (PVOID*)&pjBitsMsk, NULL, 0); + ok(hbmMsk != 0, "CreateDIBSection failed\n"); /* Do the masking */ - pjBitsDst[0] = 0xAA; - pjBitsSrc[0] = 0xCC; - pjBitsMsk[0] = 0xF0; + pulBitsDst[0] = 0x12345678; + pulBitsDst[1] = 0x9abcdef0; + pulBitsSrc[0] = 0x87684321; + pulBitsSrc[1] = 0x0fedcba9; + pjBitsMsk[0] = 0x80; ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000)); ok(ret == 1, "MaskBlt failed (%d)\n", ret); - ok (pjBitsDst[0] == 0xCA, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]); + ok (pulBitsDst[0] == 0x87684321, "pulBitsDst[0] == 0x%lx\n", pulBitsDst[0]); + ok (pulBitsDst[1] == 0x9abcdef0, "pulBitsDst[0] == 0x%lx\n", pulBitsDst[1]); - pjBitsDst[0] = 0x00; - pjBitsSrc[0] = 0xFF; - pjBitsMsk[0] = 0xF0; - ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCCOPY, 0xAA0000)); + pulBitsDst[0] = 0x12345678; + pulBitsDst[1] = 0x9abcdef0; + ret = MaskBlt(hdcDst, 0, 0, 8, 1, hdcSrc, 0, 0, hbmMsk, 0, 0, MAKEROP4(SRCPAINT, MERGEPAINT)); ok(ret == 1, "MaskBlt failed (%d)\n", ret); - ok (pjBitsDst[0] == 0xF0, "pjBitsDst[0] == 0x%x\n", pjBitsDst[0]); - + ok (pulBitsDst[0] == 0x977c5779, "pulBitsDst[0] == 0x%lx\n", pulBitsDst[0]); + ok (pulBitsDst[1] == 0xfabefef6, "pulBitsDst[0] == 0x%lx\n", pulBitsDst[1]); } START_TEST(MaskBlt) { Test_MaskBlt_1bpp(); + switch (GetDeviceCaps(GetDC(NULL), BITSPIXEL)) + { + case 16: Test_MaskBlt_16bpp(); + case 32: Test_MaskBlt_32bpp(); + } + }
13 years, 9 months
1
0
0
0
[jimtabor] 50936: [Win32k|User32] - Use User32 GetWindowRgnBox, still passing both wine msg SetWindowRgn and win winregion tests, see bug 5959.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Mon Feb 28 16:45:57 2011 New Revision: 50936 URL:
http://svn.reactos.org/svn/reactos?rev=50936&view=rev
Log: [Win32k|User32] - Use User32 GetWindowRgnBox, still passing both wine msg SetWindowRgn and win winregion tests, see bug 5959. Modified: trunk/reactos/dll/win32/user32/windows/paint.c trunk/reactos/include/reactos/win32k/ntuser.h trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c trunk/reactos/subsystems/win32/win32k/ntuser/window.c Modified: trunk/reactos/dll/win32/user32/windows/paint.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/p…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/paint.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/paint.c [iso-8859-1] Mon Feb 28 16:45:57 2011 @@ -278,9 +278,9 @@ pWnd = ValidateHwnd(hWnd); - if (!pWnd) // || !pWnd->hrgnClip || pWnd->state2 & WNDS2_MAXIMIZEDMONITORREGION) - return ERROR; -/* + if (!pWnd || !pWnd->hrgnClip || pWnd->state2 & WNDS2_MAXIMIZEDMONITORREGION) + return ERROR; + Ret = CombineRgn(hRgn, pWnd->hrgnClip, NULL, RGN_COPY); if (!Ret) @@ -291,8 +291,6 @@ if (pWnd->ExStyle & WS_EX_LAYOUTRTL) MirrorRgn(hWnd, hRgn); -*/ - Ret = (int)NtUserCallTwoParam((DWORD_PTR)hWnd, (DWORD_PTR)hRgn, TWOPARAM_ROUTINE_GETWINDOWRGN); return Ret; } Modified: trunk/reactos/include/reactos/win32k/ntuser.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
============================================================================== --- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Mon Feb 28 16:45:57 2011 @@ -3130,7 +3130,6 @@ #define ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING 0xfffe000d #define ONEPARAM_ROUTINE_GETDESKTOPMAPPING 0xfffe000e #define ONEPARAM_ROUTINE_GETCURSORPOSITION 0xfffe0048 // use ONEPARAM_ or TWOPARAM routine ? -#define TWOPARAM_ROUTINE_GETWINDOWRGN 0xfffd0049 // user mode #define TWOPARAM_ROUTINE_SETMENUBARHEIGHT 0xfffd0050 #define TWOPARAM_ROUTINE_SETGUITHRDHANDLE 0xfffd0052 #define MSQ_STATE_CAPTURE 0x1 Modified: trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c [iso-8859-1] Mon Feb 28 16:45:57 2011 @@ -375,13 +375,6 @@ switch(Routine) { - case TWOPARAM_ROUTINE_GETWINDOWRGN: - { - Window = UserGetWindowObject((HWND)Param1); - if (!Window) RETURN(ERROR); - - RETURN( (DWORD_PTR)IntGetWindowRgn(Window, (HRGN)Param2)); - } case TWOPARAM_ROUTINE_SETMENUBARHEIGHT: { DWORD_PTR Ret; Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Mon Feb 28 16:45:57 2011 @@ -4016,46 +4016,6 @@ END_CLEANUP; } - -// This should be in user32! -INT FASTCALL -IntGetWindowRgn(PWND Window, HRGN hRgn) -{ - INT Ret; - HRGN VisRgn; - ROSRGNDATA *pRgn; - - if(!Window) - { - return ERROR; - } - if(!hRgn) - { - return ERROR; - } - - /* Create a new window region using the window rectangle */ - VisRgn = IntSysCreateRectRgnIndirect(&Window->rcWindow); - NtGdiOffsetRgn(VisRgn, -Window->rcWindow.left, -Window->rcWindow.top); - /* if there's a region assigned to the window, combine them both */ - if(Window->hrgnClip && !(Window->style & WS_MINIMIZE)) - NtGdiCombineRgn(VisRgn, VisRgn, Window->hrgnClip, RGN_AND); - /* Copy the region into hRgn */ - NtGdiCombineRgn(hRgn, VisRgn, NULL, RGN_COPY); - - if((pRgn = RGNOBJAPI_Lock(hRgn, NULL))) - { - Ret = REGION_Complexity(pRgn); - RGNOBJAPI_Unlock(pRgn); - } - else - Ret = ERROR; - - REGION_FreeRgnByHandle(VisRgn); - - return Ret; -} - /* * @implemented */ @@ -4084,9 +4044,6 @@ if (GDIOBJ_ValidateHandle(hRgn, GDI_OBJECT_TYPE_REGION)) { hrgnCopy = IntSysCreateRectRgn(0, 0, 0, 0); - - /* Set public ownership */ - IntGdiSetRegionOwner(hrgnCopy, GDI_OBJ_HMGR_PUBLIC); NtGdiCombineRgn(hrgnCopy, hRgn, 0, RGN_COPY); }
13 years, 9 months
1
0
0
0
[khornicek] 50935: [WIN32K] Fix calculating of ScanLines and source point in NtGdiGetDIBitsInternal for top-down bitmaps to more closely mimic win xp behavior. (Timo - high five for your test app) ...
by khornicek@svn.reactos.org
Author: khornicek Date: Mon Feb 28 12:47:01 2011 New Revision: 50935 URL:
http://svn.reactos.org/svn/reactos?rev=50935&view=rev
Log: [WIN32K] Fix calculating of ScanLines and source point in NtGdiGetDIBitsInternal for top-down bitmaps to more closely mimic win xp behavior. (Timo - high five for your test app) See issue #5524 for more details. Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c 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] Mon Feb 28 12:47:01 2011 @@ -939,9 +939,26 @@ rcDest.bottom = ScanLines; rcDest.right = psurf->SurfObj.sizlBitmap.cx; - srcPoint.x = 0; - srcPoint.y = height < 0 ? - psurf->SurfObj.sizlBitmap.cy - (StartScan + ScanLines) : StartScan; + srcPoint.x = 0; + + if(height < 0) + { + srcPoint.y = 0; + + if(ScanLines <= StartScan) + { + ScanLines = 1; + SURFACE_ShareUnlockSurface(psurfDest); + GreDeleteObject(hBmpDest); + goto done; + } + + ScanLines -= StartScan; + } + else + { + srcPoint.y = StartScan; + } EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0xffffff, 0xffffff, 0);
13 years, 9 months
1
0
0
0
[jimtabor] 50934: [Win32k|User32] - Use User32 GetWindowRgnBox, still passing both wine msg SetWindowRgn and win winregion tests, see bug 5959.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Mon Feb 28 09:10:43 2011 New Revision: 50934 URL:
http://svn.reactos.org/svn/reactos?rev=50934&view=rev
Log: [Win32k|User32] - Use User32 GetWindowRgnBox, still passing both wine msg SetWindowRgn and win winregion tests, see bug 5959. Modified: trunk/reactos/dll/win32/user32/windows/paint.c trunk/reactos/include/reactos/win32k/ntuser.h trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c trunk/reactos/subsystems/win32/win32k/ntuser/window.c Modified: trunk/reactos/dll/win32/user32/windows/paint.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/p…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/paint.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/paint.c [iso-8859-1] Mon Feb 28 09:10:43 2011 @@ -278,7 +278,7 @@ pWnd = ValidateHwnd(hWnd); - if (!pWnd) // || !pwnd->hrgnClip || pwnd->state2 & WNDS2_MAXIMIZEDMONITORREGION) + if (!pWnd) // || !pWnd->hrgnClip || pWnd->state2 & WNDS2_MAXIMIZEDMONITORREGION) return ERROR; /* Ret = CombineRgn(hRgn, pWnd->hrgnClip, NULL, RGN_COPY); @@ -314,21 +314,19 @@ pWnd = ValidateHwnd(hWnd); - if (!pWnd) // || !pwnd->hrgnClip || pwnd->state2 & WNDS2_MAXIMIZEDMONITORREGION) - return ERROR; -/* + if (!pWnd || !pWnd->hrgnClip || pWnd->state2 & WNDS2_MAXIMIZEDMONITORREGION) + return ERROR; + Ret = GetRgnBox(pWnd->hrgnClip, lprc); if (!Ret) return ERROR; if (pWnd->fnid != FNID_DESKTOP) - Ret = OffsetRect(lprc, -pWnd->rcWindow.left, -pWnd->rcWindow.top); + OffsetRect(lprc, -pWnd->rcWindow.left, -pWnd->rcWindow.top); if (pWnd->ExStyle & WS_EX_LAYOUTRTL) MirrorWindowRect(pWnd, lprc); -*/ - Ret = (int)NtUserCallTwoParam((DWORD_PTR)hWnd, (DWORD_PTR)lprc, TWOPARAM_ROUTINE_GETWINDOWRGNBOX); return Ret; } Modified: trunk/reactos/include/reactos/win32k/ntuser.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
============================================================================== --- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Mon Feb 28 09:10:43 2011 @@ -3130,7 +3130,6 @@ #define ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING 0xfffe000d #define ONEPARAM_ROUTINE_GETDESKTOPMAPPING 0xfffe000e #define ONEPARAM_ROUTINE_GETCURSORPOSITION 0xfffe0048 // use ONEPARAM_ or TWOPARAM routine ? -#define TWOPARAM_ROUTINE_GETWINDOWRGNBOX 0xfffd0048 // user mode #define TWOPARAM_ROUTINE_GETWINDOWRGN 0xfffd0049 // user mode #define TWOPARAM_ROUTINE_SETMENUBARHEIGHT 0xfffd0050 #define TWOPARAM_ROUTINE_SETGUITHRDHANDLE 0xfffd0052 Modified: trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c [iso-8859-1] Mon Feb 28 09:10:43 2011 @@ -367,7 +367,6 @@ DWORD_PTR Param2, DWORD Routine) { - NTSTATUS Status; PWND Window; DECLARE_RETURN(DWORD_PTR); @@ -376,22 +375,6 @@ switch(Routine) { - case TWOPARAM_ROUTINE_GETWINDOWRGNBOX: - { - DWORD_PTR Ret; - RECTL rcRect; - Window = UserGetWindowObject((HWND)Param1); - if (!Window) RETURN(ERROR); - - Ret = (DWORD_PTR)IntGetWindowRgnBox(Window, &rcRect); - Status = MmCopyToCaller((PVOID)Param2, &rcRect, sizeof(RECT)); - if(!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - RETURN( ERROR); - } - RETURN( Ret); - } case TWOPARAM_ROUTINE_GETWINDOWRGN: { Window = UserGetWindowObject((HWND)Param1); Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Mon Feb 28 09:10:43 2011 @@ -4056,45 +4056,6 @@ return Ret; } -// This should be in user32! -INT FASTCALL -IntGetWindowRgnBox(PWND Window, RECTL *Rect) -{ - INT Ret; - HRGN VisRgn; - ROSRGNDATA *pRgn; - - if(!Window) - { - return ERROR; - } - if(!Rect) - { - return ERROR; - } - - /* Create a new window region using the window rectangle */ - VisRgn = IntSysCreateRectRgnIndirect(&Window->rcWindow); - NtGdiOffsetRgn(VisRgn, -Window->rcWindow.left, -Window->rcWindow.top); - /* if there's a region assigned to the window, combine them both */ - if(Window->hrgnClip && !(Window->style & WS_MINIMIZE)) - NtGdiCombineRgn(VisRgn, VisRgn, Window->hrgnClip, RGN_AND); - - if((pRgn = RGNOBJAPI_Lock(VisRgn, NULL))) - { - Ret = REGION_Complexity(pRgn); - *Rect = pRgn->rdh.rcBound; - RGNOBJAPI_Unlock(pRgn); - } - else - Ret = ERROR; - - REGION_FreeRgnByHandle(VisRgn); - - return Ret; -} - - /* * @implemented */ @@ -4142,6 +4103,12 @@ /* Delete no longer needed region handle */ GreDeleteObject(Window->hrgnClip); } + + if (Window->fnid != FNID_DESKTOP) + NtGdiOffsetRgn(hrgnCopy, Window->rcWindow.left, Window->rcWindow.top); + + /* Set public ownership */ + IntGdiSetRegionOwner(hrgnCopy, GDI_OBJ_HMGR_PUBLIC); Window->hrgnClip = hrgnCopy;
13 years, 9 months
1
0
0
0
[jimtabor] 50933: [Win32k|User32] - Clarify the meaning and the use of 0, 1 and 2 for user window regions, wine never did. Noticing patches not corresponding in correctness and understanding, leavi...
by jimtabor@svn.reactos.org
Author: jimtabor Date: Mon Feb 28 06:31:44 2011 New Revision: 50933 URL:
http://svn.reactos.org/svn/reactos?rev=50933&view=rev
Log: [Win32k|User32] - Clarify the meaning and the use of 0, 1 and 2 for user window regions, wine never did. Noticing patches not corresponding in correctness and understanding, leaving potential crashes in the DCE code, which depend on these types. - Patch based on Rafal Harabien patch, fixes wine msg SetWindowRgn test, see also bug 5959. Modified: trunk/reactos/dll/win32/user32/windows/defwnd.c trunk/reactos/dll/win32/user32/windows/nonclient.c trunk/reactos/dll/win32/user32/windows/window.c trunk/reactos/include/reactos/win32k/ntuser.h trunk/reactos/subsystems/win32/win32k/ntuser/painting.c trunk/reactos/subsystems/win32/win32k/ntuser/windc.c trunk/reactos/subsystems/win32/win32k/ntuser/window.c trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c Modified: trunk/reactos/dll/win32/user32/windows/defwnd.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/d…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] Mon Feb 28 06:31:44 2011 @@ -1189,7 +1189,7 @@ case WM_SYSCOLORCHANGE: { /* force to redraw non-client area */ - DefWndNCPaint(hWnd, (HRGN)1, -1); + DefWndNCPaint(hWnd, HRGN_WINDOW, -1); /* Use InvalidateRect to redraw client area, enable * erase to redraw all subcontrols otherwise send the * WM_SYSCOLORCHANGE to child windows/controls is required @@ -1966,7 +1966,7 @@ if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION) { - DefWndNCPaint(hWnd, (HRGN)1, -1); + DefWndNCPaint(hWnd, HRGN_WINDOW, -1); } Result = 1; break; @@ -2112,7 +2112,7 @@ if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION) { - DefWndNCPaint(hWnd, (HRGN)1, -1); + DefWndNCPaint(hWnd, HRGN_WINDOW, -1); } Result = 1; break; Modified: trunk/reactos/dll/win32/user32/windows/nonclient.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/n…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/nonclient.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/nonclient.c [iso-8859-1] Mon Feb 28 06:31:44 2011 @@ -489,7 +489,8 @@ } ReleaseDC(hWnd, hDC); - DeleteObject(hRgn); // We use DCX_KEEPCLIPRGN + if (hRgn != HRGN_WINDOW) + DeleteObject(hRgn); // We use DCX_KEEPCLIPRGN return 0; } @@ -650,7 +651,7 @@ LRESULT DefWndNCActivate(HWND hWnd, WPARAM wParam) { - DefWndNCPaint(hWnd, (HRGN)1, wParam); + DefWndNCPaint(hWnd, HRGN_WINDOW, wParam); return TRUE; } Modified: trunk/reactos/dll/win32/user32/windows/window.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/w…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] Mon Feb 28 06:31:44 2011 @@ -1727,7 +1727,7 @@ if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION) { - DefWndNCPaint(hWnd, (HRGN)1, -1); + DefWndNCPaint(hWnd, HRGN_WINDOW, -1); } return TRUE; } @@ -1757,7 +1757,7 @@ if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION) { - DefWndNCPaint(hWnd, (HRGN)1, -1); + DefWndNCPaint(hWnd, HRGN_WINDOW, -1); } return TRUE; } Modified: trunk/reactos/include/reactos/win32k/ntuser.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
============================================================================== --- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Mon Feb 28 06:31:44 2011 @@ -230,6 +230,10 @@ C_ASSERT(sizeof(CLIENTINFO) <= sizeof(((PTEB)0)->Win32ClientInfo)); #define GetWin32ClientInfo() ((PCLIENTINFO)(NtCurrentTeb()->Win32ClientInfo)) + +#define HRGN_NULL ( (HRGN) 0) // NULL empty region +#define HRGN_WINDOW ( (HRGN) 1) // region from window rcWindow +#define HRGN_MONITOR ( (HRGN) 2) // region from monitor region. /* Menu Item fType. */ #define MFT_RTOL 0x6000 Modified: trunk/reactos/subsystems/win32/win32k/ntuser/painting.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] Mon Feb 28 06:31:44 2011 @@ -141,7 +141,7 @@ UINT RgnType; if (Window->hrgnUpdate != NULL && - Window->hrgnUpdate != (HRGN)1) + Window->hrgnUpdate != HRGN_WINDOW) { hRgnNonClient = IntCalcWindowRgn(Window, FALSE); @@ -151,14 +151,14 @@ */ if (hRgnNonClient == NULL) { - return (HRGN)1; + return HRGN_WINDOW; } hRgnWindow = IntCalcWindowRgn(Window, TRUE); if (hRgnWindow == NULL) { REGION_FreeRgnByHandle(hRgnNonClient); - return (HRGN)1; + return HRGN_WINDOW; } RgnType = NtGdiCombineRgn(hRgnNonClient, hRgnNonClient, @@ -167,7 +167,7 @@ { REGION_FreeRgnByHandle(hRgnWindow); REGION_FreeRgnByHandle(hRgnNonClient); - return (HRGN)1; + return HRGN_WINDOW; } else if (RgnType == NULLREGION) { @@ -1049,7 +1049,7 @@ else { /* Get the update region bounding box. */ - if (Window->hrgnUpdate == (HRGN)1) + if (Window->hrgnUpdate == HRGN_WINDOW) { Rect = Window->rcClient; } Modified: trunk/reactos/subsystems/win32/win32k/ntuser/windc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/windc.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/windc.c [iso-8859-1] Mon Feb 28 06:31:44 2011 @@ -551,7 +551,7 @@ ClipRegion = Wnd->hrgnUpdate; } - if (ClipRegion == (HRGN) 1) + if (ClipRegion == HRGN_WINDOW) { if (!(Flags & DCX_WINDOW)) { Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Mon Feb 28 06:31:44 2011 @@ -4017,6 +4017,7 @@ } +// This should be in user32! INT FASTCALL IntGetWindowRgn(PWND Window, HRGN hRgn) { @@ -4055,6 +4056,7 @@ return Ret; } +// This should be in user32! INT FASTCALL IntGetWindowRgnBox(PWND Window, RECTL *Rect) { @@ -4104,6 +4106,8 @@ { HRGN hrgnCopy; PWND Window; + INT flags = (SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE); + BOOLEAN Ret = FALSE; DECLARE_RETURN(INT); DPRINT("Enter NtUserSetWindowRgn\n"); @@ -4119,32 +4123,31 @@ if (GDIOBJ_ValidateHandle(hRgn, GDI_OBJECT_TYPE_REGION)) { hrgnCopy = IntSysCreateRectRgn(0, 0, 0, 0); + + /* Set public ownership */ + IntGdiSetRegionOwner(hrgnCopy, GDI_OBJ_HMGR_PUBLIC); + NtGdiCombineRgn(hrgnCopy, hRgn, 0, RGN_COPY); } else RETURN( 0); } else - hrgnCopy = (HRGN) 1; + { + hrgnCopy = IntSysCreateRectRgnIndirect(&Window->rcWindow); //HRGN_WINDOW; + } if (Window->hrgnClip) { /* Delete no longer needed region handle */ GreDeleteObject(Window->hrgnClip); } + Window->hrgnClip = hrgnCopy; - /* FIXME - send WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window */ - - if(bRedraw) - { - USER_REFERENCE_ENTRY Ref; - UserRefObjectCo(Window, &Ref); - co_UserRedrawWindow(Window, NULL, NULL, RDW_INVALIDATE); - UserDerefObjectCo(Window); - } - - RETURN( (INT)hRgn); + Ret = co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, bRedraw ? flags : (flags|SWP_NOREDRAW) ); + + RETURN( (INT)Ret); CLEANUP: DPRINT("Leave NtUserSetWindowRgn, ret=%i\n",_ret_); Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] Mon Feb 28 06:31:44 2011 @@ -1120,7 +1120,7 @@ Window->style |= WS_VISIBLE; } - if (Window->hrgnUpdate != NULL && Window->hrgnUpdate != (HRGN)1) + if (Window->hrgnUpdate != NULL && Window->hrgnUpdate != HRGN_WINDOW) { NtGdiOffsetRgn(Window->hrgnUpdate, NewWindowRect.left - OldWindowRect.left,
13 years, 10 months
1
0
0
0
[tkreuzer] 50932: [WIN32K] addendum to r50928: 24 and 32bpp BI_RGB bitmaps are BGR
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Mon Feb 28 00:48:19 2011 New Revision: 50932 URL:
http://svn.reactos.org/svn/reactos?rev=50932&view=rev
Log: [WIN32K] addendum to r50928: 24 and 32bpp BI_RGB bitmaps are BGR Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c 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] Mon Feb 28 00:48:19 2011 @@ -929,7 +929,6 @@ case BMF_1BPP: case BMF_4BPP: case BMF_8BPP: - case BMF_24BPP: pds->dsBmih.biCompression = BI_RGB; break; @@ -940,8 +939,10 @@ pds->dsBmih.biCompression = BI_BITFIELDS; break; + case BMF_24BPP: case BMF_32BPP: - if (psurf->ppal->flFlags & (PAL_RGB|PAL_BGR)) + /* 24/32bpp BI_RGB is actually BGR format */ + if (psurf->ppal->flFlags & PAL_BGR) pds->dsBmih.biCompression = BI_RGB; else pds->dsBmih.biCompression = BI_BITFIELDS;
13 years, 10 months
1
0
0
0
[tkreuzer] 50931: [GDI32] Revert r50519 and r50519
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Mon Feb 28 00:19:32 2011 New Revision: 50931 URL:
http://svn.reactos.org/svn/reactos?rev=50931&view=rev
Log: [GDI32] Revert r50519 and r50519 Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/bi…
============================================================================== --- trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] Mon Feb 28 00:19:32 2011 @@ -410,35 +410,6 @@ return CreateDIBSection(hDC, (CONST BITMAPINFO *)&dibs.dsBmih, 0, NULL, NULL, 0); } -void -ConvertBackBitmapInfo(PBITMAPINFO pbmi, PBITMAPINFO pbmiConverted) -{ - INT i; - - /* Check if we converted from PBITMAPCOREINFO */ - if (pbmiConverted != pbmi) - { - PBITMAPCOREINFO pbci = (PBITMAPCOREINFO)pbmi; - - /* Convert back header */ - pbci->bmciHeader.bcSize = sizeof(BITMAPCOREHEADER); - pbci->bmciHeader.bcWidth = pbmiConverted->bmiHeader.biWidth; - pbci->bmciHeader.bcHeight = pbmiConverted->bmiHeader.biHeight; - pbci->bmciHeader.bcPlanes = 1; - pbci->bmciHeader.bcBitCount = pbmiConverted->bmiHeader.biBitCount; - - /* Convert back colors */ - for (i = 0; i < pbmiConverted->bmiHeader.biClrUsed; i++) - { - pbci->bmciColors[i].rgbtRed = pbmiConverted->bmiColors[i].rgbRed; - pbci->bmciColors[i].rgbtGreen = pbmiConverted->bmiColors[i].rgbGreen; - pbci->bmciColors[i].rgbtBlue = pbmiConverted->bmiColors[i].rgbBlue; - } - - /* Free memory */ - RtlFreeHeap(RtlGetProcessHeap(), 0, pbmiConverted); - } -} INT WINAPI @@ -451,9 +422,8 @@ LPBITMAPINFO lpbmi, UINT uUsage) { - PBITMAPINFO pbmiConverted; - UINT cjBmpScanSize, cjInfoSize; - INT iResult; + UINT cjBmpScanSize; + UINT cjInfoSize; if (!hDC || !GdiIsHandleValid((HGDIOBJ)hDC) || !lpbmi) { @@ -461,22 +431,15 @@ return 0; } - /* Convert BITMAPINFO to a proper format */ - pbmiConverted = ConvertBitmapInfo(lpbmi, uUsage, &cjInfoSize, FALSE); - if (!pbmiConverted) - { - GdiSetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - cjBmpScanSize = DIB_BitmapMaxBitsSize(lpbmi, cScanLines); - - if (lpvBits) - { - if (lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) - { - if (lpbmi->bmiHeader.biCompression == BI_JPEG || - lpbmi->bmiHeader.biCompression == BI_PNG) + cjInfoSize = DIB_BitmapInfoSize(lpbmi, uUsage); + + if ( lpvBits ) + { + if ( lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) ) + { + if ( lpbmi->bmiHeader.biCompression == BI_JPEG || + lpbmi->bmiHeader.biCompression == BI_PNG ) { SetLastError(ERROR_INVALID_PARAMETER); return 0; @@ -484,21 +447,16 @@ } } - iResult = NtGdiGetDIBitsInternal(hDC, - hbmp, - uStartScan, - cScanLines, - lpvBits, - pbmiConverted, - uUsage, - cjBmpScanSize, - cjInfoSize); - - ConvertBackBitmapInfo(lpbmi, pbmiConverted); - - return iResult; -} - + return NtGdiGetDIBitsInternal(hDC, + hbmp, + uStartScan, + cScanLines, + lpvBits, + lpbmi, + uUsage, + cjBmpScanSize, + cjInfoSize); +} /* * @implemented
13 years, 10 months
1
0
0
0
← Newer
1
2
3
4
...
36
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Results per page:
10
25
50
100
200