VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.1.0/fbbits.h

Last change on this file was 51223, checked in by vboxsync, 11 years ago

Additions/x11/x11include: added header files for X.Org Server 1.0 and 1.1.

  • Property svn:eol-style set to native
File size: 20.0 KB
Line 
1/*
2 * $XFree86$
3 *
4 * Copyright © 1998 Keith Packard
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Keith Packard makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
15 *
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
23 */
24
25/*
26 * This file defines functions for drawing some primitives using
27 * underlying datatypes instead of masks
28 */
29
30#define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & 0x80008000)
31
32#ifdef HAVE_DIX_CONFIG_H
33#include <dix-config.h>
34#endif
35
36#ifdef BITSMUL
37#define MUL BITSMUL
38#else
39#define MUL 1
40#endif
41
42#ifdef BITSSTORE
43#define STORE(b,x) BITSSTORE(b,x)
44#else
45#define STORE(b,x) (*(b) = (x))
46#endif
47
48#ifdef BITSRROP
49#define RROP(b,a,x) BITSRROP(b,a,x)
50#else
51#define RROP(b,a,x) (*(b) = FbDoRRop (*(b), (a), (x)))
52#endif
53
54#ifdef BITSUNIT
55#define UNIT BITSUNIT
56#define USE_SOLID
57#else
58#define UNIT BITS
59#endif
60
61/*
62 * Define the following before including this file:
63 *
64 * BRESSOLID name of function for drawing a solid segment
65 * BRESDASH name of function for drawing a dashed segment
66 * DOTS name of function for drawing dots
67 * ARC name of function for drawing a solid arc
68 * BITS type of underlying unit
69 */
70
71#ifdef BRESSOLID
72void
73BRESSOLID (DrawablePtr pDrawable,
74 GCPtr pGC,
75 int dashOffset,
76 int signdx,
77 int signdy,
78 int axis,
79 int x1,
80 int y1,
81 int e,
82 int e1,
83 int e3,
84 int len)
85{
86 FbBits *dst;
87 FbStride dstStride;
88 int dstBpp;
89 int dstXoff, dstYoff;
90 FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
91 UNIT *bits;
92 FbStride bitsStride;
93 FbStride majorStep, minorStep;
94 BITS xor = (BITS) pPriv->xor;
95
96 fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
97 bits = ((UNIT *) (dst + ((y1 + dstYoff) * dstStride))) + (x1 + dstXoff) * MUL;
98 bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
99 if (signdy < 0)
100 bitsStride = -bitsStride;
101 if (axis == X_AXIS)
102 {
103 majorStep = signdx * MUL;
104 minorStep = bitsStride;
105 }
106 else
107 {
108 majorStep = bitsStride;
109 minorStep = signdx * MUL;
110 }
111 while (len--)
112 {
113 STORE(bits,xor);
114 bits += majorStep;
115 e += e1;
116 if (e >= 0)
117 {
118 bits += minorStep;
119 e += e3;
120 }
121 }
122}
123#endif
124
125#ifdef BRESDASH
126void
127BRESDASH (DrawablePtr pDrawable,
128 GCPtr pGC,
129 int dashOffset,
130 int signdx,
131 int signdy,
132 int axis,
133 int x1,
134 int y1,
135 int e,
136 int e1,
137 int e3,
138 int len)
139{
140 FbBits *dst;
141 FbStride dstStride;
142 int dstBpp;
143 int dstXoff, dstYoff;
144 FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
145 UNIT *bits;
146 FbStride bitsStride;
147 FbStride majorStep, minorStep;
148 BITS xorfg, xorbg;
149 FbDashDeclare;
150 int dashlen;
151 Bool even;
152 Bool doOdd;
153
154 fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
155 doOdd = pGC->lineStyle == LineDoubleDash;
156 xorfg = (BITS) pPriv->xor;
157 xorbg = (BITS) pPriv->bgxor;
158
159 FbDashInit (pGC, pPriv, dashOffset, dashlen, even);
160
161 bits = ((UNIT *) (dst + ((y1 + dstYoff) * dstStride))) + (x1 + dstXoff) * MUL;
162 bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
163 if (signdy < 0)
164 bitsStride = -bitsStride;
165 if (axis == X_AXIS)
166 {
167 majorStep = signdx * MUL;
168 minorStep = bitsStride;
169 }
170 else
171 {
172 majorStep = bitsStride;
173 minorStep = signdx * MUL;
174 }
175 if (dashlen >= len)
176 dashlen = len;
177 if (doOdd)
178 {
179 if (!even)
180 goto doubleOdd;
181 for (;;)
182 {
183 len -= dashlen;
184 while (dashlen--)
185 {
186 STORE(bits,xorfg);
187 bits += majorStep;
188 if ((e += e1) >= 0)
189 {
190 e += e3;
191 bits += minorStep;
192 }
193 }
194 if (!len)
195 break;
196
197 FbDashNextEven(dashlen);
198
199 if (dashlen >= len)
200 dashlen = len;
201doubleOdd:
202 len -= dashlen;
203 while (dashlen--)
204 {
205 STORE(bits,xorbg);
206 bits += majorStep;
207 if ((e += e1) >= 0)
208 {
209 e += e3;
210 bits += minorStep;
211 }
212 }
213 if (!len)
214 break;
215
216 FbDashNextOdd(dashlen);
217
218 if (dashlen >= len)
219 dashlen = len;
220 }
221 }
222 else
223 {
224 if (!even)
225 goto onOffOdd;
226 for (;;)
227 {
228 len -= dashlen;
229 while (dashlen--)
230 {
231 STORE(bits,xorfg);
232 bits += majorStep;
233 if ((e += e1) >= 0)
234 {
235 e += e3;
236 bits += minorStep;
237 }
238 }
239 if (!len)
240 break;
241
242 FbDashNextEven (dashlen);
243
244 if (dashlen >= len)
245 dashlen = len;
246onOffOdd:
247 len -= dashlen;
248 while (dashlen--)
249 {
250 bits += majorStep;
251 if ((e += e1) >= 0)
252 {
253 e += e3;
254 bits += minorStep;
255 }
256 }
257 if (!len)
258 break;
259
260 FbDashNextOdd (dashlen);
261
262 if (dashlen >= len)
263 dashlen = len;
264 }
265 }
266}
267#endif
268
269#ifdef DOTS
270void
271DOTS (FbBits *dst,
272 FbStride dstStride,
273 int dstBpp,
274 BoxPtr pBox,
275 xPoint *ptsOrig,
276 int npt,
277 int xorg,
278 int yorg,
279 int xoff,
280 int yoff,
281 FbBits and,
282 FbBits xor)
283{
284 INT32 *pts = (INT32 *) ptsOrig;
285 UNIT *bits = (UNIT *) dst;
286 UNIT *point;
287 BITS bxor = (BITS) xor;
288 BITS band = (BITS) and;
289 FbStride bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
290 INT32 ul, lr;
291 INT32 pt;
292
293 ul = coordToInt(pBox->x1 - xorg, pBox->y1 - yorg);
294 lr = coordToInt(pBox->x2 - xorg - 1, pBox->y2 - yorg - 1);
295
296 bits += bitsStride * (yorg + yoff) + (xorg + xoff) * MUL;
297
298 if (and == 0)
299 {
300 while (npt--)
301 {
302 pt = *pts++;
303 if (!isClipped(pt,ul,lr))
304 {
305 point = bits + intToY(pt) * bitsStride + intToX(pt) * MUL;
306 STORE(point,bxor);
307 }
308 }
309 }
310 else
311 {
312 while (npt--)
313 {
314 pt = *pts++;
315 if (!isClipped(pt,ul,lr))
316 {
317 point = bits + intToY(pt) * bitsStride + intToX(pt) * MUL;
318 RROP(point,band,bxor);
319 }
320 }
321 }
322}
323#endif
324
325#ifdef ARC
326
327#define ARCCOPY(d) STORE(d,xorBits)
328#define ARCRROP(d) RROP(d,andBits,xorBits)
329
330void
331ARC (FbBits *dst,
332 FbStride dstStride,
333 int dstBpp,
334 xArc *arc,
335 int drawX,
336 int drawY,
337 FbBits and,
338 FbBits xor)
339{
340 UNIT *bits;
341 FbStride bitsStride;
342 miZeroArcRec info;
343 Bool do360;
344 int x;
345 UNIT *yorgp, *yorgop;
346 BITS andBits, xorBits;
347 int yoffset, dyoffset;
348 int y, a, b, d, mask;
349 int k1, k3, dx, dy;
350
351 bits = (UNIT *) dst;
352 bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
353 andBits = (BITS) and;
354 xorBits = (BITS) xor;
355 do360 = miZeroArcSetup(arc, &info, TRUE);
356 yorgp = bits + ((info.yorg + drawY) * bitsStride);
357 yorgop = bits + ((info.yorgo + drawY) * bitsStride);
358 info.xorg = (info.xorg + drawX) * MUL;
359 info.xorgo = (info.xorgo + drawX) * MUL;
360 MIARCSETUP();
361 yoffset = y ? bitsStride : 0;
362 dyoffset = 0;
363 mask = info.initialMask;
364
365 if (!(arc->width & 1))
366 {
367 if (andBits == 0)
368 {
369 if (mask & 2)
370 ARCCOPY(yorgp + info.xorgo);
371 if (mask & 8)
372 ARCCOPY(yorgop + info.xorgo);
373 }
374 else
375 {
376 if (mask & 2)
377 ARCRROP(yorgp + info.xorgo);
378 if (mask & 8)
379 ARCRROP(yorgop + info.xorgo);
380 }
381 }
382 if (!info.end.x || !info.end.y)
383 {
384 mask = info.end.mask;
385 info.end = info.altend;
386 }
387 if (do360 && (arc->width == arc->height) && !(arc->width & 1))
388 {
389 int xoffset = bitsStride;
390 UNIT *yorghb = yorgp + (info.h * bitsStride) + info.xorg;
391 UNIT *yorgohb = yorghb - info.h * MUL;
392
393 yorgp += info.xorg;
394 yorgop += info.xorg;
395 yorghb += info.h * MUL;
396 while (1)
397 {
398 if (andBits == 0)
399 {
400 ARCCOPY(yorgp + yoffset + x * MUL);
401 ARCCOPY(yorgp + yoffset - x * MUL);
402 ARCCOPY(yorgop - yoffset - x * MUL);
403 ARCCOPY(yorgop - yoffset + x * MUL);
404 }
405 else
406 {
407 ARCRROP(yorgp + yoffset + x * MUL);
408 ARCRROP(yorgp + yoffset - x * MUL);
409 ARCRROP(yorgop - yoffset - x * MUL);
410 ARCRROP(yorgop - yoffset + x * MUL);
411 }
412 if (a < 0)
413 break;
414 if (andBits == 0)
415 {
416 ARCCOPY(yorghb - xoffset - y * MUL);
417 ARCCOPY(yorgohb - xoffset + y * MUL);
418 ARCCOPY(yorgohb + xoffset + y * MUL);
419 ARCCOPY(yorghb + xoffset - y * MUL);
420 }
421 else
422 {
423 ARCRROP(yorghb - xoffset - y * MUL);
424 ARCRROP(yorgohb - xoffset + y * MUL);
425 ARCRROP(yorgohb + xoffset + y * MUL);
426 ARCRROP(yorghb + xoffset - y * MUL);
427 }
428 xoffset += bitsStride;
429 MIARCCIRCLESTEP(yoffset += bitsStride;);
430 }
431 yorgp -= info.xorg;
432 yorgop -= info.xorg;
433 x = info.w;
434 yoffset = info.h * bitsStride;
435 }
436 else if (do360)
437 {
438 while (y < info.h || x < info.w)
439 {
440 MIARCOCTANTSHIFT(dyoffset = bitsStride;);
441 if (andBits == 0)
442 {
443 ARCCOPY(yorgp + yoffset + info.xorg + x * MUL);
444 ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL);
445 ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL);
446 ARCCOPY(yorgop - yoffset + info.xorg + x * MUL);
447 }
448 else
449 {
450 ARCRROP(yorgp + yoffset + info.xorg + x * MUL);
451 ARCRROP(yorgp + yoffset + info.xorgo - x * MUL);
452 ARCRROP(yorgop - yoffset + info.xorgo - x * MUL);
453 ARCRROP(yorgop - yoffset + info.xorg + x * MUL);
454 }
455 MIARCSTEP(yoffset += dyoffset;, yoffset += bitsStride;);
456 }
457 }
458 else
459 {
460 while (y < info.h || x < info.w)
461 {
462 MIARCOCTANTSHIFT(dyoffset = bitsStride;);
463 if ((x == info.start.x) || (y == info.start.y))
464 {
465 mask = info.start.mask;
466 info.start = info.altstart;
467 }
468 if (andBits == 0)
469 {
470 if (mask & 1)
471 ARCCOPY(yorgp + yoffset + info.xorg + x * MUL);
472 if (mask & 2)
473 ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL);
474 if (mask & 4)
475 ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL);
476 if (mask & 8)
477 ARCCOPY(yorgop - yoffset + info.xorg + x * MUL);
478 }
479 else
480 {
481 if (mask & 1)
482 ARCRROP(yorgp + yoffset + info.xorg + x * MUL);
483 if (mask & 2)
484 ARCRROP(yorgp + yoffset + info.xorgo - x * MUL);
485 if (mask & 4)
486 ARCRROP(yorgop - yoffset + info.xorgo - x * MUL);
487 if (mask & 8)
488 ARCRROP(yorgop - yoffset + info.xorg + x * MUL);
489 }
490 if ((x == info.end.x) || (y == info.end.y))
491 {
492 mask = info.end.mask;
493 info.end = info.altend;
494 }
495 MIARCSTEP(yoffset += dyoffset;, yoffset += bitsStride;);
496 }
497 }
498 if ((x == info.start.x) || (y == info.start.y))
499 mask = info.start.mask;
500 if (andBits == 0)
501 {
502 if (mask & 1)
503 ARCCOPY(yorgp + yoffset + info.xorg + x * MUL);
504 if (mask & 4)
505 ARCCOPY(yorgop - yoffset + info.xorgo - x * MUL);
506 if (arc->height & 1)
507 {
508 if (mask & 2)
509 ARCCOPY(yorgp + yoffset + info.xorgo - x * MUL);
510 if (mask & 8)
511 ARCCOPY(yorgop - yoffset + info.xorg + x * MUL);
512 }
513 }
514 else
515 {
516 if (mask & 1)
517 ARCRROP(yorgp + yoffset + info.xorg + x * MUL);
518 if (mask & 4)
519 ARCRROP(yorgop - yoffset + info.xorgo - x * MUL);
520 if (arc->height & 1)
521 {
522 if (mask & 2)
523 ARCRROP(yorgp + yoffset + info.xorgo - x * MUL);
524 if (mask & 8)
525 ARCRROP(yorgop - yoffset + info.xorg + x * MUL);
526 }
527 }
528}
529#undef ARCCOPY
530#undef ARCRROP
531#endif
532
533#ifdef GLYPH
534#if BITMAP_BIT_ORDER == LSBFirst
535# define WRITE_ADDR1(n) (n)
536# define WRITE_ADDR2(n) (n)
537# define WRITE_ADDR4(n) (n)
538#else
539# define WRITE_ADDR1(n) ((n) ^ 3)
540# define WRITE_ADDR2(n) ((n) ^ 2)
541# define WRITE_ADDR4(n) ((n))
542#endif
543
544#define WRITE1(d,n,fg) ((d)[WRITE_ADDR1(n)] = (BITS) (fg))
545
546#ifdef BITS2
547# define WRITE2(d,n,fg) (*((BITS2 *) &((d)[WRITE_ADDR2(n)])) = (BITS2) (fg))
548#else
549# define WRITE2(d,n,fg) WRITE1(d,(n)+1,WRITE1(d,n,fg))
550#endif
551
552#ifdef BITS4
553# define WRITE4(d,n,fg) (*((BITS4 *) &((d)[WRITE_ADDR4(n)])) = (BITS4) (fg))
554#else
555# define WRITE4(d,n,fg) WRITE2(d,(n)+2,WRITE2(d,n,fg))
556#endif
557
558void
559GLYPH (FbBits *dstBits,
560 FbStride dstStride,
561 int dstBpp,
562 FbStip *stipple,
563 FbBits fg,
564 int x,
565 int height)
566{
567 int lshift;
568 FbStip bits;
569 BITS *dstLine;
570 BITS *dst;
571 int n;
572 int shift;
573
574 dstLine = (BITS *) dstBits;
575 dstLine += x & ~3;
576 dstStride *= (sizeof (FbBits) / sizeof (BITS));
577 shift = x & 3;
578 lshift = 4 - shift;
579 while (height--)
580 {
581 bits = *stipple++;
582 dst = (BITS *) dstLine;
583 n = lshift;
584 while (bits)
585 {
586 switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) {
587 case 0:
588 break;
589 case 1:
590 WRITE1(dst,0,fg);
591 break;
592 case 2:
593 WRITE1(dst,1,fg);
594 break;
595 case 3:
596 WRITE2(dst,0,fg);
597 break;
598 case 4:
599 WRITE1(dst,2,fg);
600 break;
601 case 5:
602 WRITE1(dst,0,fg);
603 WRITE1(dst,2,fg);
604 break;
605 case 6:
606 WRITE1(dst,1,fg);
607 WRITE1(dst,2,fg);
608 break;
609 case 7:
610 WRITE2(dst,0,fg);
611 WRITE1(dst,2,fg);
612 break;
613 case 8:
614 WRITE1(dst,3,fg);
615 break;
616 case 9:
617 WRITE1(dst,0,fg);
618 WRITE1(dst,3,fg);
619 break;
620 case 10:
621 WRITE1(dst,1,fg);
622 WRITE1(dst,3,fg);
623 break;
624 case 11:
625 WRITE2(dst,0,fg);
626 WRITE1(dst,3,fg);
627 break;
628 case 12:
629 WRITE2(dst,2,fg);
630 break;
631 case 13:
632 WRITE1(dst,0,fg);
633 WRITE2(dst,2,fg);
634 break;
635 case 14:
636 WRITE1(dst,1,fg);
637 WRITE2(dst,2,fg);
638 break;
639 case 15:
640 WRITE4(dst,0,fg);
641 break;
642 }
643 bits = FbStipLeft (bits, n);
644 n = 4;
645 dst += 4;
646 }
647 dstLine += dstStride;
648 }
649}
650#undef WRITE_ADDR1
651#undef WRITE_ADDR2
652#undef WRITE_ADDR4
653#undef WRITE1
654#undef WRITE2
655#undef WRITE4
656
657#endif
658
659#ifdef POLYLINE
660void
661POLYLINE (DrawablePtr pDrawable,
662 GCPtr pGC,
663 int mode,
664 int npt,
665 DDXPointPtr ptsOrig)
666{
667 INT32 *pts = (INT32 *) ptsOrig;
668 int xoff = pDrawable->x;
669 int yoff = pDrawable->y;
670 unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
671 BoxPtr pBox = REGION_EXTENTS (pDrawable->pScreen, fbGetCompositeClip (pGC));
672
673 FbBits *dst;
674 int dstStride;
675 int dstBpp;
676 int dstXoff, dstYoff;
677
678 UNIT *bits, *bitsBase;
679 FbStride bitsStride;
680 BITS xor = fbGetGCPrivate(pGC)->xor;
681 BITS and = fbGetGCPrivate(pGC)->and;
682 int dashoffset = 0;
683
684 INT32 ul, lr;
685 INT32 pt1, pt2;
686
687 int e, e1, e3, len;
688 int stepmajor, stepminor;
689 int octant;
690
691 if (mode == CoordModePrevious)
692 fbFixCoordModePrevious (npt, ptsOrig);
693
694 fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
695 bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
696 bitsBase = ((UNIT *) dst) + (yoff + dstYoff) * bitsStride + (xoff + dstXoff) * MUL;
697 ul = coordToInt(pBox->x1 - xoff, pBox->y1 - yoff);
698 lr = coordToInt(pBox->x2 - xoff - 1, pBox->y2 - yoff - 1);
699
700 pt1 = *pts++;
701 npt--;
702 pt2 = *pts++;
703 npt--;
704 for (;;)
705 {
706 if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr))
707 {
708 fbSegment (pDrawable, pGC,
709 intToX(pt1) + xoff, intToY(pt1) + yoff,
710 intToX(pt2) + xoff, intToY(pt2) + yoff,
711 npt == 0 && pGC->capStyle != CapNotLast,
712 &dashoffset);
713 if (!npt)
714 return;
715 pt1 = pt2;
716 pt2 = *pts++;
717 npt--;
718 }
719 else
720 {
721 bits = bitsBase + intToY(pt1) * bitsStride + intToX(pt1) * MUL;
722 for (;;)
723 {
724 CalcLineDeltas (intToX(pt1), intToY(pt1),
725 intToX(pt2), intToY(pt2),
726 len, e1, stepmajor, stepminor, 1, bitsStride,
727 octant);
728 stepmajor *= MUL;
729 if (len < e1)
730 {
731 e3 = len;
732 len = e1;
733 e1 = e3;
734
735 e3 = stepminor;
736 stepminor = stepmajor;
737 stepmajor = e3;
738 SetYMajorOctant(octant);
739 }
740 e = -len;
741 e1 <<= 1;
742 e3 = e << 1;
743 FIXUP_ERROR (e, octant, bias);
744 if (and == 0)
745 {
746 while (len--)
747 {
748 STORE(bits,xor);
749 bits += stepmajor;
750 e += e1;
751 if (e >= 0)
752 {
753 bits += stepminor;
754 e += e3;
755 }
756 }
757 }
758 else
759 {
760 while (len--)
761 {
762 RROP(bits,and,xor);
763 bits += stepmajor;
764 e += e1;
765 if (e >= 0)
766 {
767 bits += stepminor;
768 e += e3;
769 }
770 }
771 }
772 if (!npt)
773 {
774 if (pGC->capStyle != CapNotLast &&
775 pt2 != *((INT32 *) ptsOrig))
776 {
777 RROP(bits,and,xor);
778 }
779 return;
780 }
781 pt1 = pt2;
782 pt2 = *pts++;
783 --npt;
784 if (isClipped (pt2, ul, lr))
785 break;
786 }
787 }
788 }
789}
790#endif
791
792#ifdef POLYSEGMENT
793void
794POLYSEGMENT (DrawablePtr pDrawable,
795 GCPtr pGC,
796 int nseg,
797 xSegment *pseg)
798{
799 INT32 *pts = (INT32 *) pseg;
800 int xoff = pDrawable->x;
801 int yoff = pDrawable->y;
802 unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
803 BoxPtr pBox = REGION_EXTENTS (pDrawable->pScreen, fbGetCompositeClip (pGC));
804
805 FbBits *dst;
806 int dstStride;
807 int dstBpp;
808 int dstXoff, dstYoff;
809
810 UNIT *bits, *bitsBase;
811 FbStride bitsStride;
812 FbBits xorBits = fbGetGCPrivate(pGC)->xor;
813 FbBits andBits = fbGetGCPrivate(pGC)->and;
814 BITS xor = xorBits;
815 BITS and = andBits;
816 int dashoffset = 0;
817
818 INT32 ul, lr;
819 INT32 pt1, pt2;
820
821 int e, e1, e3, len;
822 int stepmajor, stepminor;
823 int octant;
824 Bool capNotLast;
825
826 fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
827 bitsStride = dstStride * (sizeof (FbBits) / sizeof (UNIT));
828 bitsBase = ((UNIT *) dst) + (yoff + dstYoff) * bitsStride + (xoff + dstXoff) * MUL;
829 ul = coordToInt(pBox->x1 - xoff, pBox->y1 - yoff);
830 lr = coordToInt(pBox->x2 - xoff - 1, pBox->y2 - yoff - 1);
831
832 capNotLast = pGC->capStyle == CapNotLast;
833
834 while (nseg--)
835 {
836 pt1 = *pts++;
837 pt2 = *pts++;
838 if (isClipped (pt1, ul, lr) | isClipped (pt2, ul, lr))
839 {
840 fbSegment (pDrawable, pGC,
841 intToX(pt1) + xoff, intToY(pt1) + yoff,
842 intToX(pt2) + xoff, intToY(pt2) + yoff,
843 !capNotLast, &dashoffset);
844 }
845 else
846 {
847 CalcLineDeltas (intToX(pt1), intToY(pt1),
848 intToX(pt2), intToY(pt2),
849 len, e1, stepmajor, stepminor, 1, bitsStride,
850 octant);
851 if (e1 == 0 && len > 3
852#if MUL != 1
853 && FbCheck24Pix(and) && FbCheck24Pix(xor)
854#endif
855 )
856 {
857 int x1, x2;
858 FbBits *dstLine;
859 int dstX, width;
860 FbBits startmask, endmask;
861 int nmiddle;
862
863 if (stepmajor < 0)
864 {
865 x1 = intToX(pt2);
866 x2 = intToX(pt1) + 1;
867 if (capNotLast)
868 x1++;
869 }
870 else
871 {
872 x1 = intToX(pt1);
873 x2 = intToX(pt2);
874 if (!capNotLast)
875 x2++;
876 }
877 dstX = (x1 + xoff + dstXoff) * (sizeof (UNIT) * 8 * MUL);
878 width = (x2 - x1) * (sizeof (UNIT) * 8 * MUL);
879
880 dstLine = dst + (intToY(pt1) + yoff + dstYoff) * dstStride;
881 dstLine += dstX >> FB_SHIFT;
882 dstX &= FB_MASK;
883 FbMaskBits (dstX, width, startmask, nmiddle, endmask);
884 if (startmask)
885 {
886 *dstLine = FbDoMaskRRop (*dstLine, andBits, xorBits, startmask);
887 dstLine++;
888 }
889 if (!andBits)
890 while (nmiddle--)
891 *dstLine++ = xorBits;
892 else
893 while (nmiddle--)
894 {
895 *dstLine = FbDoRRop (*dstLine, andBits, xorBits);
896 dstLine++;
897 }
898 if (endmask)
899 *dstLine = FbDoMaskRRop (*dstLine, andBits, xorBits, endmask);
900 }
901 else
902 {
903 stepmajor *= MUL;
904 bits = bitsBase + intToY(pt1) * bitsStride + intToX(pt1) * MUL;
905 if (len < e1)
906 {
907 e3 = len;
908 len = e1;
909 e1 = e3;
910
911 e3 = stepminor;
912 stepminor = stepmajor;
913 stepmajor = e3;
914 SetYMajorOctant(octant);
915 }
916 e = -len;
917 e1 <<= 1;
918 e3 = e << 1;
919 FIXUP_ERROR (e, octant, bias);
920 if (!capNotLast)
921 len++;
922 if (and == 0)
923 {
924 while (len--)
925 {
926 STORE(bits,xor);
927 bits += stepmajor;
928 e += e1;
929 if (e >= 0)
930 {
931 bits += stepminor;
932 e += e3;
933 }
934 }
935 }
936 else
937 {
938 while (len--)
939 {
940 RROP(bits,and,xor);
941 bits += stepmajor;
942 e += e1;
943 if (e >= 0)
944 {
945 bits += stepminor;
946 e += e3;
947 }
948 }
949 }
950 }
951 }
952 }
953}
954#endif
955
956#undef MUL
957#undef STORE
958#undef RROP
959#undef UNIT
960#undef USE_SOLID
961
962#undef isClipped
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette