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.
26 * a couple macros to fill a single pixel or a line
28 #define PUTPIXEL(x,y,BrushInst) \
29 ret = ret && IntEngLineTo(&BitmapObj->SurfObj, \
31 &BrushInst.BrushObject, \
34 ROP2_TO_MIX(Dc_Attr->jROP2));
36 #define PUTLINE(x1,y1,x2,y2,BrushInst) \
37 ret = ret && IntEngLineTo(&BitmapObj->SurfObj, \
39 &BrushInst.BrushObject, \
42 ROP2_TO_MIX(Dc_Attr->jROP2));
44 #define Rsin(d) ((d) == 0.0 ? 0.0 : ((d) == 90.0 ? 1.0 : sin(d*M_PI/180.0)))
45 #define Rcos(d) ((d) == 0.0 ? 1.0 : ((d) == 90.0 ? 0.0 : cos(d*M_PI/180.0)))
47 BOOL FASTCALL
IntFillEllipse( PDC dc
, INT XLeft
, INT YLeft
, INT Width
, INT Height
);
48 BOOL FASTCALL
IntDrawEllipse( PDC dc
, INT XLeft
, INT YLeft
, INT Width
, INT Height
, PGDIBRUSHOBJ PenBrushObj
);
49 BOOL FASTCALL
IntFillRoundRect( PDC dc
, INT Left
, INT Top
, INT Right
, INT Bottom
, INT Wellipse
, INT Hellipse
);
50 BOOL FASTCALL
IntDrawRoundRect( PDC dc
, INT Left
, INT Top
, INT Right
, INT Bottom
, INT Wellipse
, INT Hellipse
, PGDIBRUSHOBJ PenBrushObj
);
58 PGDIBRUSHOBJ PenBrushObj
, FillBrushObj
;
59 GDIBRUSHINST PenBrushInst
, FillBrushInst
;
60 BOOL ret
= FALSE
; // default to failure
65 ASSERT(dc
); // caller's responsibility to pass a valid dc
67 if ( NULL
== UnsafePoints
|| Count
< 2 )
69 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
73 Dc_Attr
= dc
->pDc_Attr
;
74 if (!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
76 /* Convert to screen coordinates */
77 IntLPtoDP(dc
, UnsafePoints
, Count
);
78 for (CurrentPoint
= 0; CurrentPoint
< Count
; CurrentPoint
++)
80 UnsafePoints
[CurrentPoint
].x
+= dc
->ptlDCOrig
.x
;
81 UnsafePoints
[CurrentPoint
].y
+= dc
->ptlDCOrig
.y
;
83 // No need to have path here.
85 DestRect
.left
= UnsafePoints
[0].x
;
86 DestRect
.right
= UnsafePoints
[0].x
;
87 DestRect
.top
= UnsafePoints
[0].y
;
88 DestRect
.bottom
= UnsafePoints
[0].y
;
90 for (CurrentPoint
= 1; CurrentPoint
< Count
; ++CurrentPoint
)
92 DestRect
.left
= min(DestRect
.left
, UnsafePoints
[CurrentPoint
].x
);
93 DestRect
.right
= max(DestRect
.right
, UnsafePoints
[CurrentPoint
].x
);
94 DestRect
.top
= min(DestRect
.top
, UnsafePoints
[CurrentPoint
].y
);
95 DestRect
.bottom
= max(DestRect
.bottom
, UnsafePoints
[CurrentPoint
].y
);
98 /* Special locking order to avoid lock-ups */
99 FillBrushObj
= BRUSHOBJ_LockBrush(Dc_Attr
->hbrush
);
100 PenBrushObj
= PENOBJ_LockPen(Dc_Attr
->hpen
);
101 BitmapObj
= BITMAPOBJ_LockBitmap(dc
->w
.hBitmap
);
102 /* FIXME - BitmapObj can be NULL!!!! don't assert but handle this case gracefully! */
105 /* Now fill the polygon with the current brush. */
106 if (FillBrushObj
&& !(FillBrushObj
->flAttrs
& GDIBRUSH_IS_NULL
))
108 IntGdiInitBrushInstance(&FillBrushInst
, FillBrushObj
, dc
->XlateBrush
);
109 ret
= FillPolygon ( dc
, BitmapObj
, &FillBrushInst
.BrushObject
, ROP2_TO_MIX(Dc_Attr
->jROP2
), UnsafePoints
, Count
, DestRect
);
112 BRUSHOBJ_UnlockBrush(FillBrushObj
);
114 // Draw the Polygon Edges with the current pen ( if not a NULL pen )
115 if (PenBrushObj
&& !(PenBrushObj
->flAttrs
& GDIBRUSH_IS_NULL
))
119 IntGdiInitBrushInstance(&PenBrushInst
, PenBrushObj
, dc
->XlatePen
);
121 for (i
= 0; i
< Count
-1; i
++)
124 // DPRINT1("Polygon Making line from (%d,%d) to (%d,%d)\n",
125 // UnsafePoints[0].x, UnsafePoints[0].y,
126 // UnsafePoints[1].x, UnsafePoints[1].y );
128 ret
= IntEngLineTo(&BitmapObj
->SurfObj
,
130 &PenBrushInst
.BrushObject
,
131 UnsafePoints
[i
].x
, /* From */
133 UnsafePoints
[i
+1].x
, /* To */
136 ROP2_TO_MIX(Dc_Attr
->jROP2
)); /* MIX */
139 /* Close the polygon */
142 ret
= IntEngLineTo(&BitmapObj
->SurfObj
,
144 &PenBrushInst
.BrushObject
,
145 UnsafePoints
[Count
-1].x
, /* From */
146 UnsafePoints
[Count
-1].y
,
147 UnsafePoints
[0].x
, /* To */
150 ROP2_TO_MIX(Dc_Attr
->jROP2
)); /* MIX */
154 PENOBJ_UnlockPen(PenBrushObj
);
156 BITMAPOBJ_UnlockBitmap(BitmapObj
);
162 IntGdiPolyPolygon(DC
*dc
,
167 if (PATH_IsPathOpen(dc
->DcLevel
))
168 return PATH_PolyPolygon ( dc
, Points
, 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.
206 PGDIBRUSHOBJ PenBrushObj
;
208 LONG PenWidth
, PenOrigWidth
;
209 LONG RadiusX
, RadiusY
, CenterX
, CenterY
;
211 if ((Left
== Right
) || (Top
== Bottom
)) return TRUE
;
216 SetLastWin32Error(ERROR_INVALID_HANDLE
);
219 if (dc
->DC_Type
== DC_TYPE_INFO
)
222 /* Yes, Windows really returns TRUE in this case */
226 if (PATH_IsPathOpen(dc
->DcLevel
))
228 ret
= PATH_Ellipse(dc
, Left
, Top
, Right
, Bottom
);
235 INT tmp
= Right
; Right
= Left
; Left
= tmp
;
239 INT tmp
= Bottom
; Bottom
= Top
; Top
= tmp
;
242 Dc_Attr
= dc
->pDc_Attr
;
243 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
245 PenBrushObj
= PENOBJ_LockPen(Dc_Attr
->hpen
);
246 if (NULL
== PenBrushObj
)
248 DPRINT1("Ellipse Fail 1\n");
250 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
254 PenOrigWidth
= PenWidth
= PenBrushObj
->ptPenWidth
.x
;
255 if (PenBrushObj
->ulPenStyle
== PS_NULL
) PenWidth
= 0;
257 if (PenBrushObj
->ulPenStyle
== PS_INSIDEFRAME
)
259 if (2*PenWidth
> (Right
- Left
)) PenWidth
= (Right
-Left
+ 1)/2;
260 if (2*PenWidth
> (Bottom
- Top
)) PenWidth
= (Bottom
-Top
+ 1)/2;
261 Left
+= PenWidth
/ 2;
262 Right
-= (PenWidth
- 1) / 2;
264 Bottom
-= (PenWidth
- 1) / 2;
267 if (!PenWidth
) PenWidth
= 1;
268 PenBrushObj
->ptPenWidth
.x
= PenWidth
;
270 RectBounds
.left
= Left
;
271 RectBounds
.right
= Right
;
272 RectBounds
.top
= Top
;
273 RectBounds
.bottom
= Bottom
;
275 IntLPtoDP(dc
, (LPPOINT
)&RectBounds
, 2);
277 RectBounds
.left
+= dc
->ptlDCOrig
.x
;
278 RectBounds
.right
+= dc
->ptlDCOrig
.x
;
279 RectBounds
.top
+= dc
->ptlDCOrig
.y
;
280 RectBounds
.bottom
+= dc
->ptlDCOrig
.y
;
282 // Setup for dynamic width and height.
283 RadiusX
= max((RectBounds
.right
- RectBounds
.left
) / 2, 2); // Needs room
284 RadiusY
= max((RectBounds
.bottom
- RectBounds
.top
) / 2, 2);
285 CenterX
= (RectBounds
.right
+ RectBounds
.left
) / 2;
286 CenterY
= (RectBounds
.bottom
+ RectBounds
.top
) / 2;
288 DPRINT("Ellipse 1: Left: %d, Top: %d, Right: %d, Bottom: %d\n",
289 RectBounds
.left
,RectBounds
.top
,RectBounds
.right
,RectBounds
.bottom
);
291 DPRINT("Ellipse 2: XLeft: %d, YLeft: %d, Width: %d, Height: %d\n",
292 CenterX
- RadiusX
, CenterY
+ RadiusY
, RadiusX
*2, RadiusY
*2);
294 ret
= IntFillEllipse( dc
,
298 RadiusY
*2); // Height
300 ret
= IntDrawEllipse( dc
,
307 PenBrushObj
->ptPenWidth
.x
= PenOrigWidth
;
308 PENOBJ_UnlockPen(PenBrushObj
);
310 DPRINT("Ellipse Exit.\n");
316 //When the fill mode is ALTERNATE, GDI fills the area between odd-numbered and
317 //even-numbered polygon sides on each scan line. That is, GDI fills the area between the
318 //first and second side, between the third and fourth side, and so on.
320 //WINDING Selects winding mode (fills any region with a nonzero winding value).
321 //When the fill mode is WINDING, GDI fills any region that has a nonzero winding value.
322 //This value is defined as the number of times a pen used to draw the polygon would go around the region.
323 //The direction of each edge of the polygon is important.
325 extern BOOL
FillPolygon(PDC dc
,
338 NtGdiPolyPolyDraw( IN HDC hDC
,
340 IN PULONG PolyCounts
,
346 LPINT SafePolyPoints
;
347 NTSTATUS Status
= STATUS_SUCCESS
;
349 INT nPoints
, nEmpty
, nInvalid
, i
;
351 if (iFunc
== GdiPolyPolyRgn
)
353 return (ULONG_PTR
) GdiCreatePolyPolygonRgn((CONST PPOINT
) Points
,
354 (CONST PINT
) PolyCounts
,
361 SetLastWin32Error(ERROR_INVALID_HANDLE
);
364 if (dc
->DC_Type
== DC_TYPE_INFO
)
367 /* Yes, Windows really returns TRUE in this case */
376 Count
* sizeof(POINT
),
378 ProbeForRead(PolyCounts
,
384 Status
= _SEH_GetExceptionCode();
388 if (!NT_SUCCESS(Status
))
391 SetLastNtError(Status
);
395 SafePolyPoints
= ExAllocatePoolWithTag(PagedPool
, Count
* sizeof(INT
), TAG_SHAPE
);
399 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
405 /* pointers already probed! */
406 RtlCopyMemory(SafePolyPoints
,
408 Count
* sizeof(INT
));
412 Status
= _SEH_GetExceptionCode();
416 if (!NT_SUCCESS(Status
))
419 ExFreePool(SafePolyPoints
);
420 SetLastNtError(Status
);
423 /* validate poligons */
427 for (i
= 0; i
< Count
; i
++)
429 if (SafePolyPoints
[i
] == 0)
433 if (SafePolyPoints
[i
] == 1)
437 nPoints
+= SafePolyPoints
[i
];
442 /* if all polygon counts are zero, return without setting a last error code. */
443 ExFreePool(SafePolyPoints
);
448 /* if at least one poly count is 1, fail */
449 ExFreePool(SafePolyPoints
);
450 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
454 Safept
= ExAllocatePoolWithTag(PagedPool
, nPoints
* sizeof(POINT
), TAG_SHAPE
);
458 ExFreePool(SafePolyPoints
);
459 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
465 /* pointers already probed! */
466 RtlCopyMemory(Safept
,
468 nPoints
* sizeof(POINT
));
472 Status
= _SEH_GetExceptionCode();
476 if (!NT_SUCCESS(Status
))
479 ExFreePool(SafePolyPoints
);
481 SetLastNtError(Status
);
488 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
495 Ret
= IntGdiPolyPolygon(dc
, Safept
, SafePolyPoints
, Count
);
497 case GdiPolyPolyLine
:
498 Ret
= IntGdiPolyPolyline(dc
, Safept
, (LPDWORD
) SafePolyPoints
, Count
);
501 Ret
= IntGdiPolyBezier(dc
, Safept
, *PolyCounts
);
504 Ret
= IntGdiPolylineTo(dc
, Safept
, *PolyCounts
);
506 case GdiPolyBezierTo
:
507 Ret
= IntGdiPolyBezierTo(dc
, Safept
, *PolyCounts
);
510 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
513 ExFreePool(SafePolyPoints
);
517 return (ULONG_PTR
) Ret
;
529 BITMAPOBJ
*BitmapObj
= NULL
;
530 PGDIBRUSHOBJ PenBrushObj
= NULL
, FillBrushObj
= NULL
;
531 GDIBRUSHINST PenBrushInst
, FillBrushInst
;
532 BOOL ret
= FALSE
; // default to failure
537 ASSERT ( dc
); // caller's responsibility to set this up
539 Dc_Attr
= dc
->pDc_Attr
;
540 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
542 /* Do we rotate or shear? */
543 if (!(dc
->DcLevel
.mxWorldToDevice
.flAccel
& MX_SCALE
))
545 POINTL DestCoords
[4];
546 DestCoords
[0].x
= DestCoords
[3].x
= LeftRect
;
547 DestCoords
[0].y
= DestCoords
[1].y
= TopRect
;
548 DestCoords
[1].x
= DestCoords
[2].x
= RightRect
;
549 DestCoords
[2].y
= DestCoords
[3].y
= BottomRect
;
550 return IntGdiPolygon(dc
, DestCoords
, 4);
553 if ( PATH_IsPathOpen(dc
->DcLevel
) )
555 return PATH_Rectangle ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
);
558 DestRect
.left
= LeftRect
;
559 DestRect
.right
= RightRect
;
560 DestRect
.top
= TopRect
;
561 DestRect
.bottom
= BottomRect
;
563 IntLPtoDP(dc
, (LPPOINT
)&DestRect
, 2);
565 DestRect
.left
+= dc
->ptlDCOrig
.x
;
566 DestRect
.right
+= dc
->ptlDCOrig
.x
;
567 DestRect
.top
+= dc
->ptlDCOrig
.y
;
568 DestRect
.bottom
+= dc
->ptlDCOrig
.y
;
570 /* In GM_COMPATIBLE, don't include bottom and right edges */
571 if (IntGetGraphicsMode(dc
) == GM_COMPATIBLE
)
577 /* Special locking order to avoid lock-ups! */
578 FillBrushObj
= BRUSHOBJ_LockBrush(Dc_Attr
->hbrush
);
579 PenBrushObj
= PENOBJ_LockPen(Dc_Attr
->hpen
);
585 BitmapObj
= BITMAPOBJ_LockBitmap(dc
->w
.hBitmap
);
594 if (!(FillBrushObj
->flAttrs
& GDIBRUSH_IS_NULL
))
596 IntGdiInitBrushInstance(&FillBrushInst
, FillBrushObj
, dc
->XlateBrush
);
597 ret
= IntEngBitBlt(&BitmapObj
->SurfObj
,
605 &FillBrushInst
.BrushObject
,
607 ROP3_TO_ROP4(PATCOPY
));
611 IntGdiInitBrushInstance(&PenBrushInst
, PenBrushObj
, dc
->XlatePen
);
613 // Draw the rectangle with the current pen
615 ret
= TRUE
; // change default to success
617 if (!(PenBrushObj
->flAttrs
& GDIBRUSH_IS_NULL
))
619 Mix
= ROP2_TO_MIX(Dc_Attr
->jROP2
);
620 ret
= ret
&& IntEngLineTo(&BitmapObj
->SurfObj
,
622 &PenBrushInst
.BrushObject
,
623 DestRect
.left
, DestRect
.top
, DestRect
.right
, DestRect
.top
,
624 &DestRect
, // Bounding rectangle
627 ret
= ret
&& IntEngLineTo(&BitmapObj
->SurfObj
,
629 &PenBrushInst
.BrushObject
,
630 DestRect
.right
, DestRect
.top
, DestRect
.right
, DestRect
.bottom
,
631 &DestRect
, // Bounding rectangle
634 ret
= ret
&& IntEngLineTo(&BitmapObj
->SurfObj
,
636 &PenBrushInst
.BrushObject
,
637 DestRect
.right
, DestRect
.bottom
, DestRect
.left
, DestRect
.bottom
,
638 &DestRect
, // Bounding rectangle
641 ret
= ret
&& IntEngLineTo(&BitmapObj
->SurfObj
,
643 &PenBrushInst
.BrushObject
,
644 DestRect
.left
, DestRect
.bottom
, DestRect
.left
, DestRect
.top
,
645 &DestRect
, // Bounding rectangle
651 BRUSHOBJ_UnlockBrush(FillBrushObj
);
654 PENOBJ_UnlockPen(PenBrushObj
);
657 BITMAPOBJ_UnlockBitmap(BitmapObj
);
659 /* Move current position in DC?
660 MSDN: The current position is neither used nor updated by Rectangle. */
667 NtGdiRectangle(HDC hDC
,
674 BOOL ret
; // default to failure
679 SetLastWin32Error(ERROR_INVALID_HANDLE
);
682 if (dc
->DC_Type
== DC_TYPE_INFO
)
685 /* Yes, Windows really returns TRUE in this case */
689 ret
= IntRectangle ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
);
708 PGDIBRUSHOBJ PenBrushObj
;
710 LONG PenWidth
, PenOrigWidth
;
711 BOOL ret
= TRUE
; // default to success
713 ASSERT ( dc
); // caller's responsibility to set this up
715 if ( PATH_IsPathOpen(dc
->DcLevel
) )
716 return PATH_RoundRect ( dc
, Left
, Top
, Right
, Bottom
,
717 xCurveDiameter
, yCurveDiameter
);
719 if ((Left
== Right
) || (Top
== Bottom
)) return TRUE
;
721 xCurveDiameter
= max(abs( xCurveDiameter
), 1);
722 yCurveDiameter
= max(abs( yCurveDiameter
), 1);
726 INT tmp
= Right
; Right
= Left
; Left
= tmp
;
730 INT tmp
= Bottom
; Bottom
= Top
; Top
= tmp
;
733 Dc_Attr
= dc
->pDc_Attr
;
734 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
736 PenBrushObj
= PENOBJ_LockPen(Dc_Attr
->hpen
);
739 /* Nothing to do, as we don't have a bitmap */
740 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
744 PenOrigWidth
= PenWidth
= PenBrushObj
->ptPenWidth
.x
;
745 if (PenBrushObj
->ulPenStyle
== PS_NULL
) PenWidth
= 0;
747 if (PenBrushObj
->ulPenStyle
== PS_INSIDEFRAME
)
749 if (2*PenWidth
> (Right
- Left
)) PenWidth
= (Right
-Left
+ 1)/2;
750 if (2*PenWidth
> (Bottom
- Top
)) PenWidth
= (Bottom
-Top
+ 1)/2;
751 Left
+= PenWidth
/ 2;
752 Right
-= (PenWidth
- 1) / 2;
754 Bottom
-= (PenWidth
- 1) / 2;
757 if (!PenWidth
) PenWidth
= 1;
758 PenBrushObj
->ptPenWidth
.x
= PenWidth
;
760 RectBounds
.left
= Left
;
761 RectBounds
.top
= Top
;
762 RectBounds
.right
= Right
;
763 RectBounds
.bottom
= Bottom
;
765 IntLPtoDP(dc
, (LPPOINT
)&RectBounds
, 2);
767 RectBounds
.left
+= dc
->ptlDCOrig
.x
;
768 RectBounds
.top
+= dc
->ptlDCOrig
.y
;
769 RectBounds
.right
+= dc
->ptlDCOrig
.x
;
770 RectBounds
.bottom
+= dc
->ptlDCOrig
.y
;
772 ret
= IntFillRoundRect( dc
,
780 ret
= IntDrawRoundRect( dc
,
789 PenBrushObj
->ptPenWidth
.x
= PenOrigWidth
;
790 PENOBJ_UnlockPen(PenBrushObj
);
805 DC
*dc
= DC_LockDc(hDC
);
806 BOOL ret
= FALSE
; /* default to failure */
808 DPRINT("NtGdiRoundRect(0x%x,%i,%i,%i,%i,%i,%i)\n",hDC
,LeftRect
,TopRect
,RightRect
,BottomRect
,Width
,Height
);
811 DPRINT1("NtGdiRoundRect() - hDC is invalid\n");
812 SetLastWin32Error(ERROR_INVALID_HANDLE
);
814 else if (dc
->DC_Type
== DC_TYPE_INFO
)
817 /* Yes, Windows really returns TRUE in this case */
822 ret
= IntRoundRect ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
, Width
, Height
);
838 BITMAPOBJ
*BitmapObj
;
845 HPALETTE hDestPalette
;
853 /* check parameters */
854 if (ulMode
& GRADIENT_FILL_TRIANGLE
)
856 PGRADIENT_TRIANGLE tr
= (PGRADIENT_TRIANGLE
)pMesh
;
858 for (i
= 0; i
< uMesh
; i
++, tr
++)
860 if (tr
->Vertex1
>= uVertex
||
861 tr
->Vertex2
>= uVertex
||
862 tr
->Vertex3
>= uVertex
)
864 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
871 PGRADIENT_RECT rc
= (PGRADIENT_RECT
)pMesh
;
872 for (i
= 0; i
< uMesh
; i
++, rc
++)
874 if (rc
->UpperLeft
>= uVertex
|| rc
->LowerRight
>= uVertex
)
876 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
882 /* calculate extent */
883 Extent
.left
= Extent
.right
= pVertex
->x
;
884 Extent
.top
= Extent
.bottom
= pVertex
->y
;
885 for (i
= 0; i
< uVertex
; i
++)
887 Extent
.left
= min(Extent
.left
, (pVertex
+ i
)->x
);
888 Extent
.right
= max(Extent
.right
, (pVertex
+ i
)->x
);
889 Extent
.top
= min(Extent
.top
, (pVertex
+ i
)->y
);
890 Extent
.bottom
= max(Extent
.bottom
, (pVertex
+ i
)->y
);
893 DitherOrg
.x
= dc
->ptlDCOrig
.x
;
894 DitherOrg
.y
= dc
->ptlDCOrig
.y
;
895 Extent
.left
+= DitherOrg
.x
;
896 Extent
.right
+= DitherOrg
.x
;
897 Extent
.top
+= DitherOrg
.y
;
898 Extent
.bottom
+= DitherOrg
.y
;
900 BitmapObj
= BITMAPOBJ_LockBitmap(dc
->w
.hBitmap
);
901 /* FIXME - BitmapObj can be NULL!!! Don't assert but handle this case gracefully! */
904 hDestPalette
= BitmapObj
->hDIBPalette
;
905 if (!hDestPalette
) hDestPalette
= pPrimarySurface
->DevInfo
.hpalDefault
;
907 PalDestGDI
= PALETTE_LockPalette(hDestPalette
);
910 Mode
= PalDestGDI
->Mode
;
911 PALETTE_UnlockPalette(PalDestGDI
);
916 XlateObj
= (XLATEOBJ
*)IntEngCreateXlate(Mode
, PAL_RGB
, hDestPalette
, NULL
);
919 Ret
= IntEngGradientFill(&BitmapObj
->SurfObj
,
930 BITMAPOBJ_UnlockBitmap(BitmapObj
);
931 EngDeleteXlate(XlateObj
);
948 PTRIVERTEX SafeVertex
;
951 NTSTATUS Status
= STATUS_SUCCESS
;
956 SetLastWin32Error(ERROR_INVALID_HANDLE
);
959 if (dc
->DC_Type
== DC_TYPE_INFO
)
962 /* Yes, Windows really returns TRUE in this case */
965 if (!pVertex
|| !uVertex
|| !pMesh
|| !uMesh
)
968 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
974 case GRADIENT_FILL_RECT_H
:
975 case GRADIENT_FILL_RECT_V
:
976 SizeMesh
= uMesh
* sizeof(GRADIENT_RECT
);
978 case GRADIENT_FILL_TRIANGLE
:
979 SizeMesh
= uMesh
* sizeof(TRIVERTEX
);
983 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
989 ProbeForRead(pVertex
,
990 uVertex
* sizeof(TRIVERTEX
),
998 Status
= _SEH_GetExceptionCode();
1002 if (!NT_SUCCESS(Status
))
1005 SetLastWin32Error(Status
);
1009 if (!(SafeVertex
= ExAllocatePoolWithTag(PagedPool
, (uVertex
* sizeof(TRIVERTEX
)) + SizeMesh
, TAG_SHAPE
)))
1012 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
1016 SafeMesh
= (PTRIVERTEX
)(SafeVertex
+ uVertex
);
1020 /* pointers were already probed! */
1021 RtlCopyMemory(SafeVertex
,
1023 uVertex
* sizeof(TRIVERTEX
));
1024 RtlCopyMemory(SafeMesh
,
1030 Status
= _SEH_GetExceptionCode();
1034 if (!NT_SUCCESS(Status
))
1037 ExFreePool(SafeVertex
);
1038 SetLastNtError(Status
);
1042 Ret
= IntGdiGradientFill(dc
, SafeVertex
, uVertex
, SafeMesh
, uMesh
, ulMode
);
1045 ExFreePool(SafeVertex
);
1057 DPRINT1("FIXME: NtGdiExtFloodFill is UNIMPLEMENTED\n");
1059 /* lie and say we succeded */