Author: tkreuzer
Date: Wed May 9 08:23:25 2012
New Revision: 56549
URL:
http://svn.reactos.org/svn/reactos?rev=56549&view=rev
Log:
Merge r56543 - r56548
Modified:
branches/dib_rewrite/ (props changed)
branches/dib_rewrite/win32ss/gdi/eng/mouse.c
branches/dib_rewrite/win32ss/gdi/eng/xlate.c
branches/dib_rewrite/win32ss/gdi/ntgdi/dibobj.c
branches/dib_rewrite/win32ss/gdi/ntgdi/gdiobj.c
branches/dib_rewrite/win32ss/gdi/ntgdi/palette.c
branches/dib_rewrite/win32ss/gdi/ntgdi/palette.h
Propchange: branches/dib_rewrite/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 9 08:23:25 2012
@@ -13,4 +13,4 @@
/branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859
/branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567
/branches/wlan-bringup:54809-54998
-/trunk/reactos:56444-56543
+/trunk/reactos:56444-56548
Modified: branches/dib_rewrite/win32ss/gdi/eng/mouse.c
URL:
http://svn.reactos.org/svn/reactos/branches/dib_rewrite/win32ss/gdi/eng/mou…
==============================================================================
--- branches/dib_rewrite/win32ss/gdi/eng/mouse.c [iso-8859-1] (original)
+++ branches/dib_rewrite/win32ss/gdi/eng/mouse.c [iso-8859-1] Wed May 9 08:23:25 2012
@@ -391,7 +391,7 @@
/* Initialize an EXLATEOBJ */
ppal = PALETTE_ShareLockPalette(ppdev->devinfo.hpalDefault);
EXLATEOBJ_vInitialize(&exlo,
- &gpalMono,
+ gppalMono,
ppal,
0,
RGB(0xff,0xff,0xff),
Modified: branches/dib_rewrite/win32ss/gdi/eng/xlate.c
URL:
http://svn.reactos.org/svn/reactos/branches/dib_rewrite/win32ss/gdi/eng/xla…
==============================================================================
--- branches/dib_rewrite/win32ss/gdi/eng/xlate.c [iso-8859-1] (original)
+++ branches/dib_rewrite/win32ss/gdi/eng/xlate.c [iso-8859-1] Wed May 9 08:23:25 2012
@@ -591,8 +591,8 @@
/* Normal initialisation. No surface means DEFAULT_BITMAP */
EXLATEOBJ_vInitialize(pexlo,
- psurfSrc ? psurfSrc->ppal : &gpalMono,
- psurfDst ? psurfDst->ppal : &gpalMono,
+ psurfSrc ? psurfSrc->ppal : gppalMono,
+ psurfDst ? psurfDst->ppal : gppalMono,
pdcSrc->pdcattr->crBackgroundClr,
pdcDst->pdcattr->crBackgroundClr,
pdcDst->pdcattr->crForegroundClr);
Modified: branches/dib_rewrite/win32ss/gdi/ntgdi/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/dib_rewrite/win32ss/gdi/ntgdi/d…
==============================================================================
--- branches/dib_rewrite/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] (original)
+++ branches/dib_rewrite/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] Wed May 9 08:23:25 2012
@@ -111,13 +111,23 @@
_In_ ULONG iUsage)
{
PPALETTE ppal;
- ULONG i, cColors;
+ ULONG i, cBitsPixel, cColors;
+
+ if (pbmi->bmiHeader.biSize < sizeof(BITMAPINFOHEADER))
+ {
+ PBITMAPCOREINFO pbci = (PBITMAPCOREINFO)pbmi;
+ cBitsPixel = pbci->bmciHeader.bcBitCount;
+ }
+ else
+ {
+ cBitsPixel = pbmi->bmiHeader.biBitCount;
+ }
/* Check if the colors are indexed */
- if (pbmi->bmiHeader.biBitCount <= 8)
+ if (cBitsPixel <= 8)
{
/* We create a "full" palette */
- cColors = 1 << pbmi->bmiHeader.biBitCount;
+ cColors = 1 << cBitsPixel;
/* Allocate the palette */
ppal = PALETTE_AllocPalette(PAL_INDEXED,
@@ -128,7 +138,8 @@
0);
/* Check if the BITMAPINFO specifies how many colors to use */
- if (pbmi->bmiHeader.biClrUsed != 0)
+ if ((pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) &&
+ (pbmi->bmiHeader.biClrUsed != 0))
{
/* This is how many colors we can actually process */
cColors = min(cColors, pbmi->bmiHeader.biClrUsed);
@@ -179,7 +190,7 @@
// FIXME: this one is undocumented
// ASSERT(FALSE);
// }
- else // if (iUsage == DIB_RGB_COLORS)
+ else if (pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER))
{
/* The colors are an array of RGBQUAD values */
RGBQUAD *prgb = (RGBQUAD*)((PCHAR)pbmi + pbmi->bmiHeader.biSize);
@@ -197,6 +208,22 @@
PALETTE_vSetRGBColorForIndex(ppal, i, crColor);
}
}
+ else
+ {
+ /* The colors are an array of RGBTRIPLE values */
+ RGBTRIPLE *prgb = (RGBTRIPLE*)((PCHAR)pbmi + pbmi->bmiHeader.biSize);
+
+ /* Loop all color indices in the DIB */
+ for (i = 0; i < cColors; i++)
+ {
+ /* Get the color value and translate it to a COLORREF */
+ RGBTRIPLE rgb = prgb[i];
+ COLORREF crColor = RGB(rgb.rgbtRed, rgb.rgbtGreen, rgb.rgbtBlue);
+
+ /* Set the RGB value in the palette */
+ PALETTE_vSetRGBColorForIndex(ppal, i, crColor);
+ }
+ }
}
else
{
@@ -204,7 +231,8 @@
ULONG flRedMask, flGreenMask, flBlueMask;
/* Check if the DIB contains bitfield values */
- if (pbmi->bmiHeader.biCompression == BI_BITFIELDS)
+ if ((pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) &&
+ (pbmi->bmiHeader.biCompression == BI_BITFIELDS))
{
/* Check if we have a v4/v5 header */
if (pbmi->bmiHeader.biSize >= sizeof(BITMAPV4HEADER))
@@ -228,7 +256,7 @@
{
/* Check what bit depth we have. Note: optimization flags are
calculated in PALETTE_AllocPalette() */
- if (pbmi->bmiHeader.biBitCount == 16)
+ if (cBitsPixel == 16)
{
/* This is an RGB 555 palette */
flRedMask = 0x7C00;
@@ -255,136 +283,6 @@
/* We're done, return the palette */
return ppal;
-}
-
-
-UINT
-APIENTRY
-IntSetDIBColorTable(
- HDC hDC,
- UINT StartIndex,
- UINT Entries,
- CONST RGBQUAD *Colors)
-{
- PDC dc;
- PSURFACE psurf;
- PPALETTE PalGDI;
- UINT Index;
- ULONG biBitCount;
-
- if (!(dc = DC_LockDc(hDC))) return 0;
- if (dc->dctype == DC_TYPE_INFO)
- {
- DC_UnlockDc(dc);
- return 0;
- }
-
- psurf = dc->dclevel.pSurface;
- if (psurf == NULL)
- {
- DC_UnlockDc(dc);
- EngSetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- if (psurf->hSecure == NULL)
- {
- DC_UnlockDc(dc);
- EngSetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
- if ((biBitCount <= 8) && (StartIndex < (1UL << biBitCount)))
- {
- if (StartIndex + Entries > (1UL << biBitCount))
- Entries = (1 << biBitCount) - StartIndex;
-
- if (psurf->ppal == NULL)
- {
- DC_UnlockDc(dc);
- EngSetLastError(ERROR_INVALID_HANDLE);
- return 0;
- }
-
- PalGDI = psurf->ppal;
-
- for (Index = StartIndex;
- Index < StartIndex + Entries && Index <
PalGDI->NumColors;
- Index++)
- {
- PalGDI->IndexedColors[Index].peRed = Colors[Index - StartIndex].rgbRed;
- PalGDI->IndexedColors[Index].peGreen = Colors[Index -
StartIndex].rgbGreen;
- PalGDI->IndexedColors[Index].peBlue = Colors[Index - StartIndex].rgbBlue;
- }
- }
- else
- Entries = 0;
-
- /* Mark the brushes invalid */
- dc->pdcattr->ulDirty_ |= DIRTY_FILL|DIRTY_LINE|DIRTY_BACKGROUND|DIRTY_TEXT;
-
- DC_UnlockDc(dc);
-
- return Entries;
-}
-
-UINT
-APIENTRY
-IntGetDIBColorTable(
- HDC hDC,
- UINT StartIndex,
- UINT Entries,
- RGBQUAD *Colors)
-{
- PDC dc;
- PSURFACE psurf;
- PPALETTE ppal;
- UINT Index, Count = 0;
-
- if (!(dc = DC_LockDc(hDC))) return 0;
- if (dc->dctype == DC_TYPE_INFO)
- {
- DC_UnlockDc(dc);
- return 0;
- }
-
- psurf = dc->dclevel.pSurface;
- if (psurf == NULL)
- {
- DC_UnlockDc(dc);
- EngSetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- if (psurf->hSecure == NULL)
- {
- DC_UnlockDc(dc);
- EngSetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- ppal = psurf->ppal;
- ASSERT(ppal);
-
- if (ppal->flFlags & PAL_INDEXED)
- {
-
- for (Index = StartIndex;
- Index < StartIndex + Entries && Index <
ppal->NumColors;
- Index++)
- {
- Colors[Index - StartIndex].rgbRed = ppal->IndexedColors[Index].peRed;
- Colors[Index - StartIndex].rgbGreen = ppal->IndexedColors[Index].peGreen;
- Colors[Index - StartIndex].rgbBlue = ppal->IndexedColors[Index].peBlue;
- Colors[Index - StartIndex].rgbReserved = 0;
- Count++;
- }
- }
-
- DC_UnlockDc(dc);
-
- return Count;
}
// Converts a DIB to a device-dependent bitmap
Modified: branches/dib_rewrite/win32ss/gdi/ntgdi/gdiobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/dib_rewrite/win32ss/gdi/ntgdi/g…
==============================================================================
--- branches/dib_rewrite/win32ss/gdi/ntgdi/gdiobj.c [iso-8859-1] (original)
+++ branches/dib_rewrite/win32ss/gdi/ntgdi/gdiobj.c [iso-8859-1] Wed May 9 08:23:25 2012
@@ -576,9 +576,6 @@
{
ULONG cRefs;
- /* Must not be exclusively locked */
- ASSERT(pobj->cExclusiveLock == 0);
-
/* Check if the object has a handle */
if (GDI_HANDLE_GET_INDEX(pobj->hHmgr))
{
Modified: branches/dib_rewrite/win32ss/gdi/ntgdi/palette.c
URL:
http://svn.reactos.org/svn/reactos/branches/dib_rewrite/win32ss/gdi/ntgdi/p…
==============================================================================
--- branches/dib_rewrite/win32ss/gdi/ntgdi/palette.c [iso-8859-1] (original)
+++ branches/dib_rewrite/win32ss/gdi/ntgdi/palette.c [iso-8859-1] Wed May 9 08:23:25
2012
@@ -14,7 +14,7 @@
static UINT SystemPaletteUse = SYSPAL_NOSTATIC; /* The program need save the pallete and
restore it */
-PALETTE gpalRGB, gpalBGR, gpalMono, gpalRGB555, gpalRGB565, *gppalDefault;
+PALETTE gpalRGB, gpalBGR, gpalRGB555, gpalRGB565, *gppalMono, *gppalDefault;
PPALETTE appalSurfaceDefault[11];
const PALETTEENTRY g_sysPalTemplate[NB_RESERVED_COLORS] =
@@ -62,30 +62,13 @@
NTAPI
InitPaletteImpl()
{
- int i;
- HPALETTE hpalette;
- PLOGPALETTE palPtr;
-
// Create default palette (20 system colors)
- palPtr = ExAllocatePoolWithTag(PagedPool,
- sizeof(LOGPALETTE) +
- (NB_RESERVED_COLORS * sizeof(PALETTEENTRY)),
- TAG_PALETTE);
- if (!palPtr) return STATUS_NO_MEMORY;
-
- palPtr->palVersion = 0x300;
- palPtr->palNumEntries = NB_RESERVED_COLORS;
- for (i=0; i<NB_RESERVED_COLORS; i++)
- {
- palPtr->palPalEntry[i].peRed = g_sysPalTemplate[i].peRed;
- palPtr->palPalEntry[i].peGreen = g_sysPalTemplate[i].peGreen;
- palPtr->palPalEntry[i].peBlue = g_sysPalTemplate[i].peBlue;
- palPtr->palPalEntry[i].peFlags = 0;
- }
-
- hpalette = GreCreatePaletteInternal(palPtr,NB_RESERVED_COLORS);
- ASSERT(hpalette);
- ExFreePoolWithTag(palPtr, TAG_PALETTE);
+ gppalDefault = PALETTE_AllocPalWithHandle(PAL_INDEXED,
+ 20,
+ (PULONG)g_sysPalTemplate,
+ 0, 0, 0);
+ GDIOBJ_vReferenceObjectByPointer(&gppalDefault->BaseObject);
+ PALETTE_UnlockPalette(gppalDefault);
/* palette_size = visual->map_entries; */
@@ -117,14 +100,12 @@
gpalRGB565.BaseObject.ulShareCount = 1;
gpalRGB565.BaseObject.BaseFlags = 0 ;
- memset(&gpalMono, 0, sizeof(PALETTE));
- gpalMono.flFlags = PAL_MONOCHROME;
- gpalMono.BaseObject.ulShareCount = 1;
- gpalMono.BaseObject.BaseFlags = 0 ;
+ gppalMono = PALETTE_AllocPalette(PAL_MONOCHROME|PAL_INDEXED, 2, NULL, 0, 0, 0);
+ PALETTE_vSetRGBColorForIndex(gppalMono, 0, 0x000000);
+ PALETTE_vSetRGBColorForIndex(gppalMono, 1, 0xffffff);
/* Initialize default surface palettes */
- gppalDefault = PALETTE_ShareLockPalette(hpalette);
- appalSurfaceDefault[BMF_1BPP] = &gpalMono;
+ appalSurfaceDefault[BMF_1BPP] = gppalMono;
appalSurfaceDefault[BMF_4BPP] = gppalDefault;
appalSurfaceDefault[BMF_8BPP] = gppalDefault;
appalSurfaceDefault[BMF_16BPP] = &gpalRGB565;
@@ -160,7 +141,7 @@
ULONG fl = 0, cjSize = sizeof(PALETTE);
/* Check if the palette has entries */
- if (iMode == PAL_INDEXED)
+ if (iMode & PAL_INDEXED)
{
/* Check color count */
if ((cColors == 0) || (cColors > 1024)) return NULL;
@@ -1010,6 +991,86 @@
return Entries;
}
+ULONG
+APIENTRY
+GreGetSetColorTable(
+ HDC hdc,
+ ULONG iStartIndex,
+ ULONG cEntries,
+ RGBQUAD *prgbColors,
+ BOOL bSet)
+{
+ PDC pdc;
+ PSURFACE psurf;
+ PPALETTE ppal = NULL;
+ ULONG i, iEndIndex, iResult = 0;
+
+ /* Lock the DC */
+ pdc = DC_LockDc(hdc);
+ if (!pdc)
+ {
+ return 0;
+ }
+
+ /* Get the surace from the DC */
+ psurf = pdc->dclevel.pSurface;
+
+ /* Check if we have the default surface */
+ if ((psurf == NULL) && !bSet)
+ {
+ /* Use a mono palette */
+ ppal = gppalMono;
+ }
+ else if (psurf->SurfObj.iType == STYPE_BITMAP)
+ {
+ /* Get the palette of the surface */
+ ppal = psurf->ppal;
+ }
+
+ /* Check if this is an indexed palette and the range is ok */
+ if (ppal && (ppal->flFlags & PAL_INDEXED) &&
+ (iStartIndex < ppal->NumColors))
+ {
+ /* Calculate the end of the operation */
+ iEndIndex = min(iStartIndex + cEntries, ppal->NumColors);
+
+ /* Check what operation to perform */
+ if (bSet)
+ {
+ /* Loop all colors and set the palette entries */
+ for (i = iStartIndex; i < iEndIndex; i++, prgbColors++)
+ {
+ ppal->IndexedColors[i].peRed = prgbColors->rgbRed;
+ ppal->IndexedColors[i].peGreen = prgbColors->rgbGreen;
+ ppal->IndexedColors[i].peBlue = prgbColors->rgbBlue;
+ }
+
+ /* Mark the dc brushes invalid */
+ pdc->pdcattr->ulDirty_ |= DIRTY_FILL|DIRTY_LINE|
+ DIRTY_BACKGROUND|DIRTY_TEXT;
+ }
+ else
+ {
+ /* Loop all colors and get the palette entries */
+ for (i = iStartIndex; i < iEndIndex; i++, prgbColors++)
+ {
+ prgbColors->rgbRed = ppal->IndexedColors[i].peRed;
+ prgbColors->rgbGreen = ppal->IndexedColors[i].peGreen;
+ prgbColors->rgbBlue = ppal->IndexedColors[i].peBlue;
+ prgbColors->rgbReserved = 0;
+ }
+ }
+
+ /* Calculate how many entries were modified */
+ iResult = iEndIndex - iStartIndex;
+ }
+
+ /* Unlock the DC */
+ DC_UnlockDc(pdc);
+
+ return iResult;
+}
+
W32KAPI
LONG
APIENTRY
@@ -1051,6 +1112,11 @@
}
_SEH2_END
}
+ else
+ {
+ /* Zero it out, so we don't accidentally leak kernel data */
+ RtlZeroMemory(pEntries, cEntries * sizeof(PALETTEENTRY));
+ }
}
ret = 0;
@@ -1076,12 +1142,12 @@
case GdiPalSetColorTable:
if (pEntries)
- ret = IntSetDIBColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries);
+ ret = GreGetSetColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries, TRUE);
break;
case GdiPalGetColorTable:
if (pEntries)
- ret = IntGetDIBColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries);
+ ret = GreGetSetColorTable((HDC)hObj, iStart, cEntries, (RGBQUAD*)pEntries, FALSE);
break;
}
Modified: branches/dib_rewrite/win32ss/gdi/ntgdi/palette.h
URL:
http://svn.reactos.org/svn/reactos/branches/dib_rewrite/win32ss/gdi/ntgdi/p…
==============================================================================
--- branches/dib_rewrite/win32ss/gdi/ntgdi/palette.h [iso-8859-1] (original)
+++ branches/dib_rewrite/win32ss/gdi/ntgdi/palette.h [iso-8859-1] Wed May 9 08:23:25
2012
@@ -43,7 +43,7 @@
PALETTEENTRY apalColors[0];
} PALETTE;
-extern PALETTE gpalRGB, gpalBGR, gpalMono, gpalRGB555, gpalRGB565, *gppalDefault;
+extern PALETTE gpalRGB, gpalBGR, gpalRGB555, gpalRGB565, *gppalMono, *gppalDefault;
extern PPALETTE appalSurfaceDefault[];
#define PALETTE_UnlockPalette(pPalette) GDIOBJ_vUnlockObject((POBJ)pPalette)