1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086
|
/***********************************************************
Copyright (c) 1987 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/* $XConsortium: mfbgc.c,v 5.35 94/04/17 20:28:23 dpw Exp $ */
#include "X.h"
#include "Xmd.h"
#include "Xproto.h"
#include "mfb.h"
#include "dixfontstr.h"
#include "fontstruct.h"
#include "gcstruct.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "scrnintstr.h"
#include "region.h"
#include "mistruct.h"
#include "migc.h"
#include "maskbits.h"
static GCFuncs mfbFuncs = {
mfbValidateGC,
miChangeGC,
miCopyGC,
miDestroyGC,
miChangeClip,
miDestroyClip,
miCopyClip
};
static GCOps whiteTECopyOps = {
mfbWhiteSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
mfbZeroPolyArcSS,
mfbFillPolyWhite,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
mfbTEGlyphBltWhite,
mfbPolyGlyphBltWhite,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
static GCOps blackTECopyOps = {
mfbBlackSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
mfbZeroPolyArcSS,
mfbFillPolyBlack,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
mfbTEGlyphBltBlack,
mfbPolyGlyphBltBlack,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
static GCOps whiteTEInvertOps = {
mfbInvertSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
miZeroPolyArc,
mfbFillPolyInvert,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
mfbTEGlyphBltWhite,
mfbPolyGlyphBltInvert,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
static GCOps blackTEInvertOps = {
mfbInvertSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
miZeroPolyArc,
mfbFillPolyInvert,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
mfbTEGlyphBltBlack,
mfbPolyGlyphBltInvert,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
static GCOps whiteCopyOps = {
mfbWhiteSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
mfbZeroPolyArcSS,
mfbFillPolyWhite,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
mfbImageGlyphBltWhite,
mfbPolyGlyphBltWhite,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
static GCOps blackCopyOps = {
mfbBlackSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
mfbZeroPolyArcSS,
mfbFillPolyBlack,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
mfbImageGlyphBltBlack,
mfbPolyGlyphBltBlack,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
static GCOps whiteInvertOps = {
mfbInvertSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
miZeroPolyArc,
mfbFillPolyInvert,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
mfbImageGlyphBltWhite,
mfbPolyGlyphBltInvert,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
static GCOps blackInvertOps = {
mfbInvertSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
miZeroPolyArc,
mfbFillPolyInvert,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
mfbImageGlyphBltBlack,
mfbPolyGlyphBltInvert,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
static GCOps whiteWhiteCopyOps = {
mfbWhiteSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
mfbZeroPolyArcSS,
mfbFillPolyWhite,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
miImageGlyphBlt,
mfbPolyGlyphBltWhite,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
static GCOps blackBlackCopyOps = {
mfbBlackSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
mfbZeroPolyArcSS,
mfbFillPolyBlack,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
miImageGlyphBlt,
mfbPolyGlyphBltBlack,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
static GCOps fgEqBgInvertOps = {
mfbInvertSolidFS,
mfbSetSpans,
mfbPutImage,
mfbCopyArea,
mfbCopyPlane,
mfbPolyPoint,
mfbLineSS,
mfbSegmentSS,
miPolyRectangle,
miZeroPolyArc,
mfbFillPolyInvert,
mfbPolyFillRect,
mfbPolyFillArcSolid,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
miImageGlyphBlt,
mfbPolyGlyphBltInvert,
mfbSolidPP
#ifdef NEED_LINEHELPER
,NULL
#endif
};
struct commonOps {
int fg, bg;
int rrop;
int terminalFont;
GCOps *ops;
void (*fillArea)();
};
static struct commonOps mfbCommonOps[] = {
{ 1, 0, RROP_WHITE, 1, &whiteTECopyOps, mfbSolidWhiteArea },
{ 0, 1, RROP_BLACK, 1, &blackTECopyOps, mfbSolidBlackArea },
{ 1, 0, RROP_INVERT, 1, &whiteTEInvertOps, mfbSolidInvertArea },
{ 0, 1, RROP_INVERT, 1, &blackTEInvertOps, mfbSolidInvertArea },
{ 1, 0, RROP_WHITE, 0, &whiteCopyOps, mfbSolidWhiteArea },
{ 0, 1, RROP_BLACK, 0, &blackCopyOps, mfbSolidBlackArea },
{ 1, 0, RROP_INVERT, 0, &whiteInvertOps, mfbSolidInvertArea },
{ 0, 1, RROP_INVERT, 0, &blackInvertOps, mfbSolidInvertArea },
{ 1, 1, RROP_WHITE, 0, &whiteWhiteCopyOps, mfbSolidWhiteArea },
{ 0, 0, RROP_BLACK, 0, &blackBlackCopyOps, mfbSolidBlackArea },
{ 1, 1, RROP_INVERT, 0, &fgEqBgInvertOps, mfbSolidInvertArea },
{ 0, 0, RROP_INVERT, 0, &fgEqBgInvertOps, mfbSolidInvertArea },
};
#define numberCommonOps (sizeof (mfbCommonOps) / sizeof (mfbCommonOps[0]))
static GCOps *
matchCommon (pGC)
GCPtr pGC;
{
int i;
struct commonOps *cop;
mfbPrivGC *priv;
if (pGC->lineWidth != 0)
return 0;
if (pGC->lineStyle != LineSolid)
return 0;
if (pGC->fillStyle != FillSolid)
return 0;
if (!pGC->font ||
FONTMAXBOUNDS(pGC->font,rightSideBearing) -
FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
FONTMINBOUNDS(pGC->font,characterWidth) < 0)
return 0;
priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
for (i = 0; i < numberCommonOps; i++) {
cop = &mfbCommonOps[i];
if ((pGC->fgPixel & 1) != cop->fg)
continue;
if ((pGC->bgPixel & 1) != cop->bg)
continue;
if (priv->rop != cop->rrop)
continue;
if (cop->terminalFont && !TERMINALFONT(pGC->font))
continue;
priv->FillArea = cop->fillArea;
return cop->ops;
}
return 0;
}
Bool
mfbCreateGC(pGC)
register GCPtr pGC;
{
mfbPrivGC *pPriv;
pGC->clientClip = NULL;
pGC->clientClipType = CT_NONE;
/* some of the output primitives aren't really necessary, since
they will be filled in ValidateGC because of dix/CreateGC()
setting all the change bits. Others are necessary because although
they depend on being a monochrome frame buffer, they don't change
*/
pGC->ops = &whiteCopyOps;
pGC->funcs = &mfbFuncs;
/* mfb wants to translate before scan convesion */
pGC->miTranslate = 1;
pPriv = (mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr);
pPriv->rop = mfbReduceRop(pGC->alu, pGC->fgPixel);
pPriv->fExpose = TRUE;
pPriv->pRotatedPixmap = NullPixmap;
pPriv->freeCompClip = FALSE;
pPriv->FillArea = mfbSolidInvertArea;
return TRUE;
}
/* Clipping conventions
if the drawable is a window
CT_REGION ==> pCompositeClip really is the composite
CT_other ==> pCompositeClip is the window clip region
if the drawable is a pixmap
CT_REGION ==> pCompositeClip is the translated client region
clipped to the pixmap boundary
CT_other ==> pCompositeClip is the pixmap bounding box
*/
/*ARGSUSED*/
void
mfbValidateGC(pGC, changes, pDrawable)
register GCPtr pGC;
unsigned long changes;
DrawablePtr pDrawable;
{
register mfbPrivGCPtr devPriv;
int mask; /* stateChanges */
int index; /* used for stepping through bitfields */
int xrot, yrot; /* rotations for tile and stipple pattern */
int rrop; /* reduced rasterop */
/* flags for changing the proc vector
and updating things in devPriv
*/
int new_rotate, new_rrop, new_line, new_text, new_fill;
DDXPointRec oldOrg; /* origin of thing GC was last used with */
oldOrg = pGC->lastWinOrg;
pGC->lastWinOrg.x = pDrawable->x;
pGC->lastWinOrg.y = pDrawable->y;
/* we need to re-rotate the tile if the previous window/pixmap
origin (oldOrg) differs from the new window/pixmap origin
(pGC->lastWinOrg)
*/
new_rotate = (oldOrg.x != pGC->lastWinOrg.x) ||
(oldOrg.y != pGC->lastWinOrg.y);
devPriv = ((mfbPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr));
/*
if the client clip is different or moved OR
the subwindowMode has changed OR
the window's clip has changed since the last validation
we need to recompute the composite clip
*/
if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
(pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
)
{
miComputeCompositeClip(pGC, pDrawable);
}
new_rrop = FALSE;
new_line = FALSE;
new_text = FALSE;
new_fill = FALSE;
mask = changes;
while (mask)
{
index = lowbit (mask);
mask &= ~index;
/* this switch acculmulates a list of which procedures
might have to change due to changes in the GC. in
some cases (e.g. changing one 16 bit tile for another)
we might not really need a change, but the code is
being paranoid.
this sort of batching wins if, for example, the alu
and the font have been changed, or any other pair
of items that both change the same thing.
*/
switch (index)
{
case GCFunction:
case GCForeground:
new_rrop = TRUE;
break;
case GCPlaneMask:
break;
case GCBackground:
new_rrop = TRUE; /* for opaque stipples */
break;
case GCLineStyle:
case GCLineWidth:
case GCJoinStyle:
new_line = TRUE;
break;
case GCCapStyle:
break;
case GCFillStyle:
new_fill = TRUE;
break;
case GCFillRule:
break;
case GCTile:
if(pGC->tileIsPixel)
break;
new_rotate = TRUE;
new_fill = TRUE;
break;
case GCStipple:
if(pGC->stipple == (PixmapPtr)NULL)
break;
new_rotate = TRUE;
new_fill = TRUE;
break;
case GCTileStipXOrigin:
new_rotate = TRUE;
break;
case GCTileStipYOrigin:
new_rotate = TRUE;
break;
case GCFont:
new_text = TRUE;
break;
case GCSubwindowMode:
break;
case GCGraphicsExposures:
break;
case GCClipXOrigin:
break;
case GCClipYOrigin:
break;
case GCClipMask:
break;
case GCDashOffset:
break;
case GCDashList:
break;
case GCArcMode:
break;
default:
break;
}
}
/* deal with the changes we've collected .
new_rrop must be done first because subsequent things
depend on it.
*/
if(new_rotate || new_fill)
{
Bool new_pix = FALSE;
/* figure out how much to rotate */
xrot = pGC->patOrg.x;
yrot = pGC->patOrg.y;
xrot += pDrawable->x;
yrot += pDrawable->y;
switch (pGC->fillStyle)
{
case FillTiled:
/* copy current tile and stipple */
if (!pGC->tileIsPixel && (pGC->tile.pixmap->drawable.width <= PPW) &&
!(pGC->tile.pixmap->drawable.width & (pGC->tile.pixmap->drawable.width - 1)))
{
mfbCopyRotatePixmap(pGC->tile.pixmap,
&devPriv->pRotatedPixmap, xrot, yrot);
new_pix = TRUE;
}
break;
case FillStippled:
case FillOpaqueStippled:
if (pGC->stipple && (pGC->stipple->drawable.width <= PPW) &&
!(pGC->stipple->drawable.width & (pGC->stipple->drawable.width - 1)))
{
mfbCopyRotatePixmap(pGC->stipple,
&devPriv->pRotatedPixmap, xrot, yrot);
new_pix = TRUE;
}
}
/* destroy any previously rotated tile or stipple */
if (!new_pix && devPriv->pRotatedPixmap)
{
(*pDrawable->pScreen->DestroyPixmap)(devPriv->pRotatedPixmap);
devPriv->pRotatedPixmap = (PixmapPtr)NULL;
}
}
/*
* duck out here when the GC is unchanged
*/
if (!changes)
return;
if (new_rrop || new_fill)
{
rrop = mfbReduceRop(pGC->alu, pGC->fgPixel);
devPriv->rop = rrop;
new_fill = TRUE;
/* FillArea raster op is GC's for tile filling,
and the reduced rop for solid and stipple
*/
if (pGC->fillStyle == FillTiled)
devPriv->ropFillArea = pGC->alu;
else
devPriv->ropFillArea = rrop;
/* opaque stipples:
fg bg ropOpStip fill style
1 0 alu tile
0 1 inverseAlu tile
1 1 rrop(fg, alu) solid
0 0 rrop(fg, alu) solid
Note that rrop(fg, alu) == mfbPrivGC.rop, so we don't really need to
compute it.
*/
if (pGC->fillStyle == FillOpaqueStippled)
{
if ((pGC->fgPixel & 1) != (pGC->bgPixel & 1))
{
if (pGC->fgPixel & 1)
devPriv->ropOpStip = pGC->alu;
else
devPriv->ropOpStip = InverseAlu[pGC->alu];
}
else
devPriv->ropOpStip = rrop;
devPriv->ropFillArea = devPriv->ropOpStip;
}
}
else
rrop = devPriv->rop;
if (new_line || new_fill || new_text)
{
GCOps *newops;
if (newops = matchCommon (pGC))
{
if (pGC->ops->devPrivate.val)
miDestroyGCOps (pGC->ops);
pGC->ops = newops;
new_line = new_fill = new_text = 0;
}
else
{
if (!pGC->ops->devPrivate.val)
{
pGC->ops = miCreateGCOps (pGC->ops);
pGC->ops->devPrivate.val = 1;
}
}
}
if (new_line || new_fill)
{
if (pGC->lineWidth == 0)
{
if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid)
&& ((rrop == RROP_WHITE) || (rrop == RROP_BLACK)))
pGC->ops->PolyArc = mfbZeroPolyArcSS;
else
pGC->ops->PolyArc = miZeroPolyArc;
}
else
pGC->ops->PolyArc = miPolyArc;
if (pGC->lineStyle == LineSolid)
{
if(pGC->lineWidth == 0)
{
if (pGC->fillStyle == FillSolid)
{
pGC->ops->PolySegment = mfbSegmentSS;
pGC->ops->Polylines = mfbLineSS;
}
else
{
pGC->ops->PolySegment = miPolySegment;
pGC->ops->Polylines = miZeroLine;
}
}
else
{
pGC->ops->PolySegment = miPolySegment;
pGC->ops->Polylines = miWideLine;
}
}
else
{
if(pGC->lineWidth == 0 && pGC->fillStyle == FillSolid)
{
pGC->ops->Polylines = mfbLineSD;
pGC->ops->PolySegment = mfbSegmentSD;
}
else
{
pGC->ops->Polylines = miWideDash;
pGC->ops->PolySegment = miPolySegment;
}
}
}
if (new_text || new_fill)
{
if ((pGC->font) &&
(FONTMAXBOUNDS(pGC->font,rightSideBearing) -
FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
FONTMINBOUNDS(pGC->font,characterWidth) < 0))
{
pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
}
else
{
/* special case ImageGlyphBlt for terminal emulator fonts */
if ((pGC->font) &&
TERMINALFONT(pGC->font) &&
((pGC->fgPixel & 1) != (pGC->bgPixel & 1)))
{
/* pcc bug makes this not compile...
pGC->ops->ImageGlyphBlt = (pGC->fgPixel & 1) ? mfbTEGlyphBltWhite :
mfbTEGlyphBltBlack;
*/
if (pGC->fgPixel & 1)
pGC->ops->ImageGlyphBlt = mfbTEGlyphBltWhite;
else
pGC->ops->ImageGlyphBlt = mfbTEGlyphBltBlack;
}
else
{
if (pGC->fgPixel & 1)
pGC->ops->ImageGlyphBlt = mfbImageGlyphBltWhite;
else
pGC->ops->ImageGlyphBlt = mfbImageGlyphBltBlack;
}
/* now do PolyGlyphBlt */
if (pGC->fillStyle == FillSolid ||
(pGC->fillStyle == FillOpaqueStippled &&
(pGC->fgPixel & 1) == (pGC->bgPixel & 1)
)
)
{
if (rrop == RROP_WHITE)
pGC->ops->PolyGlyphBlt = mfbPolyGlyphBltWhite;
else if (rrop == RROP_BLACK)
pGC->ops->PolyGlyphBlt = mfbPolyGlyphBltBlack;
else if (rrop == RROP_INVERT)
pGC->ops->PolyGlyphBlt = mfbPolyGlyphBltInvert;
else
pGC->ops->PolyGlyphBlt = (void (*)())NoopDDA;
}
else
{
pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
}
}
}
if (new_fill)
{
/* install a suitable fillspans and pushpixels */
pGC->ops->PushPixels = mfbPushPixels;
pGC->ops->FillPolygon = miFillPolygon;
if ((pGC->fillStyle == FillSolid) ||
((pGC->fillStyle == FillOpaqueStippled) &&
((pGC->fgPixel & 1) == (pGC->bgPixel & 1))))
{
pGC->ops->PushPixels = mfbSolidPP;
switch(devPriv->rop)
{
case RROP_WHITE:
pGC->ops->FillSpans = mfbWhiteSolidFS;
pGC->ops->FillPolygon = mfbFillPolyWhite;
break;
case RROP_BLACK:
pGC->ops->FillSpans = mfbBlackSolidFS;
pGC->ops->FillPolygon = mfbFillPolyBlack;
break;
case RROP_INVERT:
pGC->ops->FillSpans = mfbInvertSolidFS;
pGC->ops->FillPolygon = mfbFillPolyInvert;
break;
case RROP_NOP:
pGC->ops->FillSpans = (void (*)())NoopDDA;
pGC->ops->FillPolygon = (void (*)())NoopDDA;
break;
}
}
/* beyond this point, opaqueStippled ==> fg != bg */
else if (((pGC->fillStyle == FillTiled) ||
(pGC->fillStyle == FillOpaqueStippled)) &&
!devPriv->pRotatedPixmap)
{
pGC->ops->FillSpans = mfbUnnaturalTileFS;
}
else if ((pGC->fillStyle == FillStippled) && !devPriv->pRotatedPixmap)
{
pGC->ops->FillSpans = mfbUnnaturalStippleFS;
}
else if (pGC->fillStyle == FillStippled)
{
switch(devPriv->rop)
{
case RROP_WHITE:
pGC->ops->FillSpans = mfbWhiteStippleFS;
break;
case RROP_BLACK:
pGC->ops->FillSpans = mfbBlackStippleFS;
break;
case RROP_INVERT:
pGC->ops->FillSpans = mfbInvertStippleFS;
break;
case RROP_NOP:
pGC->ops->FillSpans = (void (*)())NoopDDA;
break;
}
}
else /* overload tiles to do parti-colored opaque stipples */
{
pGC->ops->FillSpans = mfbTileFS;
}
if (pGC->fillStyle == FillSolid)
pGC->ops->PolyFillArc = mfbPolyFillArcSolid;
else
pGC->ops->PolyFillArc = miPolyFillArc;
/* the rectangle code doesn't deal with opaque stipples that
are two colors -- we can fool it for fg==bg, though
*/
if ((((pGC->fillStyle == FillTiled) ||
(pGC->fillStyle == FillStippled)) &&
!devPriv->pRotatedPixmap) ||
((pGC->fillStyle == FillOpaqueStippled) &&
((pGC->fgPixel & 1) != (pGC->bgPixel & 1)))
)
{
pGC->ops->PolyFillRect = miPolyFillRect;
}
else /* deal with solids and natural stipples and tiles */
{
pGC->ops->PolyFillRect = mfbPolyFillRect;
if ((pGC->fillStyle == FillSolid) ||
((pGC->fillStyle == FillOpaqueStippled) &&
((pGC->fgPixel & 1) == (pGC->bgPixel & 1))))
{
switch(devPriv->rop)
{
case RROP_WHITE:
devPriv->FillArea = mfbSolidWhiteArea;
break;
case RROP_BLACK:
devPriv->FillArea = mfbSolidBlackArea;
break;
case RROP_INVERT:
devPriv->FillArea = mfbSolidInvertArea;
break;
case RROP_NOP:
devPriv->FillArea = (void (*)())NoopDDA;
break;
}
}
else if (pGC->fillStyle == FillStippled)
{
switch(devPriv->rop)
{
case RROP_WHITE:
devPriv->FillArea = mfbStippleWhiteArea;
break;
case RROP_BLACK:
devPriv->FillArea = mfbStippleBlackArea;
break;
case RROP_INVERT:
devPriv->FillArea = mfbStippleInvertArea;
break;
case RROP_NOP:
devPriv->FillArea = (void (*)())NoopDDA;
break;
}
}
else /* deal with tiles */
{
switch (pGC->alu)
{
case GXcopy:
devPriv->FillArea = mfbTileAreaPPWCopy;
break;
default:
devPriv->FillArea = mfbTileAreaPPWGeneral;
break;
}
}
} /* end of natural rectangles */
} /* end of new_fill */
}
/* table to map alu(src, dst) to alu(~src, dst) */
int InverseAlu[16] = {
GXclear,
GXandInverted,
GXnor,
GXcopyInverted,
GXand,
GXnoop,
GXequiv,
GXorInverted,
GXandReverse,
GXxor,
GXinvert,
GXnand,
GXcopy,
GXor,
GXorReverse,
GXset
};
int
mfbReduceRop(alu, src)
register int alu;
register Pixel src;
{
int rop;
if ((src & 1) == 0) /* src is black */
{
switch(alu)
{
case GXclear:
rop = RROP_BLACK;
break;
case GXand:
rop = RROP_BLACK;
break;
case GXandReverse:
rop = RROP_BLACK;
break;
case GXcopy:
rop = RROP_BLACK;
break;
case GXandInverted:
rop = RROP_NOP;
break;
case GXnoop:
rop = RROP_NOP;
break;
case GXxor:
rop = RROP_NOP;
break;
case GXor:
rop = RROP_NOP;
break;
case GXnor:
rop = RROP_INVERT;
break;
case GXequiv:
rop = RROP_INVERT;
break;
case GXinvert:
rop = RROP_INVERT;
break;
case GXorReverse:
rop = RROP_INVERT;
break;
case GXcopyInverted:
rop = RROP_WHITE;
break;
case GXorInverted:
rop = RROP_WHITE;
break;
case GXnand:
rop = RROP_WHITE;
break;
case GXset:
rop = RROP_WHITE;
break;
}
}
else /* src is white */
{
switch(alu)
{
case GXclear:
rop = RROP_BLACK;
break;
case GXand:
rop = RROP_NOP;
break;
case GXandReverse:
rop = RROP_INVERT;
break;
case GXcopy:
rop = RROP_WHITE;
break;
case GXandInverted:
rop = RROP_BLACK;
break;
case GXnoop:
rop = RROP_NOP;
break;
case GXxor:
rop = RROP_INVERT;
break;
case GXor:
rop = RROP_WHITE;
break;
case GXnor:
rop = RROP_BLACK;
break;
case GXequiv:
rop = RROP_NOP;
break;
case GXinvert:
rop = RROP_INVERT;
break;
case GXorReverse:
rop = RROP_WHITE;
break;
case GXcopyInverted:
rop = RROP_BLACK;
break;
case GXorInverted:
rop = RROP_NOP;
break;
case GXnand:
rop = RROP_INVERT;
break;
case GXset:
rop = RROP_WHITE;
break;
}
}
return rop;
}
|