1
/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbgcunder.c,v 1.5 2001/12/14 19:59:52 dawes Exp $ */
2
/***********************************************************
4
Copyright 1987, 1998 The Open Group
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
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
Except as contained in this notice, the name of The Open Group shall not be
23
used in advertising or otherwise to promote the sale, use or other dealings
24
in this Software without prior written authorization from The Open Group.
27
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
31
Permission to use, copy, modify, and distribute this software and its
32
documentation for any purpose and without fee is hereby granted,
33
provided that the above copyright notice appear in all copies and that
34
both that copyright notice and this permission notice appear in
35
supporting documentation, and that the name of Digital not be
36
used in advertising or publicity pertaining to distribution of the
37
software without specific, written prior permission.
39
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47
******************************************************************/
54
#include "fontstruct.h"
55
#include "dixfontstr.h"
57
#include "windowstr.h"
58
#include "pixmapstr.h"
59
#include "scrnintstr.h"
65
#include "mioverlay.h"
67
#include "cfbmskbits.h"
71
# define useTEGlyphBlt cfbImageGlyphBlt8
73
# define useTEGlyphBlt cfbTEGlyphBlt
77
# define useImageGlyphBlt cfbImageGlyphBlt8
78
# define usePolyGlyphBlt cfbPolyGlyphBlt8
80
# define useImageGlyphBlt miImageGlyphBlt
81
# define usePolyGlyphBlt miPolyGlyphBlt
85
# define usePushPixels cfbPushPixels8
88
# define usePushPixels mfbPushPixels
90
# define usePushPixels miPushPixels
91
#endif /* ifndef LOWMEMFTPT */
95
# define ZeroPolyArc cfbZeroPolyArcSS8Copy
97
# define ZeroPolyArc miZeroPolyArc
101
static GCOps cfbTEOps1Rect = {
117
cfbFillPoly1RectCopy,
119
cfbPolyFillArcSolidCopy,
127
#ifdef NEED_LINEHELPER
132
static GCOps cfbNonTEOps1Rect = {
148
cfbFillPoly1RectCopy,
150
cfbPolyFillArcSolidCopy,
158
#ifdef NEED_LINEHELPER
163
static GCOps cfbTEOps = {
176
cfbPolyFillArcSolidCopy,
184
#ifdef NEED_LINEHELPER
189
static GCOps cfbNonTEOps = {
200
cfbZeroPolyArcSS8Copy,
206
cfbPolyFillArcSolidCopy,
214
#ifdef NEED_LINEHELPER
220
cfb32MatchCommon_Underlay (pGC, devPriv)
222
cfbPrivGCPtr devPriv;
224
if (pGC->lineWidth != 0)
226
if (pGC->lineStyle != LineSolid)
228
if (pGC->fillStyle != FillSolid)
230
if (devPriv->rop != GXcopy)
233
FONTMAXBOUNDS(pGC->font,rightSideBearing) -
234
FONTMINBOUNDS(pGC->font,leftSideBearing) <= 32 &&
235
FONTMINBOUNDS(pGC->font,characterWidth) >= 0)
237
if (TERMINALFONT(pGC->font)
239
&& FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB
243
return &cfbTEOps1Rect;
245
if (devPriv->oneRect)
246
return &cfbTEOps1Rect;
252
return &cfbNonTEOps1Rect;
254
if (devPriv->oneRect)
255
return &cfbNonTEOps1Rect;
265
cfb32ValidateGC_Underlay(
267
unsigned long changes,
268
DrawablePtr pDrawable
270
int mask; /* stateChanges */
271
int index; /* used for stepping through bitfields */
273
int new_line, new_text, new_fillspans, new_fillarea;
274
/* flags for changing the proc vector */
275
cfbPrivGCPtr devPriv;
278
pGC->lastWinOrg.x = pDrawable->x;
279
pGC->lastWinOrg.y = pDrawable->y;
280
devPriv = cfbGetGCPrivate(pGC);
285
new_fillspans = FALSE;
286
new_fillarea = FALSE;
289
* if the client clip is different or moved OR the subwindowMode has
290
* changed OR the window's clip has changed since the last validation
291
* we need to recompute the composite clip
294
if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
295
(pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
298
if(pDrawable->type == DRAWABLE_WINDOW)
299
miOverlayComputeCompositeClip (pGC, (WindowPtr)pDrawable);
301
miComputeCompositeClip (pGC, pDrawable);
303
devPriv->oneRect = FALSE;
305
oneRect = REGION_NUM_RECTS(pGC->pCompositeClip) == 1;
306
if (oneRect != devPriv->oneRect)
308
devPriv->oneRect = oneRect;
314
index = lowbit (mask);
337
new_fillspans = TRUE;
344
new_fillspans = TRUE;
348
new_fillspans = TRUE;
351
case GCTileStipXOrigin:
352
case GCTileStipYOrigin:
357
case GCSubwindowMode:
358
case GCGraphicsExposures:
371
* If the drawable has changed, ensure suitable
372
* entries are in the proc vector.
374
if (pDrawable->serialNumber != (pGC->serialNumber & (DRAWABLE_SERIAL_BITS)))
375
new_fillspans = TRUE; /* deal with FillSpans later */
381
old_rrop = devPriv->rop;
382
devPriv->rop = cfbReduceRasterOp (pGC->alu, pGC->fgPixel,
384
&devPriv->and, &devPriv->xor);
385
if (old_rrop == devPriv->rop)
395
new_fillspans = TRUE;
401
pGC->ops = & cfbNonTEOps;
404
if (new_rrop || new_fillspans || new_text || new_fillarea || new_line)
408
if ((newops = cfb32MatchCommon_Underlay (pGC, devPriv)))
410
if (pGC->ops->devPrivate.val)
411
miDestroyGCOps (pGC->ops);
413
new_rrop = new_line = new_fillspans = new_text = new_fillarea = 0;
417
if (!pGC->ops->devPrivate.val)
419
pGC->ops = miCreateGCOps (pGC->ops);
420
pGC->ops->devPrivate.val = 1;
425
/* deal with the changes we've collected */
428
pGC->ops->FillPolygon = miFillPolygon;
430
if (pGC->fillStyle == FillSolid)
432
switch (devPriv->rop) {
434
pGC->ops->FillPolygon = cfbFillPoly1RectCopy;
437
pGC->ops->FillPolygon = cfbFillPoly1RectGeneral;
442
if (devPriv->oneRect && pGC->fillStyle == FillSolid)
444
switch (devPriv->rop) {
446
pGC->ops->FillPolygon = cfbFillPoly1RectCopy;
449
pGC->ops->FillPolygon = cfbFillPoly1RectGeneral;
454
if (pGC->lineWidth == 0)
457
if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid))
459
switch (devPriv->rop)
462
pGC->ops->PolyArc = cfbZeroPolyArcSS8Xor;
465
pGC->ops->PolyArc = cfbZeroPolyArcSS8Copy;
468
pGC->ops->PolyArc = cfbZeroPolyArcSS8General;
474
pGC->ops->PolyArc = miZeroPolyArc;
477
pGC->ops->PolyArc = miPolyArc;
478
pGC->ops->PolySegment = miPolySegment;
479
switch (pGC->lineStyle)
482
if(pGC->lineWidth == 0)
484
if (pGC->fillStyle == FillSolid)
486
#if defined(PIXEL_ADDR) && !defined(NO_ONE_RECT)
487
if (devPriv->oneRect &&
488
((pDrawable->x >= pGC->pScreen->width - 32768) &&
489
(pDrawable->y >= pGC->pScreen->height - 32768)))
491
pGC->ops->Polylines = cfb8LineSS1Rect;
492
pGC->ops->PolySegment = cfb8SegmentSS1Rect;
497
pGC->ops->Polylines = cfb8LineSS1Rect;
498
pGC->ops->PolySegment = cfb8SegmentSS1Rect;
502
pGC->ops->Polylines = cfbLineSS;
503
pGC->ops->PolySegment = cfbSegmentSS;
508
pGC->ops->Polylines = miZeroLine;
511
pGC->ops->Polylines = miWideLine;
515
if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid)
517
pGC->ops->Polylines = cfbLineSD;
518
pGC->ops->PolySegment = cfbSegmentSD;
520
pGC->ops->Polylines = miWideDash;
525
if (new_text && (pGC->font))
527
if (FONTMAXBOUNDS(pGC->font,rightSideBearing) -
528
FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
529
FONTMINBOUNDS(pGC->font,characterWidth) < 0)
531
pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
532
pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
537
if (pGC->fillStyle == FillSolid)
539
if (devPriv->rop == GXcopy)
540
pGC->ops->PolyGlyphBlt = cfbPolyGlyphBlt8;
543
pGC->ops->PolyGlyphBlt = cfbPolyGlyphRop8;
545
pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
550
pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
551
/* special case ImageGlyphBlt for terminal emulator fonts */
552
#if !defined(WriteBitGroup) || PSZ == 8
553
if (TERMINALFONT(pGC->font) &&
554
(pGC->planemask & PMSK) == PMSK
556
&& FONTMAXBOUNDS(pGC->font,characterWidth) >= PGSZB
560
pGC->ops->ImageGlyphBlt = useTEGlyphBlt;
566
if (devPriv->rop == GXcopy &&
567
pGC->fillStyle == FillSolid &&
568
(pGC->planemask & PMSK) == PMSK)
569
pGC->ops->ImageGlyphBlt = cfbImageGlyphBlt8;
572
pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
579
switch (pGC->fillStyle) {
581
switch (devPriv->rop) {
583
pGC->ops->FillSpans = cfbSolidSpansCopy;
586
pGC->ops->FillSpans = cfbSolidSpansXor;
589
pGC->ops->FillSpans = cfbSolidSpansGeneral;
594
pGC->ops->FillSpans = cfbUnnaturalTileFS;
597
case FillOpaqueStippled:
598
pGC->ops->FillSpans = cfbUnnaturalStippleFS;
601
FatalError("cfbValidateGC: illegal fillStyle\n");
603
} /* end of new_fillspans */
606
#ifndef FOUR_BIT_CODE
607
pGC->ops->PolyFillRect = miPolyFillRect;
608
if (pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled)
610
pGC->ops->PolyFillRect = cfbPolyFillRect;
615
pGC->ops->PushPixels = mfbPushPixels;
617
pGC->ops->PushPixels = miPushPixels;
618
#endif /* ifndef LOWMEMFTPT */
619
if (pGC->fillStyle == FillSolid && devPriv->rop == GXcopy)
620
pGC->ops->PushPixels = cfbPushPixels8;
622
pGC->ops->PolyFillArc = miPolyFillArc;
623
if (pGC->fillStyle == FillSolid)
625
switch (devPriv->rop)
628
pGC->ops->PolyFillArc = cfbPolyFillArcSolidCopy;
631
pGC->ops->PolyFillArc = cfbPolyFillArcSolidGeneral;