ReactOS 0.4.16-dev-2207-geb15453
fillshap.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for fillshap.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define Rsin(d)   ((d) == 0.0 ? 0.0 : ((d) == 90.0 ? 1.0 : sin(d*M_PI/180.0)))
 
#define Rcos(d)   ((d) == 0.0 ? 1.0 : ((d) == 90.0 ? 0.0 : cos(d*M_PI/180.0)))
 

Functions

BOOL FASTCALL IntGdiPolygon (PDC dc, PPOINT Points, int Count)
 
BOOL FASTCALL IntGdiPolyPolygon (DC *dc, LPPOINT Points, PULONG PolyCounts, int Count)
 
BOOL FASTCALL IntPolygon (HDC hdc, POINT *Point, int Count)
 
BOOL APIENTRY NtGdiEllipse (HDC hDC, int Left, int Top, int Right, int Bottom)
 
ULONG_PTR APIENTRY NtGdiPolyPolyDraw (IN HDC hDC, IN PPOINT UnsafePoints, IN PULONG UnsafeCounts, IN ULONG Count, IN INT iFunc)
 
BOOL FASTCALL IntRectangle (PDC dc, int LeftRect, int TopRect, int RightRect, int BottomRect)
 
BOOL APIENTRY NtGdiRectangle (HDC hDC, int LeftRect, int TopRect, int RightRect, int BottomRect)
 
BOOL FASTCALL IntRoundRect (PDC dc, int Left, int Top, int Right, int Bottom, int xCurveDiameter, int yCurveDiameter)
 
BOOL APIENTRY NtGdiRoundRect (HDC hDC, int LeftRect, int TopRect, int RightRect, int BottomRect, int Width, int Height)
 
BOOL NTAPI GreGradientFill (HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nMesh, ULONG ulMode)
 
BOOL APIENTRY NtGdiGradientFill (HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nMesh, ULONG ulMode)
 
BOOL APIENTRY NtGdiExtFloodFill (HDC hDC, INT XStart, INT YStart, COLORREF Color, UINT FillType)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file fillshap.c.

◆ Rcos

#define Rcos (   d)    ((d) == 0.0 ? 1.0 : ((d) == 90.0 ? 0.0 : cos(d*M_PI/180.0)))

Definition at line 15 of file fillshap.c.

◆ Rsin

#define Rsin (   d)    ((d) == 0.0 ? 0.0 : ((d) == 90.0 ? 1.0 : sin(d*M_PI/180.0)))

Definition at line 14 of file fillshap.c.

Function Documentation

◆ GreGradientFill()

BOOL NTAPI GreGradientFill ( HDC  hdc,
PTRIVERTEX  pVertex,
ULONG  nVertex,
PVOID  pMesh,
ULONG  nMesh,
ULONG  ulMode 
)

Definition at line 940 of file fillshap.c.

947{
948 PDC pdc;
949 SURFACE *psurf;
950 EXLATEOBJ exlo;
951 RECTL rclExtent;
952 POINTL ptlDitherOrg;
953 ULONG i;
954 BOOL bRet;
955
956 /* Check parameters */
957 if (ulMode == GRADIENT_FILL_TRIANGLE)
958 {
960
961 for (i = 0; i < nMesh; i++, pTriangle++)
962 {
963 if (pTriangle->Vertex1 >= nVertex ||
964 pTriangle->Vertex2 >= nVertex ||
965 pTriangle->Vertex3 >= nVertex)
966 {
968 return FALSE;
969 }
970 }
971 }
972 else
973 {
975 for (i = 0; i < nMesh; i++, pRect++)
976 {
977 if (pRect->UpperLeft >= nVertex || pRect->LowerRight >= nVertex)
978 {
980 return FALSE;
981 }
982 }
983 }
984
985 /* Lock the output DC */
986 pdc = DC_LockDc(hdc);
987 if(!pdc)
988 {
990 return FALSE;
991 }
992
993 if (!pdc->dclevel.pSurface)
994 {
995 /* Memory DC with no surface selected */
996 DC_UnlockDc(pdc);
997 return TRUE; // CHECKME
998 }
999
1000 /* Calculate extent */
1001 rclExtent.left = rclExtent.right = pVertex->x;
1002 rclExtent.top = rclExtent.bottom = pVertex->y;
1003 for (i = 0; i < nVertex; i++)
1004 {
1005 rclExtent.left = min(rclExtent.left, (pVertex + i)->x);
1006 rclExtent.right = max(rclExtent.right, (pVertex + i)->x);
1007 rclExtent.top = min(rclExtent.top, (pVertex + i)->y);
1008 rclExtent.bottom = max(rclExtent.bottom, (pVertex + i)->y);
1009 }
1010 IntLPtoDP(pdc, (LPPOINT)&rclExtent, 2);
1011
1012 rclExtent.left += pdc->ptlDCOrig.x;
1013 rclExtent.right += pdc->ptlDCOrig.x;
1014 rclExtent.top += pdc->ptlDCOrig.y;
1015 rclExtent.bottom += pdc->ptlDCOrig.y;
1016
1017 if (RECTL_bIsEmptyRect(&rclExtent))
1018 {
1019 DC_UnlockDc(pdc);
1020 return TRUE;
1021 }
1022
1023 /* Offset vertex for rectangles */
1024 if (ulMode == GRADIENT_FILL_RECT_H ||
1025 ulMode == GRADIENT_FILL_RECT_V)
1026 {
1027 for (i = 0; i < nVertex; i++)
1028 {
1029 IntLPtoDP(pdc, (LPPOINT)&pVertex[i], 1);
1030 pVertex[i].x += pdc->ptlDCOrig.x;
1031 pVertex[i].y += pdc->ptlDCOrig.y;
1032 }
1033 }
1034
1035 ptlDitherOrg.x = ptlDitherOrg.y = 0;
1036 IntLPtoDP(pdc, (LPPOINT)&ptlDitherOrg, 1);
1037
1038 ptlDitherOrg.x += pdc->ptlDCOrig.x;
1039 ptlDitherOrg.y += pdc->ptlDCOrig.y;
1040
1041 if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
1042 {
1043 IntUpdateBoundsRect(pdc, &rclExtent);
1044 }
1045
1046 DC_vPrepareDCsForBlit(pdc, &rclExtent, NULL, NULL);
1047
1048 psurf = pdc->dclevel.pSurface;
1049
1050 EXLATEOBJ_vInitialize(&exlo, &gpalRGB, psurf->ppal, 0, 0, 0);
1051
1052 bRet = IntEngGradientFill(&psurf->SurfObj,
1053 (CLIPOBJ *)&pdc->co,
1054 &exlo.xlo,
1055 pVertex,
1056 nVertex,
1057 pMesh,
1058 nMesh,
1059 &rclExtent,
1060 &ptlDitherOrg,
1061 ulMode);
1062
1063 EXLATEOBJ_vCleanup(&exlo);
1064 DC_vFinishBlit(pdc, NULL);
1065 DC_UnlockDc(pdc);
1066
1067 return bRet;
1068}
static BOOLEAN IntLPtoDP(DC *pdc, PPOINTL ppt, UINT count)
Definition: coord.h:182
VOID FASTCALL DC_vPrepareDCsForBlit(PDC pdcDest, const RECT *rcDest, PDC pdcSrc, const RECT *rcSrc)
Definition: dclife.c:505
VOID FASTCALL DC_vFinishBlit(PDC pdc1, PDC pdc2)
Definition: dclife.c:614
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
VOID FASTCALL IntUpdateBoundsRect(PDC, PRECTL)
Definition: dcutil.c:694
@ DC_ACCUM_APP
Definition: dc.h:25
@ DC_ACCUM_WMGR
Definition: dc.h:24
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HDC hdc
Definition: main.c:9
#define min(a, b)
Definition: monoChain.cc:55
Definition: polytest.cpp:41
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
XLATEOBJ xlo
Definition: xlateobj.h:21
ULONG LowerRight
Definition: wingdi.h:3252
ULONG UpperLeft
Definition: wingdi.h:3251
LONG y
Definition: windef.h:130
LONG x
Definition: windef.h:129
SURFOBJ SurfObj
Definition: surface.h:8
struct _PALETTE *const ppal
Definition: surface.h:11
#define max(a, b)
Definition: svc.c:63
uint32_t ULONG
Definition: typedefs.h:59
BOOL APIENTRY IntEngGradientFill(IN SURFOBJ *psoDest, IN CLIPOBJ *pco, IN XLATEOBJ *pxlo, IN TRIVERTEX *pVertex, IN ULONG nVertex, IN PVOID pMesh, IN ULONG nMesh, IN RECTL *prclExtents, IN POINTL *pptlDitherOrg, IN ULONG ulMode)
Definition: gradient.c:557
PALETTE gpalRGB
Definition: palette.c:20
FORCEINLINE BOOL RECTL_bIsEmptyRect(_In_ const RECTL *prcl)
Definition: rect.h:44
_In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ TRIVERTEX _In_ ULONG _In_ PVOID pMesh
Definition: winddi.h:3653
_In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ TRIVERTEX _In_ ULONG nVertex
Definition: winddi.h:3652
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
_In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ TRIVERTEX _In_ ULONG _In_ PVOID _In_ ULONG _In_ RECTL _In_ POINTL _In_ ULONG ulMode
Definition: winddi.h:3657
_In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ TRIVERTEX * pVertex
Definition: winddi.h:3651
_In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ TRIVERTEX _In_ ULONG _In_ PVOID _In_ ULONG nMesh
Definition: winddi.h:3654
struct _GRADIENT_RECT * PGRADIENT_RECT
struct _GRADIENT_TRIANGLE * PGRADIENT_TRIANGLE
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:491
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:894

Referenced by NtGdiGradientFill(), and UserDrawCaption().

◆ IntGdiPolygon()

BOOL FASTCALL IntGdiPolygon ( PDC  dc,
PPOINT  Points,
int  Count 
)

Definition at line 18 of file fillshap.c.

21{
22 SURFACE *psurf;
23 PBRUSH pbrLine, pbrFill;
24 BOOL ret = FALSE; // Default to failure
25 RECTL DestRect;
26 INT i, CurrentPoint;
27 PDC_ATTR pdcattr;
28 POINTL BrushOrigin;
29 PPATH pPath;
30// int Left;
31// int Top;
32
33 ASSERT(dc); // Caller's responsibility to pass a valid dc
34
35 if (!Points || Count < 2 )
36 {
38 return FALSE;
39 }
40
41/*
42 // Find start x, y
43 Left = Points[0].x;
44 Top = Points[0].y;
45 for (CurrentPoint = 1; CurrentPoint < Count; ++CurrentPoint) {
46 Left = min(Left, Points[CurrentPoint].x);
47 Top = min(Top, Points[CurrentPoint].y);
48 }
49*/
50
51 pdcattr = dc->pdcattr;
52
53 /* Convert to screen coordinates */
54 IntLPtoDP(dc, Points, Count);
55 for (CurrentPoint = 0; CurrentPoint < Count; CurrentPoint++)
56 {
57 Points[CurrentPoint].x += dc->ptlDCOrig.x;
58 Points[CurrentPoint].y += dc->ptlDCOrig.y;
59 }
60 // No need to have path here.
61 {
62 DestRect.left = Points[0].x;
63 DestRect.right = Points[0].x;
64 DestRect.top = Points[0].y;
65 DestRect.bottom = Points[0].y;
66
67 for (CurrentPoint = 1; CurrentPoint < Count; ++CurrentPoint)
68 {
69 DestRect.left = min(DestRect.left, Points[CurrentPoint].x);
70 DestRect.right = max(DestRect.right, Points[CurrentPoint].x);
71 DestRect.top = min(DestRect.top, Points[CurrentPoint].y);
72 DestRect.bottom = max(DestRect.bottom, Points[CurrentPoint].y);
73 }
74
75 if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
77
78 if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
80
81 /* Special locking order to avoid lock-ups */
82 pbrFill = dc->dclevel.pbrFill;
83 pbrLine = dc->dclevel.pbrLine;
84 psurf = dc->dclevel.pSurface;
85 if (psurf == NULL)
86 {
87 /* Memory DC without a bitmap selected, nothing to do. */
88 return TRUE;
89 }
90
91 /* Now fill the polygon with the current fill brush. */
92 if (!(pbrFill->flAttrs & BR_IS_NULL))
93 {
94 BrushOrigin = *((PPOINTL)&pbrFill->ptOrigin);
95 BrushOrigin.x += dc->ptlDCOrig.x;
96 BrushOrigin.y += dc->ptlDCOrig.y;
98 psurf,
99 &dc->eboFill.BrushObject,
100 Points,
101 Count,
102 DestRect,
103 &BrushOrigin);
104 }
105
106 // Draw the Polygon Edges with the current pen ( if not a NULL pen )
107 if (!(pbrLine->flAttrs & BR_IS_NULL))
108 {
109 if (IntIsEffectiveWidePen(pbrLine))
110 {
111 /* Clear the path */
112 PATH_Delete(dc->dclevel.hPath);
113 dc->dclevel.hPath = NULL;
114
115 /* Begin a path */
116 pPath = PATH_CreatePath(Count + 1);
117 dc->dclevel.flPath |= DCPATH_ACTIVE;
118 dc->dclevel.hPath = pPath->BaseObject.hHmgr;
119 pPath->pos = Points[0];
120 IntLPtoDP(dc, &pPath->pos, 1);
121
122 PATH_MoveTo(dc, pPath);
123 for (i = 1; i < Count; ++i)
124 {
125 PATH_LineTo(dc, Points[i].x, Points[i].y);
126 }
127 PATH_LineTo(dc, Points[0].x, Points[0].y);
128
129 /* Close the path */
130 pPath->state = PATH_Closed;
131 dc->dclevel.flPath &= ~DCPATH_ACTIVE;
132
133 /* Actually stroke a path */
134 ret = PATH_StrokePath(dc, pPath);
135
136 /* Clear the path */
137 PATH_UnlockPath(pPath);
138 PATH_Delete(dc->dclevel.hPath);
139 dc->dclevel.hPath = NULL;
140 }
141 else
142 {
143 for (i = 0; i < Count-1; i++)
144 {
145// DPRINT1("Polygon Making line from (%d,%d) to (%d,%d)\n",
146// Points[0].x, Points[0].y,
147// Points[1].x, Points[1].y );
148
149 ret = IntEngLineTo(&psurf->SurfObj,
150 (CLIPOBJ *)&dc->co,
151 &dc->eboLine.BrushObject,
152 Points[i].x, /* From */
153 Points[i].y,
154 Points[i+1].x, /* To */
155 Points[i+1].y,
156 &DestRect,
157 ROP2_TO_MIX(pdcattr->jROP2)); /* MIX */
158 if (!ret) break;
159 }
160 /* Close the polygon */
161 if (ret)
162 {
163 ret = IntEngLineTo(&psurf->SurfObj,
164 (CLIPOBJ *)&dc->co,
165 &dc->eboLine.BrushObject,
166 Points[Count-1].x, /* From */
167 Points[Count-1].y,
168 Points[0].x, /* To */
169 Points[0].y,
170 &DestRect,
171 ROP2_TO_MIX(pdcattr->jROP2)); /* MIX */
172 }
173 }
174 }
175 }
176
177 return ret;
178}
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
HDC dc
Definition: cylfrac.c:34
VOID FASTCALL DC_vUpdateLineBrush(PDC pdc)
Definition: dcobjs.c:62
VOID FASTCALL DC_vUpdateFillBrush(PDC pdc)
Definition: dcobjs.c:16
return ret
Definition: mutex.c:146
#define BR_IS_NULL
Definition: brush.h:105
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define ROP2_TO_MIX(Rop2)
Definition: inteng.h:40
#define ASSERT(a)
Definition: mode.c:44
int Count
Definition: noreturn.cpp:7
#define DIRTY_FILL
Definition: ntgdihdl.h:123
#define DC_PEN_DIRTY
Definition: ntgdihdl.h:136
#define DIRTY_LINE
Definition: ntgdihdl.h:124
#define DC_BRUSH_DIRTY
Definition: ntgdihdl.h:135
BOOL FASTCALL IntFillPolygon(PDC dc, SURFACE *psurf, BRUSHOBJ *BrushObj, CONST PPOINT Points, int Count, RECTL DestRect, POINTL *BrushOrigin)
Definition: polyfill.c:590
#define PATH_UnlockPath(pPath)
Definition: path.h:71
@ PATH_Closed
Definition: path.h:20
@ DCPATH_ACTIVE
Definition: path.h:6
#define IntIsEffectiveWidePen(pbrLine)
Definition: pen.h:33
void IntEngLineTo(SURFOBJ *, CLIPOBJ, PBRUSHOBJ, int x1, int y1, int x2, int y2, RECTL *, MIX mix)
Definition: polytest.cpp:107
Definition: types.h:101
ULONG ulDirty_
Definition: ntgdihdl.h:294
BYTE jROP2
Definition: ntgdihdl.h:307
Definition: path.h:35
POINT pos
Definition: path.h:58
BASEOBJECT BaseObject
Definition: path.h:36
FLONG state
Definition: path.h:52
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int32_t INT
Definition: typedefs.h:58
BOOL FASTCALL PATH_Delete(HPATH hPath)
Definition: path.c:90
BOOL FASTCALL PATH_LineTo(PDC dc, INT x, INT y)
Definition: path.c:583
BOOL FASTCALL PATH_StrokePath(DC *dc, PPATH pPath)
Definition: path.c:1597
PPATH FASTCALL PATH_CreatePath(int count)
Definition: path.c:35
BOOL FASTCALL PATH_MoveTo(PDC dc, PPATH pPath)
Definition: path.c:554
struct _POINTL * PPOINTL

Referenced by IntGdiPolyPolygon(), and IntPolygon().

◆ IntGdiPolyPolygon()

BOOL FASTCALL IntGdiPolyPolygon ( DC dc,
LPPOINT  Points,
PULONG  PolyCounts,
int  Count 
)

Definition at line 181 of file fillshap.c.

185{
186 if (PATH_IsPathOpen(dc->dclevel))
187 return PATH_PolyPolygon ( dc, Points, (PINT)PolyCounts, Count);
188
189 while (--Count >=0)
190 {
191 if (!IntGdiPolygon ( dc, Points, *PolyCounts ))
192 return FALSE;
193 Points+=*PolyCounts++;
194 }
195 return TRUE;
196}
BOOL FASTCALL IntGdiPolygon(PDC dc, PPOINT Points, int Count)
Definition: fillshap.c:18
int * PINT
Definition: minwindef.h:150
#define PATH_IsPathOpen(dclevel)
Definition: path.h:72
BOOL FASTCALL PATH_PolyPolygon(PDC dc, const POINT *pts, const INT *counts, UINT polygons)
Definition: path.c:1288

Referenced by NtGdiPolyPolyDraw(), and NtGdiRectangle().

◆ IntPolygon()

BOOL FASTCALL IntPolygon ( HDC  hdc,
POINT Point,
int  Count 
)

Definition at line 199 of file fillshap.c.

200{
201 BOOL bResult;
202 PDC pdc;
203
204 pdc = DC_LockDc(hdc);
205 if (pdc == NULL)
206 {
208 return FALSE;
209 }
210
211 bResult = IntGdiPolygon(pdc, Point, Count);
212
213 DC_UnlockDc(pdc);
214 return bResult;
215}

Referenced by IntDrawDiagEdge().

◆ IntRectangle()

BOOL FASTCALL IntRectangle ( PDC  dc,
int  LeftRect,
int  TopRect,
int  RightRect,
int  BottomRect 
)

Definition at line 565 of file fillshap.c.

570{
571 SURFACE *psurf = NULL;
572 PBRUSH pbrLine, pbrFill;
573 BOOL ret = FALSE; // Default to failure
574 RECTL DestRect;
575 MIX Mix;
576 PDC_ATTR pdcattr;
577 POINTL BrushOrigin;
578 PPATH pPath;
579
580 ASSERT ( dc ); // Caller's responsibility to set this up
581
582 pdcattr = dc->pdcattr;
583
584 // Rectangle Path only.
585 if ( PATH_IsPathOpen(dc->dclevel) )
586 {
587 return PATH_Rectangle ( dc, LeftRect, TopRect, RightRect, BottomRect );
588 }
589
590 /* Make sure rectangle is not inverted */
591 DestRect.left = min(LeftRect, RightRect);
592 DestRect.right = max(LeftRect, RightRect);
593 DestRect.top = min(TopRect, BottomRect);
594 DestRect.bottom = max(TopRect, BottomRect);
595
596 IntLPtoDP(dc, (LPPOINT)&DestRect, 2);
597
598 DestRect.left += dc->ptlDCOrig.x;
599 DestRect.right += dc->ptlDCOrig.x;
600 DestRect.top += dc->ptlDCOrig.y;
601 DestRect.bottom += dc->ptlDCOrig.y;
602
603 if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
604 {
605 IntUpdateBoundsRect(dc, &DestRect);
606 }
607
608 /* In GM_COMPATIBLE, don't include bottom and right edges */
609 if (pdcattr->iGraphicsMode == GM_COMPATIBLE)
610 {
611 DestRect.right--;
612 DestRect.bottom--;
613 }
614
615 DC_vPrepareDCsForBlit(dc, &DestRect, NULL, NULL);
616
617 if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
619
620 if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
622
623 pbrFill = dc->dclevel.pbrFill;
624 pbrLine = dc->dclevel.pbrLine;
625 if (!pbrLine)
626 {
627 ret = FALSE;
628 goto cleanup;
629 }
630
631 psurf = dc->dclevel.pSurface;
632 if (!psurf)
633 {
634 ret = TRUE;
635 goto cleanup;
636 }
637
638 if (pbrFill)
639 {
640 if (!(pbrFill->flAttrs & BR_IS_NULL))
641 {
642 BrushOrigin = *((PPOINTL)&pbrFill->ptOrigin);
643 BrushOrigin.x += dc->ptlDCOrig.x;
644 BrushOrigin.y += dc->ptlDCOrig.y;
645 ret = IntEngBitBlt(&psurf->SurfObj,
646 NULL,
647 NULL,
648 (CLIPOBJ *)&dc->co,
649 NULL,
650 &DestRect,
651 NULL,
652 NULL,
653 &dc->eboFill.BrushObject,
654 &BrushOrigin,
656 }
657 }
658
659 // Draw the rectangle with the current pen
660
661 ret = TRUE; // Change default to success
662
663 if (!(pbrLine->flAttrs & BR_IS_NULL))
664 {
665 if (IntIsEffectiveWidePen(pbrLine))
666 {
667 /* Clear the path */
668 PATH_Delete(dc->dclevel.hPath);
669 dc->dclevel.hPath = NULL;
670
671 /* Begin a path */
672 pPath = PATH_CreatePath(5);
673 dc->dclevel.flPath |= DCPATH_ACTIVE;
674 dc->dclevel.hPath = pPath->BaseObject.hHmgr;
675 pPath->pos.x = LeftRect;
676 pPath->pos.y = TopRect;
677 IntLPtoDP(dc, &pPath->pos, 1);
678
679 PATH_MoveTo(dc, pPath);
680 PATH_LineTo(dc, RightRect, TopRect);
681 PATH_LineTo(dc, RightRect, BottomRect);
682 PATH_LineTo(dc, LeftRect, BottomRect);
683 PATH_LineTo(dc, LeftRect, TopRect);
684
685 /* Close the path */
686 pPath->state = PATH_Closed;
687 dc->dclevel.flPath &= ~DCPATH_ACTIVE;
688
689 /* Actually stroke a path */
690 ret = PATH_StrokePath(dc, pPath);
691
692 /* Clear the path */
693 PATH_UnlockPath(pPath);
694 PATH_Delete(dc->dclevel.hPath);
695 dc->dclevel.hPath = NULL;
696 }
697 else
698 {
699 Mix = ROP2_TO_MIX(pdcattr->jROP2);
700 ret = ret && IntEngLineTo(&psurf->SurfObj,
701 (CLIPOBJ *)&dc->co,
702 &dc->eboLine.BrushObject,
703 DestRect.left, DestRect.top, DestRect.right, DestRect.top,
704 &DestRect, // Bounding rectangle
705 Mix);
706
707 ret = ret && IntEngLineTo(&psurf->SurfObj,
708 (CLIPOBJ *)&dc->co,
709 &dc->eboLine.BrushObject,
710 DestRect.right, DestRect.top, DestRect.right, DestRect.bottom,
711 &DestRect, // Bounding rectangle
712 Mix);
713
714 ret = ret && IntEngLineTo(&psurf->SurfObj,
715 (CLIPOBJ *)&dc->co,
716 &dc->eboLine.BrushObject,
717 DestRect.right, DestRect.bottom, DestRect.left, DestRect.bottom,
718 &DestRect, // Bounding rectangle
719 Mix);
720
721 ret = ret && IntEngLineTo(&psurf->SurfObj,
722 (CLIPOBJ *)&dc->co,
723 &dc->eboLine.BrushObject,
724 DestRect.left, DestRect.bottom, DestRect.left, DestRect.top,
725 &DestRect, // Bounding rectangle
726 Mix);
727 }
728 }
729
730cleanup:
732
733 /* Move current position in DC?
734 MSDN: The current position is neither used nor updated by Rectangle. */
735
736 return ret;
737}
static void cleanup(void)
Definition: main.c:1335
#define ROP4_FROM_INDEX(index)
Definition: inteng.h:42
@ R3_OPINDEX_PATCOPY
Definition: inteng.h:35
INT iGraphicsMode
Definition: ntgdihdl.h:306
BOOL APIENTRY IntEngBitBlt(SURFOBJ *psoTrg, SURFOBJ *psoSrc, SURFOBJ *psoMask, CLIPOBJ *pco, XLATEOBJ *pxlo, RECTL *prclTrg, POINTL *pptlSrc, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush, ROP4 Rop4)
Definition: bitblt.c:656
BOOL FASTCALL PATH_Rectangle(PDC dc, INT x1, INT y1, INT x2, INT y2)
Definition: path.c:627
ULONG MIX
Definition: winddi.h:129
#define GM_COMPATIBLE
Definition: wingdi.h:864

Referenced by NtGdiRectangle().

◆ IntRoundRect()

BOOL FASTCALL IntRoundRect ( PDC  dc,
int  Left,
int  Top,
int  Right,
int  Bottom,
int  xCurveDiameter,
int  yCurveDiameter 
)

Definition at line 783 of file fillshap.c.

791{
792 PDC_ATTR pdcattr;
793 PBRUSH pbrLine, pbrFill;
794 RECTL RectBounds;
795 LONG PenWidth, PenOrigWidth;
796 BOOL ret = TRUE; // Default to success
797 BRUSH brushTemp;
798
799 ASSERT ( dc ); // Caller's responsibility to set this up
800
801 if ( PATH_IsPathOpen(dc->dclevel) )
802 return PATH_RoundRect ( dc, Left, Top, Right, Bottom,
803 xCurveDiameter, yCurveDiameter );
804
805 if ((Left == Right) || (Top == Bottom)) return TRUE;
806
807 xCurveDiameter = max(abs( xCurveDiameter ), 1);
808 yCurveDiameter = max(abs( yCurveDiameter ), 1);
809
810 if (Right < Left)
811 {
812 INT tmp = Right; Right = Left; Left = tmp;
813 }
814 if (Bottom < Top)
815 {
816 INT tmp = Bottom; Bottom = Top; Top = tmp;
817 }
818
819 pdcattr = dc->pdcattr;
820
821 if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
823
824 if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
826
827 pbrLine = PEN_ShareLockPen(pdcattr->hpen);
828 if (!pbrLine)
829 {
830 /* Nothing to do, as we don't have a bitmap */
832 return FALSE;
833 }
834
835 PenOrigWidth = PenWidth = pbrLine->lWidth;
836 if (pbrLine->ulPenStyle == PS_NULL) PenWidth = 0;
837
838 if (pbrLine->ulPenStyle == PS_INSIDEFRAME)
839 {
840 if (2*PenWidth > (Right - Left)) PenWidth = (Right -Left + 1)/2;
841 if (2*PenWidth > (Bottom - Top)) PenWidth = (Bottom -Top + 1)/2;
842 Left += PenWidth / 2;
843 Right -= (PenWidth - 1) / 2;
844 Top += PenWidth / 2;
845 Bottom -= (PenWidth - 1) / 2;
846 }
847
848 if (!PenWidth) PenWidth = 1;
849 pbrLine->lWidth = PenWidth;
850
851 RectBounds.left = Left;
852 RectBounds.top = Top;
853 RectBounds.right = Right;
854 RectBounds.bottom = Bottom;
855
856 IntLPtoDP(dc, (LPPOINT)&RectBounds, 2);
857
858 RectBounds.left += dc->ptlDCOrig.x;
859 RectBounds.top += dc->ptlDCOrig.y;
860 RectBounds.right += dc->ptlDCOrig.x;
861 RectBounds.bottom += dc->ptlDCOrig.y;
862
863 pbrFill = BRUSH_ShareLockBrush(pdcattr->hbrush);
864 if (!pbrFill)
865 {
866 DPRINT1("FillRound Fail\n");
868 ret = FALSE;
869 }
870 else
871 {
872
873 DC_vPrepareDCsForBlit(dc, &RectBounds, NULL, NULL);
874
875 RtlCopyMemory(&brushTemp, pbrFill, sizeof(brushTemp));
876 brushTemp.ptOrigin.x += RectBounds.left - Left;
877 brushTemp.ptOrigin.y += RectBounds.top - Top;
879 RectBounds.left,
880 RectBounds.top,
881 RectBounds.right,
882 RectBounds.bottom,
883 xCurveDiameter,
884 yCurveDiameter,
885 &brushTemp);
886 BRUSH_ShareUnlockBrush(pbrFill);
887
888 if (ret)
889 {
891 RectBounds.left,
892 RectBounds.top,
893 RectBounds.right,
894 RectBounds.bottom,
895 xCurveDiameter,
896 yCurveDiameter,
897 pbrLine);
898 }
899
901 }
902
903
904 pbrLine->lWidth = PenOrigWidth;
905 PEN_ShareUnlockPen(pbrLine);
906 return ret;
907}
#define DPRINT1
Definition: precomp.h:8
static LPHIST_ENTRY Bottom
Definition: history.c:54
static LPHIST_ENTRY Top
Definition: history.c:53
Definition: brush.hpp:16
BOOL FASTCALL IntDrawRoundRect(PDC dc, INT Left, INT Top, INT Right, INT Bottom, INT Wellipse, INT Hellipse, PBRUSH pbrushPen)
Definition: drawing.c:1454
BOOL FASTCALL IntFillRoundRect(PDC dc, INT Left, INT Top, INT Right, INT Bottom, INT Wellipse, INT Hellipse, PBRUSH pbrush)
Definition: drawing.c:1388
#define abs(i)
Definition: fconv.c:206
#define BRUSH_ShareLockBrush(hBrush)
Definition: brush.h:117
#define BRUSH_ShareUnlockBrush(pBrush)
Definition: brush.h:118
long LONG
Definition: pedump.c:60
#define PEN_ShareUnlockPen(ppen)
Definition: pen.h:18
POINT ptOrigin
Definition: brush.h:24
HANDLE hbrush
Definition: ntgdihdl.h:295
HANDLE hpen
Definition: ntgdihdl.h:296
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
BOOL PATH_RoundRect(DC *dc, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height)
Definition: path.c:675
PBRUSH FASTCALL PEN_ShareLockPen(HPEN hobj)
Definition: pen.c:61
#define ERROR_INTERNAL_ERROR
Definition: winerror.h:1185
#define PS_NULL
Definition: wingdi.h:591
#define PS_INSIDEFRAME
Definition: wingdi.h:593

Referenced by NtGdiRoundRect().

◆ NtGdiEllipse()

BOOL APIENTRY NtGdiEllipse ( HDC  hDC,
int  Left,
int  Top,
int  Right,
int  Bottom 
)

Definition at line 233 of file fillshap.c.

239{
240 PDC dc;
241 PDC_ATTR pdcattr;
242 RECTL RectBounds;
243 PBRUSH pbrush;
244 BOOL ret = TRUE;
245 LONG PenWidth, PenOrigWidth;
246 LONG RadiusX, RadiusY, CenterX, CenterY;
247 PBRUSH pFillBrushObj;
248 BRUSH tmpFillBrushObj;
249
250 dc = DC_LockDc(hDC);
251 if (dc == NULL)
252 {
254 return FALSE;
255 }
256
257 if (PATH_IsPathOpen(dc->dclevel))
258 {
259 ret = PATH_Ellipse(dc, Left, Top, Right, Bottom);
261 return ret;
262 }
263
267 if ((Left == Right) || (Top == Bottom))
268 {
270 return TRUE;
271 }
272
273 if (Right < Left)
274 {
275 INT tmp = Right; Right = Left; Left = tmp;
276 }
277 if (Bottom < Top)
278 {
279 INT tmp = Bottom; Bottom = Top; Top = tmp;
280 }
282
283 pdcattr = dc->pdcattr;
284
285 if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
287
288 if (pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
290
291 pbrush = PEN_ShareLockPen(pdcattr->hpen);
292 if (!pbrush)
293 {
294 DPRINT1("Ellipse Fail 1\n");
297 return FALSE;
298 }
299
300 PenOrigWidth = PenWidth = pbrush->lWidth;
301 if (pbrush->ulPenStyle == PS_NULL) PenWidth = 0;
302
303 if (pbrush->ulPenStyle == PS_INSIDEFRAME)
304 {
305 if (2*PenWidth > (Right - Left)) PenWidth = (Right -Left + 1)/2;
306 if (2*PenWidth > (Bottom - Top)) PenWidth = (Bottom -Top + 1)/2;
307 Left += PenWidth / 2;
308 Right -= (PenWidth - 1) / 2;
309 Top += PenWidth / 2;
310 Bottom -= (PenWidth - 1) / 2;
311 }
312
313 if (!PenWidth) PenWidth = 1;
314 pbrush->lWidth = PenWidth;
315
316 RectBounds.left = Left;
317 RectBounds.right = Right;
318 RectBounds.top = Top;
319 RectBounds.bottom = Bottom;
320
321 IntLPtoDP(dc, (LPPOINT)&RectBounds, 2);
322
323 RectBounds.left += dc->ptlDCOrig.x;
324 RectBounds.right += dc->ptlDCOrig.x;
325 RectBounds.top += dc->ptlDCOrig.y;
326 RectBounds.bottom += dc->ptlDCOrig.y;
327
328 // Setup for dynamic width and height.
329 RadiusX = max((RectBounds.right - RectBounds.left) / 2, 2); // Needs room
330 RadiusY = max((RectBounds.bottom - RectBounds.top) / 2, 2);
331 CenterX = (RectBounds.right + RectBounds.left) / 2;
332 CenterY = (RectBounds.bottom + RectBounds.top) / 2;
333
334 DPRINT("Ellipse 1: Left: %d, Top: %d, Right: %d, Bottom: %d\n",
335 RectBounds.left,RectBounds.top,RectBounds.right,RectBounds.bottom);
336
337 DPRINT("Ellipse 2: XLeft: %d, YLeft: %d, Width: %d, Height: %d\n",
338 CenterX - RadiusX, CenterY + RadiusY, RadiusX*2, RadiusY*2);
339
340 pFillBrushObj = BRUSH_ShareLockBrush(pdcattr->hbrush);
341 if (NULL == pFillBrushObj)
342 {
343 DPRINT1("FillEllipse Fail\n");
345 ret = FALSE;
346 }
347 else
348 {
349 RtlCopyMemory(&tmpFillBrushObj, pFillBrushObj, sizeof(tmpFillBrushObj));
350 //tmpFillBrushObj.ptOrigin.x += RectBounds.left - Left;
351 //tmpFillBrushObj.ptOrigin.y += RectBounds.top - Top;
352 tmpFillBrushObj.ptOrigin.x += dc->ptlDCOrig.x;
353 tmpFillBrushObj.ptOrigin.y += dc->ptlDCOrig.y;
354
355 DC_vPrepareDCsForBlit(dc, &RectBounds, NULL, NULL);
356
358 CenterX - RadiusX,
359 CenterY - RadiusY,
360 RadiusX*2, // Width
361 RadiusY*2, // Height
362 &tmpFillBrushObj);
363 BRUSH_ShareUnlockBrush(pFillBrushObj);
364
365 if (ret)
366 {
368 CenterX - RadiusX,
369 CenterY - RadiusY,
370 RadiusX*2, // Width
371 RadiusY*2, // Height
372 pbrush);
373 }
374
376 }
377
378 pbrush->lWidth = PenOrigWidth;
379 PEN_ShareUnlockPen(pbrush);
381 DPRINT("Ellipse Exit.\n");
382 return ret;
383}
static HDC hDC
Definition: 3dtext.c:33
BOOL FASTCALL IntFillEllipse(PDC dc, INT XLeft, INT YLeft, INT Width, INT Height, PBRUSH pbrush)
Definition: drawing.c:1376
BOOL FASTCALL IntDrawEllipse(PDC dc, INT XLeft, INT YLeft, INT Width, INT Height, PBRUSH pbrush)
Definition: drawing.c:1364
#define DPRINT
Definition: sndvol32.h:73
BOOL PATH_Ellipse(PDC dc, INT x1, INT y1, INT x2, INT y2)
Definition: path.c:782

◆ NtGdiExtFloodFill()

BOOL APIENTRY NtGdiExtFloodFill ( HDC  hDC,
INT  XStart,
INT  YStart,
COLORREF  Color,
UINT  FillType 
)

Definition at line 1148 of file fillshap.c.

1154{
1155 PDC dc;
1156#if 0
1157 PDC_ATTR pdcattr;
1158#endif
1159 SURFACE *psurf;
1160 EXLATEOBJ exlo;
1161 BOOL Ret = FALSE;
1162 RECTL DestRect;
1163 POINTL Pt;
1164 ULONG ConvColor;
1165 PREGION prgn;
1166
1167 dc = DC_LockDc(hDC);
1168 if (!dc)
1169 {
1171 return FALSE;
1172 }
1173
1174 if (!dc->dclevel.pSurface)
1175 {
1176 Ret = TRUE;
1177 goto cleanup;
1178 }
1179
1180#if 0
1181 pdcattr = dc->pdcattr;
1182#endif
1183
1184 Pt.x = XStart;
1185 Pt.y = YStart;
1186 IntLPtoDP(dc, (LPPOINT)&Pt, 1);
1187
1188 DC_vPrepareDCsForBlit(dc, &DestRect, NULL, NULL);
1189
1190 psurf = dc->dclevel.pSurface;
1191
1192 prgn = dc->prgnRao ? dc->prgnRao : dc->prgnVis;
1193 if (prgn)
1194 {
1195 Ret = REGION_PtInRegion(prgn, Pt.x, Pt.y);
1196 if (Ret)
1197 REGION_GetRgnBox(prgn, (LPRECT)&DestRect);
1198 else
1199 {
1201 goto cleanup;
1202 }
1203 }
1204 else
1205 {
1206 RECTL_vSetRect(&DestRect, 0, 0, psurf->SurfObj.sizlBitmap.cx, psurf->SurfObj.sizlBitmap.cy);
1207 }
1208
1209 if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
1210 {
1211 IntUpdateBoundsRect(dc, &DestRect);
1212 }
1213
1214 EXLATEOBJ_vInitialize(&exlo, &gpalRGB, psurf->ppal, 0, 0xffffff, 0);
1215
1216 /* Only solid fills supported for now
1217 * How to support pattern brushes and non standard surfaces (not offering dib functions):
1218 * Version a (most likely slow): call DrvPatBlt for every pixel
1219 * Version b: create a flood mask and let MaskBlt blit a masked brush */
1220 ConvColor = XLATEOBJ_iXlate(&exlo.xlo, Color);
1221 Ret = DIB_XXBPP_FloodFillSolid(&psurf->SurfObj, &dc->eboFill.BrushObject, &DestRect, &Pt, ConvColor, FillType);
1222
1224
1225 EXLATEOBJ_vCleanup(&exlo);
1226
1227cleanup:
1228 DC_UnlockDc(dc);
1229 return Ret;
1230}
Definition: region.h:8
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
SIZEL sizlBitmap
Definition: winddi.h:1209
BOOLEAN DIB_XXBPP_FloodFillSolid(SURFOBJ *, BRUSHOBJ *, RECTL *, POINTL *, ULONG, UINT)
Definition: floodfill.c:86
FORCEINLINE VOID RECTL_vSetRect(_Out_ RECTL *prcl, _In_ LONG left, _In_ LONG top, _In_ LONG right, _In_ LONG bottom)
Definition: rect.h:5
BOOL FASTCALL REGION_PtInRegion(PREGION prgn, INT X, INT Y)
Definition: region.c:2582
INT FASTCALL REGION_GetRgnBox(PREGION Rgn, PRECTL pRect)
Definition: region.c:2543
ENGAPI ULONG APIENTRY XLATEOBJ_iXlate(_In_ XLATEOBJ *pxlo, _In_ ULONG iColor)
Definition: xlateobj.c:909

◆ NtGdiGradientFill()

BOOL APIENTRY NtGdiGradientFill ( HDC  hdc,
PTRIVERTEX  pVertex,
ULONG  nVertex,
PVOID  pMesh,
ULONG  nMesh,
ULONG  ulMode 
)

Definition at line 1072 of file fillshap.c.

1079{
1080 BOOL bRet;
1081 PTRIVERTEX SafeVertex;
1082 PVOID SafeMesh;
1083 ULONG cbVertex, cbMesh;
1084
1085 /* Validate parameters */
1086 if (!pVertex || !nVertex || !pMesh || !nMesh)
1087 {
1089 return FALSE;
1090 }
1091
1092 switch (ulMode)
1093 {
1094 case GRADIENT_FILL_RECT_H:
1095 case GRADIENT_FILL_RECT_V:
1096 cbMesh = nMesh * sizeof(GRADIENT_RECT);
1097 break;
1098 case GRADIENT_FILL_TRIANGLE:
1099 cbMesh = nMesh * sizeof(GRADIENT_TRIANGLE);
1100 break;
1101 default:
1103 return FALSE;
1104 }
1105
1106 cbVertex = nVertex * sizeof(TRIVERTEX) ;
1107 if(cbVertex + cbMesh <= cbVertex)
1108 {
1109 /* Overflow */
1110 return FALSE ;
1111 }
1112
1113 /* Allocate a kernel mode buffer */
1114 SafeVertex = ExAllocatePoolWithTag(PagedPool, cbVertex + cbMesh, TAG_SHAPE);
1115 if(!SafeVertex)
1116 {
1118 return FALSE;
1119 }
1120
1121 SafeMesh = (PVOID)((ULONG_PTR)SafeVertex + cbVertex);
1122
1123 /* Copy the parameters to kernel mode */
1124 _SEH2_TRY
1125 {
1126 ProbeForRead(pVertex, cbVertex, 1);
1127 ProbeForRead(pMesh, cbMesh, 1);
1128 RtlCopyMemory(SafeVertex, pVertex, cbVertex);
1129 RtlCopyMemory(SafeMesh, pMesh, cbMesh);
1130 }
1132 {
1133 ExFreePoolWithTag(SafeVertex, TAG_SHAPE);
1135 _SEH2_YIELD(return FALSE;)
1136 }
1137 _SEH2_END;
1138
1139 /* Call the internal function */
1140 bRet = GreGradientFill(hdc, SafeVertex, nVertex, SafeMesh, nMesh, ulMode);
1141
1142 /* Cleanup and return result */
1143 ExFreePoolWithTag(SafeVertex, TAG_SHAPE);
1144 return bRet;
1145}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
BOOL NTAPI GreGradientFill(HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nMesh, ULONG ulMode)
Definition: fillshap.c:940
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
#define TAG_SHAPE
Definition: tags.h:14
struct _GRADIENT_TRIANGLE GRADIENT_TRIANGLE
struct _TRIVERTEX TRIVERTEX
struct _GRADIENT_RECT GRADIENT_RECT

◆ NtGdiPolyPolyDraw()

ULONG_PTR APIENTRY NtGdiPolyPolyDraw ( IN HDC  hDC,
IN PPOINT  UnsafePoints,
IN PULONG  UnsafeCounts,
IN ULONG  Count,
IN INT  iFunc 
)

Definition at line 409 of file fillshap.c.

414{
415 DC *dc;
416 PVOID pTemp;
417 LPPOINT SafePoints;
418 PULONG SafeCounts;
420 BOOL Ret = TRUE;
421 ULONG nPoints = 0, nMaxPoints = 0, nInvalid = 0, i;
422
423 if (!UnsafePoints || !UnsafeCounts ||
424 Count == 0 || iFunc == 0 || iFunc > GdiPolyPolyRgn)
425 {
426 /* Windows doesn't set last error */
427 return FALSE;
428 }
429
431 {
432 ProbeForRead(UnsafePoints, Count * sizeof(POINT), 1);
433 ProbeForRead(UnsafeCounts, Count * sizeof(ULONG), 1);
434
435 /* Count points and validate poligons */
436 for (i = 0; i < Count; i++)
437 {
438 if (UnsafeCounts[i] < 2)
439 {
440 nInvalid++;
441 }
442 nPoints += UnsafeCounts[i];
443 nMaxPoints = max(nMaxPoints, UnsafeCounts[i]);
444 }
445 }
447 {
449 }
450 _SEH2_END;
451
452 if (!NT_SUCCESS(Status))
453 {
454 /* Windows doesn't set last error */
455 return FALSE;
456 }
457
458 if (nPoints == 0 || nPoints < nMaxPoints)
459 {
460 /* If all polygon counts are zero, or we have overflow,
461 return without setting a last error code. */
462 return FALSE;
463 }
464
465 if (nInvalid != 0)
466 {
467 /* If at least one poly count is 0 or 1, fail */
469 return FALSE;
470 }
471
472 /* Allocate one buffer for both counts and points */
474 Count * sizeof(ULONG) + nPoints * sizeof(POINT),
475 TAG_SHAPE);
476 if (!pTemp)
477 {
479 return FALSE;
480 }
481
482 SafeCounts = pTemp;
483 SafePoints = (PVOID)(SafeCounts + Count);
484
486 {
487 /* Pointers already probed! */
488 RtlCopyMemory(SafeCounts, UnsafeCounts, Count * sizeof(ULONG));
489 RtlCopyMemory(SafePoints, UnsafePoints, nPoints * sizeof(POINT));
490 }
492 {
494 }
495 _SEH2_END;
496
497 if (!NT_SUCCESS(Status))
498 {
500 return FALSE;
501 }
502
503 /* Special handling for GdiPolyPolyRgn */
504 if (iFunc == GdiPolyPolyRgn)
505 {
507 HRGN hrgn;
508
509 hrgn = GreCreatePolyPolygonRgn(SafePoints, SafeCounts, Count, iMode);
510
512 return (ULONG_PTR)hrgn;
513 }
514
515 dc = DC_LockDc(hDC);
516 if (!dc)
517 {
520 return FALSE;
521 }
522
524
525 if (dc->pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
527
528 if (dc->pdcattr->ulDirty_ & (DIRTY_LINE | DC_PEN_DIRTY))
530
531 /* Perform the actual work */
532 switch (iFunc)
533 {
534 case GdiPolyPolygon:
535 Ret = IntGdiPolyPolygon(dc, SafePoints, SafeCounts, Count);
536 break;
537 case GdiPolyPolyLine:
538 Ret = IntGdiPolyPolyline(dc, SafePoints, SafeCounts, Count);
539 break;
540 case GdiPolyBezier:
541 Ret = IntGdiPolyBezier(dc, SafePoints, *SafeCounts);
542 break;
543 case GdiPolyLineTo:
544 Ret = IntGdiPolylineTo(dc, SafePoints, *SafeCounts);
545 break;
546 case GdiPolyBezierTo:
547 Ret = IntGdiPolyBezierTo(dc, SafePoints, *SafeCounts);
548 break;
549 default:
551 Ret = FALSE;
552 }
553
554 /* Cleanup and return */
558
559 return (ULONG_PTR)Ret;
560}
static HRGN hrgn
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
BOOL FASTCALL IntGdiPolyPolygon(DC *dc, LPPOINT Points, PULONG PolyCounts, int Count)
Definition: fillshap.c:181
Status
Definition: gdiplustypes.h:25
BOOL FASTCALL IntGdiPolyBezier(DC *dc, LPPOINT pt, DWORD Count)
Definition: line.c:262
BOOL FASTCALL IntGdiPolylineTo(DC *dc, LPPOINT pt, DWORD Count)
Definition: line.c:425
BOOL FASTCALL IntGdiPolyPolyline(DC *dc, LPPOINT pt, PULONG PolyPoints, DWORD Count)
Definition: line.c:464
BOOL FASTCALL IntGdiPolyBezierTo(DC *dc, LPPOINT pt, DWORD Count)
Definition: line.c:290
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
@ GdiPolyPolygon
Definition: ntgdityp.h:38
@ GdiPolyPolyLine
Definition: ntgdityp.h:39
@ GdiPolyBezierTo
Definition: ntgdityp.h:42
@ GdiPolyLineTo
Definition: ntgdityp.h:41
@ GdiPolyPolyRgn
Definition: ntgdityp.h:43
@ GdiPolyBezier
Definition: ntgdityp.h:40
#define INT
Definition: polytest.cpp:20
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t * PULONG
Definition: typedefs.h:59
HRGN NTAPI GreCreatePolyPolygonRgn(_In_ const POINT *ppt, _In_ const ULONG *pcPoints, _In_ ULONG cPolygons, _In_ INT iMode)
Definition: region.c:3452
_In_ ULONG iMode
Definition: winddi.h:3520

◆ NtGdiRectangle()

BOOL APIENTRY NtGdiRectangle ( HDC  hDC,
int  LeftRect,
int  TopRect,
int  RightRect,
int  BottomRect 
)

Definition at line 741 of file fillshap.c.

746{
747 DC *dc;
748 BOOL ret; // Default to failure
749
750 dc = DC_LockDc(hDC);
751 if (!dc)
752 {
754 return FALSE;
755 }
756
757 /* Do we rotate or shear? */
758 if (!(dc->pdcattr->mxWorldToDevice.flAccel & XFORM_SCALE))
759 {
760 POINTL DestCoords[4];
761 ULONG PolyCounts = 4;
762
763 DestCoords[0].x = DestCoords[3].x = LeftRect;
764 DestCoords[0].y = DestCoords[1].y = TopRect;
765 DestCoords[1].x = DestCoords[2].x = RightRect;
766 DestCoords[2].y = DestCoords[3].y = BottomRect;
767 // Use IntGdiPolyPolygon so to support PATH.
768 ret = IntGdiPolyPolygon(dc, DestCoords, &PolyCounts, 1);
769 }
770 else
771 {
772 ret = IntRectangle(dc, LeftRect, TopRect, RightRect, BottomRect );
773 }
774
776
777 return ret;
778}
BOOL FASTCALL IntRectangle(PDC dc, int LeftRect, int TopRect, int RightRect, int BottomRect)
Definition: fillshap.c:565
@ XFORM_SCALE
Definition: ntgdityp.h:106

◆ NtGdiRoundRect()

BOOL APIENTRY NtGdiRoundRect ( HDC  hDC,
int  LeftRect,
int  TopRect,
int  RightRect,
int  BottomRect,
int  Width,
int  Height 
)

Definition at line 911 of file fillshap.c.

919{
920 DC *dc = DC_LockDc(hDC);
921 BOOL ret = FALSE; /* Default to failure */
922
923 DPRINT("NtGdiRoundRect(0x%p,%i,%i,%i,%i,%i,%i)\n",hDC,LeftRect,TopRect,RightRect,BottomRect,Width,Height);
924 if ( !dc )
925 {
926 DPRINT1("NtGdiRoundRect() - hDC is invalid\n");
928 }
929 else
930 {
931 ret = IntRoundRect ( dc, LeftRect, TopRect, RightRect, BottomRect, Width, Height );
932 DC_UnlockDc ( dc );
933 }
934
935 return ret;
936}
BOOL FASTCALL IntRoundRect(PDC dc, int Left, int Top, int Right, int Bottom, int xCurveDiameter, int yCurveDiameter)
Definition: fillshap.c:783
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88