ReactOS 0.4.16-dev-338-g34e76ad
floodfill.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for floodfill.c:

Go to the source code of this file.

Classes

struct  _floodItem
 
struct  _floodInfo
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _floodItem FLOODITEM
 
typedef struct _floodInfo FLOODINFO
 

Functions

static __inline BOOL initFlood (FLOODINFO *info, RECTL *DstRect)
 
static __inline VOID finalizeFlood (FLOODINFO *info)
 
static __inline VOID addItemFlood (FLOODINFO *info, ULONG x, ULONG y, SURFOBJ *DstSurf, RECTL *DstRect, ULONG Color, BOOL isSurf)
 
static __inline VOID removeItemFlood (FLOODINFO *info)
 
BOOLEAN DIB_XXBPP_FloodFillSolid (SURFOBJ *DstSurf, BRUSHOBJ *Brush, RECTL *DstRect, POINTL *Origin, ULONG ConvColor, UINT FillType)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file floodfill.c.

Typedef Documentation

◆ FLOODINFO

◆ FLOODITEM

Function Documentation

◆ addItemFlood()

static __inline VOID addItemFlood ( FLOODINFO info,
ULONG  x,
ULONG  y,
SURFOBJ DstSurf,
RECTL DstRect,
ULONG  Color,
BOOL  isSurf 
)
static

Definition at line 54 of file floodfill.c.

61{
62 if (RECTL_bPointInRect(DstRect,x,y))
63 {
64 if (isSurf &&
66 {
67 return;
68 }
69 else if (isSurf == FALSE &&
71 {
72 return;
73 }
74 info->floodStart--;
75 info->floodStart->x = x;
76 info->floodStart->y = y;
77 info->floodLen++;
78 }
79}
#define FALSE
Definition: types.h:117
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
PFN_DIB_GetPixel DIB_GetPixel
Definition: dib.h:46
ULONG iBitmapFormat
Definition: winddi.h:1215
DIB_FUNCTIONS DibFunctionsForBitmapFormat[]
Definition: dib.c:20
FORCEINLINE BOOL RECTL_bPointInRect(_In_ const RECTL *prcl, _In_ INT x, _In_ INT y)
Definition: rect.h:52

Referenced by DIB_XXBPP_FloodFillSolid().

◆ DIB_XXBPP_FloodFillSolid()

BOOLEAN DIB_XXBPP_FloodFillSolid ( SURFOBJ DstSurf,
BRUSHOBJ Brush,
RECTL DstRect,
POINTL Origin,
ULONG  ConvColor,
UINT  FillType 
)

Definition at line 86 of file floodfill.c.

92{
93 ULONG x, y;
94 ULONG BrushColor;
95 FLOODINFO flood = {0, NULL, NULL};
96
97 BrushColor = Brush->iSolidColor;
98 x = Origin->x;
99 y = Origin->y;
100
101 if (FillType == FLOODFILLBORDER)
102 {
103 /* Check if the start pixel has the border color */
104 if (DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_GetPixel(DstSurf, x, y) == ConvColor)
105 {
106 return FALSE;
107 }
108
109 if (initFlood(&flood, DstRect) == FALSE)
110 {
111 return FALSE;
112 }
113 addItemFlood(&flood, x, y, DstSurf, DstRect, ConvColor, FALSE);
114 while (flood.floodLen != 0)
115 {
116 x = flood.floodStart->x;
117 y = flood.floodStart->y;
118 removeItemFlood(&flood);
119
120 DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_PutPixel(DstSurf, x, y, BrushColor);
121 if (flood.floodStart - 4 < flood.floodData)
122 {
123 DPRINT1("Can't finish flooding!\n");
124 finalizeFlood(&flood);
125 return FALSE;
126 }
127 addItemFlood(&flood, x, y + 1, DstSurf, DstRect, ConvColor, FALSE);
128 addItemFlood(&flood, x, y - 1, DstSurf, DstRect, ConvColor, FALSE);
129 addItemFlood(&flood, x + 1, y, DstSurf, DstRect, ConvColor, FALSE);
130 addItemFlood(&flood, x - 1, y, DstSurf, DstRect, ConvColor, FALSE);
131 }
132 finalizeFlood(&flood);
133 }
134 else if (FillType == FLOODFILLSURFACE)
135 {
136 /* Check if the start pixel has the surface color */
137 if (DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_GetPixel(DstSurf, x, y) != ConvColor)
138 {
139 return FALSE;
140 }
141
142 if (initFlood(&flood, DstRect) == FALSE)
143 {
144 return FALSE;
145 }
146 addItemFlood(&flood, x, y, DstSurf, DstRect, ConvColor, TRUE);
147 while (flood.floodLen != 0)
148 {
149 x = flood.floodStart->x;
150 y = flood.floodStart->y;
151 removeItemFlood(&flood);
152
153 DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_PutPixel(DstSurf, x, y, BrushColor);
154 if (flood.floodStart - 4 < flood.floodData)
155 {
156 DPRINT1("Can't finish flooding!\n");
157 finalizeFlood(&flood);
158 return FALSE;
159 }
160 addItemFlood(&flood, x, y + 1, DstSurf, DstRect, ConvColor, TRUE);
161 addItemFlood(&flood, x, y - 1, DstSurf, DstRect, ConvColor, TRUE);
162 addItemFlood(&flood, x + 1, y, DstSurf, DstRect, ConvColor, TRUE);
163 addItemFlood(&flood, x - 1, y, DstSurf, DstRect, ConvColor, TRUE);
164 }
165 finalizeFlood(&flood);
166 }
167 else
168 {
169 DPRINT1("Unsupported FloodFill type!\n");
170 return FALSE;
171 }
172 return TRUE;
173}
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
static __inline VOID removeItemFlood(FLOODINFO *info)
Definition: floodfill.c:80
static __inline VOID addItemFlood(FLOODINFO *info, ULONG x, ULONG y, SURFOBJ *DstSurf, RECTL *DstRect, ULONG Color, BOOL isSurf)
Definition: floodfill.c:54
static __inline VOID finalizeFlood(FLOODINFO *info)
Definition: floodfill.c:50
static __inline BOOL initFlood(FLOODINFO *info, RECTL *DstRect)
Definition: floodfill.c:37
PFN_DIB_PutPixel DIB_PutPixel
Definition: dib.h:45
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
FLOODITEM * floodData
Definition: floodfill.c:34
ULONG floodLen
Definition: floodfill.c:32
FLOODITEM * floodStart
Definition: floodfill.c:33
ULONG x
Definition: floodfill.c:26
ULONG y
Definition: floodfill.c:27
uint32_t ULONG
Definition: typedefs.h:59
#define FLOODFILLBORDER
Definition: wingdi.h:644
#define FLOODFILLSURFACE
Definition: wingdi.h:645

Referenced by NtGdiExtFloodFill().

◆ finalizeFlood()

static __inline VOID finalizeFlood ( FLOODINFO info)
static

Definition at line 50 of file floodfill.c.

51{
52 ExFreePoolWithTag(info->floodData, TAG_DIB);
53}
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define TAG_DIB
Definition: tags.h:17

Referenced by DIB_XXBPP_FloodFillSolid().

◆ initFlood()

static __inline BOOL initFlood ( FLOODINFO info,
RECTL DstRect 
)
static

Definition at line 37 of file floodfill.c.

38{
39 ULONG width = DstRect->right - DstRect->left;
40 ULONG height = DstRect->bottom - DstRect->top;
42 if (info->floodData == NULL)
43 {
44 return FALSE;
45 }
46 info->floodStart = info->floodData + (width * height);
47 DPRINT("Allocated flood stack from %p to %p\n", info->floodData, info->floodStart);
48 return TRUE;
49}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
#define DPRINT
Definition: sndvol32.h:73
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53

Referenced by DIB_XXBPP_FloodFillSolid().

◆ removeItemFlood()

static __inline VOID removeItemFlood ( FLOODINFO info)
static

Definition at line 80 of file floodfill.c.

81{
82 info->floodStart++;
83 info->floodLen--;
84}

Referenced by DIB_XXBPP_FloodFillSolid().