2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #define Rsin(d) ((d) == 0.0 ? 0.0 : ((d) == 90.0 ? 1.0 : sin(d*M_PI/180.0)))
26 #define Rcos(d) ((d) == 0.0 ? 1.0 : ((d) == 90.0 ? 0.0 : cos(d*M_PI/180.0)))
28 BOOL FASTCALL
IntFillEllipse( PDC dc
, INT XLeft
, INT YLeft
, INT Width
, INT Height
, PBRUSH pbrush
);
29 BOOL FASTCALL
IntDrawEllipse( PDC dc
, INT XLeft
, INT YLeft
, INT Width
, INT Height
, PBRUSH pbrush
);
30 BOOL FASTCALL
IntFillRoundRect( PDC dc
, INT Left
, INT Top
, INT Right
, INT Bottom
, INT Wellipse
, INT Hellipse
, PBRUSH pbrush
);
31 BOOL FASTCALL
IntDrawRoundRect( PDC dc
, INT Left
, INT Top
, INT Right
, INT Bottom
, INT Wellipse
, INT Hellipse
, PBRUSH pbrush
);
39 PBRUSH pbrLine
, pbrFill
;
40 BOOL ret
= FALSE
; // default to failure
48 ASSERT(dc
); // caller's responsibility to pass a valid dc
50 if (!Points
|| Count
< 2 )
52 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
60 for (CurrentPoint = 1; CurrentPoint < Count; ++CurrentPoint) {
61 Left = min(Left, Points[CurrentPoint].x);
62 Top = min(Top, Points[CurrentPoint].y);
66 pdcattr
= dc
->pdcattr
;
68 /* Convert to screen coordinates */
69 IntLPtoDP(dc
, Points
, Count
);
70 for (CurrentPoint
= 0; CurrentPoint
< Count
; CurrentPoint
++)
72 Points
[CurrentPoint
].x
+= dc
->ptlDCOrig
.x
;
73 Points
[CurrentPoint
].y
+= dc
->ptlDCOrig
.y
;
75 // No need to have path here.
77 DestRect
.left
= Points
[0].x
;
78 DestRect
.right
= Points
[0].x
;
79 DestRect
.top
= Points
[0].y
;
80 DestRect
.bottom
= Points
[0].y
;
82 for (CurrentPoint
= 1; CurrentPoint
< Count
; ++CurrentPoint
)
84 DestRect
.left
= min(DestRect
.left
, Points
[CurrentPoint
].x
);
85 DestRect
.right
= max(DestRect
.right
, Points
[CurrentPoint
].x
);
86 DestRect
.top
= min(DestRect
.top
, Points
[CurrentPoint
].y
);
87 DestRect
.bottom
= max(DestRect
.bottom
, Points
[CurrentPoint
].y
);
90 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
91 DC_vUpdateFillBrush(dc
);
93 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
94 DC_vUpdateLineBrush(dc
);
96 /* Special locking order to avoid lock-ups */
97 pbrFill
= dc
->dclevel
.pbrFill
;
98 pbrLine
= dc
->dclevel
.pbrLine
;
99 psurf
= SURFACE_LockSurface(dc
->rosdc
.hBitmap
);
100 /* FIXME - psurf can be NULL!!!! don't assert but handle this case gracefully! */
103 /* Now fill the polygon with the current fill brush. */
104 if (!(pbrFill
->flAttrs
& GDIBRUSH_IS_NULL
))
106 BrushOrigin
= *((PPOINTL
)&pbrFill
->ptOrigin
);
107 BrushOrigin
.x
+= dc
->ptlDCOrig
.x
;
108 BrushOrigin
.y
+= dc
->ptlDCOrig
.y
;
109 ret
= IntFillPolygon (dc
,
111 &dc
->eboFill
.BrushObject
,
118 // Draw the Polygon Edges with the current pen ( if not a NULL pen )
119 if (!(pbrLine
->flAttrs
& GDIBRUSH_IS_NULL
))
123 for (i
= 0; i
< Count
-1; i
++)
126 // DPRINT1("Polygon Making line from (%d,%d) to (%d,%d)\n",
127 // Points[0].x, Points[0].y,
128 // Points[1].x, Points[1].y );
130 ret
= IntEngLineTo(&psurf
->SurfObj
,
131 dc
->rosdc
.CombinedClip
,
132 &dc
->eboLine
.BrushObject
,
133 Points
[i
].x
, /* From */
135 Points
[i
+1].x
, /* To */
138 ROP2_TO_MIX(pdcattr
->jROP2
)); /* MIX */
141 /* Close the polygon */
144 ret
= IntEngLineTo(&psurf
->SurfObj
,
145 dc
->rosdc
.CombinedClip
,
146 &dc
->eboLine
.BrushObject
,
147 Points
[Count
-1].x
, /* From */
149 Points
[0].x
, /* To */
152 ROP2_TO_MIX(pdcattr
->jROP2
)); /* MIX */
156 SURFACE_UnlockSurface(psurf
);
162 IntGdiPolyPolygon(DC
*dc
,
167 if (PATH_IsPathOpen(dc
->dclevel
))
168 return PATH_PolyPolygon ( dc
, Points
, (PINT
)PolyCounts
, Count
);
172 if (!IntGdiPolygon ( dc
, Points
, *PolyCounts
))
174 Points
+=*PolyCounts
++;
181 /******************************************************************************/
190 * This function uses optimized Bresenham's ellipse algorithm. It draws
191 * four lines of the ellipse in one pass.
208 LONG PenWidth
, PenOrigWidth
;
209 LONG RadiusX
, RadiusY
, CenterX
, CenterY
;
210 PBRUSH pFillBrushObj
;
211 BRUSH tmpFillBrushObj
;
213 if ((Left
== Right
) || (Top
== Bottom
)) return TRUE
;
218 SetLastWin32Error(ERROR_INVALID_HANDLE
);
221 if (dc
->dctype
== DC_TYPE_INFO
)
224 /* Yes, Windows really returns TRUE in this case */
228 if (PATH_IsPathOpen(dc
->dclevel
))
230 ret
= PATH_Ellipse(dc
, Left
, Top
, Right
, Bottom
);
237 INT tmp
= Right
; Right
= Left
; Left
= tmp
;
241 INT tmp
= Bottom
; Bottom
= Top
; Top
= tmp
;
244 pdcattr
= dc
->pdcattr
;
246 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
247 DC_vUpdateFillBrush(dc
);
249 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
250 DC_vUpdateLineBrush(dc
);
252 pbrush
= PEN_LockPen(pdcattr
->hpen
);
255 DPRINT1("Ellipse Fail 1\n");
257 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
261 PenOrigWidth
= PenWidth
= pbrush
->ptPenWidth
.x
;
262 if (pbrush
->ulPenStyle
== PS_NULL
) PenWidth
= 0;
264 if (pbrush
->ulPenStyle
== PS_INSIDEFRAME
)
266 if (2*PenWidth
> (Right
- Left
)) PenWidth
= (Right
-Left
+ 1)/2;
267 if (2*PenWidth
> (Bottom
- Top
)) PenWidth
= (Bottom
-Top
+ 1)/2;
268 Left
+= PenWidth
/ 2;
269 Right
-= (PenWidth
- 1) / 2;
271 Bottom
-= (PenWidth
- 1) / 2;
274 if (!PenWidth
) PenWidth
= 1;
275 pbrush
->ptPenWidth
.x
= PenWidth
;
277 RectBounds
.left
= Left
;
278 RectBounds
.right
= Right
;
279 RectBounds
.top
= Top
;
280 RectBounds
.bottom
= Bottom
;
282 IntLPtoDP(dc
, (LPPOINT
)&RectBounds
, 2);
284 RectBounds
.left
+= dc
->ptlDCOrig
.x
;
285 RectBounds
.right
+= dc
->ptlDCOrig
.x
;
286 RectBounds
.top
+= dc
->ptlDCOrig
.y
;
287 RectBounds
.bottom
+= dc
->ptlDCOrig
.y
;
289 // Setup for dynamic width and height.
290 RadiusX
= max((RectBounds
.right
- RectBounds
.left
) / 2, 2); // Needs room
291 RadiusY
= max((RectBounds
.bottom
- RectBounds
.top
) / 2, 2);
292 CenterX
= (RectBounds
.right
+ RectBounds
.left
) / 2;
293 CenterY
= (RectBounds
.bottom
+ RectBounds
.top
) / 2;
295 DPRINT("Ellipse 1: Left: %d, Top: %d, Right: %d, Bottom: %d\n",
296 RectBounds
.left
,RectBounds
.top
,RectBounds
.right
,RectBounds
.bottom
);
298 DPRINT("Ellipse 2: XLeft: %d, YLeft: %d, Width: %d, Height: %d\n",
299 CenterX
- RadiusX
, CenterY
+ RadiusY
, RadiusX
*2, RadiusY
*2);
301 pFillBrushObj
= BRUSH_LockBrush(pdcattr
->hbrush
);
302 if (NULL
== pFillBrushObj
)
304 DPRINT1("FillEllipse Fail\n");
305 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
310 RtlCopyMemory(&tmpFillBrushObj
, pFillBrushObj
, sizeof(tmpFillBrushObj
));
311 // tmpFillBrushObj.ptOrigin.x += RectBounds.left - Left;
312 // tmpFillBrushObj.ptOrigin.y += RectBounds.top - Top;
313 tmpFillBrushObj
.ptOrigin
.x
+= dc
->ptlDCOrig
.x
;
314 tmpFillBrushObj
.ptOrigin
.y
+= dc
->ptlDCOrig
.y
;
315 ret
= IntFillEllipse( dc
,
321 BRUSH_UnlockBrush(pFillBrushObj
);
325 ret
= IntDrawEllipse( dc
,
332 pbrush
->ptPenWidth
.x
= PenOrigWidth
;
333 PEN_UnlockPen(pbrush
);
335 DPRINT("Ellipse Exit.\n");
341 //When the fill mode is ALTERNATE, GDI fills the area between odd-numbered and
342 //even-numbered polygon sides on each scan line. That is, GDI fills the area between the
343 //first and second side, between the third and fourth side, and so on.
345 //WINDING Selects winding mode (fills any region with a nonzero winding value).
346 //When the fill mode is WINDING, GDI fills any region that has a nonzero winding value.
347 //This value is defined as the number of times a pen used to draw the polygon would go around the region.
348 //The direction of each edge of the polygon is important.
350 extern BOOL
FillPolygon(PDC dc
,
363 NtGdiPolyPolyDraw( IN HDC hDC
,
364 IN PPOINT UnsafePoints
,
365 IN PULONG UnsafeCounts
,
373 NTSTATUS Status
= STATUS_SUCCESS
;
375 INT nPoints
= 0, nMaxPoints
= 0, nInvalid
= 0, i
;
377 if (!UnsafePoints
|| !UnsafeCounts
||
378 Count
== 0 || iFunc
== 0 || iFunc
> GdiPolyPolyRgn
)
380 /* Windows doesn't set last error */
386 ProbeForRead(UnsafePoints
, Count
* sizeof(POINT
), 1);
387 ProbeForRead(UnsafeCounts
, Count
* sizeof(ULONG
), 1);
389 /* Count points and validate poligons */
390 for (i
= 0; i
< Count
; i
++)
392 if (UnsafeCounts
[i
] < 2)
396 nPoints
+= UnsafeCounts
[i
];
397 nMaxPoints
= max(nMaxPoints
, UnsafeCounts
[i
]);
400 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
402 Status
= _SEH2_GetExceptionCode();
406 if (!NT_SUCCESS(Status
))
408 /* Windows doesn't set last error */
412 if (nPoints
== 0 || nPoints
< nMaxPoints
)
414 /* If all polygon counts are zero, or we have overflow,
415 return without setting a last error code. */
421 /* If at least one poly count is 0 or 1, fail */
422 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
426 /* Allocate one buffer for both counts and points */
427 pTemp
= ExAllocatePoolWithTag(PagedPool
,
428 Count
* sizeof(ULONG
) + nPoints
* sizeof(POINT
),
432 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
437 SafePoints
= (PVOID
)(SafeCounts
+ Count
);
441 /* Pointers already probed! */
442 RtlCopyMemory(SafeCounts
, UnsafeCounts
, Count
* sizeof(ULONG
));
443 RtlCopyMemory(SafePoints
, UnsafePoints
, nPoints
* sizeof(POINT
));
445 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
447 Status
= _SEH2_GetExceptionCode();
451 if (!NT_SUCCESS(Status
))
453 ExFreePoolWithTag(pTemp
, TAG_SHAPE
);
457 /* Special handling for GdiPolyPolyRgn */
458 if (iFunc
== GdiPolyPolyRgn
)
461 hRgn
= IntCreatePolyPolygonRgn(SafePoints
, SafeCounts
, Count
, (INT_PTR
)hDC
);
462 ExFreePoolWithTag(pTemp
, TAG_SHAPE
);
463 return (ULONG_PTR
)hRgn
;
469 SetLastWin32Error(ERROR_INVALID_HANDLE
);
474 if (dc
->dctype
== DC_TYPE_INFO
)
478 /* Yes, Windows really returns TRUE in this case */
482 /* Perform the actual work */
486 Ret
= IntGdiPolyPolygon(dc
, SafePoints
, SafeCounts
, Count
);
488 case GdiPolyPolyLine
:
489 Ret
= IntGdiPolyPolyline(dc
, SafePoints
, SafeCounts
, Count
);
492 Ret
= IntGdiPolyBezier(dc
, SafePoints
, *SafeCounts
);
495 Ret
= IntGdiPolylineTo(dc
, SafePoints
, *SafeCounts
);
497 case GdiPolyBezierTo
:
498 Ret
= IntGdiPolyBezierTo(dc
, SafePoints
, *SafeCounts
);
501 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
505 /* Cleanup and return */
509 return (ULONG_PTR
)Ret
;
521 SURFACE
*psurf
= NULL
;
522 PBRUSH pbrLine
, pbrFill
;
523 BOOL ret
= FALSE
; // default to failure
529 ASSERT ( dc
); // caller's responsibility to set this up
531 pdcattr
= dc
->pdcattr
;
533 /* Do we rotate or shear? */
534 if (!(dc
->dclevel
.mxWorldToDevice
.flAccel
& MX_SCALE
))
537 POINTL DestCoords
[4];
538 ULONG PolyCounts
= 4;
539 DestCoords
[0].x
= DestCoords
[3].x
= LeftRect
;
540 DestCoords
[0].y
= DestCoords
[1].y
= TopRect
;
541 DestCoords
[1].x
= DestCoords
[2].x
= RightRect
;
542 DestCoords
[2].y
= DestCoords
[3].y
= BottomRect
;
543 // Use IntGdiPolyPolygon so to support PATH.
544 return IntGdiPolyPolygon(dc
, DestCoords
, &PolyCounts
, 1);
546 // Rectangle Path only.
547 if ( PATH_IsPathOpen(dc
->dclevel
) )
549 return PATH_Rectangle ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
);
552 DestRect
.left
= LeftRect
;
553 DestRect
.right
= RightRect
;
554 DestRect
.top
= TopRect
;
555 DestRect
.bottom
= BottomRect
;
557 IntLPtoDP(dc
, (LPPOINT
)&DestRect
, 2);
559 DestRect
.left
+= dc
->ptlDCOrig
.x
;
560 DestRect
.right
+= dc
->ptlDCOrig
.x
;
561 DestRect
.top
+= dc
->ptlDCOrig
.y
;
562 DestRect
.bottom
+= dc
->ptlDCOrig
.y
;
564 /* In GM_COMPATIBLE, don't include bottom and right edges */
565 if (pdcattr
->iGraphicsMode
== GM_COMPATIBLE
)
571 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
572 DC_vUpdateFillBrush(dc
);
574 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
575 DC_vUpdateLineBrush(dc
);
577 pbrFill
= dc
->dclevel
.pbrFill
;
578 pbrLine
= dc
->dclevel
.pbrLine
;
584 psurf
= SURFACE_LockSurface(dc
->rosdc
.hBitmap
);
593 if (!(pbrFill
->flAttrs
& GDIBRUSH_IS_NULL
))
595 BrushOrigin
= *((PPOINTL
)&pbrFill
->ptOrigin
);
596 BrushOrigin
.x
+= dc
->ptlDCOrig
.x
;
597 BrushOrigin
.y
+= dc
->ptlDCOrig
.y
;
598 ret
= IntEngBitBlt(&psurf
->SurfObj
,
601 dc
->rosdc
.CombinedClip
,
606 &dc
->eboFill
.BrushObject
,
608 ROP3_TO_ROP4(PATCOPY
));
612 // Draw the rectangle with the current pen
614 ret
= TRUE
; // change default to success
616 if (!(pbrLine
->flAttrs
& GDIBRUSH_IS_NULL
))
618 Mix
= ROP2_TO_MIX(pdcattr
->jROP2
);
619 ret
= ret
&& IntEngLineTo(&psurf
->SurfObj
,
620 dc
->rosdc
.CombinedClip
,
621 &dc
->eboLine
.BrushObject
,
622 DestRect
.left
, DestRect
.top
, DestRect
.right
, DestRect
.top
,
623 &DestRect
, // Bounding rectangle
626 ret
= ret
&& IntEngLineTo(&psurf
->SurfObj
,
627 dc
->rosdc
.CombinedClip
,
628 &dc
->eboLine
.BrushObject
,
629 DestRect
.right
, DestRect
.top
, DestRect
.right
, DestRect
.bottom
,
630 &DestRect
, // Bounding rectangle
633 ret
= ret
&& IntEngLineTo(&psurf
->SurfObj
,
634 dc
->rosdc
.CombinedClip
,
635 &dc
->eboLine
.BrushObject
,
636 DestRect
.right
, DestRect
.bottom
, DestRect
.left
, DestRect
.bottom
,
637 &DestRect
, // Bounding rectangle
640 ret
= ret
&& IntEngLineTo(&psurf
->SurfObj
,
641 dc
->rosdc
.CombinedClip
,
642 &dc
->eboLine
.BrushObject
,
643 DestRect
.left
, DestRect
.bottom
, DestRect
.left
, DestRect
.top
,
644 &DestRect
, // Bounding rectangle
650 SURFACE_UnlockSurface(psurf
);
652 /* Move current position in DC?
653 MSDN: The current position is neither used nor updated by Rectangle. */
660 NtGdiRectangle(HDC hDC
,
667 BOOL ret
; // default to failure
672 SetLastWin32Error(ERROR_INVALID_HANDLE
);
675 if (dc
->dctype
== DC_TYPE_INFO
)
678 /* Yes, Windows really returns TRUE in this case */
682 ret
= IntRectangle ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
);
701 PBRUSH pbrushLine
, pbrushFill
;
703 LONG PenWidth
, PenOrigWidth
;
704 BOOL ret
= TRUE
; // default to success
707 ASSERT ( dc
); // caller's responsibility to set this up
709 if ( PATH_IsPathOpen(dc
->dclevel
) )
710 return PATH_RoundRect ( dc
, Left
, Top
, Right
, Bottom
,
711 xCurveDiameter
, yCurveDiameter
);
713 if ((Left
== Right
) || (Top
== Bottom
)) return TRUE
;
715 xCurveDiameter
= max(abs( xCurveDiameter
), 1);
716 yCurveDiameter
= max(abs( yCurveDiameter
), 1);
720 INT tmp
= Right
; Right
= Left
; Left
= tmp
;
724 INT tmp
= Bottom
; Bottom
= Top
; Top
= tmp
;
727 pdcattr
= dc
->pdcattr
;
729 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
730 DC_vUpdateFillBrush(dc
);
732 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
733 DC_vUpdateLineBrush(dc
);
735 pbrushLine
= PEN_LockPen(pdcattr
->hpen
);
738 /* Nothing to do, as we don't have a bitmap */
739 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
743 PenOrigWidth
= PenWidth
= pbrushLine
->ptPenWidth
.x
;
744 if (pbrushLine
->ulPenStyle
== PS_NULL
) PenWidth
= 0;
746 if (pbrushLine
->ulPenStyle
== PS_INSIDEFRAME
)
748 if (2*PenWidth
> (Right
- Left
)) PenWidth
= (Right
-Left
+ 1)/2;
749 if (2*PenWidth
> (Bottom
- Top
)) PenWidth
= (Bottom
-Top
+ 1)/2;
750 Left
+= PenWidth
/ 2;
751 Right
-= (PenWidth
- 1) / 2;
753 Bottom
-= (PenWidth
- 1) / 2;
756 if (!PenWidth
) PenWidth
= 1;
757 pbrushLine
->ptPenWidth
.x
= PenWidth
;
759 RectBounds
.left
= Left
;
760 RectBounds
.top
= Top
;
761 RectBounds
.right
= Right
;
762 RectBounds
.bottom
= Bottom
;
764 IntLPtoDP(dc
, (LPPOINT
)&RectBounds
, 2);
766 RectBounds
.left
+= dc
->ptlDCOrig
.x
;
767 RectBounds
.top
+= dc
->ptlDCOrig
.y
;
768 RectBounds
.right
+= dc
->ptlDCOrig
.x
;
769 RectBounds
.bottom
+= dc
->ptlDCOrig
.y
;
771 pbrushFill
= BRUSH_LockBrush(pdcattr
->hbrush
);
772 if (NULL
== pbrushFill
)
774 DPRINT1("FillRound Fail\n");
775 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
780 RtlCopyMemory(&brushTemp
, pbrushFill
, sizeof(brushTemp
));
781 brushTemp
.ptOrigin
.x
+= RectBounds
.left
- Left
;
782 brushTemp
.ptOrigin
.y
+= RectBounds
.top
- Top
;
783 ret
= IntFillRoundRect( dc
,
791 BRUSH_UnlockBrush(pbrushFill
);
795 ret
= IntDrawRoundRect( dc
,
804 pbrushLine
->ptPenWidth
.x
= PenOrigWidth
;
805 PEN_UnlockPen(pbrushLine
);
820 DC
*dc
= DC_LockDc(hDC
);
821 BOOL ret
= FALSE
; /* default to failure */
823 DPRINT("NtGdiRoundRect(0x%x,%i,%i,%i,%i,%i,%i)\n",hDC
,LeftRect
,TopRect
,RightRect
,BottomRect
,Width
,Height
);
826 DPRINT1("NtGdiRoundRect() - hDC is invalid\n");
827 SetLastWin32Error(ERROR_INVALID_HANDLE
);
829 else if (dc
->dctype
== DC_TYPE_INFO
)
832 /* Yes, Windows really returns TRUE in this case */
837 ret
= IntRoundRect ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
, Width
, Height
);
860 HPALETTE hDestPalette
;
868 /* check parameters */
869 if (ulMode
& GRADIENT_FILL_TRIANGLE
)
871 PGRADIENT_TRIANGLE tr
= (PGRADIENT_TRIANGLE
)pMesh
;
873 for (i
= 0; i
< uMesh
; i
++, tr
++)
875 if (tr
->Vertex1
>= uVertex
||
876 tr
->Vertex2
>= uVertex
||
877 tr
->Vertex3
>= uVertex
)
879 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
886 PGRADIENT_RECT rc
= (PGRADIENT_RECT
)pMesh
;
887 for (i
= 0; i
< uMesh
; i
++, rc
++)
889 if (rc
->UpperLeft
>= uVertex
|| rc
->LowerRight
>= uVertex
)
891 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
897 /* calculate extent */
898 Extent
.left
= Extent
.right
= pVertex
->x
;
899 Extent
.top
= Extent
.bottom
= pVertex
->y
;
900 for (i
= 0; i
< uVertex
; i
++)
902 Extent
.left
= min(Extent
.left
, (pVertex
+ i
)->x
);
903 Extent
.right
= max(Extent
.right
, (pVertex
+ i
)->x
);
904 Extent
.top
= min(Extent
.top
, (pVertex
+ i
)->y
);
905 Extent
.bottom
= max(Extent
.bottom
, (pVertex
+ i
)->y
);
907 IntLPtoDP(dc
, (LPPOINT
)&Extent
, 2);
909 Extent
.left
+= dc
->ptlDCOrig
.x
;
910 Extent
.right
+= dc
->ptlDCOrig
.x
;
911 Extent
.top
+= dc
->ptlDCOrig
.y
;
912 Extent
.bottom
+= dc
->ptlDCOrig
.y
;
914 DitherOrg
.x
= DitherOrg
.y
= 0;
915 IntLPtoDP(dc
, (LPPOINT
)&DitherOrg
, 1);
917 DitherOrg
.x
+= dc
->ptlDCOrig
.x
;
918 DitherOrg
.y
+= dc
->ptlDCOrig
.y
;
920 psurf
= SURFACE_LockSurface(dc
->rosdc
.hBitmap
);
921 /* FIXME - psurf can be NULL!!! Don't assert but handle this case gracefully! */
924 hDestPalette
= psurf
->hDIBPalette
;
925 if (!hDestPalette
) hDestPalette
= pPrimarySurface
->DevInfo
.hpalDefault
;
927 PalDestGDI
= PALETTE_LockPalette(hDestPalette
);
930 Mode
= PalDestGDI
->Mode
;
931 PALETTE_UnlockPalette(PalDestGDI
);
936 XlateObj
= (XLATEOBJ
*)IntEngCreateXlate(Mode
, PAL_RGB
, hDestPalette
, NULL
);
939 Ret
= IntEngGradientFill(&psurf
->SurfObj
,
940 dc
->rosdc
.CombinedClip
,
950 SURFACE_UnlockSurface(psurf
);
951 EngDeleteXlate(XlateObj
);
968 PTRIVERTEX SafeVertex
;
971 NTSTATUS Status
= STATUS_SUCCESS
;
976 SetLastWin32Error(ERROR_INVALID_HANDLE
);
979 if (dc
->dctype
== DC_TYPE_INFO
)
982 /* Yes, Windows really returns TRUE in this case */
985 if (!pVertex
|| !uVertex
|| !pMesh
|| !uMesh
)
988 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
994 case GRADIENT_FILL_RECT_H
:
995 case GRADIENT_FILL_RECT_V
:
996 SizeMesh
= uMesh
* sizeof(GRADIENT_RECT
);
998 case GRADIENT_FILL_TRIANGLE
:
999 SizeMesh
= uMesh
* sizeof(TRIVERTEX
);
1003 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
1009 ProbeForRead(pVertex
,
1010 uVertex
* sizeof(TRIVERTEX
),
1016 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1018 Status
= _SEH2_GetExceptionCode();
1022 if (!NT_SUCCESS(Status
))
1025 SetLastWin32Error(Status
);
1029 if (!(SafeVertex
= ExAllocatePoolWithTag(PagedPool
, (uVertex
* sizeof(TRIVERTEX
)) + SizeMesh
, TAG_SHAPE
)))
1032 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1036 SafeMesh
= (PTRIVERTEX
)(SafeVertex
+ uVertex
);
1040 /* pointers were already probed! */
1041 RtlCopyMemory(SafeVertex
,
1043 uVertex
* sizeof(TRIVERTEX
));
1044 RtlCopyMemory(SafeMesh
,
1048 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1050 Status
= _SEH2_GetExceptionCode();
1054 if (!NT_SUCCESS(Status
))
1057 ExFreePoolWithTag(SafeVertex
, TAG_SHAPE
);
1058 SetLastNtError(Status
);
1062 Ret
= IntGdiGradientFill(dc
, SafeVertex
, uVertex
, SafeMesh
, uMesh
, ulMode
);
1065 ExFreePool(SafeVertex
);
1079 SURFACE
*psurf
= NULL
;
1080 PBRUSH pbrFill
= NULL
;
1085 DPRINT1("FIXME: NtGdiExtFloodFill is UNIMPLEMENTED\n");
1087 dc
= DC_LockDc(hDC
);
1090 SetLastWin32Error(ERROR_INVALID_HANDLE
);
1093 if (dc
->dctype
== DC_TYPE_INFO
)
1096 /* Yes, Windows really returns TRUE in this case */
1100 pdcattr
= dc
->pdcattr
;
1102 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
1103 DC_vUpdateFillBrush(dc
);
1105 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
1106 DC_vUpdateLineBrush(dc
);
1110 IntLPtoDP(dc
, (LPPOINT
)&Pt
, 1);
1112 Ret
= NtGdiPtInRegion(dc
->rosdc
.hGCClipRgn
, Pt
.x
, Pt
.y
);
1114 IntGdiGetRgnBox(dc
->rosdc
.hGCClipRgn
,(LPRECT
)&DestRect
);
1118 pbrFill
= dc
->dclevel
.pbrFill
;
1124 psurf
= SURFACE_LockSurface(dc
->rosdc
.hBitmap
);
1133 SURFACE_UnlockSurface(psurf
);