ReactOS 0.4.15-dev-8102-g108db8f
bezier.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for bezier.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define BEZIERSHIFTBITS   4
 
#define BEZIERSHIFTUP(x)   ((x)<<BEZIERSHIFTBITS)
 
#define BEZIERPIXEL   BEZIERSHIFTUP(1)
 
#define BEZIERSHIFTDOWN(x)   (((x)+(1<<(BEZIERSHIFTBITS-1)))>>BEZIERSHIFTBITS)
 
#define BEZIERMAXDEPTH   8
 
#define BEZIER_INITBUFSIZE   (150)
 
#define BEZIERMIDDLE(Mid, P1, P2)
 

Functions

static BOOL BezierCheck (int level, POINT *Points)
 
static void GDI_InternalBezier (POINT *Points, POINT **PtsOut, INT *dwOut, INT *nPtsOut, INT level)
 
POINTGDI_Bezier (const POINT *Points, INT count, INT *nPtsOut)
 

Macro Definition Documentation

◆ BEZIER_INITBUFSIZE

#define BEZIER_INITBUFSIZE   (150)

Definition at line 46 of file bezier.c.

◆ BEZIERMAXDEPTH

#define BEZIERMAXDEPTH   8

Definition at line 42 of file bezier.c.

◆ BEZIERMIDDLE

#define BEZIERMIDDLE (   Mid,
  P1,
  P2 
)
Value:
(Mid).x=((P1).x+(P2).x + 1)/2;\
(Mid).y=((P1).y+(P2).y + 1)/2;
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Definition at line 52 of file bezier.c.

◆ BEZIERPIXEL

#define BEZIERPIXEL   BEZIERSHIFTUP(1)

Definition at line 39 of file bezier.c.

◆ BEZIERSHIFTBITS

#define BEZIERSHIFTBITS   4

Definition at line 37 of file bezier.c.

◆ BEZIERSHIFTDOWN

#define BEZIERSHIFTDOWN (   x)    (((x)+(1<<(BEZIERSHIFTBITS-1)))>>BEZIERSHIFTBITS)

Definition at line 40 of file bezier.c.

◆ BEZIERSHIFTUP

#define BEZIERSHIFTUP (   x)    ((x)<<BEZIERSHIFTBITS)

Definition at line 38 of file bezier.c.

◆ NDEBUG

#define NDEBUG

Definition at line 8 of file bezier.c.

Function Documentation

◆ BezierCheck()

static BOOL BezierCheck ( int  level,
POINT Points 
)
static

Definition at line 64 of file bezier.c.

65{
66 INT dx, dy;
67 dx=Points[3].x-Points[0].x;
68 dy=Points[3].y-Points[0].y;
69 if(abs(dy)<=abs(dx)){/* shallow line */
70 /* check that control points are between begin and end */
71 if(Points[1].x < Points[0].x){
72 if(Points[1].x < Points[3].x)
73 return FALSE;
74 }else
75 if(Points[1].x > Points[3].x)
76 return FALSE;
77 if(Points[2].x < Points[0].x){
78 if(Points[2].x < Points[3].x)
79 return FALSE;
80 }else
81 if(Points[2].x > Points[3].x)
82 return FALSE;
84 if(!dx) return TRUE;
85 if(abs(Points[1].y-Points[0].y-(dy/dx)*
86 BEZIERSHIFTDOWN(Points[1].x-Points[0].x)) > BEZIERPIXEL ||
87 abs(Points[2].y-Points[0].y-(dy/dx)*
88 BEZIERSHIFTDOWN(Points[2].x-Points[0].x)) > BEZIERPIXEL )
89 return FALSE;
90 else
91 return TRUE;
92 }else{ /* steep line */
93 /* check that control points are between begin and end */
94 if(Points[1].y < Points[0].y){
95 if(Points[1].y < Points[3].y)
96 return FALSE;
97 }else
98 if(Points[1].y > Points[3].y)
99 return FALSE;
100 if(Points[2].y < Points[0].y){
101 if(Points[2].y < Points[3].y)
102 return FALSE;
103 }else
104 if(Points[2].y > Points[3].y)
105 return FALSE;
107 if(!dy) return TRUE;
108 if(abs(Points[1].x-Points[0].x-(dx/dy)*
109 BEZIERSHIFTDOWN(Points[1].y-Points[0].y)) > BEZIERPIXEL ||
110 abs(Points[2].x-Points[0].x-(dx/dy)*
111 BEZIERSHIFTDOWN(Points[2].y-Points[0].y)) > BEZIERPIXEL )
112 return FALSE;
113 else
114 return TRUE;
115 }
116}
#define BEZIERPIXEL
Definition: bezier.c:39
#define BEZIERSHIFTDOWN(x)
Definition: bezier.c:40
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define abs(i)
Definition: fconv.c:206
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int32_t INT
Definition: typedefs.h:58

Referenced by GDI_InternalBezier().

◆ GDI_Bezier()

POINT * GDI_Bezier ( const POINT Points,
INT  count,
INT nPtsOut 
)

Definition at line 189 of file bezier.c.

190{
191 POINT *out;
192 INT Bezier, dwOut = BEZIER_INITBUFSIZE, i;
193
194 if (count == 1 || (count - 1) % 3 != 0) {
195 DPRINT1("Invalid no. of points %d\n", count);
196 return NULL;
197 }
198 *nPtsOut = 0;
199
201 if (!out) return NULL;
202
203 for(Bezier = 0; Bezier < (count-1)/3; Bezier++) {
204 POINT ptBuf[4];
205 memcpy(ptBuf, Points + Bezier * 3, sizeof(POINT) * 4);
206 for(i = 0; i < 4; i++) {
207 ptBuf[i].x = BEZIERSHIFTUP(ptBuf[i].x);
208 ptBuf[i].y = BEZIERSHIFTUP(ptBuf[i].y);
209 }
210 GDI_InternalBezier( ptBuf, &out, &dwOut, nPtsOut, BEZIERMAXDEPTH );
211 }
212 DPRINT("Produced %d points\n", *nPtsOut);
213 return out;
214}
#define DPRINT1
Definition: precomp.h:8
#define BEZIERSHIFTUP(x)
Definition: bezier.c:38
static void GDI_InternalBezier(POINT *Points, POINT **PtsOut, INT *dwOut, INT *nPtsOut, INT level)
Definition: bezier.c:121
#define BEZIERMAXDEPTH
Definition: bezier.c:42
#define BEZIER_INITBUFSIZE
Definition: bezier.c:46
#define NULL
Definition: types.h:112
void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, COLORREF color, int thickness)
Definition: drawing.cpp:93
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
GLuint GLuint GLsizei count
Definition: gl.h:1545
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
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static FILE * out
Definition: regtests2xml.c:44
#define DPRINT
Definition: sndvol32.h:73
#define TAG_BEZIER
Definition: tags.h:13

Referenced by IntGdiPolyBezier(), NtGdiPolyDraw(), PATH_AddFlatBezier(), and PATH_StrokePath().

◆ GDI_InternalBezier()

static void GDI_InternalBezier ( POINT Points,
POINT **  PtsOut,
INT dwOut,
INT nPtsOut,
INT  level 
)
static
Todo:
FIXME!

Definition at line 121 of file bezier.c.

123{
124 if(*nPtsOut == *dwOut) {
125 *dwOut *= 2;
126 *PtsOut = ExAllocatePoolWithTag(PagedPool, *dwOut * sizeof(POINT), TAG_BEZIER);
127 if (*PtsOut == NULL)
128 {
131 return;
132 }
133 }
134
135 if(!level || BezierCheck(level, Points)) {
136 if(*nPtsOut == 0) {
137 (*PtsOut)[0].x = BEZIERSHIFTDOWN(Points[0].x);
138 (*PtsOut)[0].y = BEZIERSHIFTDOWN(Points[0].y);
139 *nPtsOut = 1;
140 }
141 (*PtsOut)[*nPtsOut].x = BEZIERSHIFTDOWN(Points[3].x);
142 (*PtsOut)[*nPtsOut].y = BEZIERSHIFTDOWN(Points[3].y);
143 (*nPtsOut) ++;
144 } else {
145 POINT Points2[4]; /* for the second recursive call */
146 Points2[3]=Points[3];
147 BEZIERMIDDLE(Points2[2], Points[2], Points[3]);
148 BEZIERMIDDLE(Points2[0], Points[1], Points[2]);
149 BEZIERMIDDLE(Points2[1],Points2[0],Points2[2]);
150
151 BEZIERMIDDLE(Points[1], Points[0], Points[1]);
152 BEZIERMIDDLE(Points[2], Points[1], Points2[0]);
153 BEZIERMIDDLE(Points[3], Points[2], Points2[1]);
154
155 Points2[0]=Points[3];
156
157 /* do the two halves */
158 GDI_InternalBezier(Points, PtsOut, dwOut, nPtsOut, level-1);
159 GDI_InternalBezier(Points2, PtsOut, dwOut, nPtsOut, level-1);
160 }
161}
static BOOL BezierCheck(int level, POINT *Points)
Definition: bezier.c:64
#define BEZIERMIDDLE(Mid, P1, P2)
Definition: bezier.c:52
GLint level
Definition: gl.h:1546
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by GDI_Bezier(), and GDI_InternalBezier().