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
40ROP16 (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
78
79void
80ROP16 (HDC hdc, int rop)
81{
82  switch (rop)
83    {
84    case GXclear:
85      SetROP2 (hdc, R2_BLACK);
86      break;
87
88    case GXand:
89      SetROP2 (hdc, R2_MASKPEN);
90      break;
91
92    case GXandReverse:
93      SetROP2 (hdc, R2_MASKPENNOT);
94      break;
95
96    case GXcopy:
97      SetROP2 (hdc, R2_COPYPEN);
98      break;
99
100    case GXnoop:
101      SetROP2 (hdc, R2_NOP);
102      break;
103
104    case GXxor:
105      SetROP2 (hdc, R2_XORPEN);
106      break;
107
108    case GXor:
109      SetROP2 (hdc, R2_MERGEPEN);
110      break;
111
112    case GXnor:
113      SetROP2 (hdc, R2_NOTMERGEPEN);
114      break;
115
116    case GXequiv:
117      SetROP2 (hdc, R2_NOTXORPEN);
118      break;
119
120    case GXinvert:
121      SetROP2 (hdc, R2_NOT);
122      break;
123
124    case GXorReverse:
125      SetROP2 (hdc, R2_MERGEPENNOT);
126      break;
127
128    case GXcopyInverted:
129      SetROP2 (hdc, R2_NOTCOPYPEN);
130      break;
131
132    case GXorInverted:
133      SetROP2 (hdc, R2_MERGENOTPEN);
134      break;
135
136    case GXnand:
137      SetROP2 (hdc, R2_NOTMASKPEN);
138      break;
139
140    case GXset:
141      SetROP2 (hdc, R2_WHITE);
142      break;
143    }
144}
145