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