9ef13d68b2651e1cd9494230c13cbaf775efab9f
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.
22 #include "../vgaddi.h"
23 #include "../vgavideo/vgavideo.h"
26 * Draw a line from top-left to bottom-right
29 vgaNWtoSE(CLIPOBJ
* Clip
, BRUSHOBJ
* Brush
, LONG x
, LONG y
, LONG deltax
, LONG deltay
)
36 ULONG Pixel
= Brush
->iSolidColor
;
39 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_RIGHTDOWN
, 0);
40 EnumMore
= CLIPOBJ_bEnum(Clip
, (ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
41 ClipRect
= RectEnum
.arcl
;
42 delta
= max(deltax
, deltay
);
45 while (i
< delta
&& (ClipRect
< RectEnum
.arcl
+ RectEnum
.c
|| EnumMore
))
47 while ((ClipRect
< RectEnum
.arcl
+ RectEnum
.c
/* there's still a current clip rect */
48 && (ClipRect
->bottom
<= y
/* but it's above us */
49 || (ClipRect
->top
<= y
&& ClipRect
->right
<= x
))) /* or to the left of us */
50 || EnumMore
) /* no current clip rect, but rects left */
52 /* Skip to the next clip rect */
53 if (RectEnum
.arcl
+ RectEnum
.c
<= ClipRect
)
55 EnumMore
= CLIPOBJ_bEnum(Clip
, (ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
56 ClipRect
= RectEnum
.arcl
;
63 if ( ClipRect
< RectEnum
.arcl
+ RectEnum
.c
) /* If there's no current clip rect we're done */
65 if (ClipRect
->left
<= x
&& ClipRect
->top
<= y
)
67 vgaPutPixel ( x
, y
, Pixel
);
69 if ( deltax
< deltay
)
73 if ( error
>= deltay
)
83 if ( error
>= deltax
)
95 vgaSWtoNE(CLIPOBJ
* Clip
, BRUSHOBJ
* Brush
, LONG x
, LONG y
, LONG deltax
, LONG deltay
)
102 ULONG Pixel
= Brush
->iSolidColor
;
105 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_RIGHTUP
, 0);
106 EnumMore
= CLIPOBJ_bEnum(Clip
, (ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
107 ClipRect
= RectEnum
.arcl
;
108 delta
= max(deltax
, deltay
);
111 while (i
< delta
&& (ClipRect
< RectEnum
.arcl
+ RectEnum
.c
|| EnumMore
))
113 while ((ClipRect
< RectEnum
.arcl
+ RectEnum
.c
114 && (y
< ClipRect
->top
115 || (y
< ClipRect
->bottom
&& ClipRect
->right
<= x
)))
118 if (RectEnum
.arcl
+ RectEnum
.c
<= ClipRect
)
120 EnumMore
= CLIPOBJ_bEnum(Clip
, (ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
121 ClipRect
= RectEnum
.arcl
;
128 if (ClipRect
< RectEnum
.arcl
+ RectEnum
.c
)
130 if (ClipRect
->left
<= x
&& y
< ClipRect
->bottom
)
132 vgaPutPixel(x
, y
, Pixel
);
137 error
= error
+ deltax
;
141 error
= error
- deltay
;
147 error
= error
+ deltay
;
151 error
= error
- deltax
;
160 vgaNEtoSW(CLIPOBJ
* Clip
, BRUSHOBJ
* Brush
, LONG x
, LONG y
, LONG deltax
, LONG deltay
)
167 ULONG Pixel
= Brush
->iSolidColor
;
170 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_LEFTDOWN
, 0);
171 EnumMore
= CLIPOBJ_bEnum(Clip
, (ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
172 ClipRect
= RectEnum
.arcl
;
173 delta
= max(deltax
, deltay
);
176 while (i
< delta
&& (ClipRect
< RectEnum
.arcl
+ RectEnum
.c
|| EnumMore
))
178 while ((ClipRect
< RectEnum
.arcl
+ RectEnum
.c
179 && (ClipRect
->bottom
<= y
180 || (ClipRect
->top
<= y
&& x
< ClipRect
->left
)))
183 if (RectEnum
.arcl
+ RectEnum
.c
<= ClipRect
)
185 EnumMore
= CLIPOBJ_bEnum(Clip
, (ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
186 ClipRect
= RectEnum
.arcl
;
193 if (ClipRect
< RectEnum
.arcl
+ RectEnum
.c
)
195 if (x
< ClipRect
->right
&& ClipRect
->top
<= y
)
197 vgaPutPixel(x
, y
, Pixel
);
202 error
= error
+ deltax
;
206 error
= error
- deltay
;
212 error
= error
+ deltay
;
216 error
= error
- deltax
;
225 vgaSEtoNW(CLIPOBJ
* Clip
, BRUSHOBJ
* Brush
, LONG x
, LONG y
, LONG deltax
, LONG deltay
)
232 ULONG Pixel
= Brush
->iSolidColor
;
235 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_LEFTUP
, 0);
236 EnumMore
= CLIPOBJ_bEnum(Clip
, (ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
237 ClipRect
= RectEnum
.arcl
;
238 delta
= max(deltax
, deltay
);
241 while (i
< delta
&& (ClipRect
< RectEnum
.arcl
+ RectEnum
.c
|| EnumMore
))
243 while ((ClipRect
< RectEnum
.arcl
+ RectEnum
.c
244 && (y
< ClipRect
->top
245 || (y
< ClipRect
->bottom
&& x
< ClipRect
->left
)))
248 if (RectEnum
.arcl
+ RectEnum
.c
<= ClipRect
)
250 EnumMore
= CLIPOBJ_bEnum(Clip
, (ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
251 ClipRect
= RectEnum
.arcl
;
258 if (ClipRect
< RectEnum
.arcl
+ RectEnum
.c
)
260 if (x
< ClipRect
->right
&& y
< ClipRect
->bottom
)
262 vgaPutPixel(x
, y
, Pixel
);
267 error
= error
+ deltax
;
271 error
= error
- deltay
;
277 error
= error
+ deltay
;
281 error
= error
- deltax
;
290 * FIXME: Use Mix to perform ROPs
291 * FIXME: Non-solid Brush
294 DrvLineTo(SURFOBJ
*DestObj
,
304 LONG x
, y
, deltax
, deltay
, i
, xchange
, ychange
, hx
, vy
;
305 ULONG Pixel
= Brush
->iSolidColor
;
342 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_RIGHTDOWN
, 0);
345 EnumMore
= CLIPOBJ_bEnum(Clip
, (ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
346 for (i
= 0; i
< RectEnum
.c
&& RectEnum
.arcl
[i
].top
<= y1
; i
++)
348 if (y1
< RectEnum
.arcl
[i
].bottom
&&
349 RectEnum
.arcl
[i
].left
<= hx
+ deltax
&&
350 hx
< RectEnum
.arcl
[i
].right
)
353 vgaHLine(max(hx
, RectEnum
.arcl
[i
].left
), y1
,
354 min(hx
+ deltax
, RectEnum
.arcl
[i
].right
)
355 -max(hx
, RectEnum
.arcl
[i
].left
), Pixel
);
363 CLIPOBJ_cEnumStart(Clip
, FALSE
, CT_RECTANGLES
, CD_RIGHTDOWN
, 0);
366 EnumMore
= CLIPOBJ_bEnum(Clip
, (ULONG
) sizeof(RectEnum
), (PVOID
) &RectEnum
);
367 for (i
= 0; i
< RectEnum
.c
; i
++)
369 if (RectEnum
.arcl
[i
].left
<= x1
&&
370 x1
< RectEnum
.arcl
[i
].right
&&
371 RectEnum
.arcl
[i
].top
<= vy
+ deltay
&&
372 vy
< RectEnum
.arcl
[i
].bottom
)
375 max(vy
, RectEnum
.arcl
[i
].top
),
376 min(vy
+ deltay
, RectEnum
.arcl
[i
].bottom
)
377 - max(vy
, RectEnum
.arcl
[i
].top
),
390 vgaNWtoSE(Clip
, Brush
, x
, y
, deltax
, deltay
);
394 vgaSWtoNE(Clip
, Brush
, x
, y
, deltax
, deltay
);
401 vgaNEtoSW(Clip
, Brush
, x
, y
, deltax
, deltay
);
405 vgaSEtoNW(Clip
, Brush
, x
, y
, deltax
, deltay
);