Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / xwin / winrop.c
CommitLineData
a09e091a
JB
1/*
2 *Copyright (C) 1994-2002 The XFree86 Project, Inc. All Rights Reserved.
3 *
4 *Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 *"Software"), to deal in the Software without restriction, including
7 *without limitation the rights to use, copy, modify, merge, publish,
8 *distribute, sublicense, and/or sell copies of the Software, and to
9 *permit persons to whom the Software is furnished to do so, subject to
10 *the following conditions:
11 *
12 *The above copyright notice and this permission notice shall be
13 *included in all copies or substantial portions of the Software.
14 *
15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
19 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 *Except as contained in this notice, the name of the XFree86 Project
24 *shall not be used in advertising or otherwise to promote the sale, use
25 *or other dealings in this Software without prior written authorization
26 *from the XFree86 Project.
27 *
28 * Authors: Alan Hourihane <alanh@fairlite.demon.co.uk>
29 */
30
31/*
32 * Raster operations used by Windows translated to X's 16 rop codes...
33 */
34#ifdef HAVE_XWIN_CONFIG_H
35#include <xwin-config.h>
36#endif
37#include "win.h"
38
39void
40 ROP16(HDC hdc, int rop);
41
42int g_copyROP[16] = { 0xFF0062, /* GXclear - 0 */
43 0x8800C6, /* GXand - S & D */
44 0x440328, /* GXandReverse - S & !D */
45 0xCC0020, /* GXcopy - S */
46 0x220326, /* GXandInverted - !S & D */
47 0xAA0029, /* GXnoop - D */
48 0x660046, /* GXxor - S ^ D */
49 0xEE0086, /* GXor - S | D */
50 0x1100A6, /* GXnor - !S & !D */
51 0x990126, /* GXequiv - !S ^ D */
52 0x550009, /* GXinvert - !D */
53 0xDD0228, /* GXorReverse - S | !D */
54 0x330008, /* GXcopyInverted - !S */
55 0xBB0226, /* GXorInverted - !S | D */
56 0x7700C6, /* GXnand - !S | !D */
57 0x000042 /* GXset - 1 */
58};
59
60int g_patternROP[16] = { 0xFF0062, /* GXclear - 0 */
61 0xA000C9, /* GXand - P & D */
62 0xF50225, /* GXandReverse - P & !D */
63 0xF00021, /* GXcopy - P */
64 0x5F00E9, /* GXandInverted - !P & D */
65 0xAA0029, /* GXnoop - D */
66 0xA50065, /* GXxor - P ^ D */
67 0xA000C9, /* GXor - P | D */
68 0x5F00E9, /* GXnor - !P & !D */
69 0x5A0049, /* GXequiv - !P ^ D */
70 0x550009, /* GXinvert - !D */
71 0x500325, /* GXorReverse - P | !D */
72 0x0F0001, /* GXcopyInverted - !P */
73 0x0A0329, /* GXorInverted - !P | D */
74 0x0500A9, /* GXnand - !P | !D */
75 0x000042 /* GXset - 1 */
76};
77
78void
79ROP16(HDC hdc, int rop)
80{
81 switch (rop) {
82 case GXclear:
83 SetROP2(hdc, R2_BLACK);
84 break;
85
86 case GXand:
87 SetROP2(hdc, R2_MASKPEN);
88 break;
89
90 case GXandReverse:
91 SetROP2(hdc, R2_MASKPENNOT);
92 break;
93
94 case GXcopy:
95 SetROP2(hdc, R2_COPYPEN);
96 break;
97
98 case GXnoop:
99 SetROP2(hdc, R2_NOP);
100 break;
101
102 case GXxor:
103 SetROP2(hdc, R2_XORPEN);
104 break;
105
106 case GXor:
107 SetROP2(hdc, R2_MERGEPEN);
108 break;
109
110 case GXnor:
111 SetROP2(hdc, R2_NOTMERGEPEN);
112 break;
113
114 case GXequiv:
115 SetROP2(hdc, R2_NOTXORPEN);
116 break;
117
118 case GXinvert:
119 SetROP2(hdc, R2_NOT);
120 break;
121
122 case GXorReverse:
123 SetROP2(hdc, R2_MERGEPENNOT);
124 break;
125
126 case GXcopyInverted:
127 SetROP2(hdc, R2_NOTCOPYPEN);
128 break;
129
130 case GXorInverted:
131 SetROP2(hdc, R2_MERGENOTPEN);
132 break;
133
134 case GXnand:
135 SetROP2(hdc, R2_NOTMASKPEN);
136 break;
137
138 case GXset:
139 SetROP2(hdc, R2_WHITE);
140 break;
141 }
142}