fbpict.h revision c0dfd29d0951fba6d2505a1a5fd79b2c1c32eccd
/*
*
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _FBPICT_H_
#define _FBPICT_H_
#include "renderedge.h"
#if defined(__GNUC__)
#define INLINE __inline__
#else
#define INLINE
#endif
/*
* There are two ways of handling alpha -- either as a single unified value or
* a separate value for each component, hence each macro must have two
* versions. The unified alpha version has a 'U' at the end of the name,
* the component version has a 'C'. Similarly, functions which deal with
* this difference will have two versions using the same convention.
*/
(0 - ((t) >> 8)))) << (i))
#define Alpha(x) ((x) >> 24)
#define Blue(x) ((x) & 0xff)
/**
* Returns TRUE if the fbComposeGetSolid can be used to get a single solid
* color representing every source sampling location of the picture.
*/
{
{
return FALSE;
}
return FALSE;
case PICT_a8r8g8b8:
case PICT_x8r8g8b8:
case PICT_a8b8g8r8:
case PICT_x8b8g8r8:
case PICT_r8g8b8:
case PICT_b8g8r8:
case PICT_r5g6b5:
case PICT_b5g6r5:
return TRUE;
default:
return FALSE;
}
}
int __bpp__; \
\
switch (__bpp__) { \
case 32: \
break; \
case 24: \
break; \
case 16: \
break; \
case 8: \
break; \
case 1: \
break; \
default: \
return; \
} \
/* If necessary, convert RGB <--> BGR. */ \
{ \
(((bits) & 0x0000ff00) >> 0) | \
} \
/* manage missing src alpha */ \
(bits) |= 0xff000000; \
}
int __bpp__; \
\
}
(((s) >> 5) & 0x07e0) | \
(((s) >> 8) & 0xf800))
((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
#if IMAGE_BYTE_ORDER == MSBFirst
#define Fetch24(a) ((unsigned long) (a) & 1 ? \
#define Store24(a,v) ((unsigned long) (a) & 1 ? \
#else
#define Fetch24(a) ((unsigned long) (a) & 1 ? \
#define Store24(a,v) ((unsigned long) (a) & 1 ? \
#endif
/*
The methods below use some tricks to be able to do two color
components at the same time.
*/
/*
x_c = (x_c * a) / 255
*/
#define FbByteMul(x, a) do { \
t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
t &= 0xff00ff; \
\
x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
x = (x + ((x >> 8) & 0xff00ff)); \
x &= 0xff00ff00; \
x += t; \
} while (0)
/*
x_c = (x_c * a) / 255 + y
*/
#define FbByteMulAdd(x, a, y) do { \
t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
t &= 0xff00ff; \
t += y & 0xff00ff; \
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
t &= 0xff00ff; \
\
x = (((x >> 8) & 0xff00ff) * a) + 0x800080; \
x = (x + ((x >> 8) & 0xff00ff)) >> 8; \
x &= 0xff00ff; \
x += (y >> 8) & 0xff00ff; \
x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
x &= 0xff00ff; \
x <<= 8; \
x += t; \
} while (0)
/*
x_c = (x_c * a + y_c * b) / 255
*/
#define FbByteAddMul(x, a, y, b) do { \
CARD32 t; \
r += (r >> 8); \
r >>= 8; \
\
t = (x & 0xff00) * a + (y & 0xff00) * b; \
t += (t >> 8) + 0x8000; \
t >>= 16; \
\
t |= r << 16; \
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
t &= 0xff00ff; \
t <<= 8; \
\
r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b + 0x80; \
r += (r >> 8); \
r >>= 8; \
\
x = (x & 0xff) * a + (y & 0xff) * b + 0x80; \
x += (x >> 8); \
x >>= 8; \
x |= r << 16; \
x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
x &= 0xff00ff; \
x |= t; \
} while (0)
/*
x_c = (x_c * a + y_c *b) / 256
*/
#define FbByteAddMul_256(x, a, y, b) do { \
t >>= 8; \
t &= 0xff00ff; \
\
x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; \
x &= 0xff00ff00; \
x += t; \
} while (0)
/*
x_c = (x_c * a_c) / 255
*/
#define FbByteMulC(x, a) do { \
CARD32 t; \
r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
r += 0x800080; \
r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
r &= 0xff00ff; \
\
x >>= 8; \
t = (x & 0xff) * ((a >> 8) & 0xff); \
t |= (x & 0xff0000) * (a >> 24); \
t += 0x800080; \
t = t + ((t >> 8) & 0xff00ff); \
x = r | (t & 0xff00ff00); \
\
} while (0)
/*
x_c = (x_c * a) / 255 + y
*/
#define FbByteMulAddC(x, a, y) do { \
CARD32 t; \
r |= (x & 0xff0000) * ((a >> 16) & 0xff); \
r += 0x800080; \
r = (r + ((r >> 8) & 0xff00ff)) >> 8; \
r &= 0xff00ff; \
r += y & 0xff00ff; \
r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
r &= 0xff00ff; \
\
x >>= 8; \
t = (x & 0xff) * ((a >> 8) & 0xff); \
t |= (x & 0xff0000) * (a >> 24); \
t += 0x800080; \
t = (t + ((t >> 8) & 0xff00ff)) >> 8; \
t &= 0xff00ff; \
t += (y >> 8) & 0xff00ff; \
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
t &= 0xff00ff; \
x = r | (t << 8); \
} while (0)
/*
x_c = (x_c * a_c + y_c * b) / 255
*/
#define FbByteAddMulC(x, a, y, b) do { \
CARD32 t; \
r += (r >> 8) + 0x80; \
r >>= 8; \
\
t = (x & 0xff00) * ((a >> 8) & 0xff) + (y & 0xff00) * b; \
t += (t >> 8) + 0x8000; \
t >>= 16; \
\
t |= r << 16; \
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
t &= 0xff00ff; \
t <<= 8; \
\
r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b + 0x80; \
r += (r >> 8); \
r >>= 8; \
\
x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b + 0x80; \
x += (x >> 8); \
x >>= 8; \
x |= r << 16; \
x |= 0x1000100 - ((x >> 8) & 0xff00ff); \
x &= 0xff00ff; \
x |= t; \
} while (0)
/*
x_c = min(x_c + y_c, 255)
*/
#define FbByteAdd(x, y) do { \
CARD32 t; \
r |= 0x1000100 - ((r >> 8) & 0xff00ff); \
r &= 0xff00ff; \
\
t = ((x >> 8) & 0xff00ff) + ((y >> 8) & 0xff00ff); \
t |= 0x1000100 - ((t >> 8) & 0xff00ff); \
r |= (t & 0xff00ff) << 8; \
x = r; \
} while (0)
#else
#define FASTCALL
#endif
typedef struct _FbComposeData {
void
typedef struct _FbComposeFunctions {
/* fbcompose.c */
void
/* fbpict.c */
void
void
/* fbtrap.c */
void
int ntrap,
void
int x_off,
int y_off);
void
int ntri,
#endif /* _FBPICT_H_ */