~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xfree86/xaa/xaaLineMisc.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaLineMisc.c,v 1.4 1998/09/27 04:43:45 dawes Exp $ */
 
2
 
 
3
#ifdef HAVE_XORG_CONFIG_H
 
4
#include <xorg-config.h>
 
5
#endif
 
6
 
 
7
#include "misc.h"
 
8
#include "xf86.h"
 
9
#include "xf86_ansic.h"
 
10
#include "xf86_OSproc.h"
 
11
 
 
12
#include <X11/X.h>
 
13
#include "scrnintstr.h"
 
14
#include "miline.h"
 
15
#include "xf86str.h"
 
16
#include "xaa.h"
 
17
#include "xaalocal.h"
 
18
   
 
19
 
 
20
void 
 
21
XAASolidHorVertLineAsRects(
 
22
   ScrnInfoPtr pScrn,
 
23
   int x, int y, int len, int dir
 
24
){
 
25
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
 
26
 
 
27
    if(dir == DEGREES_0) 
 
28
        (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, len, 1);
 
29
    else
 
30
        (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, len);
 
31
}
 
32
   
 
33
 
 
34
void 
 
35
XAASolidHorVertLineAsTwoPoint(
 
36
   ScrnInfoPtr pScrn,
 
37
   int x, int y, int len, int dir
 
38
){
 
39
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
 
40
 
 
41
    len--;
 
42
 
 
43
    if(dir == DEGREES_0) 
 
44
        (*infoRec->SubsequentSolidTwoPointLine)(pScrn, x, y, x + len, y, 0);
 
45
    else
 
46
        (*infoRec->SubsequentSolidTwoPointLine)(pScrn, x, y, x, y + len, 0);
 
47
}
 
48
   
 
49
void 
 
50
XAASolidHorVertLineAsBresenham(
 
51
   ScrnInfoPtr pScrn,
 
52
   int x, int y, int len, int dir
 
53
){
 
54
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
 
55
 
 
56
    if(dir == DEGREES_0) 
 
57
        (*infoRec->SubsequentSolidBresenhamLine)(
 
58
                pScrn, x, y, len << 1, 0, -len, len, 0);
 
59
    else
 
60
        (*infoRec->SubsequentSolidBresenhamLine)(
 
61
                pScrn, x, y, len << 1, 0, -len, len, YMAJOR);
 
62
}
 
63
 
 
64
 
 
65
void
 
66
XAAComputeDash(GCPtr pGC)
 
67
{
 
68
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
 
69
    XAAGCPtr   pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGCIndex].ptr;
 
70
    Bool EvenDash = (pGC->numInDashList & 0x01) ? FALSE : TRUE;
 
71
    int PatternLength = 0;
 
72
    unsigned char* DashPtr = (unsigned char*)pGC->dash;
 
73
    CARD32 *ptr;
 
74
    int count = pGC->numInDashList; 
 
75
    int shift, value, direction;
 
76
    Bool set;
 
77
 
 
78
    if(pGCPriv->DashPattern)
 
79
        xfree(pGCPriv->DashPattern);
 
80
 
 
81
    pGCPriv->DashPattern = NULL;
 
82
    pGCPriv->DashLength = 0; 
 
83
 
 
84
    while(count--) 
 
85
        PatternLength += *(DashPtr++);
 
86
 
 
87
    if(!EvenDash)
 
88
        PatternLength <<= 1;
 
89
 
 
90
    if(PatternLength > infoRec->DashPatternMaxLength) 
 
91
        return;
 
92
 
 
93
    if((infoRec->DashedLineFlags & LINE_PATTERN_POWER_OF_2_ONLY) && 
 
94
                                (PatternLength & (PatternLength - 1)))
 
95
        return;
 
96
 
 
97
    pGCPriv->DashPattern = xcalloc((PatternLength + 31) >> 5, 4);
 
98
    if(!pGCPriv->DashPattern) return;
 
99
    pGCPriv->DashLength = PatternLength;
 
100
 
 
101
    if(infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED |
 
102
                                   LINE_PATTERN_LSBFIRST_LSBJUSTIFIED)) {
 
103
        direction = 1;
 
104
        set = TRUE;
 
105
        DashPtr = (unsigned char*)pGC->dash;
 
106
    } else {
 
107
        direction = -1;
 
108
        set = FALSE;
 
109
        DashPtr = (unsigned char*)pGC->dash + pGC->numInDashList - 1;
 
110
    }
 
111
 
 
112
    if(infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED |
 
113
                                   LINE_PATTERN_MSBFIRST_MSBJUSTIFIED))
 
114
        shift = 32 - (PatternLength & 31);
 
115
    else
 
116
        shift = 0;
 
117
 
 
118
    ptr = (CARD32*)(pGCPriv->DashPattern);
 
119
 
 
120
CONCATENATE:
 
121
 
 
122
    count = pGC->numInDashList;
 
123
 
 
124
    while(count--) {
 
125
        value = *DashPtr;
 
126
        DashPtr += direction;
 
127
        while(value) {
 
128
            if(value < (32 - shift)) {
 
129
                if(set) *ptr |= XAAShiftMasks[value] << shift;
 
130
                shift += value;
 
131
                break;
 
132
             } else {
 
133
                if(set) *ptr |= ~0L << shift;
 
134
                value -= (32 - shift);
 
135
                shift = 0;
 
136
                ptr++;
 
137
             }
 
138
        }
 
139
        if(set) set = FALSE;
 
140
        else set = TRUE;
 
141
    }
 
142
 
 
143
    if(!EvenDash) {
 
144
        EvenDash = TRUE;
 
145
        if(infoRec->DashedLineFlags & (LINE_PATTERN_LSBFIRST_MSBJUSTIFIED |
 
146
                                       LINE_PATTERN_LSBFIRST_LSBJUSTIFIED))
 
147
           DashPtr = (unsigned char*)pGC->dash;
 
148
        else
 
149
           DashPtr = (unsigned char*)pGC->dash + pGC->numInDashList;
 
150
        goto CONCATENATE;
 
151
    }
 
152
}