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 (!Points
|| 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
, Points
, Count
);
78 for (CurrentPoint
= 0; CurrentPoint
< Count
; CurrentPoint
++)
80 Points
[CurrentPoint
].x
+= dc
->ptlDCOrig
.x
;
81 Points
[CurrentPoint
].y
+= dc
->ptlDCOrig
.y
;
83 // No need to have path here.
85 DestRect
.left
= Points
[0].x
;
86 DestRect
.right
= Points
[0].x
;
87 DestRect
.top
= Points
[0].y
;
88 DestRect
.bottom
= Points
[0].y
;
90 for (CurrentPoint
= 1; CurrentPoint
< Count
; ++CurrentPoint
)
92 DestRect
.left
= min(DestRect
.left
, Points
[CurrentPoint
].x
);
93 DestRect
.right
= max(DestRect
.right
, Points
[CurrentPoint
].x
);
94 DestRect
.top
= min(DestRect
.top
, Points
[CurrentPoint
].y
);
95 DestRect
.bottom
= max(DestRect
.bottom
, Points
[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
), Points
, 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 // Points[0].x, Points[0].y,
126 // Points[1].x, Points[1].y );
128 ret
= IntEngLineTo(&BitmapObj
->SurfObj
,
130 &PenBrushInst
.BrushObject
,
131 Points
[i
].x
, /* From */
133 Points
[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 Points
[Count
-1].x
, /* From */
147 Points
[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
, (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.
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
,
339 IN PPOINT UnsafePoints
,
340 IN PULONG UnsafeCounts
,
348 NTSTATUS Status
= STATUS_SUCCESS
;
350 INT nPoints
= 0, nMaxPoints
= 0, nInvalid
= 0, i
;
352 if (!UnsafePoints
|| !UnsafeCounts
||
353 Count
== 0 || iFunc
== 0 || iFunc
> GdiPolyPolyRgn
)
355 /* Windows doesn't set last error */
361 ProbeForRead(UnsafePoints
, Count
* sizeof(POINT
), 1);
362 ProbeForRead(UnsafeCounts
, Count
* sizeof(ULONG
), 1);
364 /* Count points and validate poligons */
365 for (i
= 0; i
< Count
; i
++)
367 if (UnsafeCounts
[i
] < 2)
371 nPoints
+= UnsafeCounts
[i
];
372 nMaxPoints
= max(nMaxPoints
, UnsafeCounts
[i
]);
377 Status
= _SEH_GetExceptionCode();
381 if (!NT_SUCCESS(Status
))
383 /* Windows doesn't set last error */
387 if (nPoints
== 0 || nPoints
< nMaxPoints
)
389 /* If all polygon counts are zero, or we have overflow,
390 return without setting a last error code. */
396 /* If at least one poly count is 0 or 1, fail */
397 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
401 /* Allocate one buffer for both counts and points */
402 pTemp
= ExAllocatePoolWithTag(PagedPool
,
403 Count
* sizeof(ULONG
) + nPoints
* sizeof(POINT
),
407 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
412 SafePoints
= (PVOID
)(SafeCounts
+ Count
);
416 /* Pointers already probed! */
417 RtlCopyMemory(SafeCounts
, UnsafeCounts
, Count
* sizeof(ULONG
));
418 RtlCopyMemory(SafePoints
, UnsafePoints
, nPoints
* sizeof(POINT
));
422 Status
= _SEH_GetExceptionCode();
426 if (!NT_SUCCESS(Status
))
432 /* Special handling for GdiPolyPolyRgn */
433 if (iFunc
== GdiPolyPolyRgn
)
436 hRgn
= IntCreatePolyPolygonRgn(SafePoints
, SafeCounts
, Count
, (INT_PTR
)hDC
);
438 return (ULONG_PTR
)hRgn
;
444 SetLastWin32Error(ERROR_INVALID_HANDLE
);
449 if (dc
->DC_Type
== DC_TYPE_INFO
)
453 /* Yes, Windows really returns TRUE in this case */
457 /* Perform the actual work */
461 Ret
= IntGdiPolyPolygon(dc
, SafePoints
, SafeCounts
, Count
);
463 case GdiPolyPolyLine
:
464 Ret
= IntGdiPolyPolyline(dc
, SafePoints
, SafeCounts
, Count
);
467 Ret
= IntGdiPolyBezier(dc
, SafePoints
, *SafeCounts
);
470 Ret
= IntGdiPolylineTo(dc
, SafePoints
, *SafeCounts
);
472 case GdiPolyBezierTo
:
473 Ret
= IntGdiPolyBezierTo(dc
, SafePoints
, *SafeCounts
);
476 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
480 /* Cleanup and return */
484 return (ULONG_PTR
)Ret
;
496 BITMAPOBJ
*BitmapObj
= NULL
;
497 PGDIBRUSHOBJ PenBrushObj
= NULL
, FillBrushObj
= NULL
;
498 GDIBRUSHINST PenBrushInst
, FillBrushInst
;
499 BOOL ret
= FALSE
; // default to failure
504 ASSERT ( dc
); // caller's responsibility to set this up
506 Dc_Attr
= dc
->pDc_Attr
;
507 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
509 if ( PATH_IsPathOpen(dc
->DcLevel
) )
511 return PATH_Rectangle ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
);
514 /* Do we rotate or shear? */
515 if (!(dc
->DcLevel
.mxWorldToDevice
.flAccel
& MX_SCALE
))
517 POINTL DestCoords
[4];
518 DestCoords
[0].x
= DestCoords
[3].x
= LeftRect
;
519 DestCoords
[0].y
= DestCoords
[1].y
= TopRect
;
520 DestCoords
[1].x
= DestCoords
[2].x
= RightRect
;
521 DestCoords
[2].y
= DestCoords
[3].y
= BottomRect
;
522 return IntGdiPolygon(dc
, DestCoords
, 4);
525 DestRect
.left
= LeftRect
;
526 DestRect
.right
= RightRect
;
527 DestRect
.top
= TopRect
;
528 DestRect
.bottom
= BottomRect
;
530 IntLPtoDP(dc
, (LPPOINT
)&DestRect
, 2);
532 DestRect
.left
+= dc
->ptlDCOrig
.x
;
533 DestRect
.right
+= dc
->ptlDCOrig
.x
;
534 DestRect
.top
+= dc
->ptlDCOrig
.y
;
535 DestRect
.bottom
+= dc
->ptlDCOrig
.y
;
537 /* In GM_COMPATIBLE, don't include bottom and right edges */
538 if (IntGetGraphicsMode(dc
) == GM_COMPATIBLE
)
544 /* Special locking order to avoid lock-ups! */
545 FillBrushObj
= BRUSHOBJ_LockBrush(Dc_Attr
->hbrush
);
546 PenBrushObj
= PENOBJ_LockPen(Dc_Attr
->hpen
);
552 BitmapObj
= BITMAPOBJ_LockBitmap(dc
->w
.hBitmap
);
561 if (!(FillBrushObj
->flAttrs
& GDIBRUSH_IS_NULL
))
563 IntGdiInitBrushInstance(&FillBrushInst
, FillBrushObj
, dc
->XlateBrush
);
564 ret
= IntEngBitBlt(&BitmapObj
->SurfObj
,
572 &FillBrushInst
.BrushObject
,
574 ROP3_TO_ROP4(PATCOPY
));
578 IntGdiInitBrushInstance(&PenBrushInst
, PenBrushObj
, dc
->XlatePen
);
580 // Draw the rectangle with the current pen
582 ret
= TRUE
; // change default to success
584 if (!(PenBrushObj
->flAttrs
& GDIBRUSH_IS_NULL
))
586 Mix
= ROP2_TO_MIX(Dc_Attr
->jROP2
);
587 ret
= ret
&& IntEngLineTo(&BitmapObj
->SurfObj
,
589 &PenBrushInst
.BrushObject
,
590 DestRect
.left
, DestRect
.top
, DestRect
.right
, DestRect
.top
,
591 &DestRect
, // Bounding rectangle
594 ret
= ret
&& IntEngLineTo(&BitmapObj
->SurfObj
,
596 &PenBrushInst
.BrushObject
,
597 DestRect
.right
, DestRect
.top
, DestRect
.right
, DestRect
.bottom
,
598 &DestRect
, // Bounding rectangle
601 ret
= ret
&& IntEngLineTo(&BitmapObj
->SurfObj
,
603 &PenBrushInst
.BrushObject
,
604 DestRect
.right
, DestRect
.bottom
, DestRect
.left
, DestRect
.bottom
,
605 &DestRect
, // Bounding rectangle
608 ret
= ret
&& IntEngLineTo(&BitmapObj
->SurfObj
,
610 &PenBrushInst
.BrushObject
,
611 DestRect
.left
, DestRect
.bottom
, DestRect
.left
, DestRect
.top
,
612 &DestRect
, // Bounding rectangle
618 BRUSHOBJ_UnlockBrush(FillBrushObj
);
621 PENOBJ_UnlockPen(PenBrushObj
);
624 BITMAPOBJ_UnlockBitmap(BitmapObj
);
626 /* Move current position in DC?
627 MSDN: The current position is neither used nor updated by Rectangle. */
634 NtGdiRectangle(HDC hDC
,
641 BOOL ret
; // default to failure
646 SetLastWin32Error(ERROR_INVALID_HANDLE
);
649 if (dc
->DC_Type
== DC_TYPE_INFO
)
652 /* Yes, Windows really returns TRUE in this case */
656 ret
= IntRectangle ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
);
675 PGDIBRUSHOBJ PenBrushObj
;
677 LONG PenWidth
, PenOrigWidth
;
678 BOOL ret
= TRUE
; // default to success
680 ASSERT ( dc
); // caller's responsibility to set this up
682 if ( PATH_IsPathOpen(dc
->DcLevel
) )
683 return PATH_RoundRect ( dc
, Left
, Top
, Right
, Bottom
,
684 xCurveDiameter
, yCurveDiameter
);
686 if ((Left
== Right
) || (Top
== Bottom
)) return TRUE
;
688 xCurveDiameter
= max(abs( xCurveDiameter
), 1);
689 yCurveDiameter
= max(abs( yCurveDiameter
), 1);
693 INT tmp
= Right
; Right
= Left
; Left
= tmp
;
697 INT tmp
= Bottom
; Bottom
= Top
; Top
= tmp
;
700 Dc_Attr
= dc
->pDc_Attr
;
701 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
703 PenBrushObj
= PENOBJ_LockPen(Dc_Attr
->hpen
);
706 /* Nothing to do, as we don't have a bitmap */
707 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
711 PenOrigWidth
= PenWidth
= PenBrushObj
->ptPenWidth
.x
;
712 if (PenBrushObj
->ulPenStyle
== PS_NULL
) PenWidth
= 0;
714 if (PenBrushObj
->ulPenStyle
== PS_INSIDEFRAME
)
716 if (2*PenWidth
> (Right
- Left
)) PenWidth
= (Right
-Left
+ 1)/2;
717 if (2*PenWidth
> (Bottom
- Top
)) PenWidth
= (Bottom
-Top
+ 1)/2;
718 Left
+= PenWidth
/ 2;
719 Right
-= (PenWidth
- 1) / 2;
721 Bottom
-= (PenWidth
- 1) / 2;
724 if (!PenWidth
) PenWidth
= 1;
725 PenBrushObj
->ptPenWidth
.x
= PenWidth
;
727 RectBounds
.left
= Left
;
728 RectBounds
.top
= Top
;
729 RectBounds
.right
= Right
;
730 RectBounds
.bottom
= Bottom
;
732 IntLPtoDP(dc
, (LPPOINT
)&RectBounds
, 2);
734 RectBounds
.left
+= dc
->ptlDCOrig
.x
;
735 RectBounds
.top
+= dc
->ptlDCOrig
.y
;
736 RectBounds
.right
+= dc
->ptlDCOrig
.x
;
737 RectBounds
.bottom
+= dc
->ptlDCOrig
.y
;
739 ret
= IntFillRoundRect( dc
,
747 ret
= IntDrawRoundRect( dc
,
756 PenBrushObj
->ptPenWidth
.x
= PenOrigWidth
;
757 PENOBJ_UnlockPen(PenBrushObj
);
772 DC
*dc
= DC_LockDc(hDC
);
773 BOOL ret
= FALSE
; /* default to failure */
775 DPRINT("NtGdiRoundRect(0x%x,%i,%i,%i,%i,%i,%i)\n",hDC
,LeftRect
,TopRect
,RightRect
,BottomRect
,Width
,Height
);
778 DPRINT1("NtGdiRoundRect() - hDC is invalid\n");
779 SetLastWin32Error(ERROR_INVALID_HANDLE
);
781 else if (dc
->DC_Type
== DC_TYPE_INFO
)
784 /* Yes, Windows really returns TRUE in this case */
789 ret
= IntRoundRect ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
, Width
, Height
);
805 BITMAPOBJ
*BitmapObj
;
812 HPALETTE hDestPalette
;
820 /* check parameters */
821 if (ulMode
& GRADIENT_FILL_TRIANGLE
)
823 PGRADIENT_TRIANGLE tr
= (PGRADIENT_TRIANGLE
)pMesh
;
825 for (i
= 0; i
< uMesh
; i
++, tr
++)
827 if (tr
->Vertex1
>= uVertex
||
828 tr
->Vertex2
>= uVertex
||
829 tr
->Vertex3
>= uVertex
)
831 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
838 PGRADIENT_RECT rc
= (PGRADIENT_RECT
)pMesh
;
839 for (i
= 0; i
< uMesh
; i
++, rc
++)
841 if (rc
->UpperLeft
>= uVertex
|| rc
->LowerRight
>= uVertex
)
843 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
849 /* calculate extent */
850 Extent
.left
= Extent
.right
= pVertex
->x
;
851 Extent
.top
= Extent
.bottom
= pVertex
->y
;
852 for (i
= 0; i
< uVertex
; i
++)
854 Extent
.left
= min(Extent
.left
, (pVertex
+ i
)->x
);
855 Extent
.right
= max(Extent
.right
, (pVertex
+ i
)->x
);
856 Extent
.top
= min(Extent
.top
, (pVertex
+ i
)->y
);
857 Extent
.bottom
= max(Extent
.bottom
, (pVertex
+ i
)->y
);
860 DitherOrg
.x
= dc
->ptlDCOrig
.x
;
861 DitherOrg
.y
= dc
->ptlDCOrig
.y
;
862 Extent
.left
+= DitherOrg
.x
;
863 Extent
.right
+= DitherOrg
.x
;
864 Extent
.top
+= DitherOrg
.y
;
865 Extent
.bottom
+= DitherOrg
.y
;
867 BitmapObj
= BITMAPOBJ_LockBitmap(dc
->w
.hBitmap
);
868 /* FIXME - BitmapObj can be NULL!!! Don't assert but handle this case gracefully! */
871 hDestPalette
= BitmapObj
->hDIBPalette
;
872 if (!hDestPalette
) hDestPalette
= pPrimarySurface
->DevInfo
.hpalDefault
;
874 PalDestGDI
= PALETTE_LockPalette(hDestPalette
);
877 Mode
= PalDestGDI
->Mode
;
878 PALETTE_UnlockPalette(PalDestGDI
);
883 XlateObj
= (XLATEOBJ
*)IntEngCreateXlate(Mode
, PAL_RGB
, hDestPalette
, NULL
);
886 Ret
= IntEngGradientFill(&BitmapObj
->SurfObj
,
897 BITMAPOBJ_UnlockBitmap(BitmapObj
);
898 EngDeleteXlate(XlateObj
);
915 PTRIVERTEX SafeVertex
;
918 NTSTATUS Status
= STATUS_SUCCESS
;
923 SetLastWin32Error(ERROR_INVALID_HANDLE
);
926 if (dc
->DC_Type
== DC_TYPE_INFO
)
929 /* Yes, Windows really returns TRUE in this case */
932 if (!pVertex
|| !uVertex
|| !pMesh
|| !uMesh
)
935 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
941 case GRADIENT_FILL_RECT_H
:
942 case GRADIENT_FILL_RECT_V
:
943 SizeMesh
= uMesh
* sizeof(GRADIENT_RECT
);
945 case GRADIENT_FILL_TRIANGLE
:
946 SizeMesh
= uMesh
* sizeof(TRIVERTEX
);
950 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
956 ProbeForRead(pVertex
,
957 uVertex
* sizeof(TRIVERTEX
),
965 Status
= _SEH_GetExceptionCode();
969 if (!NT_SUCCESS(Status
))
972 SetLastWin32Error(Status
);
976 if (!(SafeVertex
= ExAllocatePoolWithTag(PagedPool
, (uVertex
* sizeof(TRIVERTEX
)) + SizeMesh
, TAG_SHAPE
)))
979 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
983 SafeMesh
= (PTRIVERTEX
)(SafeVertex
+ uVertex
);
987 /* pointers were already probed! */
988 RtlCopyMemory(SafeVertex
,
990 uVertex
* sizeof(TRIVERTEX
));
991 RtlCopyMemory(SafeMesh
,
997 Status
= _SEH_GetExceptionCode();
1001 if (!NT_SUCCESS(Status
))
1004 ExFreePool(SafeVertex
);
1005 SetLastNtError(Status
);
1009 Ret
= IntGdiGradientFill(dc
, SafeVertex
, uVertex
, SafeMesh
, uMesh
, ulMode
);
1012 ExFreePool(SafeVertex
);
1024 DPRINT1("FIXME: NtGdiExtFloodFill is UNIMPLEMENTED\n");
1026 /* lie and say we succeded */