summaryrefslogtreecommitdiff
path: root/hw/xfree86/xaa/xaaROP.c
blob: 155daa4eedac8915c759ee45b36826cd57bd3ab4 (plain)
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
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif

#include <X11/X.h>
#include "misc.h"
#include "xf86.h"
#include "xf86_OSproc.h"

#include "scrnintstr.h"
#include "xf86str.h"
#include "xaarop.h"
#include "xaa.h"
#include "xaalocal.h"


int XAACopyROP[16] =
{
   ROP_0,               /* GXclear */
   ROP_DSa,             /* GXand */
   ROP_SDna,            /* GXandReverse */
   ROP_S,               /* GXcopy */
   ROP_DSna,            /* GXandInverted */
   ROP_D,               /* GXnoop */
   ROP_DSx,             /* GXxor */
   ROP_DSo,             /* GXor */
   ROP_DSon,            /* GXnor */
   ROP_DSxn,            /* GXequiv */
   ROP_Dn,              /* GXinvert*/
   ROP_SDno,            /* GXorReverse */
   ROP_Sn,              /* GXcopyInverted */
   ROP_DSno,            /* GXorInverted */
   ROP_DSan,            /* GXnand */
   ROP_1                /* GXset */
};

int XAACopyROP_PM[16] =
{
   ROP_0,		/* not used */
   ROP_DSPnoa,
   ROP_DPSnaon,
   ROP_DPSDxax,
   ROP_DPSana,
   ROP_D,		/* not used */
   ROP_DPSax,
   ROP_DPSao,
   ROP_DPSaon,
   ROP_DPSaxn,
   ROP_Dn,		/* not used */
   ROP_DPSanan,
   ROP_PSDPxox,		/* is that correct ? */
   ROP_DPSnao,
   ROP_DSPnoan,
   ROP_1		/* not used */
};


int XAAPatternROP[16]=
{
   ROP_0,
   ROP_DPa,
   ROP_PDna,
   ROP_P,
   ROP_DPna,
   ROP_D,
   ROP_DPx,
   ROP_DPo,
   ROP_DPon,
   ROP_PDxn,
   ROP_Dn,
   ROP_PDno,
   ROP_Pn,
   ROP_DPno,
   ROP_DPan,
   ROP_1
};

int XAAPatternROP_PM[16] =
{
   ROP_DPna,
   ROP_DPSnoa,
   ROP_DSPnaon,
   ROP_DSPDxax,
   ROP_DPSana,
   ROP_D,
   ROP_DPSax,
   ROP_DPSao,
   ROP_DPSaon,
   ROP_DPSaxn,
   ROP_DPx,
   ROP_DPSanan, 
   ROP_SPDSxox,		/* is that correct ? */
   ROP_DSPnao,
   ROP_DPSnoan,
   ROP_DPo
};

int XAAGetCopyROP(int i)
{
    return XAACopyROP[i];
}

int XAAGetCopyROP_PM(int i)
{
    return XAACopyROP_PM[i];
}

int XAAGetPatternROP(int i)
{
    return XAAPatternROP[i];
}

int XAAGetPatternROP_PM(int i)
{
    return XAAPatternROP_PM[i];
}

int
XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop)
{
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
    int ret = 0;
    
    pm &= infoRec->FullPlanemasks[pScrn->depth - 1];

    if(pm == infoRec->FullPlanemasks[pScrn->depth - 1]) {
	if(!NO_SRC_ROP(*rop)) 
	   ret |= ROP_PAT;
	*rop = XAAPatternROP[*rop];
    } else {	
	switch(*rop) {
	case GXnoop:
	    break;
	case GXset:
	case GXclear:
	case GXinvert:
	    ret |= ROP_PAT;
	    *fg = pm;
	    if(*bg != -1)
		*bg = pm;
	    break;
	default:
	    ret |= ROP_PAT | ROP_SRC;
	    break;
	}
	*rop = XAAPatternROP_PM[*rop];
    }

    return ret;
}


int
XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop)
{
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
    int ret = 0;
    
    pm &= infoRec->FullPlanemasks[pScrn->depth - 1];

    if(pm == infoRec->FullPlanemasks[pScrn->depth - 1]) {
	if(!NO_SRC_ROP(*rop)) 
	   ret |= ROP_PAT;
	*rop = XAAPatternROP[*rop];
    } else {	
	switch(*rop) {
	case GXnoop:
	    break;
	case GXset:
	case GXclear:
	case GXinvert:
	    ret |= ROP_PAT;
	    *fg = pm;
	    break;
	default:
	    ret |= ROP_PAT | ROP_SRC;
	    break;
	}
	*rop = XAAPatternROP_PM[*rop];
    }

    return ret;
}