deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/************************************************************
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncCopyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync All Rights Reserved
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncPermission to use, copy, modify, and distribute this
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncsoftware and its documentation for any purpose and without
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncfee is hereby granted, provided that the above copyright no-
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynctice appear in all copies and that both that copyright no-
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynctice and this permission notice appear in supporting docu-
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncmentation, and that the names of Sun or The Open Group
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncnot be used in advertising or publicity pertaining to
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncdistribution of the software without specific prior
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncwritten permission. Sun and The Open Group make no
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncrepresentations about the suitability of this software for
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncany purpose. It is provided "as is" without any express or
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncimplied warranty.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncSUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncTHE USE OR PERFORMANCE OF THIS SOFTWARE.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync********************************************************/
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* Optimizations for PSZ == 32 added by Kyle Marvin (marvin@vitec.com) */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#include <X11/X.h>
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#include <X11/Xmd.h>
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#include "servermd.h"
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if defined(XFREE86) || ( defined(__OpenBSD__) && defined(__alpha__) ) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync || (defined(__bsdi__))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#include "compiler.h"
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * ==========================================================================
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Converted from mfb to support memory-mapped color framebuffer by smarks@sun,
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * April-May 1987.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * The way I did the conversion was to consider each longword as an
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * array of four bytes instead of an array of 32 one-bit pixels. So
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * getbits() and putbits() retain much the same calling sequence, but
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * they move bytes around instead of bits. Of course, this entails the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * removal of all of the one-bit-pixel dependencies from the other
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * files, but the major bit-hacking stuff should be covered here.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * I've created some new macros that make it easier to understand what's
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * going on in the pixel calculations, and that make it easier to change the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * pixel size.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * name explanation
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * ---- -----------
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PSZ pixel size (in bits)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PGSZ pixel group size (in bits)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PGSZB pixel group size (in bytes)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PGSZBMSK mask with lowest PGSZB bits set to 1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PPW pixels per word (pixels per pixel group)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PPWMSK mask with lowest PPW bits set to 1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PLST index of last pixel in a word (should be PPW-1)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PIM pixel index mask (index within a pixel group)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PWSH pixel-to-word shift (should be log2(PPW))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PMSK mask with lowest PSZ bits set to 1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Here are some sample values. In the notation cfbA,B: A is PSZ, and
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * B is PGSZB. All the other values are derived from these
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * two. This table does not show all combinations!
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * name cfb8,4 cfb24,4 cfb32,4 cfb8,8 cfb24,8 cfb32,8
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * ---- ------ ------- ------ ------ ------ -------
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PSZ 8 24 32 8 24 32
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PGSZ 32 32 32 64 64 64
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PGSZB 4 4 4 8 8 8
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PGSZBMSK 0xF 0xF? 0xF 0xFF 0xFF 0xFF
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PPW 4 1 1 8 2 2
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PPWMSK 0xF 0x1 0x1 0xFF 0x3? 0x3
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PLST 3 0 0 7 1 1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PIM 0x3 0x0 0x0 0x7 0x1? 0x1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PWSH 2 0 0 3 1 1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PMSK 0xFF 0xFFFFFF 0xFFFFFFFF 0xFF 0xFFFFFF 0xFFFFFFFF
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * I have also added a new macro, PFILL, that takes one pixel and
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * replicates it throughout a word. This macro definition is dependent
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * upon pixel and word size; it doesn't use macros like PPW and so
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * forth. Examples: for monochrome, PFILL(1) => 0xffffffff, PFILL(0) =>
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * 0x00000000. For 8-bit color, PFILL(0x5d) => 0x5d5d5d5d. This macro
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * is used primarily for replicating a plane mask into a word.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Color framebuffers operations also support the notion of a plane
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * mask. This mask determines which planes of the framebuffer can be
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * altered; the others are left unchanged. I have added another
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * parameter to the putbits and putbitsrop macros that is the plane
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * mask.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * ==========================================================================
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Keith Packard (keithp@suse.com)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * 64bit code is no longer supported; it requires DIX support
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * for repadding images which significantly impacts performance
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PSZ needs to be defined before we get here. Usually it comes from a
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * -DPSZ=foo on the compilation command line.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#ifndef PSZ
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PSZ 8
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PixelGroup is the data type used to operate on groups of pixels.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * We typedef it here to CARD32 with the assumption that you
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * want to manipulate 32 bits worth of pixels at a time as you can. If CARD32
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * is not appropriate for your server, define it to something else
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * before including this file. In this case you will also have to define
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * PGSZB to the size in bytes of PixelGroup.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#ifndef PixelGroup
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PixelGroup CARD32
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PGSZB 4
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* PixelGroup */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#ifndef CfbBits
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define CfbBits CARD32
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PGSZ (PGSZB << 3)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PPW (PGSZ/PSZ)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PLST (PPW-1)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PIM PLST
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PMSK (((PixelGroup)1 << PSZ) - 1)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PPWMSK (((PixelGroup)1 << PPW) - 1) /* instead of BITMSK */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PGSZBMSK (((PixelGroup)1 << PGSZB) - 1)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* set PWSH = log2(PPW) using brute force */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PPW == 1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PWSH 0
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#else
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PPW == 2
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PWSH 1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#else
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PPW == 4
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PWSH 2
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#else
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PPW == 8
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PWSH 3
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#else
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PPW == 16
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PWSH 4
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* PPW == 16 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* PPW == 8 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* PPW == 4 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* PPW == 2 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* PPW == 1 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* Defining PIXEL_ADDR means that individual pixels are addressable by this
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * machine (as type PixelType). A possible CFB architecture which supported
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * 8-bits-per-pixel on a non byte-addressable machine would not have this
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * defined.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Defining FOUR_BIT_CODE means that cfb knows how to stipple on this machine;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * eventually, stippling code for 16 and 32 bit devices should be written
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * which would allow them to also use FOUR_BIT_CODE. There isn't that
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * much to do in those cases, but it would make them quite a bit faster.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PSZ == 8
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PIXEL_ADDR
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynctypedef CARD8 PixelType;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define FOUR_BIT_CODE
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PSZ == 16
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PIXEL_ADDR
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynctypedef CARD16 PixelType;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PSZ == 24
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#undef PMSK
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PMSK 0xFFFFFF
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*#undef PIM
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PIM 3*/
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PIXEL_ADDR
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynctypedef CARD32 PixelType;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PSZ == 32
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#undef PMSK
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PMSK 0xFFFFFFFF
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PIXEL_ADDR
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynctypedef CARD32 PixelType;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* the following notes use the following conventions:
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncSCREEN LEFT SCREEN RIGHT
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncin this file and maskbits.c, left and right refer to screen coordinates,
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncNOT bit numbering in registers.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynccfbstarttab[n]
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pixels[0,n-1] = 0's pixels[n,PPW-1] = 1's
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynccfbendtab[n] =
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pixels[0,n-1] = 1's pixels[n,PPW-1] = 0's
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynccfbstartpartial[], cfbendpartial[]
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync these are used as accelerators for doing putbits and masking out
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncbits that are all contained between longword boudaries. the extra
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync256 bytes of data seems a small price to pay -- code is smaller,
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncand narrow things (e.g. window borders) go faster.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncthe names may seem misleading; they are derived not from which end
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncof the word the bits are turned on, but at which end of a scanline
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncthe table tends to be used.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynclook at the tables and macros to understand boundary conditions.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync(careful readers will note that starttab[n] = ~endtab[n] for n != 0)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync-----------------------------------------------------------------------
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncthese two macros depend on the screen's bit ordering.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncin both of them x is a screen position. they are used to
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynccombine bits collected from multiple longwords into a
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncsingle destination longword, and to unpack a single
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncsource longword into multiple destinations.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncSCRLEFT(dst, x)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync takes dst[x, PPW] and moves them to dst[0, PPW-x]
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync the contents of the rest of dst are 0 ONLY IF
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst is UNSIGNED.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync is cast as an unsigned.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync this is a right shift on the VAX, left shift on
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync Sun and pc-rt.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncSCRRIGHT(dst, x)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync takes dst[0,x] and moves them to dst[PPW-x, PPW]
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync the contents of the rest of dst are 0 ONLY IF
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst is UNSIGNED.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync this is a left shift on the VAX, right shift on
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync Sun and pc-rt.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncthe remaining macros are cpu-independent; all bit order dependencies
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncare built into the tables and the two macros above.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncmaskbits(x, w, startmask, endmask, nlw)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync for a span of width w starting at position x, returns
deb4998ba50060c48cce222fd18a8eed053918d7vboxsynca mask for ragged pixels at start, mask for ragged pixels at end,
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncand the number of whole longwords between the ends.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncmaskpartialbits(x, w, mask)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync works like maskbits(), except all the pixels are in the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync same longword (i.e. (x&0xPIM + w) <= PPW)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncmask32bits(x, w, startmask, endmask, nlw)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync as maskbits, but does not calculate nlw. it is used by
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync cfbGlyphBlt to put down glyphs <= PPW bits wide.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncgetbits(psrc, x, w, dst)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync starting at position x in psrc (x < PPW), collect w
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pixels and put them in the screen left portion of dst.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync psrc is a longword pointer. this may span longword boundaries.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync it special-cases fetching all w bits from one longword.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync +--------+--------+ +--------+
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync | | m |n| | ==> | m |n| |
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync +--------+--------+ +--------+
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync x x+w 0 w
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync psrc psrc+1 dst
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync m = PPW - x
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync n = w - m
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync implementation:
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync get m pixels, move to screen-left of dst, zeroing rest of dst;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync get n pixels from next word, move screen-right by m, zeroing
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync lower m pixels of word.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync OR the two things together.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncputbits(src, x, w, pdst, planemask)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync starting at position x in pdst, put down the screen-leftmost
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync w bits of src. pdst is a longword pointer. this may
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync span longword boundaries.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync it special-cases putting all w bits into the same longword.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync +--------+ +--------+--------+
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync | m |n| | ==> | | m |n| |
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync +--------+ +--------+--------+
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync 0 w x x+w
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst pdst pdst+1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync m = PPW - x
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync n = w - m
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync implementation:
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync get m pixels, shift screen-right by x, zero screen-leftmost x
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pixels; zero rightmost m bits of *pdst and OR in stuff
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync from before the semicolon.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync shift src screen-left by m, zero bits n-32;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync zero leftmost n pixels of *(pdst+1) and OR in the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync stuff from before the semicolon.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncputbitsrop(src, x, w, pdst, planemask, ROP)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync like putbits but calls DoRop with the rasterop ROP (see cfb.h for
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync DoRop)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncgetleftbits(psrc, w, dst)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync get the leftmost w (w<=PPW) bits from *psrc and put them
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync in dst. this is used by the cfbGlyphBlt code for glyphs
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync <=PPW bits wide.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync*/
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if (BITMAP_BIT_ORDER == MSBFirst)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define BitRight(lw,n) ((lw) >> (n))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define BitLeft(lw,n) ((lw) << (n))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#else /* (BITMAP_BIT_ORDER == LSBFirst) */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define BitRight(lw,n) ((lw) << (n))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define BitLeft(lw,n) ((lw) >> (n))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* (BITMAP_BIT_ORDER == MSBFirst) */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define SCRLEFT(lw, n) BitLeft (lw, (n) * PSZ)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define SCRRIGHT(lw, n) BitRight(lw, (n) * PSZ)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Note that the shift direction is independent of the byte ordering of the
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * machine. The following is portable code.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PPW == 16
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PFILL(p) ( ((p)&PMSK) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 2*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 3*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 4*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 5*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 6*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 7*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 8*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 9*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 10*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 11*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 12*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 13*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 14*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 15*PSZ )
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PFILL2(p, pf) { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf = (p) & PMSK; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf |= (pf << PSZ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf |= (pf << 2*PSZ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf |= (pf << 4*PSZ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf |= (pf << 8*PSZ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* PPW == 16 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PPW == 8
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PFILL(p) ( ((p)&PMSK) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 2*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 3*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 4*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 5*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 6*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 7*PSZ )
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PFILL2(p, pf) { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf = (p) & PMSK; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf |= (pf << PSZ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf |= (pf << 2*PSZ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf |= (pf << 4*PSZ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PPW == 4
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PFILL(p) ( ((p)&PMSK) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 2*PSZ | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << 3*PSZ )
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PFILL2(p, pf) { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf = (p) & PMSK; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf |= (pf << PSZ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf |= (pf << 2*PSZ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PPW == 2
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PFILL(p) ( ((p)&PMSK) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ((p)&PMSK) << PSZ )
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PFILL2(p, pf) { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf = (p) & PMSK; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pf |= (pf << PSZ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PPW == 1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PFILL(p) (p)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define PFILL2(p,pf) (pf = (p))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Reduced raster op - using precomputed values, perform the above
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * in three instructions
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define DoRRop(dst, and, xor) (((dst) & (and)) ^ (xor))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define DoMaskRRop(dst, and, xor, mask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync (((dst) & ((and) | ~(mask))) ^ (xor & mask))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PSZ != 32 || PPW != 1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# if (PSZ == 24 && PPW == 1)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define maskbits(x, w, startmask, endmask, nlw) {\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync startmask = cfbstarttab[(x)&3]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync endmask = cfbendtab[((x)+(w)) & 3]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync nlw = ((((x)+(w))*3)>>2) - (((x)*3 +3)>>2); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define mask32bits(x, w, startmask, endmask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync startmask = cfbstarttab[(x)&3]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync endmask = cfbendtab[((x)+(w)) & 3];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define maskpartialbits(x, w, mask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync mask = cfbstartpartial[(x) & 3] & cfbendpartial[((x)+(w)) & 3];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define maskbits24(x, w, startmask, endmask, nlw) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync startmask = cfbstarttab24[(x) & 3]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync endmask = cfbendtab24[((x)+(w)) & 3]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync if (startmask){ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync nlw = (((w) - (4 - ((x) & 3))) >> 2); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync } else { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync nlw = (w) >> 2; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync }
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getbits24(psrc, dst, index) {\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync register int idx; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync switch(idx = ((index)&3)<<1){ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 0: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = (*(psrc) &cfbmask[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 6: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = BitLeft((*(psrc) &cfbmask[idx]), cfb24Shift[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync default: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = BitLeft((*(psrc) &cfbmask[idx]), cfb24Shift[idx]) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync BitRight(((*((psrc)+1)) &cfbmask[idx+1]), cfb24Shift[idx+1]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync }; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbits24(src, w, pdst, planemask, index) {\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync register PixelGroup dstpixel; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync register unsigned int idx; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync switch(idx = ((index)&3)<<1){ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 0: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dstpixel = (*(pdst) &cfbmask[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 6: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dstpixel = BitLeft((*(pdst) &cfbmask[idx]), cfb24Shift[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync default: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dstpixel = BitLeft((*(pdst) &cfbmask[idx]), cfb24Shift[idx])| \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync BitRight(((*((pdst)+1)) &cfbmask[idx+1]), cfb24Shift[idx+1]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync }; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dstpixel &= ~(planemask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dstpixel |= (src & planemask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) &= cfbrmask[idx]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync switch(idx){ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 0: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) |= (dstpixel & cfbmask[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 2: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 4: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pdst++;idx++; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) = ((*(pdst)) & cfbrmask[idx]) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync (BitLeft(dstpixel, cfb24Shift[idx]) & cfbmask[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pdst--;idx--; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 6: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) |= (BitRight(dstpixel, cfb24Shift[idx]) & cfbmask[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync }; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbitsrop24(src, x, pdst, planemask, rop) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync register PixelGroup t1, dstpixel; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync register unsigned int idx; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync switch(idx = (x)<<1){ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 0: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dstpixel = (*(pdst) &cfbmask[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 6: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dstpixel = BitLeft((*(pdst) &cfbmask[idx]), cfb24Shift[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync default: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dstpixel = BitLeft((*(pdst) &cfbmask[idx]), cfb24Shift[idx])| \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync BitRight(((*((pdst)+1)) &cfbmask[idx+1]), cfb24Shift[idx+1]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync }; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync DoRop(t1, rop, (src), dstpixel); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dstpixel &= ~planemask; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dstpixel |= (t1 & planemask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) &= cfbrmask[idx]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync switch(idx){ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 0: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) |= (dstpixel & cfbmask[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 2: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 4: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *((pdst)+1) = ((*((pdst)+1)) & cfbrmask[idx+1]) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync (BitLeft(dstpixel, cfb24Shift[idx+1]) & (cfbmask[idx+1])); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 6: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) |= (BitRight(dstpixel, cfb24Shift[idx]) & cfbmask[idx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync }; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# else /* PSZ == 24 && PPW == 1 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define maskbits(x, w, startmask, endmask, nlw) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync startmask = cfbstarttab[(x)&PIM]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync endmask = cfbendtab[((x)+(w)) & PIM]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync if (startmask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync nlw = (((w) - (PPW - ((x)&PIM))) >> PWSH); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync else \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync nlw = (w) >> PWSH;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define maskpartialbits(x, w, mask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync mask = cfbstartpartial[(x) & PIM] & cfbendpartial[((x) + (w)) & PIM];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define mask32bits(x, w, startmask, endmask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync startmask = cfbstarttab[(x)&PIM]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync endmask = cfbendtab[((x)+(w)) & PIM];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* FIXME */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define maskbits24(x, w, startmask, endmask, nlw) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync abort()
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getbits24(psrc, dst, index) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync abort()
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbits24(src, w, pdst, planemask, index) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync abort()
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbitsrop24(src, x, pdst, planemask, rop) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync abort()
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* PSZ == 24 && PPW == 1 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getbits(psrc, x, w, dst) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncif ( ((x) + (w)) <= PPW) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = SCRLEFT(*(psrc), (x)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync} \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncelse \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync int m; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync m = PPW-(x); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = (SCRLEFT(*(psrc), (x)) & cfbendtab[m]) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync (SCRRIGHT(*((psrc)+1), m) & cfbstarttab[m]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbits(src, x, w, pdst, planemask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncif ( ((x)+(w)) <= PPW) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup tmpmask; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync maskpartialbits((x), (w), tmpmask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync tmpmask &= PFILL(planemask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) = (*(pdst) & ~tmpmask) | (SCRRIGHT(src, x) & tmpmask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync} \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncelse \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync unsigned int m; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync unsigned int n; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup pm = PFILL(planemask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync m = PPW-(x); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync n = (w) - m; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) = (*(pdst) & (cfbendtab[x] | ~pm)) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync (SCRRIGHT(src, x) & (cfbstarttab[x] & pm)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *((pdst)+1) = (*((pdst)+1) & (cfbstarttab[n] | ~pm)) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync (SCRLEFT(src, m) & (cfbendtab[n] & pm)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if defined(__GNUC__) && defined(mc68020)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#undef getbits
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define FASTGETBITS(psrc, x, w, dst) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync asm ("bfextu %3{%1:%2},%0" \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync : "=d" (dst) : "di" (x), "di" (w), "o" (*(char *)(psrc)))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getbits(psrc,x,w,dst) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync FASTGETBITS(psrc, (x) * PSZ, (w) * PSZ, dst); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = SCRLEFT(dst,PPW-(w)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define FASTPUTBITS(src, x, w, pdst) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync asm ("bfins %3,%0{%1:%2}" \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync : "=o" (*(char *)(pdst)) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync : "di" (x), "di" (w), "d" (src), "0" (*(char *) (pdst)))
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#undef putbits
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbits(src, x, w, pdst, planemask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync if (planemask != PMSK) { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup _m, _pm; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync FASTGETBITS(pdst, (x) * PSZ , (w) * PSZ, _m); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PFILL2(planemask, _pm); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync _m &= (~_pm); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync _m |= (SCRRIGHT(src, PPW-(w)) & _pm); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync FASTPUTBITS(_m, (x) * PSZ, (w) * PSZ, pdst); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync } else { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync FASTPUTBITS(SCRRIGHT(src, PPW-(w)), (x) * PSZ, (w) * PSZ, pdst); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync } \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* mc68020 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbitsrop(src, x, w, pdst, planemask, rop) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncif ( ((x)+(w)) <= PPW) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup tmpmask; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup t1, t2; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync maskpartialbits((x), (w), tmpmask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PFILL2(planemask, t1); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync tmpmask &= t1; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync t1 = SCRRIGHT((src), (x)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync DoRop(t2, rop, t1, *(pdst)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) = (*(pdst) & ~tmpmask) | (t2 & tmpmask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync} \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncelse \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync CfbBits m; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync CfbBits n; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup t1, t2; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup pm; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PFILL2(planemask, pm); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync m = PPW-(x); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync n = (w) - m; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync t1 = SCRRIGHT((src), (x)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync DoRop(t2, rop, t1, *(pdst)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) = (*(pdst) & (cfbendtab[x] | ~pm)) | (t2 & (cfbstarttab[x] & pm));\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync t1 = SCRLEFT((src), m); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync DoRop(t2, rop, t1, *((pdst) + 1)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *((pdst)+1) = (*((pdst)+1) & (cfbstarttab[n] | ~pm)) | \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync (t2 & (cfbendtab[n] & pm)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#else /* PSZ == 32 && PPW == 1*/
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * These macros can be optimized for 32-bit pixels since there is no
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * need to worry about left/right edge masking. These macros were
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * derived from the above using the following reductions:
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * - x & PIW = 0 [since PIW = 0]
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * - all masking tables are only indexed by 0 [ due to above ]
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * - cfbstartab[0] and cfbendtab[0] = 0 [ no left/right edge masks]
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * - cfbstartpartial[0] and cfbendpartial[0] = ~0 [no partial pixel mask]
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Macro reduction based upon constants cannot be performed automatically
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * by the compiler since it does not know the contents of the masking
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * arrays in cfbmskbits.c.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define maskbits(x, w, startmask, endmask, nlw) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync startmask = endmask = 0; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync nlw = (w);
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define maskpartialbits(x, w, mask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync mask = 0xFFFFFFFF;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define mask32bits(x, w, startmask, endmask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync startmask = endmask = 0;
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * For 32-bit operations, getbits(), putbits(), and putbitsrop()
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * will only be invoked with x = 0 and w = PPW (1). The getbits()
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * macro is only called within left/right edge logic, which doesn't
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * happen for 32-bit pixels.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getbits(psrc, x, w, dst) (dst) = *(psrc)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbits(src, x, w, pdst, planemask) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) = (*(pdst) & ~planemask) | (src & planemask);
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbitsrop(src, x, w, pdst, planemask, rop) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup t1; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync DoRop(t1, rop, (src), *(pdst)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(pdst) = (*(pdst) & ~planemask) | (t1 & planemask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* PSZ != 32 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Use these macros only when you're using the MergeRop stuff
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * in ../mfb/mergerop.h
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* useful only when not spanning destination longwords */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PSZ == 24
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbitsmropshort24(src,x,w,pdst,index) {\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup _tmpmask; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup _t1; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync maskpartialbits ((x), (w), _tmpmask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync _t1 = SCRRIGHT((src), (x)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync DoMaskMergeRop24(_t1, pdst, _tmpmask, index); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbitsmropshort(src,x,w,pdst) {\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup _tmpmask; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup _t1; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync maskpartialbits ((x), (w), _tmpmask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync _t1 = SCRRIGHT((src), (x)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *pdst = DoMaskMergeRop(_t1, *pdst, _tmpmask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* useful only when spanning destination longwords */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbitsmroplong(src,x,w,pdst) { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup _startmask, _endmask; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync int _m; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup _t1; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync _m = PPW - (x); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync _startmask = cfbstarttab[x]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync _endmask = cfbendtab[(w) - _m]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync _t1 = SCRRIGHT((src), (x)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pdst[0] = DoMaskMergeRop(_t1,pdst[0],_startmask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync _t1 = SCRLEFT ((src),_m); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync pdst[1] = DoMaskMergeRop(_t1,pdst[1],_endmask); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define putbitsmrop(src,x,w,pdst) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncif ((x) + (w) <= PPW) {\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync putbitsmropshort(src,x,w,pdst); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync} else { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync putbitsmroplong(src,x,w,pdst); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if GETLEFTBITS_ALIGNMENT == 1
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getleftbits(psrc, w, dst) dst = *((unsigned int *) psrc)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getleftbits24(psrc, w, dst, idx){ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync regiseter int index; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync switch(index = ((idx)&3)<<1){ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 0: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = (*((unsigned int *) psrc))&cfbmask[index]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 2: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 4: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = BitLeft(((*((unsigned int *) psrc))&cfbmask[index]), cfb24Shift[index]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst |= BitRight(((*((unsigned int *) psrc)+1)&cfbmask[index]), cfb4Shift[index]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 6: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = BitLeft((*((unsigned int *) psrc)),cfb24Shift[index]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync }; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* GETLEFTBITS_ALIGNMENT == 1 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getglyphbits(psrc, x, w, dst) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = BitLeft((unsigned) *(psrc), (x)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync if ( ((x) + (w)) > 32) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst |= (BitRight((unsigned) *((psrc)+1), 32-(x))); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if GETLEFTBITS_ALIGNMENT == 2
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getleftbits(psrc, w, dst) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync if ( ((int)(psrc)) & 0x01 ) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync getglyphbits( ((unsigned int *)(((char *)(psrc))-1)), 8, (w), (dst) ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync else \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync dst = *((unsigned int *) psrc); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync }
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* GETLEFTBITS_ALIGNMENT == 2 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if GETLEFTBITS_ALIGNMENT == 4
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getleftbits(psrc, w, dst) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync int off, off_b; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync off_b = (off = ( ((int)(psrc)) & 0x03)) << 3; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync getglyphbits( \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync (unsigned int *)( ((char *)(psrc)) - off), \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync (off_b), (w), (dst) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync ); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync }
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* GETLEFTBITS_ALIGNMENT == 4 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/*
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * getstipplepixels( psrcstip, x, w, ones, psrcpix, destpix )
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Converts bits to pixels in a reasonable way. Takes w (1 <= w <= PPW)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * bits from *psrcstip, starting at bit x; call this a quartet of bits.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Then, takes the pixels from *psrcpix corresponding to the one-bits (if
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * ones is TRUE) or the zero-bits (if ones is FALSE) of the quartet
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * and puts these pixels into destpix.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * Example:
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * getstipplepixels( &(0x08192A3B), 17, 4, 1, &(0x4C5D6E7F), dest )
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * 0x08192A3B = 0000 1000 0001 1001 0010 1010 0011 1011
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * This will take 4 bits starting at bit 17, so the quartet is 0x5 = 0101.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * It will take pixels from 0x4C5D6E7F corresponding to the one-bits in this
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * quartet, so dest = 0x005D007F.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * XXX Works with both byte order.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * XXX This works for all values of x and w within a doubleword.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if (BITMAP_BIT_ORDER == MSBFirst)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getstipplepixels( psrcstip, x, w, ones, psrcpix, destpix ) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup q; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync int m; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync if ((m = ((x) - ((PPW*PSZ)-PPW))) > 0) { \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = (*(psrcstip)) << m; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync if ( (x)+(w) > (PPW*PSZ) ) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q |= *((psrcstip)+1) >> ((PPW*PSZ)-m); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync } \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync else \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = (*(psrcstip)) >> -m; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = QuartetBitsTable[(w)] & ((ones) ? q : ~q); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(destpix) = (*(psrcpix)) & QuartetPixelMaskTable[q]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* I just copied this to get the linker satisfied on PowerPC,
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync * so this may not be correct at all.
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getstipplepixels24(psrcstip,xt,ones,psrcpix,destpix,stipindex) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup q; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = *(psrcstip) >> (xt); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = ((ones) ? q : ~q) & 1; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(destpix) = (*(psrcpix)) & QuartetPixelMaskTable[q]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#else /* BITMAP_BIT_ORDER == LSB */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* this must load 32 bits worth; for most machines, thats an int */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define CfbFetchUnaligned(x) ldl_u(x)
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getstipplepixels( psrcstip, xt, w, ones, psrcpix, destpix ) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup q; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = CfbFetchUnaligned(psrcstip) >> (xt); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync if ( ((xt)+(w)) > (PPW*PSZ) ) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q |= (CfbFetchUnaligned((psrcstip)+1)) << ((PPW*PSZ)-(xt)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = QuartetBitsTable[(w)] & ((ones) ? q : ~q); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(destpix) = (*(psrcpix)) & QuartetPixelMaskTable[q]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PSZ == 24
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# if 0
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getstipplepixels24(psrcstip,xt,w,ones,psrcpix,destpix,stipindex,srcindex,dstindex) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup q; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync CfbBits src; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync register unsigned int sidx; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync register unsigned int didx; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync sidx = ((srcindex) & 3)<<1; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync didx = ((dstindex) & 3)<<1; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = *(psrcstip) >> (xt); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* if((srcindex)!=0)*/ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* src = (((*(psrcpix)) << cfb24Shift[sidx]) & (cfbmask[sidx])) |*/ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* (((*((psrcpix)+1)) << cfb24Shift[sidx+1]) & (cfbmask[sidx+1])); */\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync/* else */\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync src = (*(psrcpix))&0xFFFFFF; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync if ( ((xt)+(w)) > PGSZ ) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q |= (*((psrcstip)+1)) << (PGSZ -(xt)); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = QuartetBitsTable[(w)] & ((ones) ? q : ~q); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync src &= QuartetPixelMaskTable[q]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(destpix) &= cfbrmask[didx]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync switch(didx) {\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 0: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(destpix) |= (src &cfbmask[didx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 2: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 4: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync destpix++;didx++; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(destpix) = ((*(destpix)) & (cfbrmask[didx]))| \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync (BitLeft(src, cfb24Shift[didx]) & (cfbmask[didx])); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync destpix--; didx--;\
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync case 6: \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(destpix) |= (BitRight(src, cfb24Shift[didx]) & cfbmask[didx]); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync break; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync }; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# else
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#define getstipplepixels24(psrcstip,xt,ones,psrcpix,destpix,stipindex) \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync{ \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync PixelGroup q; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = *(psrcstip) >> (xt); \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync q = ((ones) ? q : ~q) & 1; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync *(destpix) = (*(psrcpix)) & QuartetPixelMaskTable[q]; \
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync}
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync# endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif /* PSZ == 24 */
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern PixelGroup cfbstarttab[];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern PixelGroup cfbendtab[];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern PixelGroup cfbstartpartial[];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern PixelGroup cfbendpartial[];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern PixelGroup cfbrmask[];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern PixelGroup cfbmask[];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern PixelGroup QuartetBitsTable[];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern PixelGroup QuartetPixelMaskTable[];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#if PSZ == 24
deb4998ba50060c48cce222fd18a8eed053918d7vboxsyncextern int cfb24Shift[];
deb4998ba50060c48cce222fd18a8eed053918d7vboxsync#endif