1706f2543Smrg/*
2706f2543Smrg *Copyright (C) 1994-2002 The XFree86 Project, Inc. All Rights Reserved.
3706f2543Smrg *
4706f2543Smrg *Permission is hereby granted, free of charge, to any person obtaining
5706f2543Smrg * a copy of this software and associated documentation files (the
6706f2543Smrg *"Software"), to deal in the Software without restriction, including
7706f2543Smrg *without limitation the rights to use, copy, modify, merge, publish,
8706f2543Smrg *distribute, sublicense, and/or sell copies of the Software, and to
9706f2543Smrg *permit persons to whom the Software is furnished to do so, subject to
10706f2543Smrg *the following conditions:
11706f2543Smrg *
12706f2543Smrg *The above copyright notice and this permission notice shall be
13706f2543Smrg *included in all copies or substantial portions of the Software.
14706f2543Smrg *
15706f2543Smrg *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16706f2543Smrg *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17706f2543Smrg *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18706f2543Smrg *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
19706f2543Smrg *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20706f2543Smrg *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21706f2543Smrg *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22706f2543Smrg *
23706f2543Smrg *Except as contained in this notice, the name of the XFree86 Project
24706f2543Smrg *shall not be used in advertising or otherwise to promote the sale, use
25706f2543Smrg *or other dealings in this Software without prior written authorization
26706f2543Smrg *from the XFree86 Project.
27706f2543Smrg *
28706f2543Smrg * 	Authors:	Alan Hourihane <alanh@fairlite.demon.co.uk>
29706f2543Smrg */
30706f2543Smrg
31706f2543Smrg/*
32706f2543Smrg * Raster operations used by Windows translated to X's 16 rop codes...
33706f2543Smrg */
34706f2543Smrg#ifdef HAVE_XWIN_CONFIG_H
35706f2543Smrg#include <xwin-config.h>
36706f2543Smrg#endif
37706f2543Smrg#include "win.h"
38706f2543Smrg
39706f2543Smrgvoid
40706f2543SmrgROP16 (HDC hdc, int rop);
41706f2543Smrg
42706f2543Smrgint g_copyROP[16] = { 	0xFF0062, /* GXclear 		- 0 */
43706f2543Smrg		 	0x8800C6, /* GXand 		- S & D */
44706f2543Smrg		 	0x440328, /* GXandReverse  	- S & !D */
45706f2543Smrg		 	0xCC0020, /* GXcopy 		- S */
46706f2543Smrg		 	0x220326, /* GXandInverted 	- !S & D */
47706f2543Smrg		 	0xAA0029, /* GXnoop		- D */
48706f2543Smrg		 	0x660046, /* GXxor 		- S ^ D */
49706f2543Smrg		 	0xEE0086, /* GXor		- S | D */
50706f2543Smrg		 	0x1100A6, /* GXnor 		- !S & !D */
51706f2543Smrg		 	0x990126, /* GXequiv		- !S ^ D */
52706f2543Smrg		 	0x550009, /* GXinvert		- !D */
53706f2543Smrg		 	0xDD0228, /* GXorReverse	- S | !D */
54706f2543Smrg		 	0x330008, /* GXcopyInverted	- !S */
55706f2543Smrg		 	0xBB0226, /* GXorInverted	- !S | D */
56706f2543Smrg		 	0x7700C6, /* GXnand		- !S | !D */
57706f2543Smrg		 	0x000042  /* GXset		- 1 */
58706f2543Smrg};
59706f2543Smrg
60706f2543Smrgint g_patternROP[16] = {0xFF0062, /* GXclear		- 0 */
61706f2543Smrg		 	0xA000C9, /* GXand 		- P & D */
62706f2543Smrg		 	0xF50225, /* GXandReverse	- P & !D */
63706f2543Smrg		 	0xF00021, /* GXcopy 		- P */
64706f2543Smrg		 	0x5F00E9, /* GXandInverted 	- !P & D */
65706f2543Smrg		 	0xAA0029, /* GXnoop		- D */
66706f2543Smrg		 	0xA50065, /* GXxor		- P ^ D */
67706f2543Smrg		 	0xA000C9, /* GXor		- P | D */
68706f2543Smrg		 	0x5F00E9, /* GXnor		- !P & !D */
69706f2543Smrg		 	0x5A0049, /* GXequiv		- !P ^ D */
70706f2543Smrg		 	0x550009, /* GXinvert		- !D */
71706f2543Smrg		 	0x500325, /* GXorReverse	- P | !D */
72706f2543Smrg		 	0x0F0001, /* GXcopyInverted	- !P */
73706f2543Smrg		 	0x0A0329, /* GXorInverted	- !P | D */
74706f2543Smrg		 	0x0500A9, /* GXnand		- !P | !D */
75706f2543Smrg		 	0x000042  /* GXset		- 1 */
76706f2543Smrg};
77706f2543Smrg
78706f2543Smrg
79706f2543Smrgvoid
80706f2543SmrgROP16 (HDC hdc, int rop)
81706f2543Smrg{
82706f2543Smrg  switch (rop)
83706f2543Smrg    {
84706f2543Smrg    case GXclear:
85706f2543Smrg      SetROP2 (hdc, R2_BLACK);
86706f2543Smrg      break;
87706f2543Smrg
88706f2543Smrg    case GXand:
89706f2543Smrg      SetROP2 (hdc, R2_MASKPEN);
90706f2543Smrg      break;
91706f2543Smrg
92706f2543Smrg    case GXandReverse:
93706f2543Smrg      SetROP2 (hdc, R2_MASKPENNOT);
94706f2543Smrg      break;
95706f2543Smrg
96706f2543Smrg    case GXcopy:
97706f2543Smrg      SetROP2 (hdc, R2_COPYPEN);
98706f2543Smrg      break;
99706f2543Smrg
100706f2543Smrg    case GXnoop:
101706f2543Smrg      SetROP2 (hdc, R2_NOP);
102706f2543Smrg      break;
103706f2543Smrg
104706f2543Smrg    case GXxor:
105706f2543Smrg      SetROP2 (hdc, R2_XORPEN);
106706f2543Smrg      break;
107706f2543Smrg
108706f2543Smrg    case GXor:
109706f2543Smrg      SetROP2 (hdc, R2_MERGEPEN);
110706f2543Smrg      break;
111706f2543Smrg
112706f2543Smrg    case GXnor:
113706f2543Smrg      SetROP2 (hdc, R2_NOTMERGEPEN);
114706f2543Smrg      break;
115706f2543Smrg
116706f2543Smrg    case GXequiv:
117706f2543Smrg      SetROP2 (hdc, R2_NOTXORPEN);
118706f2543Smrg      break;
119706f2543Smrg
120706f2543Smrg    case GXinvert:
121706f2543Smrg      SetROP2 (hdc, R2_NOT);
122706f2543Smrg      break;
123706f2543Smrg
124706f2543Smrg    case GXorReverse:
125706f2543Smrg      SetROP2 (hdc, R2_MERGEPENNOT);
126706f2543Smrg      break;
127706f2543Smrg
128706f2543Smrg    case GXcopyInverted:
129706f2543Smrg      SetROP2 (hdc, R2_NOTCOPYPEN);
130706f2543Smrg      break;
131706f2543Smrg
132706f2543Smrg    case GXorInverted:
133706f2543Smrg      SetROP2 (hdc, R2_MERGENOTPEN);
134706f2543Smrg      break;
135706f2543Smrg
136706f2543Smrg    case GXnand:
137706f2543Smrg      SetROP2 (hdc, R2_NOTMASKPEN);
138706f2543Smrg      break;
139706f2543Smrg
140706f2543Smrg    case GXset:
141706f2543Smrg      SetROP2 (hdc, R2_WHITE);
142706f2543Smrg      break;
143706f2543Smrg    }
144706f2543Smrg}
145