040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * Copyright © 2000 SuSE, Inc.
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * Permission to use, copy, modify, distribute, and sell this software and its
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * documentation for any purpose is hereby granted without fee, provided that
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * the above copyright notice appear in all copies and that both that
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * copyright notice and this permission notice appear in supporting
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * documentation, and that the name of SuSE not be used in advertising or
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * publicity pertaining to distribution of the software without specific,
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * written prior permission. SuSE makes no representations about the
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * suitability of this software for any purpose. It is provided "as is"
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * without express or implied warranty.
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * Author: Keith Packard, SuSE, Inc.
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * While the protocol is generous in format support, the
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * sample implementation allows only packed RGB and GBR
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * representations for data to simplify software rendering,
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync#define PICT_FORMAT(bpp,type,a,r,g,b) PIXMAN_FORMAT(bpp, type, a, r, g, b)
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * gray/color formats use a visual index instead of argb
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/* 32bpp formats */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/* 24bpp formats */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/* 16bpp formats */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/* 8bpp formats */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/* 4bpp formats */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/* 1bpp formats */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * For dynamic indexed visuals (GrayScale and PseudoColor), these control the
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * selection of colors allocated for drawing to Pictures. The default
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * policy depends on the size of the colormap:
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * Size Default Policy
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * ----------------------------
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * < 64 PolicyMono
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * < 256 PolicyGray
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * 256 PolicyColor (only on PseudoColor)
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * The actual allocation code lives in miindex.c, and so is
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * austensibly server dependent, but that code does:
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * PolicyMono Allocate no additional colors, use black and white
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * PolicyGray Allocate 13 gray levels (11 cells used)
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used)
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * PolicyAll Allocate as big a cube as possible, fill with gray (all)
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * Here's a picture to help understand how many colors are
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * actually allocated (this is just the gray ramp):
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * gray level
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * b/w 0000 ffff
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * 4x4x4 5555 aaaa
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * The default colormap supplies two gray levels (black/white), the
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * 4x4x4 cube allocates another two and nine more are allocated to fill
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * in the 13 levels. When the 4x4x4 cube is not allocated, a total of
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * 11 cells are allocated.
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * An unadorned "xFixed" is the same as xFixed_16_16,
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * (since it's quite common in the code)
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync/* whether 't' is a well defined not obviously empty trapezoid */
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * Standard NTSC luminance conversions:
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * y = r * 0.299 + g * 0.587 + b * 0.114
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * Approximate this for a bit more speed:
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * y = (r * 153 + g * 301 + b * 58) / 512
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync * This gives 17 bits of luminance; to get 15 bits, lop the low two
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
040abec2534dadc53ebc8fa378ef03f4feecb7dbvboxsync#endif /* _PICTURE_H_ */