1/*
2 * Copyright © 1998 Keith Packard
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission.  Keith Packard makes no
11 * representations about the suitability of this software for any purpose.  It
12 * is provided "as is" without express or implied warranty.
13 *
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
21 */
22
23#ifdef HAVE_DIX_CONFIG_H
24#include <dix-config.h>
25#endif
26
27#include "fb.h"
28
29FbBits
30fbReplicatePixel(Pixel p, int bpp)
31{
32    FbBits b = p;
33
34    b &= FbFullMask(bpp);
35    while (bpp < FB_UNIT) {
36        b |= b << bpp;
37        bpp <<= 1;
38    }
39    return b;
40}
41
42#define O 0
43#define I FB_ALLONES
44
45const FbMergeRopRec FbMergeRopBits[16] = {
46    {O, O, O, O},               /* clear         0x0         0 */
47    {I, O, O, O},               /* and           0x1         src AND dst */
48    {I, O, I, O},               /* andReverse    0x2         src AND NOT dst */
49    {O, O, I, O},               /* copy          0x3         src */
50    {I, I, O, O},               /* andInverted   0x4         NOT src AND dst */
51    {O, I, O, O},               /* noop          0x5         dst */
52    {O, I, I, O},               /* xor           0x6         src XOR dst */
53    {I, I, I, O},               /* or            0x7         src OR dst */
54    {I, I, I, I},               /* nor           0x8         NOT src AND NOT dst */
55    {O, I, I, I},               /* equiv         0x9         NOT src XOR dst */
56    {O, I, O, I},               /* invert        0xa         NOT dst */
57    {I, I, O, I},               /* orReverse     0xb         src OR NOT dst */
58    {O, O, I, I},               /* copyInverted  0xc         NOT src */
59    {I, O, I, I},               /* orInverted    0xd         NOT src OR dst */
60    {I, O, O, I},               /* nand          0xe         NOT src OR NOT dst */
61    {O, O, O, I},               /* set           0xf         1 */
62};
63
64