2 * DIB Engine ROP2 Primitives
4 * Copyright 2008 Huw Davies
5 * Copyright 2008 Massimo Del Fedele
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(dibdrv
);
29 /* ------------------------------------------------------------*/
30 /* BASIC ROP HELPER */
33 * Decompose the 16 ROP2s into an expression of the form
37 * Where A and X depend only on P (and so can be precomputed).
42 * R2_NOTMERGEPEN ~(D | P) ~P ~P
43 * R2_MASKNOTPEN ~P & D ~P 0
44 * R2_NOTCOPYPEN ~P 0 ~P
45 * R2_MASKPENNOT P & ~D P P
48 * R2_NOTMASKPEN ~(P & D) P 1
49 * R2_MASKPEN P & D P 0
50 * R2_NOTXORPEN ~(P ^ D) 1 ~P
52 * R2_MERGENOTPEN ~P | D P ~P
54 * R2_MERGEPENNOT P | ~D ~P 1
55 * R2_MERGEPEN P | D ~P P
60 /* A = (P & A1) | (~P & A2) */
62 #define ONE {0xffffffff, 0xffffffff}
63 #define P {0xffffffff, 0}
64 #define NOT_P {0, 0xffffffff}
66 static const DWORD rop2_and_array
[16][2] =
68 ZERO
, NOT_P
, NOT_P
, ZERO
,
71 ZERO
, NOT_P
, NOT_P
, ZERO
74 /* X = (P & X1) | (~P & X2) */
75 static const DWORD rop2_xor_array
[16][2] =
77 ZERO
, NOT_P
, ZERO
, NOT_P
,
79 ZERO
, NOT_P
, ZERO
, NOT_P
,
88 void _DIBDRV_CalcAndXorMasks(INT rop
, DWORD color
, DWORD
*and, DWORD
*xor)
90 /* NB The ROP2 codes start at one and the arrays are zero-based */
91 rop
= (rop
- 1) & 0x0f;
92 *and = (color
& rop2_and_array
[rop
][0]) | ((~color
) & rop2_and_array
[rop
][1]);
93 *xor = (color
& rop2_xor_array
[rop
][0]) | ((~color
) & rop2_xor_array
[rop
][1]);
96 /* ------------------------------------------------------------*/
97 /* ROP PIXEL FUNCTIONS */
99 inline void _DIBDRV_rop32(DWORD
*ptr
, DWORD
and, DWORD
xor)
101 *ptr
= (*ptr
& and) ^ xor;
104 inline void _DIBDRV_rop16(WORD
*ptr
, WORD
and, WORD
xor)
106 *ptr
= (*ptr
& and) ^ xor;
109 inline void _DIBDRV_rop8(BYTE
*ptr
, BYTE
and, BYTE
xor)
111 *ptr
= (*ptr
& and) ^ xor;