Author: jgardou
Date: Thu May 27 00:29:45 2010
New Revision: 47366
URL:
http://svn.reactos.org/svn/reactos?rev=47366&view=rev
Log:
[WIN32K]
- merge r47350, slightly modified to get it the yarotows way
Modified:
branches/reactos-yarotows/subsystems/win32/win32k/include/intgdi.h
branches/reactos-yarotows/subsystems/win32/win32k/ntuser/painting.c
branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/include/intgdi.h
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/include/intgdi.h [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/include/intgdi.h [iso-8859-1] Thu
May 27 00:29:45 2010
@@ -122,10 +122,15 @@
PULONG PolyCounts,
int Count);
-BOOL FASTCALL IntGdiGradientFill(DC *dc,
+BOOL
+NTAPI
+GreGradientFill(
+ HDC hdc,
PTRIVERTEX pVertex,
- ULONG uVertex,
- PVOID pMesh, ULONG uMesh, ULONG ulMode);
+ ULONG nVertex,
+ PVOID pMesh,
+ ULONG nMesh,
+ ULONG ulMode);
/* DC functions */
Modified: branches/reactos-yarotows/subsystems/win32/win32k/ntuser/painting.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] Thu
May 27 00:29:45 2010
@@ -1782,7 +1782,6 @@
static GRADIENT_RECT gcap = {0, 1};
TRIVERTEX vert[2];
COLORREF Colors[2];
- PDC pMemDc;
if (Wnd != NULL)
{
@@ -1835,21 +1834,12 @@
vert[1].Blue = (WORD)(Colors[1]>>8) & 0xFF00;
vert[1].Alpha = 0;
- pMemDc = DC_LockDc(hMemDc);
- if(!pMemDc)
- {
- DPRINT1("%s: Can't lock dc!\n", __FUNCTION__);
- goto cleanup;
- }
-
- /* There is no need to call DC_vPrepareDCsForBlit for memory DC */
- if(!IntGdiGradientFill(pMemDc, vert, 2, &gcap,
+ if(!GreGradientFill(hMemDc, vert, 2, &gcap,
1, GRADIENT_FILL_RECT_H))
{
DPRINT1("%s: IntGdiGradientFill() failed!\n", __FUNCTION__);
}
- DC_UnlockDc(pMemDc);
} //if(uFlags & DC_GRADIENT)
}
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] Thu
May 27 00:29:45 2010
@@ -856,39 +856,34 @@
return ret;
}
-BOOL FASTCALL
-IntGdiGradientFill(
- DC *dc,
+BOOL
+NTAPI
+GreGradientFill(
+ HDC hdc,
PTRIVERTEX pVertex,
- ULONG uVertex,
+ ULONG nVertex,
PVOID pMesh,
- ULONG uMesh,
+ ULONG nMesh,
ULONG ulMode)
{
+ PDC pdc;
SURFACE *psurf;
- PPALETTE PalDestGDI;
EXLATEOBJ exlo;
- RECTL Extent;
- POINTL DitherOrg;
+ RECTL rclExtent;
+ POINTL ptlDitherOrg;
ULONG i;
- BOOL Ret;
-
- ASSERT(dc);
- ASSERT(pVertex);
- ASSERT(uVertex);
- ASSERT(pMesh);
- ASSERT(uMesh);
+ BOOL bRet;
/* check parameters */
if (ulMode & GRADIENT_FILL_TRIANGLE)
{
- PGRADIENT_TRIANGLE tr = (PGRADIENT_TRIANGLE)pMesh;
-
- for (i = 0; i < uMesh; i++, tr++)
+ PGRADIENT_TRIANGLE pTriangle = (PGRADIENT_TRIANGLE)pMesh;
+
+ for (i = 0; i < nMesh; i++, pTriangle++)
{
- if (tr->Vertex1 >= uVertex ||
- tr->Vertex2 >= uVertex ||
- tr->Vertex3 >= uVertex)
+ if (pTriangle->Vertex1 >= nVertex ||
+ pTriangle->Vertex2 >= nVertex ||
+ pTriangle->Vertex3 >= nVertex)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -897,10 +892,10 @@
}
else
{
- PGRADIENT_RECT rc = (PGRADIENT_RECT)pMesh;
- for (i = 0; i < uMesh; i++, rc++)
+ PGRADIENT_RECT pRect = (PGRADIENT_RECT)pMesh;
+ for (i = 0; i < nMesh; i++, pRect++)
{
- if (rc->UpperLeft >= uVertex || rc->LowerRight >= uVertex)
+ if (pRect->UpperLeft >= nVertex || pRect->LowerRight >= nVertex)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -908,61 +903,74 @@
}
}
+ /* Lock the output DC */
+ pdc = DC_LockDc(hdc);
+ if(!pdc)
+ {
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if(pdc->dctype == DC_TYPE_INFO)
+ {
+ DC_UnlockDc(pdc);
+ /* Yes, Windows really returns TRUE in this case */
+ return TRUE;
+ }
+
+ psurf = pdc->dclevel.pSurface;
+ if(!psurf)
+ {
+ /* Memory DC with no surface selected */
+ DC_UnlockDc(pdc);
+ return TRUE; //CHECKME
+ }
+
/* calculate extent */
- Extent.left = Extent.right = pVertex->x;
- Extent.top = Extent.bottom = pVertex->y;
- for (i = 0; i < uVertex; i++)
- {
- Extent.left = min(Extent.left, (pVertex + i)->x);
- Extent.right = max(Extent.right, (pVertex + i)->x);
- Extent.top = min(Extent.top, (pVertex + i)->y);
- Extent.bottom = max(Extent.bottom, (pVertex + i)->y);
- }
- IntLPtoDP(dc, (LPPOINT)&Extent, 2);
-
- Extent.left += dc->ptlDCOrig.x;
- Extent.right += dc->ptlDCOrig.x;
- Extent.top += dc->ptlDCOrig.y;
- Extent.bottom += dc->ptlDCOrig.y;
-
- DitherOrg.x = DitherOrg.y = 0;
- IntLPtoDP(dc, (LPPOINT)&DitherOrg, 1);
-
- DitherOrg.x += dc->ptlDCOrig.x;
- DitherOrg.y += dc->ptlDCOrig.y;
-
- psurf = dc->dclevel.pSurface;
- /* FIXME - psurf can be NULL!!! Don't assert but handle this case gracefully! */
- ASSERT(psurf);
-
- if (psurf->ppal)
- {
- PalDestGDI = psurf->ppal;
- GDIOBJ_IncrementShareCount(&PalDestGDI->BaseObject);
- }
- else
- // Destination palette obtained from the hDC
- PalDestGDI = PALETTE_ShareLockPalette(dc->ppdev->devinfo.hpalDefault);
-
- EXLATEOBJ_vInitialize(&exlo, &gpalRGB, PalDestGDI, 0, 0, 0);
-
- Ret = IntEngGradientFill(&psurf->SurfObj,
- dc->rosdc.CombinedClip,
+ rclExtent.left = rclExtent.right = pVertex->x;
+ rclExtent.top = rclExtent.bottom = pVertex->y;
+ for (i = 0; i < nVertex; i++)
+ {
+ rclExtent.left = min(rclExtent.left, (pVertex + i)->x);
+ rclExtent.right = max(rclExtent.right, (pVertex + i)->x);
+ rclExtent.top = min(rclExtent.top, (pVertex + i)->y);
+ rclExtent.bottom = max(rclExtent.bottom, (pVertex + i)->y);
+ }
+ IntLPtoDP(pdc, (LPPOINT)&rclExtent, 2);
+
+ rclExtent.left += pdc->ptlDCOrig.x;
+ rclExtent.right += pdc->ptlDCOrig.x;
+ rclExtent.top += pdc->ptlDCOrig.y;
+ rclExtent.bottom += pdc->ptlDCOrig.y;
+
+ ptlDitherOrg.x = ptlDitherOrg.y = 0;
+ IntLPtoDP(pdc, (LPPOINT)&ptlDitherOrg, 1);
+
+ ptlDitherOrg.x += pdc->ptlDCOrig.x;
+ ptlDitherOrg.y += pdc->ptlDCOrig.y;
+
+ EXLATEOBJ_vInitialize(&exlo, &gpalRGB, psurf->ppal, 0, 0, 0);
+
+ ASSERT(pdc->rosdc.CombinedClip);
+
+ DC_vPrepareDCsForBlit(pdc, rclExtent, NULL, rclExtent);
+
+ bRet = IntEngGradientFill(&psurf->SurfObj,
+ pdc->rosdc.CombinedClip,
&exlo.xlo,
pVertex,
- uVertex,
+ nVertex,
pMesh,
- uMesh,
- &Extent,
- &DitherOrg,
+ nMesh,
+ &rclExtent,
+ &ptlDitherOrg,
ulMode);
EXLATEOBJ_vCleanup(&exlo);
-
- if (PalDestGDI)
- PALETTE_ShareUnlockPalette(PalDestGDI);
-
- return Ret;
+ DC_vFinishBlit(pdc, NULL);
+ DC_UnlockDc(pdc);
+
+ return bRet;
}
BOOL
@@ -970,33 +978,19 @@
NtGdiGradientFill(
HDC hdc,
PTRIVERTEX pVertex,
- ULONG uVertex,
+ ULONG nVertex,
PVOID pMesh,
- ULONG uMesh,
+ ULONG nMesh,
ULONG ulMode)
{
- DC *dc;
- BOOL Ret;
+ BOOL bRet;
PTRIVERTEX SafeVertex;
PVOID SafeMesh;
- ULONG SizeMesh;
- NTSTATUS Status = STATUS_SUCCESS;
-
- dc = DC_LockDc(hdc);
- if (!dc)
- {
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return FALSE;
- }
- if (dc->dctype == DC_TYPE_INFO)
- {
- DC_UnlockDc(dc);
- /* Yes, Windows really returns TRUE in this case */
- return TRUE;
- }
- if (!pVertex || !uVertex || !pMesh || !uMesh)
- {
- DC_UnlockDc(dc);
+ ULONG cbVertex, cbMesh;
+
+ /* Validate parameters */
+ if (!pVertex || !nVertex || !pMesh || !nMesh)
+ {
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -1005,81 +999,55 @@
{
case GRADIENT_FILL_RECT_H:
case GRADIENT_FILL_RECT_V:
- SizeMesh = uMesh * sizeof(GRADIENT_RECT);
+ cbMesh = nMesh * sizeof(GRADIENT_RECT);
break;
case GRADIENT_FILL_TRIANGLE:
- SizeMesh = uMesh * sizeof(TRIVERTEX);
+ cbMesh = nMesh * sizeof(GRADIENT_TRIANGLE);
break;
default:
- DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
+ cbVertex = nVertex * sizeof(TRIVERTEX) ;
+ if(cbVertex + cbMesh <= cbVertex)
+ {
+ /* Overflow */
+ return FALSE ;
+ }
+
+ /* Allocate a kernel mode buffer */
+ SafeVertex = ExAllocatePoolWithTag(PagedPool, cbVertex + cbMesh, TAG_SHAPE);
+ if(!SafeVertex)
+ {
+ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
+
+ SafeMesh = (PVOID)((ULONG_PTR)SafeVertex + cbVertex);
+
+ /* Copy the parameters to kernel mode */
_SEH2_TRY
{
- ProbeForRead(pVertex,
- uVertex * sizeof(TRIVERTEX),
- 1);
- ProbeForRead(pMesh,
- SizeMesh,
- 1);
+ ProbeForRead(pVertex, cbVertex, 1);
+ ProbeForRead(pMesh, cbMesh, 1);
+ RtlCopyMemory(SafeVertex, pVertex, cbVertex);
+ RtlCopyMemory(SafeMesh, pMesh, cbMesh);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
- Status = _SEH2_GetExceptionCode();
+ ExFreePoolWithTag(SafeVertex, TAG_SHAPE);
+ SetLastNtError(_SEH2_GetExceptionCode());
+ _SEH2_YIELD(return FALSE;)
}
_SEH2_END;
- if (!NT_SUCCESS(Status))
- {
- DC_UnlockDc(dc);
- SetLastWin32Error(Status);
- return FALSE;
- }
-
- if (!(SafeVertex = ExAllocatePoolWithTag(PagedPool, (uVertex * sizeof(TRIVERTEX)) +
SizeMesh, TAG_SHAPE)))
- {
- DC_UnlockDc(dc);
- SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
-
- SafeMesh = (PTRIVERTEX)(SafeVertex + uVertex);
-
- _SEH2_TRY
- {
- /* pointers were already probed! */
- RtlCopyMemory(SafeVertex,
- pVertex,
- uVertex * sizeof(TRIVERTEX));
- RtlCopyMemory(SafeMesh,
- pMesh,
- SizeMesh);
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- Status = _SEH2_GetExceptionCode();
- }
- _SEH2_END;
-
- if (!NT_SUCCESS(Status))
- {
- DC_UnlockDc(dc);
- ExFreePoolWithTag(SafeVertex, TAG_SHAPE);
- SetLastNtError(Status);
- return FALSE;
- }
-
- DC_vPrepareDCsForBlit(dc, dc->rosdc.CombinedClip->rclBounds,
- NULL, dc->rosdc.CombinedClip->rclBounds);
-
- Ret = IntGdiGradientFill(dc, SafeVertex, uVertex, SafeMesh, uMesh, ulMode);
-
- DC_vFinishBlit(dc, NULL) ;
- DC_UnlockDc(dc);
- ExFreePool(SafeVertex);
- return Ret;
+ /* Call the internal function */
+ bRet = GreGradientFill(hdc, SafeVertex, nVertex, SafeMesh, nMesh, ulMode);
+
+ /* Cleanup and return result */
+ ExFreePoolWithTag(SafeVertex, TAG_SHAPE);
+ return bRet;
}
BOOL APIENTRY